Yuki
Yuki

Reputation: 139

Spawning and Despawning objects in Drake

I have a robot in my simulation that carries objects to and from places. I would like to spawn an object at a certain position with an initial velocity of 0. The trigger would most likely be a collision detection or when the previous object reaches a certain location. I would also like to despawn objects after being used or if it falls off the robot's end effector (to prevent core dumps after the object drops)

Is there a method in drake to continuously spawn and despawn objects?

Thank you

Upvotes: 0

Views: 117

Answers (1)

Sherm
Sherm

Reputation: 678

Drake doesn't have a way to spawn/despawn objects automatically. A few possibilities:

  • (Easiest) Detect triggering events during simulation (the "monitor" function can be handy for that). Take control back, reconstruct the model with the new or removed objects, transfer the state from the old Context to the new one, and restart.
  • Provide all needed objects in the initial model but make unneeded ones inactive (position them far away, set their velocities to zero, and make their accelerations zero*). Detect triggering events using monitor() or witness functions, activate/deactivate objects to emulate spawn/despawn.

* Getting the inactive objects to sit still may take some effort. You could do it with a controller, or by creating a ForceElement that acts like a spring/damper until disabled with a boolean state variable. Others may have better ideas for that.

Upvotes: 0

Related Questions