ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
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:
if __name__ == '__main__':
in order to the python interpreter run your coderospy.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.