The flip cube
The flip cube is a printed 50 mm cube for pushing and flipping tasks. It opens, so what you put inside sets its mass and its centre of mass. Each face carries an ArUco marker, so a camera sees which face is up and where the cube is. The folder hardware/objects/flip_cube/ holds the files to print, the sticker sheets, the marker layout with a pose estimator, and a textured model for the simulator.

The files
Section titled “The files”Path in hardware/objects/flip_cube/ |
Content |
|---|---|
stl/ |
The parts to print, for every variant. |
flip_cube_cq.py |
The CAD source (CadQuery). It writes the files of stl/. |
tags/flip_cube_tags_A4.pdf, tags/flip_cube_tags_A4_compact.pdf |
The sticker sheets. |
tags/flip_cube_net.png |
The unfolded cube with every marker in its place. |
flip_cube_tags.py |
Writes the sticker sheets. |
flip_cube_markers.py |
The marker layout, the detection, the pose of the cube, and the writer of the files below. |
flip_cube_markers.yaml |
The layout as data: face, direction, transform and corners of each marker. |
model/flip_cube_tagged.obj, .mtl, .png |
The cube as a box with the markers as a texture. Metres. |
model/flip_cube_tagged.glb |
The same model in one file. |
model/flip_cube_tagged.xml |
A MuJoCo model that uses the OBJ file. |
The cube frame
Section titled “The cube frame”The origin is the centre of the cube. Z is the axis of the tube, so the two plates are the faces +Z and -Z. The frame is right-handed. The four sides of the tube are equal, and so are the two plates. The markers decide which side is +X: it is the side with marker 2.
The lengths on this page and in flip_cube_markers.py are in millimetres. The model files in model/ are in metres.
Print the cube
Section titled “Print the cube”| Part | Number | Print it | Content |
|---|---|---|---|
| tube | 1 | Standing, the axis up. | The four side faces. A round boss in each inner corner takes the screws. |
| plate | 2 | The outer face up. | The top and the bottom face. Each has four M3 screws. Either plate opens the cube. |
| tray2 | 0 to 2 | The openings up. | A tray with 2 × 2 pockets. Two trays fill the cavity and make eight compartments. |
| tray3 | 0 to 4 | The openings up. | A tray with 3 × 3 round pockets for 10 mm balls. |
No part needs supports. No face with a marker pocket lies on the print bed.
There are two plates and three tubes. Choose one of each. The tube and the plate must be of the same kind (both with _cap in the name, or both without).
| Plate | Screws | Plate thickness | Tube height | Cavity |
|---|---|---|---|---|
flip_cube_plate.stl |
M3 countersunk | 3 | 44 | 44 × 44 × 44 |
flip_cube_cap_plate.stl |
M3 socket head cap or pan head, head up to Ø6 × 3 | 5 | 40 | 44 × 44 × 40 |
| Tube | How the screws hold | You need |
|---|---|---|
flip_cube_tube.stl, flip_cube_cap_tube.stl |
M3 heat-set inserts at both ends of each boss (bore Ø4.6). | 8 inserts with an outer diameter of 5. |
flip_cube_nut_tube.stl, flip_cube_cap_nut_tube.stl |
A slot for a hex nut at both ends of each boss. Push the nut in from the cavity. | 8 M3 hex nuts. |
flip_cube_tap_tube.stl, flip_cube_cap_tap_tube.stl |
A Ø2.8 hole. The screw goes into the plastic. | Nothing. For nylon screws, run a steel M3 screw through each hole first. |
The trays are flip_cube_tray2.stl or flip_cube_cap_tray2.stl (they differ in height), and flip_cube_tray3.stl for both.
Other dimensions: the outer edges have a radius of 1.5, the wall is 3, and the screw axes are 5 from the two nearest outer faces. Every face has a pocket of 35 × 35 × 0.4 for a sticker, so the cube stands on a plastic rim of 7.5 and the paper does not touch the table.
To change a dimension, change it in P at the top of flip_cube_cq.py and run the script:
pip install cadquerypython hardware/objects/flip_cube/flip_cube_cq.py # writes stl/python hardware/objects/flip_cube/flip_cube_cq.py --step # also one STEP assembly per variantFill the cube
Section titled “Fill the cube”- tray2: each pocket holds about 6.7 cm³ (6.1 cm³ with the cap plates). Fill some pockets and leave others empty to move the centre of mass.
- tray3: each pocket takes one 10 mm ball. A steel ball of this size weighs about 4.1 g. The cavity takes four layers, or three layers with the cap plates. Three layers leave about 7 mm free at the top.
- A tray has 0.5 mm clearance to the walls. To take a tray out, open the other plate and push from that side.
- Fix loose parts with reusable putty, so that they do not move when the cube turns over.
A cap cube printed in PLA with eight nylon screws weighs 37 g when it is empty. With 32 steel balls of 8 mm in the lower one of two tray2, it weighs 123 g, and its centre of mass is about 6 mm from the centre (computed from the parts, not measured).
Stick the markers
Section titled “Stick the markers”The markers are ArUco markers of the dictionary DICT_4X4_50, ids 0 to 5. The black square is 30 mm. A sticker is a white square of 34.5 mm with the marker in its centre.
- Print one of the two sheets at 100 % (“actual size”, not “fit to page”). Check the 100 mm scale on the sheet with a ruler.
- Cut on the grey lines. Keep the white margin: the detector needs it.
- Stick each marker as the table says. The top edge of a marker is the edge that is at the top of the sheet.
| Id | Face | Part | The top edge of the marker points to |
|---|---|---|---|
| 0 | +Z | plate | +Y, the side with marker 4 |
| 1 | -Z | plate | +X, the side with marker 2 |
| 2 | +X | tube | +Z, the plate with marker 0 |
| 3 | -X | tube | -Z, the plate with marker 1 |
| 4 | +Y | tube | -Z, the plate with marker 1 |
| 5 | -Y | tube | -Z, the plate with marker 1 |
Seen from the plate with marker 0, the sides carry the markers 2, 4, 3 and 5 in counter-clockwise order. Start with marker 0 on one plate and marker 2 on any side. The picture shows every face from outside. The labels at the edges name the cube direction on that side of the face.

- Use matt paper. Do not cover a marker with clear tape or film: the reflection disturbs the detection.
- Paper and glue together must be thinner than the pocket (0.4 mm). Then the cube stands on plastic, and the stickers do not change the friction.
- To see only which face is up, the id on each face is enough. The directions matter when you compute the pose of the cube.
- Stick every cube in the same way. Then cubes with different fillings look the same.
Find the cube in a picture
Section titled “Find the cube in a picture”flip_cube_markers.py needs numpy and OpenCV. Both are in the dependency group robot.
import sys
import cv2
sys.path.insert(0, 'hardware/objects/flip_cube')from flip_cube_markers import estimate_pose, up_face
gray = cv2.imread('picture.jpg', cv2.IMREAD_GRAYSCALE)found = estimate_pose(gray, K, dist) # K: 3 x 3 camera matrix; dist: distortion coefficients or Noneif found: T_cam_cube, ids, rms = found # 4 x 4 transform in mm, the ids used, the reprojection error in pixels top = up_face(R_world_cam @ T_cam_cube[:3, :3]) # the id of the face that points up (world z up)| Name | Function |
|---|---|
FACES |
The layout: for each id, the face and the direction of the top edge. The only place where it is written. |
marker_pose(i), marker_corners(i) |
The transform cube ← marker, and the four corners in the cube frame. |
board() |
The six markers as a cv2.aruco.Board. |
detect(gray) |
Corners and ids, with the correction described below. |
estimate_pose(gray, K, dist) |
The pose of the cube from all markers that are seen. |
up_face(R_world_cube) |
The id of the face that points up. |
To check a real cube against the layout, take photos of it and run:
uv run --group robot python hardware/objects/flip_cube/flip_cube_markers.py check photo1.jpg photo2.jpg --f 1850 --out check.jpg--f is the focal length in pixels. The command draws the cube and the markers on the photos and prints the reprojection error. A marker that is stuck on the wrong face or turned gives an error of hundreds of pixels.
The outline of the sticker reads as the marker. The white margin (2.25 mm) is thinner than one cell of the marker (5 mm). So the outline of the whole sticker on the dark cube decodes as the same id, and
cv2.arucosometimes returns this larger square.detect()tests for this and returns the 30 mm marker. If you use your own detection, test the size of the square.
The plane of the markers is 24.7 mm from the centre: the pocket is 0.4 deep, and paper and glue are taken as 0.1.
Use the cube in MuJoCo
Section titled “Use the cube in MuJoCo”model/flip_cube_tagged.xml is a complete small model. Copy its asset entries and its body into your scene:
<asset> <texture name="flip_cube" type="2d" file="flip_cube_tagged.png"/> <material name="flip_cube" texture="flip_cube" specular="0" shininess="0" reflectance="0"/> <mesh name="flip_cube" file="flip_cube_tagged.obj"/></asset><worldbody> <body name="flip_cube" pos="0 0 0.025"> <freejoint/> <geom name="flip_cube_col" type="box" size="0.025 0.025 0.025" mass="0.037" pos="0 0 0" rgba="0 0 0 0"/> <geom name="flip_cube_vis" type="mesh" mesh="flip_cube" material="flip_cube" contype="0" conaffinity="0" mass="0"/> </body></worldbody>- The box geom collides and carries the mass. Set
massto the mass of your cube, andposto its centre of mass. - The mesh geom is what the cameras see. Its frame is the cube frame.
- Use
type="2d"for the texture. MuJoCo then places each face with thevtcoordinates of the OBJ file.type="cube"ignores these coordinates and gives a wrong cube. MuJoCo does not read the.mtlfile.

The model is a plain box. It has no rounded edges, no pockets and no screws, and its markers lie on the outer faces, 0.3 mm above the real ones.
Write the files again
Section titled “Write the files again”After a change of FACES or of a size in flip_cube_markers.py:
uv run --group robot python hardware/objects/flip_cube/flip_cube_markers.py write # the YAML file, model/ and the netuv run --group robot python hardware/objects/flip_cube/flip_cube_tags.py # the sticker sheetsuv run --group robot pytest tests/robot/test_flip_cube.py tests/test_flip_cube.pyLimits
Section titled “Limits”- Printed and in use so far: the cap plates, a cap tube and the trays. The other files are checked as closed solids of the right size, not as prints.
- The clearances fit one printer and PLA. If a tray is too tight or too loose, change
tray_gapandtray_boss_gap. - The pose from a picture of the model is within 0.5° and 3 mm at a distance of 26 cm. On photos of a real cube it depends on the calibration of the camera; it was not measured against a reference.
- A marker that is small in the picture has a stable centre, but its orientation can flip. With one marker in view, trust the id and the position more than the orientation.
- The folder holds no Fusion design of the cube.