Gazebo | Ignition | Community
Ask Your Question

How to get and set velocity of a joint in Gazebo ?

asked 2015-05-13 04:28:43 -0600

akshay5059 gravatar image

Hi everyone !

1) I have made a small robot model with 4 wheels. I simulate it in Gazebo and and provide some force to the wheel joints so that the robot starts moving. Now, I want to know the speed of the model or any particular joint by writing an API code. Can anyone please tell me how to do that ?? Also , I don't want to use ROS and Plugin methods. I just want to write a C or C++ code for that.

2) After receiving the speed, I now want to set the speed of that joint according to me by the same method as mentioned above i.e. by writing C or C++ API code, without using ROS and Plugin methods.

I would be really grateful to you if you help me out with this .

edit retag flag offensive close merge delete


You need to write a plugin to get access to the joint from the simulation.

AndreiHaidu gravatar imageAndreiHaidu ( 2015-05-13 04:45:57 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-05-13 04:57:22 -0600

djou07 gravatar image

I don't know how to do this without a plugin, so in a plugin:

to get model linear velocity in x axis :

double vel = this->model->GetRelativeLinearVel().x;

to get joint angular velocity in x axis :

      physics::JointPtr joint;
      joint = this->model->GetJoint("jointName");
      double vel = this->joint->GetVelocity(0);
edit flag offensive delete link more


Thank you for your answer but I want to do this without plugin .

akshay5059 gravatar imageakshay5059 ( 2015-05-13 05:02:19 -0600 )edit

maybe this will help you, they use main() instead of plugin

djou07 gravatar imagedjou07 ( 2015-05-13 05:08:56 -0600 )edit

I wish to use set_velocity method from gazebo class. this->model->GetJoint("right_hip_j")->SetVelocity(0, 10.0); I am unable to understand how to use this or make a plugin? Can you please share a code with basic implementation for using any gazebo class method? Thanks

sapanostic gravatar imagesapanostic ( 2018-10-31 14:00:25 -0600 )edit

Question Tools


Asked: 2015-05-13 04:28:43 -0600

Seen: 5,176 times

Last updated: May 13 '15