Skip to content

Commit

Permalink
fixed error msg 'Tried to advertise a service that is already adverti…
Browse files Browse the repository at this point in the history
…sed in this node [/camera/camera/set_camera_info]'
  • Loading branch information
jian-dong committed Jan 11, 2023
1 parent 506e525 commit af69db6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/ob_camera_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ OBCameraParams OBCameraNode::getCameraParams() {
camera_params_ = params;
return params;
} else if (pid == DABAI_MAX_PID) {
ROS_ERROR_STREAM("current SDK not support dabai max camera");
throw std::runtime_error("current SDK not support dabai max camera");
ROS_ERROR_STREAM("current SDK not support dabai max camera");
throw std::runtime_error("current SDK not support dabai max camera");
} else {
OBCameraParamsData camera_params_data;
int data_size = sizeof(camera_params_data);
Expand Down Expand Up @@ -231,7 +231,7 @@ sensor_msgs::CameraInfo OBCameraNode::getDepthCameraInfo() {
sensor_msgs::CameraInfo OBCameraNode::getColorCameraInfo() {
int width = width_[COLOR];
int height = height_[COLOR];
if (color_info_manager_->isCalibrated()) {
if (color_info_manager_ && color_info_manager_->isCalibrated()) {
auto camera_info = color_info_manager_->getCameraInfo();
if (camera_info.width != static_cast<uint32_t>(width) ||
camera_info.height != static_cast<uint32_t>(height)) {
Expand Down
6 changes: 4 additions & 2 deletions src/ob_camera_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ void OBCameraNode::init() {
auto serial_number = getSerialNumber();
ir_info_manager_ = std::make_unique<camera_info_manager::CameraInfoManager>(
nh_private_, "ir_camera", ir_info_uri_);
color_info_manager_ = std::make_unique<camera_info_manager::CameraInfoManager>(
nh_private_, "rgb_camera", color_info_uri_);
if(device_->hasSensor(openni::SENSOR_COLOR)) {
color_info_manager_ = std::make_unique<camera_info_manager::CameraInfoManager>(
nh_, "rgb_camera", color_info_uri_);
}
if (keep_alive_) {
keep_alive_timer_ =
nh_.createTimer(ros::Duration(keep_alive_interval_), &OBCameraNode::sendKeepAlive, this);
Expand Down

0 comments on commit af69db6

Please sign in to comment.