MuJoCo drone simulation with keyboard teleop#2418
Conversation
…eed (pitch and roll)
Greptile SummaryAdds a MuJoCo-based Crazyflie (cf2) drone simulation with keyboard teleoperation, enabling drone control logic to be developed and tested without physical hardware.
Confidence Score: 5/5The change is safe to merge — it adds a self-contained simulation path behind a new blueprint and does not touch any existing robot control flows. All modifications to existing files are additive: new branches in match/if-elif blocks and new key bindings that don't alter existing behaviour. The drone simulation is gated behind its own blueprint and robot_model value, so other robots are unaffected. No files require special attention — the core logic changes in mujoco_process.py are well-isolated to the cf2 robot branch. Important Files Changed
Sequence DiagramsequenceDiagram
participant KT as KeyboardTeleop
participant LCM as LCM /cmd_vel
participant DSC as DroneSimConnection
participant MC as MujocoConnection
participant SHM as SharedMemory
participant MP as mujoco_process
participant DC as DroneController (cf2)
KT->>LCM: tele_cmd_vel (Twist with linear.z)
LCM->>DSC: cmd_vel
DSC->>MC: move(twist)
MC->>SHM: write_command(linear, angular)
MP->>SHM: DroneMockController.get_command()
MP->>DC: mj_step → set_mjcb_control callback
DC->>DC: PD attitude control on roll/pitch/yaw/thrust
DC-->>MP: data.ctrl[0..3] updated
MP->>SHM: write_odom(pos, quat)
SHM->>MC: odom_stream()
MC->>DSC: _on_odom(SimOdometry)
DSC->>DSC: odom.publish + tf.publish
Reviews (3): Last reviewed commit: "added up and down along with R/F keys" | Re-trigger Greptile |
Problem
DimOS only supported drones over MAVLink / real hardware (
dimos/robot/drone/). There was no way to bring up and control a drone in simulation, so drone control logic couldn't be developed or tested without a physical aircraft.Closes #1842
Solution
Adds a MuJoCo based drone simulation with keyboard teleoperation:
drone-basic-simblueprint plus adrone_primitive_no_navprimitive and aDroneSimConnection(mujoco_sim.py) — no camera/lidar dependency.DroneController(policy.py): maps keyboard input to desired tilt / yaw-rate / thrust — PD attitude control on roll and pitch, yaw-rate control with amax_yaw_ratelimit, and thrust at hover with a lower floor (>=50% hover) for controlled slow descent.KeyboardTeleopand routedtele_cmd_velthrough to the sim connection.How to Test
Requires the
simextra, which installs MuJoCo and MuJoCo Playground (source of the cf2 model):Drive with the keyboard (WASD / arrows for translation + yaw, R/F for altitude). The Crazyflie spawns in MuJoCo and is keyboard-controllable in real time.
Contributor License Agreement