Universal_Robots_ROS_Driver
Universal_Robots_ROS_Driver copied to clipboard
Extract force value from "wrench" topic.
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.
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()
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.
This issue has been closed due to inactivity. Feel free to comment or reopen if this is still relevant.