Defining a Kinematic Object

Official Python bindings with a focus on reinforcement learning and robotics.
Post Reply
zhsh
Posts: 7
Joined: Thu Oct 11, 2018 10:48 pm

Defining a Kinematic Object

Post by zhsh »

I'd like to use PyBullet to explore a toy problem with a point robot interacting with a ball.
The input to the point robot would be (dx,dy) - a direct change in its position.
When the robot hits the ball, the robot should not react, but the ball should bounce away.
Reading from other posts, the way to do this seems to be to make the robot a kinematic object and the ball a dynamic object (by default).
How can I do this in PyBullet? None of the documentation mentions creating kinematic objects.
Once I have a kinematic object, how can I adjust its position directly? (currently using constraints)

I'm currently creating the robot and ball by loading URDF files - as far as I know nothing in there can specify that the object is kinematic.
Making the robot mass infinite might accomplish what I described, but can lead to a lot of other problems (including the ball flying off to infinity).
richardbloemenkamp
Posts: 14
Joined: Tue Sep 18, 2018 7:50 pm

Re: Defining a Kinematic Object

Post by richardbloemenkamp »

I'm not sure, but I noticed that setting an objects mass to zero results in the object staying fixed to its environment. You can still change its position but apparently according to some other post if you use "resetBasePositionAndOrientation" for that it will be a none physical change: https://pybullet.org/Bullet/phpBB3/vie ... 4&t=12114
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Defining a Kinematic Object

Post by Erwin Coumans »

It is recommended to use a fixed constraint and move the parent location of the fixed constraint. (Kinematic bodies are not supported in PyBullet)

Code: Select all

relativeChildPosition=[0,0,1]
relativeChildOrientation=[0,0,0,1]
hand_cid = p.createConstraint(hand,-1,-1,-1,p.JOINT_FIXED,[0,0,0],[0,0,0],relativeChildPosition,relativeChildOrientation)
Then change the position like this:

Code: Select all

p.changeConstraint(hand_cid,updatedChildPosition,updatedChildOrientation)
(optionally provide the maxForce=... in the changeConstraint to limit the maximum force by the fixed constraint.
Post Reply