Height field vs plane

Discussion in 'Modeling' started by sytham, Sep 5, 2017.

  1. Hi,
    I'm simulating robot locomotion (using MuJoCo through OpenAI Gym) and having an issue where I'm seeing a deterioration in locomotion speed when running the robot on a plane versus on a flat height field. All other parameters (robot controller, XML settings etc are the same). I'm loading the height field from PNG.

    I know height field collision detection works somewhat differently from planes, but even when I make a height field that's almost all black, with some white at the edges (i.e. I'd expect elevation to be 0 almost everywhere), I observe this problem. I'd expect that height with elevation 0 almost everywhere should produce the same results as a plane.

    Am I wrong to expect this? Can anything be done to produce the same results?

    Example XMLs are attached (the "hill_" one uses height field). The height field PNG that I tried to use for debugging is also attached.


    Attached Files:

  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    Plane and height field collisions are indeed different, even if the height field is perfectly flat. Height fields are always treated as a union of triangular prisms, and each prism is collided using convex collisions. So the number of configuration of contact points will generally be different, in turn resulting in somewhat different contact forces.
  3. Thanks. So is there nothing I can do about this? Average speed is more than halved in some cases. It also seems to affect the qualitative behavior (e.g. gait) of the robots.
    The reason I'm asking if something can be done is that I'm testing gait change when terrain switches from flat to rugged. But if the flat part induces a gait that is not the same as the gait on a "real" flat terrain, I'm not comparing what I really want to compare.
  4. For example, is it possible to somehow stitch together a plane and a height field in one simulation? Then I could use the plane for the flat part and the height field for the rugged part.
  5. Emo Todorov

    Emo Todorov Administrator Staff Member

    Of course, you can do that. You can create any combination of geoms that you want and attach them to any body that you want (in this case the world body).
  6. Hi Sytham, did you resolve this issue?

    Also, in general, if I want to create a staircase which should be fixed to world body, should I create very heavy boxes attached to world body or should I use the height field geom?

    Any comment would be appreciated.
  7. Emo Todorov

    Emo Todorov Administrator Staff Member

    It is not obvious which one would be more efficient. Depends on what is colliding with the stairs. A stair box would be replaced with two triangular prisms in a height field. So if you put another box on it, the maximum number of contacts you can get is 2 (one per prism) because this case is handled by the general-purpose convex-convex collider. On the other hand, the box-box collider can return up to 8 contacts for a pair of boxes -- resulting in slower but also more stable simulation.

    Note that the masses of objects attached to the world are irrelevant; you can think of the world as having infinite mass for simulation purposes.