Robotics StackExchange | Archived questions

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

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 .

Asked by akshay5059 on 2015-05-13 04:28:43 UTC

Comments

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

Asked by AndreiHaidu on 2015-05-13 04:45:57 UTC

Answers

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);

Asked by djou07 on 2015-05-13 04:57:22 UTC

Comments

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

Asked by akshay5059 on 2015-05-13 05:02:19 UTC

maybe this will help you, they use main() instead of plugin http://gazebosim.org/tutorials?tut=custom_messages

Asked by djou07 on 2015-05-13 05:08:56 UTC

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

Asked by sapanostic on 2018-10-31 14:00:25 UTC