Send joint torques directly to a joint in python without using ApplyJointEffort service

asked 2018-07-30 15:27:39 -0500

OliverHuang gravatar image

I'm currently developing a python script which implements a PID controller for a custom robot arm in gazebo. The script is going to be used for teaching students how PID controller works. Including the calculation of a PID controller is important for me, so I don't want to use ros_control. I tried to send joint torques with the /gazebo/apply_joint_effort service in the script, but it didn't work out very well because the amount of time to complete the service is too long and that time is not a fixed value.

So I'm looking for a way to send joint torques directly to the joints with python without using the /gazebo/apply_joint_effort service.

edit retag flag offensive close merge delete


Afaik, without writing a Gazebo plugin, the service and topic interfaces are all there are to interact with Gazebo. So whether you're using Python or some other programming language, you'll probably have to use them.

gvdhoorn gravatar image gvdhoorn  ( 2018-07-31 03:42:20 -0500 )edit

Thank you for your comment, gvdhoorn. I've found a genpy auto-generated python script called under /opt/ros/kinetic/lib/python2.7/dist-packages/gazebo_msgs/srv. Is it possible to use that script directly?

OliverHuang gravatar image OliverHuang  ( 2018-08-01 06:16:51 -0500 )edit

The file you found is the Python code generated to interact with the ROS service called ApplyJointEffort, which is offered by Gazebo. Whenever you do from gazebo_msgs.msg import ApplyJointEffort, that class is being imported.

So I'm not sure how that would be different ..

gvdhoorn gravatar image gvdhoorn  ( 2018-08-02 02:52:51 -0500 )edit