Gazebo | Ignition | Community
Ask Your Question
0

How to change the friction parameter of a link programmatically (c++) during runtime?

asked 2021-12-01 16:16:34 -0500

sidsingh930 gravatar image

I have a robot loaded in gazebo using a urdf with wheel links. I have specified friction on the wheels which I would want to change during runtime.

<xacro:gazebo_collision_macro mu="100" mu2="1" torsion_coef="0.01" torsion_patch="0.01" torsion_surface="0.01" use_patch="1" rest_coef="0.2" bounce_threshold="1e+13" collide_bitmask="all" ode_kp="1e+6" bullet_kp="1e+13"/>

The end result I want is to make the wheel slip. I would preferably want to do it through a gui button which I have added to the gazebo window. As of now I am spawning a zero friction tile under the wheel to make it slip using the button press. It would be better if I can change the friction of the wheel itself during runtime by the button press.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-12-05 17:51:12 -0500

You can access the friction by going from model to link to collision to surface to parameters.

auto robot = world->ModelByName("robot_name");
auto link = robot->GetLink("link_name");
auto collision = link->GetCollision("collision");
auto surface = collision->GetSurface();
auto params = boost::dynamic_pointer_cast<physics::ODESurfaceParams>(surface);
params->FrictionPyramid()->SetMu(0, x);
params->slip1 = y;
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2021-12-01 16:16:34 -0500

Seen: 143 times

Last updated: Dec 05 '21