Universal_Robots_ROS_Driver icon indicating copy to clipboard operation
Universal_Robots_ROS_Driver copied to clipboard

Extract force value from "wrench" topic.

Open ZZWang21 opened this issue 3 years ago • 1 comments

I would like to extract one of the forces value, for example, force.z, from the rostopic "wrench". I tried many methods, but still not working. I am connecting a real UR5e robot to ROS. I can get the values when using "rostopic echo /wrench". I would like to extract the force.z to use it as a control parameter in python.

Does any expert have an idea?

Thank you very much.

ZZWang21 avatar Aug 02 '22 12:08 ZZWang21

Having a node that subscribes to that topic and then doing something with the value in the msg callback should be sufficient. Something like this (Note: I haven't tested that code, so it might contain bugs):

#!/usr/bin/env python
import rospy
from gemoetry_msgs.msg import WrenchStamped

def callback(data):
    # Do whatever you want in here
    rospy.loginfo(msg.wrench.force.z)
    
def listener():
    rospy.init_node('listener', anonymous=True)
    rospy.Subscriber("wrench", WenchStamped, callback)
    rospy.spin()

if __name__ == '__main__':
    listener()

fmauch avatar Aug 15 '22 19:08 fmauch

This issue has not been updated for a long time. If no further updates are added, this will be closed automatically. Comment on the issue to prevent automatic closing.

github-actions[bot] avatar Jan 23 '23 22:01 github-actions[bot]

This issue has been closed due to inactivity. Feel free to comment or reopen if this is still relevant.

github-actions[bot] avatar Feb 22 '23 22:02 github-actions[bot]