Rosanswers logo

I tried to move de hand with rostopic and this work very well

 rostopic pub /sh_ffj3_mixed_position_velocity_controller/command std_msgs/Float64 -- 10

And I tried to make this with code.

import roslib; roslib.load_manifest('rospy_tutorials')

import rospy
from std_msgs.msg import *

def talker():
    pub = rospy.Publisher('sh_ffj3_mixed_position_velocity_controller/command', Float64)
    value = 10

if __name__ == '__main__':
    except rospy.ROSInterruptException: pass

But this didn't work. The model in the gazebo gui does not move.

This the result of this execution:

/opt/ros/fuerte/share/rospy_tutorials$ rosrun beginner_tutorials talker.py[INFO] [WallTime: 1365084692.814065] [0.000000] 10

Anyone knows what is wrong?

Originally posted by phmferreira on ROS Answers with karma: 9 on 2013-04-04

Post score: 0


1 Answer 1


Rosanswers logo

It is likely that you need to keep the node up long enough to allow the connection to be established, and then the data sent. rostopic pub does this by setting the topic to be latched, so the last sent message will be sent to a new subscriber upon estabilishing a connection, and then waiting 3 seconds before quitting to allow the connection to be established.

Originally posted by tfoote with karma: 58457 on 2013-04-04

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by Ugo on 2013-04-04:
You can also add: rospy.spin() to keep the node up and running until you kill it, and then send your targets from a loop.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.