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

No name resolution of base topic in image_transport::Subscriber #80

Open
yoshito-okada opened this issue Apr 19, 2018 · 9 comments
Open

Comments

@yoshito-okada
Copy link

image_transport::Subscriber does not resolve the name of base topic although CameraSubscriber, CameraPublisher, and Publisher do. This causes an issue that a base topic remapping does not work when the transport type is not raw. For instance, the following settings subscribe not camera/image_raw/compressed but image_in/compressed.

<remap from="image_in" to="camera/image_raw"/>
<param name="image_transport" value="compressed"/>
@christian-rauch
Copy link

I have a similar issue with the SubscriberFilter (https://answers.ros.org/question/290472/topic-remapping-in-synchronised-message_filters/). The full topic name gets compiled before the topic remapping is applied:

virtual std::string getTopicToSubscribe(const std::string& base_topic) const
{
return base_topic + "/" + getTransportName();
}

@bbferka
Copy link

bbferka commented Nov 26, 2019

I have the same issue on a multi camera system. I though I could simply remap in the launch file from a generic image topic to the actual camera topic and set the image_transport parameter to compressed but it just ended up subscribing to image/compressed and I end up having to remap this latter one instead.

@NicoMandel
Copy link

I have the same issue and still no clue how to solve it. Does anyone have a solution yet @christian-rauch ?

@christian-rauch
Copy link

The only workaround I found is to manually remap the topic:

ros::NodeHandle n_priv;

image_transport::SubscriberFilter sub_image_depth;

sub_image_depth.subscribe(
    it,
    ros::names::remap("depth/image"), // manually remap topic from 'depth/image' to target
    1,
    image_transport::TransportHints("raw", ros::TransportHints(), n_priv, "depth/image_transport")
);

See https://github.com/christian-rauch/depth_box_filter/blob/master/src/depth_box_filter_node.cpp for the full example.

@NicoMandel
Copy link

NicoMandel commented May 4, 2020

Thank you for the advice @christian-rauch . I am still a little confused, I have a raspberry running as an onboard computer, with a marker detection package. Can I just apply the fix in this line and then continue with the namespace remapping as is or am I basically hard-coding the names of the image topics now, without a chance to remap?
The line that is throwing the thing off is this one in a launch file, with the output turning into:

Subscriptions: 
 * /ml_detector/image_raw/compressed [unknown type]
 * /webcam/camera_info [sensor_msgs/CameraInfo]

@christian-rauch
Copy link

Can I just apply the fix in this line and then continue with the namespace remapping as is or am I basically hard-coding the names of the image topics now, without a chance to remap?

If you apply the remapping via ros::names::remap("image_raw") then you do not have to hardcode anything.

Just take the ROS node at https://github.com/christian-rauch/depth_box_filter as an example. The remapping is done in the launch file and the remap method provides this mapping in the node.

@NicoMandel
Copy link

Somehow, after applying the fix, see here
And using a launch file to try with my webcam, see here
with the following lines:

        <remap from="~image_raw" to="$(arg image_topic)"/>
        <remap from="~camera_info" to="$(arg camera_info_topic)"/>
        <param if="$(arg compressed)" name="image_transport" value="compressed"/>

I still get the same issue, with the subscription going to:

Subscriptions: 
 * /ml_detector/image_raw/compressed [unknown type]
 * /webcam/camera_info [sensor_msgs/CameraInfo]

What am I missing here? I recompile and source the workspace...

@christian-rauch
Copy link

Use my depth_box_filter as a template to verify that this approach works for you. This example contains the node with the remapping and a launch file, which you can use to reproduce this effect for your node. If the remapping in my nodes does not work, please report an issue report there. Your launch file differs from mine in that you use the private namespace (~).

Otherwise, this issue is not a discussion forum. If you have further troubles with remapping topic names, please ask this specific question at https://answers.ros.org.

@KenYN
Copy link

KenYN commented Oct 9, 2020

Just a quick note for nodelets: you need to use nodelet::Nodelet::getRemappingArgs() to resolve this issue. EDIT: Here is my workaround:

// Suppose we have a <remap from="image_raw" to="/another/location/with/camera/image"/>
// Also class ThisClass: public nodelet::Nodelet { ... };
std::string inTopic = ros::names::resolve(getNodeHandle().getNamespace(), std::string("image_raw"));
auto const &inRemapped = getRemappingArgs().find(inTopic);
if (inRemapped != getRemappingArgs().end())
{
    inTopic = inRemapped->second.c_str();
}
// Now we can subscribe with the remapped topic
m_image_sub = m_it.subscribe(inTopic, 1, &ThisClass::image_raw_cb, this);

lucasw added a commit to lucasw/image_manip that referenced this issue Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants