Manipulator-Mujoco is a template repository that simplifies the setup and control of manipulators in Mujoco. It provides a generic operational space controller that can work with any robot arm. It offers a Gymnasium base environment that can be tailored for reinforcement learning tasks. This repository is built with dm_control, providing effortless configuration for different Mujoco environments.
Currently, the following robot arms and grippers are supported in this repository:
- Aubo i5
- UR5e
- DH Robotics AG95
To get started, follow these steps to install the repository:
-
Clone this repository to your local machine:
git clone https://github.com/ian-chuang/Manipulator-Mujoco.git
-
Navigate to the root directory of the repository:
cd Manipulator-Mujoco
-
Install the repository in editable mode:
pip install -e .
Explore the capabilities of Manipulator-Mujoco with the provided demos located in the /demo
folder:
To run the demo for the Aubo i5 arm with the AG95 gripper, execute:
python aubo_i5_demo.py
To run the demo for the UR5e arm, execute:
python ur5e_demo.py
In the demos, you can manipulate the arm by double-clicking and selecting the target red box mocap. Hold the Ctrl key and left-click and drag to rotate or Ctrl key and right-click and drag to translate. The arm will utilize operational space control to follow the target mocap.
If you want to create your own environment, follow the structure defined in manipulator_mujoco/envs
. Here's a simplified example of how to set up an environment:
# create checkerboard floor arena
self._arena = StandardArena()
# create mocap target that OSC will try to follow
self._target = Target(self._arena.mjcf_model)
# ur5e arm
self._arm = Arm(
xml_path=os.path.join(
os.path.dirname(__file__),
'../assets/robots/ur5e/ur5e.xml',
),
eef_site_name='eef_site',
attachment_site_name='attachment_site'
)
# attach arm to arena
self._arena.attach(
self._arm.mjcf_model, pos=[0, 0, 0], quat=[0.7071068, 0, 0, -0.7071068]
)
# generate model
self._physics = mjcf.Physics.from_mjcf_model(self._arena.mjcf_model)
Operational space control setup is designed to be straightforward:
# set up OSC controller
self._controller = OperationalSpaceController(
physics=self._physics,
joints=self._arm.joints,
eef_site=self._arm.eef_site,
min_effort=-150.0,
max_effort=150.0,
kp=200,
ko=200,
kv=50,
vmax_xyz=1.0,
vmax_abg=2.0,
)
Before running physics.step()
, simply calculate the target pose and run the OSC controller to move to the target pose:
target_pose = calculate_target_pose_for_OSC() # [x, y, z, qx, qy, qz, qw]
# run OSC controller to move to target pose
self._controller.run(target_pose)
# step physics
self._physics.step()
The OperationalSpaceController and Arm classes handle the details of tracking the mjcf element IDs, eliminating the need to specify joint names or actuator names. It should work seamlessly with any robot arm model, including various joint types, as long as the actuators are removed from the model since the controller automatically applies torques to each joint.
This repository drew inspiration from the following repositories:
Feel free to explore, experiment, and contribute to this repository as you work on your robotic manipulation tasks in Mujoco with operational space control.