flatland icon indicating copy to clipboard operation
flatland copied to clipboard

Dynamic footprint?

Open RGring opened this issue 7 years ago • 3 comments

I would like to simulate a walking person (i.e. legs) with two circles, moving back and forward over time. Is it possible to have dynamic models with changing footprints? I didn't find the appropriate interface...

RGring avatar Oct 10 '18 11:10 RGring

You'd probably want to create a model plugin that expects a model with bodies of particular names "left leg" "right leg" "torso". I would recommend having maybe a body with the torso that you move around on the "3d" layer (that 3d sensors can see), to track where the person is (visually for debugging in rviz/flatland viz).

Each leg could just be a polygon or circle body (density 0 may help) that's either attached to the torso body either by explicitly setting the relative position during the plugin's BeforePhysicsStep, or by using a joint.

See tricycle_drive.cpp for examples of using GetModel()->GetBody(body_name) and GetModel()->GetJoint(joint_name), validating that the joints exist, casting to known joint types etc. It might be easiest to set a fixed joint between the "torso" object and each "massless" (density 0) leg. The physics engine will probably enforce the position for you.

You can also see the Tween plugin's BeforePhysicsStep where it manually sets the position of the body that it manages. I wouldn't recommend doing it that way since this breaks the interactive marker integration, unless you take into account relative motion that might be introduced. I'm hoping to update the Tween plugin at some point to fix this (#29).

This way your person objects may interact nicely with the interactive mark integration.

Flatland is a pretty thin layer on top of Box2D (it could have been named "Box2D with TF, Yaml loading, and Pluginlib" reasonably accurately), so feel free to check out the box2d manual: http://box2d.org/manual.pdf to get a better idea of how to muck with the underlying physics entities.

If this seems daunting, this is also something I've wanted to add for a while, so feel free to submit a partial implementation and I can try to help out. Alternatively, I may have time this weekend to work on a bare bones version of this.

josephduchesne avatar Oct 10 '18 14:10 josephduchesne

First of all thanks for the detailed reply. My problems are the following:

  • If I set the position of the body-parts (right_leg, left_leg), the position isn't updated properly. Not just the marker integration breaks, but also the laserscan data represents the old initialized configuration of the body-parts (sometimes).
  • Setting the velocity of the body-parts is also no option, because I work with weld-joints and finally the whole body moves, instead of just the leg.

I think, I might need another joint. If you have any more suggestions, please don't hesitate. But I might also dig into box2d.

RGring avatar Oct 11 '18 13:10 RGring

I found a way to accomplish it. I didn't use any joints and set the velocity and position of each body separately. It's maybe not the nicest way and I still have to check if it slows down the simulation essentially. Thanks for your support so far!

RGring avatar Oct 12 '18 12:10 RGring