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 Distribution
pybulletX-0.4.0.tar.gz
(43.5 kB
view hashes)
Built Distributions
pybulletX-0.4.0-py3-none-any.whl
(64.1 kB
view hashes)
Close
Hashes for pybulletX-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35abca103d81bfb8a40f04a857b4334a543db71cadf0ab5679e3054233adfc26 |
|
MD5 | 94e360e5a0f0699a4bd52451da0673a0 |
|
BLAKE2-256 | bd806b96918b0b8f07e4fd319c3005ea6d759d2fca04820887f4d1c8949b4216 |
Close
Hashes for pybulletX-0.4.0-1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87d8d9c62b6bbbeb1a8deed893692719b149a338f05cfc76b0f3c18ee05c8eb4 |
|
MD5 | c98a651cb948930817ca194aa5e1ba17 |
|
BLAKE2-256 | 095c5f57721aacc5a8972b7bbbbfbb0f1f12f0a8da0efbd84842dff9a6e1bb68 |