ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ROS2 node not publishing when launched instead of run

asked 2022-03-01 19:38:31 -0600

j1432 gravatar image

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/Tutorial... 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?

edit retag flag offensive close merge delete

Comments

What does ros2 doctor command ouput when you run those nodes?

Serafadam gravatar image Serafadam  ( 2022-03-02 18:27:35 -0600 )edit

They seem to be running. If I do ps -ef | grep 17868 for example then I see that the process is running.

Similarly:

ros2 node list
/remote_computer/joystick_driving_node
/remote_computer_python/lidar_viewer

Here is the output when I launch the launch file:

$ ros2 launch remote_computer_launch.py 
[INFO] [launch]: All log files can be found below /home/jack/.ros/log/2022-03-02-20-36-10-308053-jacksLaptop-17866
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [joystick_driving_node-1]: process started with pid [17868]
[INFO] [lidar_viewer-2]: process started with pid [17870]

The log file just has the same stuff that was printed to the screen. There are no error messages.

j1432 gravatar image j1432  ( 2022-03-02 19:38:32 -0600 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2022-03-02 19:57:17 -0600

j1432 gravatar image

updated 2022-03-02 19:57:39 -0600

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.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2022-03-01 19:38:31 -0600

Seen: 1,157 times

Last updated: Mar 02 '22