MuJoCo Pencil Balancer
by Neuraville
A pencil stands upright in a cup carried by a two-motor planar five-bar linkage. Two fixed cameras about 90 degrees apart watch the pencil against white backdrops, as in event-camera pencil-balancing rigs. The goal is to move the cup under the pencil so it stays upright. Sensors: two cameras, motor encoders, cup position, and a gyroscope and accelerometer on the pencil. Actuators: two position servos at the linkage base. License: Apache-2.0. See model/LICENSE.
Specifications
- Manufacturer
- Neuraville
- Type
- Classic Control
- Environment
- Simulated
- Category
- MuJoCo Physics Simulator
- Controller
- MuJoCo
- Sensors
- CameraJoint positionJoint velocityBody stateIMUGyroscopeAccelerometer
- Actuators
- Position servo
- Connectivity
- ZMQLocal
Getting started
MuJoCo Pencil Balancer Integration Guide
Overview
A pencil (0.30 m, 12 g) stands in a cup on a pivot that tilts in two directions. Two base motors drive a flat five-bar linkage that moves the cup across the board. The brain keeps the pencil upright by moving the cup under it, the way a hand balances a stick.
Without control the pencil passes 0.5 rad of tilt in about 0.5 s, so the loop from sensing to motor command has to be fast.
Actuators
| FEAGI label | What it does | Range |
|---|---|---|
left_base_motor | Position servo at the left linkage base | -1.0 to 1.0 rad |
right_base_motor | Position servo at the right linkage base | -1.0 to 1.0 rad |
Near the home pose the cup moves about:
- Left/right (x): both motors turned the same way. +0.3 rad on both moves the cup about +7 cm.
- Toward/away from the motors (y): motors turned opposite ways. Left -0.3 and right +0.3 moves the cup about +8 cm toward the motors.
Sensors
| Sensor | Notes |
|---|---|
cam_left, cam_right | Fixed cameras at the front corners, about 90 degrees apart, aimed at the pencil against white backdrops. Each sees the pencil's lean in one direction. |
| Motor encoders and velocities | left_base_motor, right_base_motor |
cup_position | Cup position on the board |
pencil_gyroscope, pencil_accelerometer | IMU at the pencil's midpoint |
pencil_tilt_roll, pencil_tilt_pitch | Ground-truth tilt from vertical, for scoring. Use the cameras or IMU for control if the goal is vision-based balancing. |
Environment feedback
Model notes
- The five-bar loop is closed with two
equality/connectconstraints onto a carriage that slides in x and y, so the pencil pivot stays aligned with the board axes. - The passive joints (elbows, carriage slides, pencil tilt) appear as joints, but only the two base motors are actuated.
- Timestep 0.002 s. The default pose (qpos0) tilts the pencil about 2 degrees (0.03 / -0.02
rad), so it starts falling on its own at every run start and reset. The tilt joints use
refso they still read the angle from vertical.
View marketplace for this embodiment · Back to embodiment explorer
