Skip to content
Noah SpiegelmanMechanical engineering
Back to all projects

Project 01 / 10Robotics · Computer vision

RASTICrane

ME416, Boston University · Fall 2026

A laser-cut robotic arm turned into a vision-guided stamp machine, using AprilTags and inverse kinematics.

  • Completed
  • Mechanical
  • Embedded
Fig. 01My arm's run: stamping my name one letter at a time, with the paper on the left and the ink pad on the right.

Key result

2.565 mm

Mean landing error

Measured

My arm, four stamped letters, each landing point measured with a ruler from the base tag. The error budget predicted 3.071 mm; the worst letter missed by 3.493 mm. The second arm's mean miss was 20.707 mm.

Technical highlights

  • Vision-guided: a camera calibration (0.188 px mean reprojection error), AprilTag detection and a homography locate the stamps, paper and ink pad with nothing hardcoded.
  • Planar inverse kinematics plus a per-servo linear calibration turn each target into servo commands, sent from MATLAB to an ESP32.
  • Checked against an error budget: predicted 3.071 mm, measured 2.565 mm mean miss on my arm, across four stamped letters.
My contribution
  • Assembled the laser-cut arm, tuned its joints and hand-soldered the ESP32 board
  • Calibrated the camera and the servos, and tuned the rack corrections
  • Ran every test and measured every landing point with a ruler
  • Wrote the code with an AI model, as the course instructed (team of two)
Tools
ESP32Arduino (C++)Servo motorsSolderingMQTTMATLABAprilTags (tag36h11)Camera calibrationHomographyInverse kinematics

Overview

A wooden robotic arm I built for ME416: Intro to Robotics, then turned into a vision-guided stamp machine. The instructions and laser-cut files were provided, so the challenge wasn't designing an arm. It was getting the hardware and software to work together: first the arm itself in about a week, then a camera system that guided it to pick up rubber stamps, ink them and stamp my name onto paper.

Side view of the wooden robotic arm reaching out to the left from its base, with three servo wires and a USB cable running to the ESP32 board on the right
Fig. 02The arm reaching out from its base, with the ESP32 on the right.
The arm moving under servo control, in two clips shown back to back.

Engineering challenge

The arm's design, instructions and laser-cut files were all provided to us, so the challenge of this project wasn't designing a robotic arm. It was to struggle through and persevere, working with hardware and software to make this work in a short amount of time, about a week.

Robotics is difficult because if one part of the robot doesn't work, none of it does. This project took a lot of effort and made me adapt over and over.

Once the arm worked, the course's second lab turned it into a stamp machine. The arm had to pick a rubber stamp off a rack with a magnet, ink it, press it onto paper, put it back, and repeat until a name was on the page. Nothing is measured by hand while it runs, so every position had to come through the camera.

Design process

We were instructed to write all the code with AI, for two reasons: AI is going to be part of our work anyway, so we might as well use it to our advantage, and there wasn't nearly enough time to write it all by hand.

We had discretion over how to move and control the arm, so I chose to select a servo and an angle and send the arm there. The sketch runs on the ESP32 and drives three servos, one 300° and two 180°. In the final system, MATLAB on the PC worked out the angles and sent the same servo-number-and-angle lines to the ESP32 over serial. The first three code snippets below show how the sketch works.

The full range of a servo isn't necessarily the full range of the robot. If I sent an angle too far one way or the other, the arm crashed into itself or the surface it sat on and the servo stalled, so I had to be careful about which angles I commanded.

For the stamp machine, the AI model wrote the code in stages. First it wrote ESP32 firmware and a MATLAB serial class so we could move the arm from MATLAB, though our final pipeline ran on the original course firmware. Next it wrote the computer vision program that detects the AprilTags; we uploaded the CAD file of the stamp rack so it knew the rack's orientation and spacing relative to the tags. For inverse kinematics we uploaded our homework and told it to build on that. After that it added the main routines: picking up a stamp, getting ink, stamping, and putting the stamp back with a wipe. It also added a dry-run check that every servo command is in range before the arm moves, and straight-line interpolation of the tip path so the stamp doesn't slide off the magnet while the servos move one at a time.

The model got us most of the way there, but we did a lot of fine-tuning. We adjusted how the end effector landed on the first letter, how far the base rotated to reach the next letter, and how far to push down on the wipe. We found that servo 1 didn't reach its full 300°, so we added a scale factor k0, between 0 and 1, that maps the commanded base angle to the angle the servo actually reaches. We refit k0 and its offset from measured misses at two letters, and the shoulder and elbow fits came from our homework's two-point fit.

We also calibrated along the rack. We picked up stamps across it, measured where each pick landed, and the model proposed yaw and radial corrections interpolated by rack position, which we tuned by trial. We fixed other problems the same way: wrong holder tag IDs, a mismatch between the camera calibration's resolution and the photo's, the wipe direction, and the stamp sliding off the magnet during lifts. For each one we reported the symptom, chose the fix and checked it on the arm. When the model said it had applied an edit that wasn't in the file, we caught it by comparing against the code we were actually running.

Every input to the model came from our own measurements. We measured the tip offsets, shoulder height and rack height with calipers, placed the tags, ink pad, paper and camera, ran every test on both arms, and measured every landing point with a ruler from the base tag.

The pipeline

  1. Calibrate the camera. The camera's intrinsics came from a calibration, and every photo was undistorted before anything was measured. The calibration's mean reprojection error was 0.188 px.

  2. Find the table frame. An AprilTag (tag36h11, 50 mm) on the arm's base plate defines the arm's base frame, with U and V along the table and W pointing up. A homography H maps table points in millimeters to photo pixels.

  3. Locate everything from tags. Tags on the stamp holder, the paper and the ink pad are detected in the same photo, so their positions come from the camera instead of being hardcoded. Each target is computed two ways, through the homography and through the tag's 3D pose, and the two are cross-checked. The holder's tags are tilted, so the stamp offsets are expressed in a flat frame that keeps the tilt out of the math.

  4. Turn positions into joint angles. A planar inverse kinematics routine, built on our homework, turns each target into a base yaw, a shoulder angle and an elbow angle.

  5. Turn angles into servo commands. A linear fit for each servo, angle = k × command + c, converts joint angles into commands. On my arm the base-yaw fit was k0 = 0.9280 and c0 = −146.0°, because that servo doesn't reach its full 300° range.

  6. Send the commands. MATLAB checks that every command is in range in a dry run, then sends the servo number and angle to the ESP32 over a serial connection, moving the tip in short straight-line steps. Each letter runs the same cycle: pick, ink, press, put back and wipe.

Overhead photo of the stamp rack, a base tag, a paper tag and an ink pad tag on a gray table, with colored markers drawn on top: yellow tag outlines with their heights, red and blue axes at the base tag, cyan circles and magenta plus signs along the arc of stamps, and green crosses for the paper start and the ink pad
Fig. 03The detection photo. Tags are outlined in yellow with their heights, the arm's U, V and W axes are drawn in red, green and blue, stamp positions from vision are cyan circles and from the CAD are magenta plus signs, and the paper and ink pad targets are green crosses.

Design decisions

Holder positions came from the tags rather than from the CAD alone, with the CAD used only for each stamp slot's offset from the tags. That makes the result independent of exactly how the rack was bolted down, and the two holder tags let us cross-check each other.

We ran the program on the PC in MATLAB instead of on the microcontroller, because the camera, AprilTag detection, homography and inverse kinematics all live there. It also let us log every intermediate value and edit parameters quickly between trials. The ESP32 only turns servo commands into motion.

Analysis & technical details

The arm in CAD

A side view of the arm from the assembly's CAD file, in the plane the arm moves in. Lengths are pivot to pivot, and they match the link lengths in the project's MATLAB code.

Orthographic side view of the RASTICrane CAD assembly: a base with a servo, a yellow upper arm and a purple back bar rising to an orange triangular elbow plate, two purple forearm bars running to a yellow tool plate, and a tool changer at the end
Fig. 04The arm in CAD
  1. Shoulder axis

    The upper arm pivots here, 17 mm out from the origin and 55.5 mm above the table, as in the arm's MATLAB code.

  2. Upper arm, a₁ = 80 mm

    The first link of the two-link arm, 80 mm between pivots.

  3. Back bar, 80 mm

    Parallel to the upper arm. With the elbow plate it forms a parallelogram, so the elbow plate keeps a fixed orientation.

  4. Elbow plate

    A triangular link where the upper arm, back bar and forearm bars meet.

  5. Forearm, a₂ = 80 mm

    Two parallel 80 mm bars. They form a second parallelogram with the tool plate, so the tool plate also keeps a fixed orientation.

  6. Tool changer

    The end of the arm, where each stamp is picked up.

The arm and its workspace in 3D

This is the project's CAD assembly, exported as a STEP file and rendered in the browser: the arm, its base and the table, paper and stamp rack it works on. Parts are grouped the way the build guide groups them (cab, boom, rigging, effector and base). Switch views, spin it, slide the layers apart, hide the table, or pick a part to see what it is and its CAD name.

Isometric render of the RASTICrane CAD assembly: the wooden arm on its base, reaching over the arc-shaped stamp rack on the table

Rotate, zoom, pull apart and inspect the real CAD assembly · about 0.5 MB

Move the arm, solve the angles

RASTICrane's linkage reduces to a two-link arm in the vertical plane it swings in. Drag the orange tool point and the inverse kinematics solve the upper-arm and forearm angles in real time, using the arm's real link lengths and offsets from the project's MATLAB code. It shows where the arm can and can't reach, but it is a geometric model, not a recording of the hardware.

BASE AXISGEOMETRIC REACHθ₁ 51°θ₂ -28°
Upper arm θ₁
51.0°
Forearm θ₂
-27.5°
Elbow angle
101.5°
Tool (r, z)
160, 78 mm
Status
Reachable

The equations behind it

q  = tool − d − shoulder        ρ = |q|
cos D = (a₁² + a₂² − ρ²) / (2·a₁·a₂)
α  = asin(a₂ · sin D / ρ)
θ₁ = atan2(q_z, q_r) + α
θ₂ = θ₁ − (π − D)

Link lengths and offsets are the ones in the project's MATLAB code: a₁ = a₂ = 80 mm, the shoulder 17 mm out and 55.5 mm above the origin, and the tool point (the magnet face) 22 mm out and 2.5 mm below the forearm pivot. I checked the lengths against the arm's CAD assembly. This is the same planar inverse-kinematics routine as the code below, without the base yaw and the 18 mm sideways tool offset, which act perpendicular to this plane. Servo ranges and collisions between parts are not modelled, so the shaded reach is purely geometric.

Error budget

Predicted versus measured miss for each arm, from the error budget in my lab report.
TermMy armSecond arm
Calibration reprojection error0.1373 mm0.06810 mm
Tag-center error through H2.800 mm1.990 mm
Parallax at the paper tag0.3980 mm0.3720 mm
Servo and geometry residual, radial0.6920 mm8.791 mm
Servo and geometry residual, yaw0.9670 mm0.7040 mm
Predicted miss (root-sum-square)3.071 mm9.049 mm
Measured mean miss2.565 mm20.707 mm
Unexplained≈ 018.63 mm

The prediction combines four independent terms by root-sum-square: the reprojection error, the tag-center error through H, the parallax at the paper tag, and the arm-side servo and geometry residual, shown here as its radial and yaw parts. The residual comes from the rack calibration trims.

Code

Moving smoothly
void stepToUs(ServoUnit &s, float targetUs) {
  while (abs(targetUs - s.currentUs) > STEP_US) {
    s.currentUs += (targetUs > s.currentUs) ? STEP_US : -STEP_US;
    writePulseUs(s.pin, s.currentUs);
    delay(STEP_DELAY_MS);
  }
  s.currentUs = targetUs;
  writePulseUs(s.pin, s.currentUs);
}

Each servo remembers where it currently is. To move, it steps toward the target pulse width 7 microseconds at a time with an 8 millisecond pause between steps, so the arm glides instead of snapping to position. Those two constants set the speed.

Choosing a servo and an angle
void moveServo(int index, float angle) {
  ServoUnit &s = servos[index];

  if (angle < 0 || angle > s.maxAngle) {
    // print an error and ignore the command
    return;
  }

  float targetUs = mapFloat(angle, 0, s.maxAngle, MIN_US, MAX_US);
  stepToUs(s, targetUs);
}

A command names a servo and an angle. The angle is checked against that servo's limit (300° for the first servo, 180° for the other two), converted to a pulse width between 500 and 2500 microseconds, and then eased there with the function above.

Serial commands and reset
if (line.equalsIgnoreCase("reset")) {
  // Retract distal joints first so the arm is folded
  // before the shoulder swings
  const int resetOrder[3] = {2, 1, 0};
  for (int k = 0; k < 3; k++) {
    stepToUs(servos[resetOrder[k]], 1500);
  }
  return;
}

int servoNum;
float angle;
int parsed = sscanf(line.c_str(), "%d %f", &servoNum, &angle);
// ...checks that both values were read and servoNum is 1-3...
moveServo(servoNum - 1, angle);

The sketch reads a line over serial, such as "2 90" to send the second servo to 90°. Typing "reset" returns every servo to its center position, moving the outer joints first so the arm folds up before the shoulder swings and doesn't crash into anything.

From a tag's pixel to a point on the table
camCentreWorld_mm = tfWorldFromCam(1:3, 4);
rayDirCam   = kMatrix \ [tag.centre_px(:); 1];            % pixel -> direction, camera frame
rayDirWorld = tfWorldFromCam(1:3, 1:3) * rayDirCam;       % rotate into world frame
t = (height_mm - camCentreWorld_mm(3)) / rayDirWorld(3);
snapped_mm = (camCentreWorld_mm + t * rayDirWorld)';

A tag's pixel gives an accurate direction from the camera, but its distance, estimated from its apparent size, is not. So the code keeps the ray through the tag's center pixel and replaces the distance with the tag's known height from the CAD: it intersects the ray with the horizontal plane at that height. The result is the tag's position in the arm's base frame, in millimeters.

Planar inverse kinematics
rho_mm = sqrt(x_mm^2 + y_mm^2);
r_mm = sqrt(rho_mm^2 - dS_mm^2); % Then everything else in the vertical (r, z) plane
theta0_rad = atan2(y_mm, x_mm) - atan2(dS_mm, r_mm);
q_mm = [r_mm; z_mm] - [b_mm; h_mm] - [d_mm(1); d_mm(2)]; % Strip the constants: q is the target as the two links see it, from A
qR_mm = q_mm(1);
qZ_mm = q_mm(2);
qMag_mm = norm(q_mm); % |q|
angleD_rad = acos((a1_mm^2 + a2_mm^2 - qMag_mm^2) / (2*a1_mm*a2_mm)); % Law of cosines at D: angleD is the interior angle between the two links
alpha_rad = asin(a2_mm*sin(angleD_rad) / qMag_mm); % Law of sines at A: alpha is the opening between q and the upper arm. (arcsin is fine as long as a1 >= a2, so alpha stays below 90 deg)
theta1_rad = atan2(qZ_mm, qR_mm) + alpha_rad;
theta2_rad = theta1_rad - (pi - angleD_rad);

The base yaw points at the target, adjusted for the small sideways offset of the arm tip. Then the two links work in the vertical plane through the target: the law of cosines gives the angle between the links, the law of sines gives how far the upper arm sits from the line to the target, and because the arm only folds one way, each target has a single solution.

Fabrication & assembly

The laser-cut file was designed for a thinner piece of wood than the one I used, so I had to sand down a lot of the connections and jam some of the others together. I also had to sand the tight servo horn pockets that were cut out of the wood.

The joints took tuning too. They had to be loose enough to rotate freely, but not so loose that they came undone.

The ESP32 sits on a PCB that I soldered by hand. The pin headers had to be perfectly vertical for the ESP32 to fit onto the board, and the connections were so close together that too much solder would spill over while too little would give a poor electrical joint. We ran continuity tests and resoldered whenever one failed.

Testing & results

The arm was assembled and moved under servo control (first video above), and then it became a working stamp machine. Both arms ran the same pipeline on the same rack, and each stamped four letters spelling its owner's name, picking every stamp off the rack, inking it, pressing it onto the paper, putting it back and wiping it off the magnet. Each arm ran its own copy of the script with its own servo calibration, rack trims and first-letter shift, and the logic of the two scripts was otherwise identical.

I measured every landing point with a ruler from the base tag. On my arm, the four letters landed an average of 2.565 mm from where they were commanded, and the worst letter missed by 3.493 mm. On the second arm, the average miss was 20.707 mm and the worst letter missed by 24.084 mm.

The error budget predicted a miss of 3.071 mm for my arm and 9.049 mm for the second. On my arm the prediction matched the measurement, and the largest term was the tag-center error through the homography (2.800 mm). On the second arm the largest term was the radial servo and geometry residual (8.791 mm), which agreed with the measured radial miss of +10.26 mm. But the measured tangential miss of −17.88 mm, about 7.7° of yaw, was not in the budget at all. The most likely sources are extrapolating the base-yaw servo fit from the rack side to the paper side, and uncalibrated tool offsets. Every letter from the second arm was also turned further clockwise than commanded, by 7.740° on average. The calibration's reprojection error was negligible for both arms.

The second arm's mean miss was 20.707 mm against 2.565 mm for mine, about eight times larger (20.707 ÷ 2.565 = 8.07). We think the servo calibration is the main source of the difference, but we can't rule out the flipped layout, since the arm and the layout changed together. Each servo is slightly different and had to be calibrated separately for each arm. We spent a lot of time on my arm, so its calibration was very accurate. After switching to the second arm, we only made sure it could pick up the four stamps we used. An error in that calibration wouldn't have shown up on those picks, but it would have grown with the large rotation to the paper on the other side of the base, and most likely produced the larger miss.

For my arm, the ink pad was on the right and the paper on the left, and for the second arm they were flipped. To save time, we combined the second arm's run with the moved-layout run. In that run the paper and ink pad were in new places and the camera found them from their tags, with nothing hardcoded, and the same sheet and video cover both. The cost is that the arm and the layout both changed between the two runs, so we can't fully separate the arm's calibration from the layout's effect on the miss.

A sheet of lined paper with two columns of ink-stamped letters, each marked with a black ring where it was commanded, a red dot where it landed and the miss in millimeters. The right column, from my arm, has misses from 1.703 to 3.493 mm, and the left column, from the second arm, has misses from 18.387 to 24.084 mm
Fig. 05The stamped sheet with both arms' results: my arm is the right column and the second arm is the left. The black rings are the commanded positions, the red dots are where the letters landed, and the blue numbers are the miss in millimeters.

The stamping runs

Fig. 06My arm's run: stamping my name one letter at a time, with the paper on the left and the ink pad on the right.
Fig. 07The second arm stamping its owner's name, with the paper and ink pad flipped to the opposite sides. This single run serves as both the second-arm run and the moved-layout run.

Problems & lessons learned

Getting the ESP32 to communicate over MQTT took the longest. A good chunk of the class, along with the professor, worked together in the robotics maker space from noon until 11:30 at night trying to figure it out. The cause turned out to be that some of the wood was blocking the ESP32's Wi-Fi chip, and that requirement was removed.

The biggest lesson was persistence: a tight fit, a bad solder joint or a blocked antenna can stop the whole robot, and each one had to be found and fixed.