How to break the joint between two rotating sphere

Official Python bindings with a focus on reinforcement learning and robotics.
Post Reply
Nanospin
Posts: 2
Joined: Wed Sep 04, 2019 6:57 pm

How to break the joint between two rotating sphere

Post by Nanospin »

Hi everyone,

I would like to do a quite simple simulation but I fail to create it... May be my understanding of bullet is wrong.

I would like to create two sphere connected by a fixed joint, the sphere is located at (0,0,2) and the second one at (0,0,2). These two spheres are rotating at a constant speed around the (0,0,0) point. At some point, I would like to break the joint and let the sphere move away.

There is no gravity

I tried to create a multibody:

Code: Select all

sphereRadius = 0.5
sphere_base = p.createCollisionShape(p.GEOM_SPHERE, radius=sphereRadius)
sphere_1 = p.createCollisionShape(p.GEOM_SPHERE, radius=sphereRadius)
sphere_2 = p.createCollisionShape(p.GEOM_SPHERE, radius=sphereRadius)

mass = 1
visualShapeId = -1

# Link related
sphereUid = p.createMultiBody(baseMass = mass,
                baseCollisionShapeIndex = sphere_base,
                baseVisualShapeIndex = visualShapeId,
                basePosition = [0, 0, 0],
                baseOrientation = [0, 0, 0, 1],
                linkMasses= [1, 1],
                linkCollisionShapeIndices=[sphere_1, sphere_2],
                linkVisualShapeIndices=[-1, -1],
                linkPositions=[[0, 0, 2], [0, 0, -2]],
                linkOrientations=[[0, 0, 0, 1], [0, 0, 0, 1]],
                linkInertialFramePositions=[[0, 0, 0], [0, 0, 0]],
                linkInertialFrameOrientations=[[0, 0, 0, 1], [0, 0, 0, 1]],
                linkParentIndices=[0, 0],
                linkJointTypes= [p.JOINT_FIXED, p.JOINT_FIXED],
                linkJointAxis=[[0, 0, 1], [0, 0, -1]])
It works but I do not know how to break the joints...
I understood that the constraint is may be a better option. I know I can remove a constraint. However, I am not able to obtain the proper rotation around 0.

Code: Select all

sphere_1 = p.createCollisionShape(p.GEOM_SPHERE, radius=sphereRadius)

sphere_0_uid = p.createMultiBody(baseMass = 1,
                baseCollisionShapeIndex = sphere_1,
                baseVisualShapeIndex = -1,
                basePosition = [0, 0, 0],
                baseOrientation = [0, 0, 0, 1])

sphere_1_uid = p.createMultiBody(baseMass = 1,
                baseCollisionShapeIndex = sphere_1,
                baseVisualShapeIndex = -1,
                basePosition = [0, 0, 2],
                baseOrientation = [0, 0, 0, 1])
                
c1 = p.createConstraint(
    parentBodyUniqueId = sphere_0_uid, 
    parentLinkIndex = -1, 
    childBodyUniqueId = sphere_1_uid, 
    childLinkIndex = -1, 
    jointType = p.JOINT_FIXED, 
    jointAxis = [0, 0, 0], 
    parentFramePosition = [0, 0, 2], 
    childFramePosition = [0, 0, -0.5])               
    
  OMEGA = 3.14
p.resetBaseVelocity(sphere_0_uid, [0, 0, 0], [0, OMEGA , 0]) 
Any advices to do this basic simulation?

ps: I don't display it but I have set all dynamic parameters (Friction, damping, stiffness) = 0. I would like to see vacuum physics
Post Reply