How to change the friction parameter of a link programmatically (c++) during runtime?
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.
Asked by sidsingh930 on 2021-12-01 17:16:34 UTC
Answers
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;
Asked by nlamprian on 2021-12-05 18:51:12 UTC
Comments