Collision Resolution

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

Collision Resolution

Post by ardabbour » Tue Jan 23, 2018 9:41 am

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: 4095
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Collision Resolution

Post by Erwin Coumans » Thu Jan 25, 2018 6:02 am

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. ...

Posts: 7
Joined: Fri Oct 06, 2017 8:42 am

Re: Collision Resolution

Post by ardabbour » Fri Jan 26, 2018 4:36 pm

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

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:
    POS, _ = p.getBasePositionAndOrientation(CUBE)
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