Project 3: a 3-DOF arm with a gripper, from an empty file

Level 2 and 5 (after Lessons 2.1 to 2.4 and 5.1 to 5.3) · Time 3 to 4 hours · Difficulty 2 of 5

Objective

Write an MJCF model of a three-joint arm with a two-finger gripper, joint limits, position servos, a workspace camera and a keyframe, starting from arm3.xml, which is empty. Do not copy a course model: the point is to make every modelling decision yourself and to be able to defend each number.

Prerequisites

Starter code

The tests find the parts by type, so names are yours to choose, with two exceptions: the camera is called workspace and the keyframe home.

Expected behaviour

The model must:

The reference model holds its keyframe to 0.21 degree. Its shoulder carries a static load of 2.73 N m with the arm horizontal, measured as qfrc_bias at that pose; with $k_p$ = 500 N m/rad the predicted steady error is 2.73/500 = 0.0055 rad (0.31 degree). Size your servos the same way: work out the worst gravity load, then pick $k_p$ for the error you can accept.

Tests

MJC_IMPL=starter pytest projects/p03_arm3
pytest projects/p03_arm3

Six tests: a warning-free compile, the required parts, the 5 s hold, contact-free poses, the gripper response, and the unit comments. Each common failure below is a mutant in mutants.json. python tools/mutate_project.py p03_arm3 applies each one to the reference and checks that the intended test fails; a control mutant (swapped fromto ends) must pass.

Common failures

Extension challenges

  1. Build the same arm with mujoco.MjSpec in Python and test that the compiled models have identical body_mass, jnt_range, actuator_gainprm and geom_size.
  2. Add a 40 mm cube on a table and a grasp test: close on it, lift 10 cm, hold for 2 s.
  3. Replace the stiff shoulder servo with a softer one plus gravcomp on the links and actuatorgravcomp on the joints, and measure the hold error again.

Solution

arm3_solution.xml (about 60 lines) and solution.py, which names its poses.