Collision Resolution

Official Python bindings with a focus on reinforcement learning and robotics.
Post Reply
ardabbour
Posts: 9
Joined: Fri Oct 06, 2017 8:42 am

Collision Resolution

Post by ardabbour »

An automatic collision resolution takes place when we step the simulation and 2 or more objects are in collision. Can we confine this resolution to 2D? That is, if 2 objects are in collision, they should be moved out of each other by applying forces to 2 axes out of 3. Is there such a way to do this?

Also, where can I read more about this collision resolution algorithm? Source code, a paper, raw mathematics or even a blog post would be great!
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Collision Resolution

Post by Erwin Coumans »

There are a few ways to keep simulation in 2D indeed: you can use a 'fixed' base and add joints that allow motion in 2D. Look at the Gym environments 'Hopper' and 'HalfCheetah' and 'Walker2D', they only move in the 2D plane.

https://github.com/bulletphysics/bullet ... 2017may.py
ardabbour
Posts: 9
Joined: Fri Oct 06, 2017 8:42 am

Re: Collision Resolution

Post by ardabbour »

I am completely stumped here, I looked around HopperBulletEnv, and its dependencies, but couldn't find anywhere how in those environments constraints were defined to allow motion in 2D.

Code: Select all

import time
import pybullet as p
p.connect(p.GUI)

SURFACE = p.loadURDF("surface.urdf", useFixedBase=True)
c = 0.51 # z distance between center of mass of CUBE and SURFACE when CUBE is on top of SURFACE

CUBE = p.loadURDF("cube.urdf", [0, 0, c])

CONSTRAINT_1 = p.createConstraint(
    SURFACE, -1, CUBE, -1, jointType=p.JOINT_PRISMATIC, jointAxis=[0, 1, 0], [0, 0, c], [0, 0, 0])

CONSTRAINT_2 = p.createConstraint(
    SURFACE, -1, CUBE, -1,  jointType=p.JOINT_PRISMATIC, jointAxis=[1, 0, 0], [0, 0, c], [0, 0, 0])

while True:
    p.stepSimulation()
    POS, _ = p.getBasePositionAndOrientation(CUBE)
    time.sleep(0.01)
Obviously, the reason this cannot work is because the two constraints contradict each other. JOINT_PRISMATIC prevents the motion in any but one dimension, and there are no jointType variables that allow for planar movements.
Post Reply