UniversalRobots / Universal_Robots_ROS_Driver

Universal Robots ROS driver supporting CB3 and e-Series
Apache License 2.0
767 stars 405 forks source link

How to use the ROSTOPIC as a variable in main function of python? #564

Closed ZZWang21 closed 2 years ago

ZZWang21 commented 2 years ago

I am planning to control the position of the robotic arm according to the contact force.

I can achieve the force signal from Rostopic. The frequency of the data is quite high.

Now I want to write a python code to control the z position of the end-effector according to the force. However, I can subscribe to the topic, I can print the force value in terminal, but I do not know how to use the force value in the main functions, such as if function.

My target is to set a "if" function, if the force is over 10 N, z position -0.1.

Anybody could help? Thank you very much.

fmauch commented 2 years ago

This is not really a question regarding this driver, that's why I'll close it as invalid. Such application-based questions are better asked on ROS answers.

However, that being said, to give you a hint:

If I understand correctly, this should help you implementing what you asked for.