ROS2 node not publishing when launched instead of run
I’m picking my way through ROS2 by building up a small robot. I have enough nodes now to be useful but it is getting tiring to run them all independently so I am now trying to create launch files for my laptop and the robot. The launch file seems to be doing what it is supposed to but the nodes aren’t publishing anything anymore.
More details: I have followed this tutorial: https://docs.ros.org/en/foxy/Tutorials/Launch/Creating-Launch-Files.html When I run a node normally and do ‘ros2 node list’, I see it as /myNode. If I use a launch file, I now see it as /myNamespace/myNode. That seems fine. Likewise, a published topic goes from /myTopic to /myNamespace/myTopic if I am using ‘ros2 topic list’.
If I do ‘ros2 topic echo /myTopic’ after having run the node separately, I see exactly the output that I would expect. If I used a launch file then I would expect do ros2 topic echo /myNamespace/myTopic but I don’t see anything at all.
What am I missing?
Asked by j1432 on 2022-03-01 20:38:31 UTC
Answers
Thank you Serafadam. I believe that your question has led me to the answer. When I run ros2 doctor I get:
/opt/ros/foxy/lib/python3.8/site-packages/ros2doctor/api/topic.py: 56: UserWarning: Subscriber without publisher detected on /remote_computer/joy.
/opt/ros/foxy/lib/python3.8/site-packages/ros2doctor/api/topic.py: 56: UserWarning: Subscriber without publisher detected on /remote_computer_python/rplidarScan.
Apparently part of running a node from a launch file is that my node now expect the topics to which they subscribe to also be different. I didn't expect that. This would explain it. Also, the launch file on the robot has a different namespace than on my computer and I haven't figured out how to run teleop_joy_twist from my launch file yet so in aggregate, that is why nothing is working!
Thanks for cluing me in. I think that this should be relatively easy to fix now.
Asked by j1432 on 2022-03-02 20:57:17 UTC
Comments
What does
ros2 doctor
command ouput when you run those nodes?Asked by Serafadam on 2022-03-02 19:27:35 UTC
They seem to be running. If I do ps -ef | grep 17868 for example then I see that the process is running.
Similarly:
Here is the output when I launch the launch file:
The log file just has the same stuff that was printed to the screen. There are no error messages.
Asked by j1432 on 2022-03-02 20:38:32 UTC