0
$\begingroup$

Gazebo Answers logo

Running Gazebo 7.14 on Ubuntu 16.04

http://gazebosim.org/tutorials?cat=guided_i&tut=guided_i5

I tried implementing this tutorial and it works fine. In the plugin code used in this tutorial, a function from Gazebo API called GetJointController() is used to get a handle to the controller for the joints in the model. In my particular project, I am trying to apply a torque to Polaris Ranger XP900 (http://models.gazebosim.org/polaris_ranger_xp900/) to the rear wheel link. Similar to the GetJointController() function, I wasn't able to find a GetLinkController() function to handle control to the links in the API documentation. Is there any similar function which serves this purpose?


Originally posted by rmv24 on Gazebo Answers with karma: 3 on 2019-03-26

Post score: 0


Original comments

Comment by kumpakri on 2019-03-28:
Attach a joint to your link and control it through the joint. There is no justification from physics point of view for having a link controller. In the real world you need some kind of actuator to move things. A joint is the actuator.

Comment by rmv24 on 2019-03-28:
Thank you for your reply. In that case, how do you apply a torque? From a physics point of view, it wouldn't be possible to apply torque to a joint

Comment by kumpakri on 2019-03-29:
There is no method in the API documentation that seems to do this. But the documentation is very bad, so either there is no such method or one of the methods do what you need but is documented and named badly. If you only need to apply some forces to the joint to test something, you can also use the terminal command gz joint -m <model_name> -j <joint_name> -f <force>

Comment by rmv24 on 2019-04-03:
Thank you, but I'm trying to apply a torque to a wheel (link) via a plugin, and not applying directly via the terminal. Hence I wanted to know if there's any specific function called GetLinkController() to handle control to the links!

Comment by kumpakri on 2019-04-09:
In that case look at the SetForce and SetTorque methods in Link and Joint objects API.

$\endgroup$

1 Answer 1

0
$\begingroup$

Gazebo Answers logo

The simulation of actuators in Gazebo occurs through joints, not through applying force directly to links. The API allows applying force directly to links, but that's for cases such as wind, buoyancy and other external forces that would push the link, not for wheel actuation.

Therefore, to move your your wheels, you should use the controllers of the revolute joints connecting the wheels to the chassis, and it seems you already found a way to get to it though GetJointController.


Originally posted by chapulina with karma: 7504 on 2019-04-09

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by rmv24 on 2019-04-09:
Yes, I figured that out, thank you! But I've run into another problem:

So I'm using the same model (http://models.gazebosim.org/polaris_ranger_xp900/). In my plugin, I'm using GetJoint() command to read the joint, and then using SetForce() command:

physics::JointPtr rear_left_wheel_joint=this->model->GetJoint("rear_left_wheel_joint"); rear_left_wheel_joint->SetForce(0,20.0);

Somehow, GetJoint command doesn't work, and a null ptr is being returned. Any idea where I'm going wrong?

Comment by kumpakri on 2019-04-10:
The correct way of getting a joint is following: std::string joint_ptr_name = this->model->GetName() + "::" + this->joint_name; this->joint_ptr_ = this->model->GetJoint(joint_ptr_name);

Comment by rmv24 on 2019-04-10:
std::string joint_ptr_name = this->model->GetName() + "::" + this->joint_name;

this->joint_ptr_ = this->model->GetJoint(joint_ptr_name);

Since I've never come across this kind of declaration ever, I have a silly doubt-Do you declare the name of the joint(from model) within the double quotes in first line, in place of the "::"? Or rather, could you briefly explain what the right hand side of the declaration in the first line means?

Comment by chapulina on 2019-04-10:
@mukund24, I suggest you start new questions instead of asking follow ups in comments. Make sure each question is clearly scoped to a specific issue you're having. And when a question has been successfully answered, mark it as accepted so other users can benefit from it.

Comment by kumpakri on 2019-04-11:
Sorry I didn't have time back then to rewrite it into your context. This code below should be directly applicable in your code as you described it.

std::string joint_ptr_name = this->model->GetName() + "::" + "rear_left_wheel_joint";
physics::JointPtr rear_left_wheel_joint=this->model->GetJoint(joint_ptr_name); 
rear_left_wheel_joint->SetForce(0,20.0);

The point is to preface the joint name with the model name.

Comment by rmv24 on 2019-04-12:
Works perfectly! Thank you, @kumpakri and @chapulina!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.