I'm trying to find a way to turn on/off gravity forces only for specific objects using pyBullet.
In the Quickstart Guide (page 87) it is said, that there might be a way by running a second physics server:
As a first step i want to connect a client with two servers by using the SHARED_MEMORY mode.Question:
How to turn off gravity only for some parts of a robot (for example the arm)?
Answer:
At the moment this is not exposed, so you would need to either turn of gravity acceleration for all objects, and manually apply gravity for the objects that need it. Or you can actively compute gravity compensation forces, like happens on a real robot. Since Bullet has a full constraint system, it would be trivial to compute those anti-gravity forces: You could run a second simulation (PyBullet lets you connect to multiple physics servers) and position the robot under gravity, set joint position control to keep the position as desired, and gather those 'anti-gravity' forces. Then apply those in the main simulation.
However, I only managed it to connect my client with one server like this:
Server:
Code: Select all
p.connect(p.GUI_SERVER)
Code: Select all
p.connect(p.SHARED_MEMORY)
So how exactly do I have to implement this? Is there any example script which does exactly that?in SHARED_MEMORY mode, optional shared memory key. When starting ExampleBrowser or SharedMemoryPhysics_* you can use optional command-line --shared_memory_key to set the key. This allows to run multiple servers on the same machine.
I would be very grateful, if someone could point me in the right direction!
Thank you,
Christoph