Please consider the sample "restitution.py" in the distribution folder "examples/pybullet/examples." In this example, the ball drops from an initial height 2, over dead center [0, 0], which we set with the python code
sphere = p.loadURDF("sphere_with_restitution", [0, 0, 2])
The ball starts with no initial velocity or initial angular velocity. I would like to add those at the script level or in the URDF file, but I am having a devil of a time finding documentation or examples of how to add them. I know I can input velocity and angular velocity from the GUI by grabbing the object with the mouse and throwing it, but I need to add velocity and angular velocity inputs FROM THE SCRIPT so that I can develop controllers, for example.
I went through a lot of examples, and could not find one that gave the object an initial velocity or angular velocity.
I *am* willing to go to the C++ level, or even the TCP / UDP level, if that's what's necessary to "programmatically" inject velocities and angular velocities, but surely this must be possible from the Python level?
This is my first time using Bullet, so please excuse my ignorance and do help me!
Setting initial velocity & angular velocity in pybullet?
-
- Posts: 3
- Joined: Thu Jul 27, 2017 7:45 pm
-
- Posts: 4
- Joined: Tue Jul 18, 2017 4:38 pm
Re: Setting initial velocity & angular velocity in pybullet?
You can reset the linear and/or angular velocity of the base of a body using resetBaseVelocity. The input parameters are:
objectUniqueId, linearVelocity, angularVelocity, physicsClientId
Example:
objectUniqueId, linearVelocity, angularVelocity, physicsClientId
Example:
Code: Select all
p.resetBaseVelocity(model, [x1, y1, z1], [x2, y2, z2])
-
- Posts: 3
- Joined: Thu Jul 27, 2017 7:45 pm
Re: Setting initial velocity & angular velocity in pybullet?
Thanks very much. By grepping the folder for "resetBaseVelocity," I found more Python APIs (from the C point of view) inside "pybullet.c"DimonK wrote:You can reset the linear and/or angular velocity of the base of a body using resetBaseVelocity. The input parameters are:
objectUniqueId, linearVelocity, angularVelocity, physicsClientId
Example:Code: Select all
p.resetBaseVelocity(model, [x1, y1, z1], [x2, y2, z2])