Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing camera_info_manager topic so that it conforms to the standard namespace #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/gscam/gscam.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ namespace gscam {
// Case of a jpeg only publisher
ros::Publisher jpeg_pub_;
ros::Publisher cinfo_pub_;

// Deprecated publishers
image_transport::ImageTransport image_transport_deprecated_;
image_transport::CameraPublisher camera_pub_deprecated_;
ros::Publisher jpeg_pub_deprecated_;
ros::Publisher cinfo_pub_deprecated_;
};

}
Expand Down
42 changes: 39 additions & 3 deletions src/gscam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,40 @@ extern "C"{

#include <camera_calibration_parsers/parse_ini.h>

#include <boost/algorithm/string.hpp>

#include <gscam/gscam.h>

namespace gscam {

template<typename SSP>
void topicDeprecationWarning(const SSP& pub)
{
std::string correct_topic = pub.getTopic();
boost::replace_first(correct_topic, "camera/", "");
ROS_WARN_STREAM(
"gscam: Your node, \""<<pub.getSubscriberName()<<"\" is subscribing to the DEPRECATED topic \""<<pub.getTopic()<<"\", which will be removed in the next release."
<<" Instead, it should subscribe to the same topic without the additional \"camera\" namespace \""<<correct_topic<<"\"."
<<" See https://github.com/ros-drivers/gscam/pull/16 for more info.");
}

void rosTopicDeprecationWarning(const ros::SingleSubscriberPublisher &pub) {
topicDeprecationWarning(pub);
}

void imageTransportTopicDeprecationWarning(const image_transport::SingleSubscriberPublisher &pub) {
topicDeprecationWarning(pub);
}


GSCam::GSCam(ros::NodeHandle nh_camera, ros::NodeHandle nh_private) :
gsconfig_(""),
pipeline_(NULL),
sink_(NULL),
nh_(nh_camera),
nh_private_(nh_private),
image_transport_(nh_camera),
image_transport_deprecated_(ros::NodeHandle(nh_camera,"camera")),
camera_info_manager_(nh_camera)
{
}
Expand Down Expand Up @@ -203,10 +226,19 @@ namespace gscam {

// Create ROS camera interface
if (image_encoding_ == "jpeg") {
jpeg_pub_ = nh_.advertise<sensor_msgs::CompressedImage>("camera/image_raw/compressed",1);
cinfo_pub_ = nh_.advertise<sensor_msgs::CameraInfo>("camera/camera_info",1);
jpeg_pub_ = nh_.advertise<sensor_msgs::CompressedImage>("image_raw/compressed",1);
cinfo_pub_ = nh_.advertise<sensor_msgs::CameraInfo>("camera_info",1);

jpeg_pub_deprecated_ = nh_.advertise<sensor_msgs::CompressedImage>("camera/image_raw/compressed",1,rosTopicDeprecationWarning);
cinfo_pub_deprecated_ = nh_.advertise<sensor_msgs::CameraInfo>("camera/camera_info",1,rosTopicDeprecationWarning);
} else {
camera_pub_ = image_transport_.advertiseCamera("camera/image_raw", 1);
camera_pub_ = image_transport_.advertiseCamera("image_raw", 1);

camera_pub_deprecated_ = image_transport_deprecated_.advertiseCamera(
"image_raw", 1,
imageTransportTopicDeprecationWarning, image_transport::SubscriberStatusCallback(),
rosTopicDeprecationWarning, ros::SubscriberStatusCallback()
);
}

return true;
Expand Down Expand Up @@ -300,6 +332,9 @@ namespace gscam {
img->data.begin());
jpeg_pub_.publish(img);
cinfo_pub_.publish(cinfo);

jpeg_pub_deprecated_.publish(img);
cinfo_pub_deprecated_.publish(cinfo);
} else {
// Complain if the returned buffer is smaller than we expect
const unsigned int expected_frame_size =
Expand Down Expand Up @@ -340,6 +375,7 @@ namespace gscam {

// Publish the image/info
camera_pub_.publish(img, cinfo);
camera_pub_deprecated_.publish(img, cinfo);
}

// Release the buffer
Expand Down