Home | Tutorials | Wiki | Issues
Ask Your Question
0

Apply angular velocity to wheel via plugin

asked 2016-07-23 10:07:18 -0500

Hanteus gravatar image

Hi, I'm trying to implement a skid steer plugin (I can't use the already implemented one), but I have some problems. I was able to apply a linear velocity to the whole model using:

this->model = _parent;
model->SetLinearVel(math::Vector3(.03, 0, 0));

but I wasn't able to select one of the wheels (also which is the type of a link element?) nor to apply an angular velocity to it. I've tried with this:

left_front_wheel = _parent->GetEntityByName("left_front_wheel");

This is the SDF of one of the wheels:

        <joint type="revolute" name="right_back_wheel_hinge">
        <pose>0 0 0 0 0 0</pose>
        <child>rigth_back_wheel</child>
        <parent>chassis</parent>
        <axis>
            <xyz>0 1 0</xyz>
        </axis>
    </joint>
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-07-24 10:27:26 -0500

Hanteus gravatar image

updated 2016-07-25 03:40:54 -0500

I was able to do it with the following lines of code:

private: physics::JointPtr leftFrontWheelJ,oint;

this->model = parent;
leftFrontWheelJoint = this->model->GetJoint("left_front_wheel_hinge");
leftFrontWheelJoint->SetVelocity(0, .1);

The parameters of SetVelocity are the index of the axis on which you want to apply the velocity and the velocity itself (I write this for people who may have my same problem).

edit flag offensive delete link more

Comments

Have a look at https://github.com/gmsanchez/gazebo_stuff/tree/master/WheelSpeedPlugin It is a plugin that applies each of the two wheels of a differential drive robot a velocity received on vel_cmd topic. The code has two standalone programs to test if it works. You can also check the differential_drive.world model where it was tested. Cheers!

guido_sanchez gravatar imageguido_sanchez ( 2016-11-16 08:17:54 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-07-23 10:07:18 -0500

Seen: 789 times

Last updated: Nov 16 '16