Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behavior in wheel slip simulation. #57

Closed
silverjoda opened this issue Nov 14, 2021 · 7 comments
Closed

Strange behavior in wheel slip simulation. #57

silverjoda opened this issue Nov 14, 2021 · 7 comments

Comments

@silverjoda
Copy link

Hello,
I'm currently working on a sim-to-real project which requires a simulation of a rear-wheel driven car
on a low-friction surface (meaning the car drifts and slips a lot). I'm getting strange behavior where when turning, the car crabs
to one side, as if there was a parasitic force acting on it, as on the video. Is this a bug or is it a matter of setting simulator parameters correctly? I tried various things and nothing works. The simulation is from the Mushr tutorial. I only decreased the friction of the wheels of the car and I can't get it to work as one would expect it to.

crabbing_buggy_cropped.mp4
@yuvaltassa
Copy link
Collaborator

Hi,
Could you please provide a link to your model?

@silverjoda
Copy link
Author

Hi, Could you please provide a link to your model?
mj_models.zip

The one_car.xml includes the buddy.xml
I tried playing with all sorts of parameters such as solimp, solref, solver type, integrator, timestep, condim
and others but I can't get rid of this behavior. It works fine if you set it to a high enough friction so that it doesn't slip then the wierd stuff starts happening.

Thanks in advance.

@yuvaltassa
Copy link
Collaborator

Hi,
Could you please add the mesh directories and otherwise make sure the model loads?
Thanks

@silverjoda
Copy link
Author

models.zip
I am sorry, I did not think that you would run it. Here is the entire models directory.
It's taken from this repo: https://github.com/prl-mushr/mushr_mujoco_ros

@yuvaltassa
Copy link
Collaborator

Hi,
Thank you for the interesting problem. This model is badly designed, but in a very subtle way.

  • First, how to diagnose:
    Load the model (I loaded "one_car.xml") in simulate and hit the C button to activate contact visualisation. Now zoom in (mouse wheel), then hold the Control key and right-button double-click on the car to make the floating camera track the car. Then use the sliders on the right to navigate your car. You should be able to see contacts turning on and off. Why are they doing this?
    Look closely at one of the wheels. Each wheel has two geoms (defined in "buddy.xml"), one is a translucent, non-colliding cylindrical mesh, the other is a primitive ellipsoid which collides with the floor. But how is the ellipsoid defined? It is defined by the line <geom fitscale="1.2" type="ellipsoid" friction="0.4 0.005 0.0001" condim="6" contype="1" conaffinity="0" mesh="buddy_mushr_wheel" mass="0.498952" />, which is telling the MuJoCo compiler to fit an ellipsoid to the mesh called "buddy_mushr_wheel". Because there is something about this specific mesh which is radially non-isotropic, the fitted ellipsoid is not precisely aligned with the axle, only almost-aligned. As the wheel turns it loses and regains contact with the ground leading to the effect you observed.

  • Second: how to solve.
    There are multiple ways of solving this. The most realistic solution is to give the wheels some sort of suspension system, after all, maintaining contact with the ground is precisely what suspension is for. In fact, the mesh of the original chassis has suspension, but it is not actually implemented in your model. A quicker solution is to replace the fitted ellipsoids with properly centred ellipsoids. E.g. the following geometry (wheels with 5cm radius) seems to do the trick:

<default class="buddy_wheel_collision">
    <geom type="ellipsoid"  size=".05 .02 .05"  .../>
</default> 

You will still see the contacts flashing out intermittently, though not like before, but that is because any non zero roll or pitch of the four co-planar contact points will lead to one of them not touching the ground. The correct way to solve this (and indeed this will also work for the original model, but unbalanced wheels are probably a bad idea in any case), is to soften the contacts. This is how one models soft things (like a rubber tyre) in MuJoCo. You can do this directly in simulate by enabling "override" (under "physics"), which will let you override all contact parameters in the model. In the model with the perfectly aligned wheels (using the snippet above), it was enough to set solimp[0]=0. To understand this better, please read up on contact parameters.

Please let us know if you have any further questions.

One last thing, I would appreciate if you forwarded this answer to the Mushr author, perhaps they will fix their model.

Cheers.

@silverjoda
Copy link
Author

silverjoda commented Nov 15, 2021

Thanks a lot for your answer. I think that I understand the solution. The simulate binary is very useful.
I tried replacing the buddy_wheel with the buddy_wheel_collision class that you
have suggested and changed solimp[0] but I'm still not getting the drifting behavior that I would like when turning.
I think that the core issue is the lack of suspension as you mentioned because I can see the contacts bouncing from
left to right, albeit not as erratically as before. I guess I'll try to add a spring/damper element to each wheel and see what happens.

I will inform the authors of the Mushr model.

Thanks a lot, it was definitely useful.
T.

@silverjoda
Copy link
Author

How to solve:
If anyone is interested in the solution, I used slider joints to add simple spring/damper suspension for each wheel, used an ellipsoid collision for each wheel and added solimp[0] = 0 on wheel collisions and the floor geometry and it works as expected now. Here is the updated models directory if anyone is interested
models.zip
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants