A Pythonic wrapper for pybullet
Project description
pybulletX
The lightweight pybullet wrapper for robotics researchers. Build robot simulation with less code. Scale your research with less boilerplate.
Examples
Here is an example of controlling Kuka arm with PyBulletX.
import time
import numpy as np
import pybullet as p
import pybulletX as px
P_GAIN = 50
desired_joint_positions = np.array([1.218, 0.507, -0.187, 1.235, 0.999, 1.279, 0])
def main():
px.init()
robot = px.Robot("kuka_iiwa/model.urdf", use_fixed_base=True)
robot.torque_control = True
while True:
time.sleep(0.01)
error = desired_joint_positions - robot.get_states().joint_position
actions = robot.action_space.new()
actions.joint_torque = error * P_GAIN
robot.set_actions(actions)
p.stepSimulation()
if __name__ == "__main__":
main()
Here is the same example but without PyBulletX.
import time
import numpy as np
import pybullet as p
import pybullet_data
P_GAIN = 50
desired_joint_positions = np.array([1.218, 0.507, -0.187, 1.235, 0.999, 1.279, 0])
def main():
p.connect(p.GUI)
p.setAdditionalSearchPath(pybullet_data.getDataPath())
p.loadURDF("plane.urdf")
robot_id = p.loadURDF("kuka_iiwa/model.urdf", useFixedBase=True)
num_dofs = 7
joint_indices = range(num_dofs)
# The magic that enables torque control
p.setJointMotorControlArray(
bodyIndex=robot_id,
jointIndices=joint_indices,
controlMode=p.VELOCITY_CONTROL,
forces=np.zeros(num_dofs),
)
while True:
time.sleep(0.01)
joint_states = p.getJointStates(robot_id, joint_indices)
joint_positions = np.array([j[0] for j in joint_states])
error = desired_joint_positions - joint_positions
torque = error * P_GAIN
p.setJointMotorControlArray(
bodyIndex=robot_id,
jointIndices=joint_indices,
controlMode=p.TORQUE_CONTROL,
forces=torque,
)
p.stepSimulation()
if __name__ == "__main__":
main()
The examples above are available in examples/with_pybulletX.py and examples/without_pybulletX.py.
License
PyBulletX is licensed under MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pybulletX-0.4.1-py3-none-any.whl.
File metadata
- Download URL: pybulletX-0.4.1-py3-none-any.whl
- Upload date:
- Size: 64.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae3999325d7b4d8ed0ffa7a2bd85727bce195d6deac0523350032093a98b58ee
|
|
| MD5 |
2d2f3c8b88dc042e007aea9ffa12319d
|
|
| BLAKE2b-256 |
6703d9733ea3cd3fe6a4b8f25395e4387b208f46af8e8a6996709d8c92f305f4
|