Skip to content

A ROS 2 package for launching MuJoCo simulation instances that interface with ROS 2.

License

Notifications You must be signed in to change notification settings

peterdavidfagan/mujoco_ros

Repository files navigation

mujoco_ros

MuJoCo simulation instances that are compatible with the ROS 2 ecosystem. For environment generation see mujoco_robot_environments; for example use cases of this package see ros2_robotics_research_toolkit.

Example Usage

import os
import time

import mujoco
import mujoco.viewer

import mujoco_ros
from mujoco_ros.franka_env import FrankaBase

model_filepath = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'models', 'base.mjb')

if __name__=="__main__":
    m = mujoco.MjModel.from_binary_path(model_filepath)
    d = mujoco.MjData(m)

    env = FrankaBase(
            m, 
            d, 
            command_interface="effort",
            control_steps=5, 
            control_timer_freq=1e-2,
            )
    env.reset()

    with mujoco.viewer.launch_passive(
        model=m, 
        data=d,
        show_left_ui=False,
        show_right_ui=False,
        ) as viewer:
        
        # run interactive viewer application
        while viewer.is_running():
            time.sleep(0.05)
            env.is_syncing = True
            viewer.sync()
            env.is_syncing = False 

ROS 2 Control Joint Trajectory Controller + MoveIt 2

Please note that the controller isn't perfectly tuned for the simulation but this is provided as an example of the interactivity you can accomplish with this package.

Screencast.from.05-30-2024.11.17.53.AM.webm

About

A ROS 2 package for launching MuJoCo simulation instances that interface with ROS 2.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published