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

rospy Gripper/command in python

asked 2020-12-07 08:49:04 -0500

MadsSander gravatar image

how can I implement this command line into my python code?

rostopic pub gripper/command std_msgs/Float64 "data: 1.0"

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-12-08 10:05:28 -0500

miura gravatar image

Have you read the following tutorial? http://wiki.ros.org/ROS/Tutorials/Wri...

It has not been tested, but it works the same as rostopic pub gripper/command std_msgs/Float64 "data: 1.0", which is the following code

#!/usr/bin/env python
# license removed for brevity
import rospy
from std_msgs.msg import Float64

def talker():
    pub = rospy.Publisher('gripper/command', Float64, queue_size=10)
    rospy.init_node('sample', anonymous=True)
    rate = rospy.Rate(10) # 10hz
    while not rospy.is_shutdown():
        msg_data = 1.0
        pub.publish(msg_data)
        rate.sleep()

if __name__ == '__main__':
    try:
        talker()
    except rospy.ROSInterruptException:
        pass
edit flag offensive delete link more

Question Tools

Stats

Asked: 2020-12-07 08:49:04 -0500

Seen: 256 times

Last updated: Dec 08 '20