Almost similar node is not subscribing the topics correctly.

asked 2021-08-31 22:22:32 -0600

ssn gravatar image

I am using ROS (melodic) in a Docker environment. The implementation is in Python. I am describing one area out of whole system.

Launch file 'A' is passing arguments to launch file 'B'. Launch file 'B' has almost identical nodes running almost identical python script. Yet, one node correctly subscribes to the topics and another one doesn't. I am unable to find out why. I made sure both the python scripts have executable permission. Here are contents of launch file 'B'.

<?xml version="1.0" encoding="utf-8"?>
<launch>
    <arg name="package_name" default="asv_perception_homography"/>
    <arg name="node_name" default="homography"/>
    <arg name="image_ir_topic" default="default1"/>
    <arg name="calibration_file" />
    <arg name="imu_topic" />
    <arg name="radar_topic" />

<node name="$(arg node_name)" pkg="$(arg package_name)" type="homography_ir.py" output="screen">
        <remap from="~imu" to="$(arg imu_topic)" />
</node>

<node name="$(arg node_name)_vis_ir" pkg="$(arg package_name)" type="visualization_ir.py" output="screen">

        <!-- remap from=sink to=source -->
        <remap from="~imu" to="$(arg imu_topic)" />
        <remap from="~ir" to="$(arg image_ir_topic)" />
        <remap from="~radarimg" to="$(arg radar_topic)" />
        <remap from="~ir_radarimg" to="$(arg node_name)/ir_radarimg" />
        <remap from="~radarimg_radar" to="$(arg node_name)/radarimg_radar"/>
        <remap from="~ir_radar" to="$(arg node_name)/ir_radar" />
        <rosparam>
            ir_image_size: [256, 320]
        </rosparam>
    </node>

<node name="$(arg node_name)_vis_ir_debug" pkg="$(arg package_name)" type="visualization_ir_debug.py" output="screen">
        <!-- remap from=sink to=source -->
        <remap from="~imu" to="$(arg imu_topic)" />
        <remap from="~ir" to="$(arg image_ir_topic)" />
        <remap from="~radarimg" to="$(arg radar_topic)" />
        <remap from="~ir_radarimg" to="$(arg node_name)/ir_radarimg" />
        <remap from="~radarimg_radar" to="$(arg node_name)/radarimg_radar"/>
        <remap from="~ir_radar" to="$(arg node_name)/ir_radar" />
        <rosparam>
            ir_image_size: [256, 320]
        </rosparam>
    </node>
</launch>

Output of rosnode info /ir_camera1/homography_vis_ir Subscriptions: * /clock [rosgraph_msgs/Clock] * /homography/radar_image/output [sensor_msgs/Image] * /ir_camera1/homography/ir_radar [asv_perception_common/Homography] * /ir_camera1/homography/ir_radarimg [asv_perception_common/Homography] * /ir_camera1/homography/radarimg_radar [asv_perception_common/Homography] * /perception/sensor/imu/throttled [sensor_msgs/Imu] * /perception/sensor/ir_camera_left [sensor_msgs/Image]

Output of rosnode info /ir_camera1/homography_vis_ir_debug Subscriptions: * /clock [rosgraph_msgs/Clock]

The python files visualization_ir.py and visualization_ir_debug.py are almost identical except for their names.

I am unable to find out what is different in 'visualization_ir_debug' which is causing it not to subscribe to the expected topics.

I can provide more details if one wants.

edit retag flag offensive close merge delete

Comments

I also verified by using print statement that the subscribe & publish methods of visualization_ir.py are called but not of visualization_ir_debug.py. This is obvious given my problem but more importantly, who is responsible for calling the subscribe method of a node.

ssn gravatar image ssn  ( 2021-08-31 22:50:54 -0600 )edit

As a troubleshooting step, have you tried setting type="visualization_ir.py" for both nodes?

tryan gravatar image tryan  ( 2021-09-01 09:43:23 -0600 )edit

I did not think of this approach, thanks. However, I tried it and both nodes worked as expected. I think it indicates some problem with 'visualization_ir_debug.py', but just that! How can I gain more insight into the issue?

ssn gravatar image ssn  ( 2021-09-01 11:13:58 -0600 )edit

Yes, it sounds like there is something wrong in visualization_ir_debug.py. To target differences between that and visualization_ir.py, you can use a tool like diff (example):

diff visualization_ir.py visualization_ir_debug.py

If the cause isn't clear, you can try creating a minimal, reproducible example (MRE). Sometimes, that process is enough to highlight the problem. If you still need help, you can post both scripts, so others can take a look. The output from the launch file may also be helpful.

tryan gravatar image tryan  ( 2021-09-01 12:37:59 -0600 )edit