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

moving sr_hand ros fuerte with code

asked 2013-04-04 04:28:38 -0500

phmferreira gravatar image

updated 2014-04-20 14:09:25 -0500

ngrennan gravatar image

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)
    rospy.init_node('ffj3Control')    
    value = 10
    rospy.loginfo(value)
    pub.publish(Float64(value))

if __name__ == '__main__':
    try:
        talker()
    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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-04-04 11:20:58 -0500

tfoote gravatar image

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.

edit flag offensive delete link more

Comments

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.

Ugo gravatar image Ugo  ( 2013-04-04 20:19:22 -0500 )edit

Question Tools

Stats

Asked: 2013-04-04 04:28:38 -0500

Seen: 150 times

Last updated: Apr 04 '13