ros-drivers / gscam

ROS Camera driver for GStreamer-based video streams.
142 stars 174 forks source link

Allow the user to specify camera topic name (when using multiple cameras) #43

Open jveitchmichaelis opened 6 years ago

jveitchmichaelis commented 6 years ago

Possibly related to: https://github.com/ros-drivers/gscam/pull/16 - it seems that would fix the issue, but it hasn't been closed yet. This is not only an issue re REP-0135, but it also makes using stereo cameras a pain.

The relevant code is here:

// 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);
    } else {
        camera_pub_ = image_transport_.advertiseCamera("camera/image_raw", 1);
}

So if you use a stereo namespace for the camera, you end up with e.g.

/stereo/camera/

and if you have multiple cameras, they all get published in the same topic,. One option is to namespace each camera individually, but that seems like an excessive amount of boilerplate and you're still forced to use /camera wtihin the namespace.

I've done this:

camera_pub_ = image_transport_.advertiseCamera(camera_name_ + "/image_raw", 1);

which works perfectly fine for my use case. Or we have another input parameter to change the topic name (defaulting to camera for back compatibility).

So now I can launch and end up with

/stereo/left /stereo/right

Or is this something I should be fixing with remapping?

EDIT - Having played around with this, it seems like namespacing does fix the issue in the cleanest way, but given that the PR is now almost 4 years old, I guess this isn't a priority?

zacwitte commented 5 years ago

I still am annoyed by this as well. I end up having to remap the topics to remove the extra /camera/ in the topic name.