ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I do not know of a way to distinguish by which node sent a message in the callback on the subscriber side.
I suggest you make your two publishing nodes publish to two different topics and your subscriber then subscribe to both indivially. Remapping topics is your friend here.
2 | No.2 Revision |
I do not know of a way to distinguish by which node sent a message in the callback on the subscriber side.
I suggest you make your two publishing nodes publish to two different topics and your subscriber then subscribe to both indivially. Remapping topics is your friend here.
Edit:
In response to your syntax problem: Have you read the actual error message? It probably indicates that you forgot to close the <remap>
tag. You can put it into a group, but I believe it is clearer to put it directly inside the node tag. Also inside a rules file I would not use the remapping syntax with command line arguments like you do for scan
. This is just confusing. Try this:
<launch>
<node pkg="leg_detector" type="leg_detector" name="leg_detector_front" args="$(find leg_detector)/config/trained_leg_detector.yaml" output="screen">
<remap from="scan" to="scan_front" />
<remap from="leg_tracker_measurements" to="leg_tracker_measurements_front" />
</node>
<node pkg="leg_detector" type="leg_detector" name="leg_detector_rear" args="$(find leg_detector)/config/trained_leg_detector.yaml" output="screen">
<remap from="scan" to="scan_rear" />
<remap from="leg_tracker_measurements" to="leg_tracker_measurements_rear" />
</node>
</launch>
Or alternatively and maybe even better in this case with namespaces, like suggested in another answer below:
<launch>
<node pkg="leg_detector" type="leg_detector" name="leg_detector_front" args="$(find leg_detector)/config/trained_leg_detector.yaml" output="screen" ns="front" />
<node pkg="leg_detector" type="leg_detector" name="leg_detector_rear" args="$(find leg_detector)/config/trained_leg_detector.yaml" output="screen" ns="rear" />
</launch>