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

Can't see my python node in rosnode list?

asked 2019-08-15 17:09:39 -0600

Anonymous gravatar image

updated 2019-08-15 19:50:20 -0600

I am trying to simulate a simple code in Gazebo to takeoff, but there is no response. However, I do not have any error codes and after typing rosnode list I don't see my python node. Could some please explain to me what could be the cause of this?

#!/usr/bin/env python 

#import library ros 
import rospy 
from geometry_msgs.msg import Twist
from std_msgs.msg import Empty


empty= Empty()

pub_takeoff = rospy.Publisher('/ardrone/takeoff',Empty,queue_size =10)

land_drone = rospy.Publisher('ardrone/land',Empty,queue_size=10)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-08-15 19:58:33 -0600

It appears your node is only very short lived. When your code runs, it inits ROS, creates publishers, tries to publish and then exits. You'll be able to see it in the node list if you add a rospy.spin() at the end as that prevents the direct exit. That won't help with the functionality you want to use, however.

When creating publishers and directly afterwards publishing on them you have to be aware that this won't work in most cases as detailed here, as publishers need to register with the master before they actually become active. The quick fix to that is adding a sleep after publisher creation.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2019-08-15 17:09:39 -0600

Seen: 846 times

Last updated: Aug 15 '19