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

Revision history [back]

click to hide/show revision 1
initial version

Hi EGam, can you give more details about your problem? Are you able to run (rosrun) both nodes?

Based on your post, the first node seems be ok. Except for an additional "space" in the beginning of line 15: rate.sleep()

The second node seems to be missing two important parts:

  • The sctructure using if if __name__ == '__main__': in order to the python interpreter run your code
  • Even if your node just do something when a new data is published, it should have at least arospy.spin() that checks and process if any event occurs (new data received on a topic or a timer event). Check this post about rospy.spin and rospy.sleep (https://answers.ros.org/question/332192/difference-between-rospyspin-and-rospysleep/)

To write nodes that only handle with events (like your second one), I like to follow the listener structure presented in the rospy tutorial (http://wiki.ros.org/rospy_tutorials/Tutorials/WritingPublisherSubscriber).

I hope this will help you.