Skip to main content

Sesame Robot Build: Fixing the Backwards Left Legs

· 9 min read
Bogdan Varlamov
Bogdan Varlamov
Technologist

I built a Sesame robot for my kids over three days, November 21 to 23. It's a small, open-source quadruped with a face on a 128x64 OLED, and it walks. Two of its legs moved the wrong way until I added one line to setServoAngle that sends 180 - angle to the left hips. The stock firmware assumes a motor geometry that is not how my motors rotate.

The finished Sesame robot with its OLED face showing

The build progress​

Sesame uses an ESP32, eight MG90 servos (two per leg), a printed frame, and a small OLED for the face. The project sells a distribution board. It also documents a DIY build around a Lolin S2 Mini. I built the DIY version and hand-wired the electronics on perfboard.

The S2 Mini sitting on pin headers soldered into a perfboard

The perfboard carries a header row for the eight servo plugs and a buck converter that reduces the battery voltage for the servos. I printed the parts in glow-in-the-dark PLA and placed everything on the bench before I assembled the frame. The battery is a 7.4V 2600mAh Li-ion rechargeable pack with an XH2.54 2-pin plug.

Printed frame, servos and joints laid out on the bench Perfboard with the buck converter wired in Servo wiring routed through the frame

Troubleshooting​

Why were my Sesame robot's left legs backwards?​

The calibration steps in the Sesame motor testing guide have you remove the hip joints, send the robot to REST so every servo holds 90 degrees, attach each hip parallel to the body, then send STAND. In STAND, the motor testing guide says each hip moves 45 degrees from 90. R1 and L2 move one way, and R2 and L1 move the other way. The legs should form a mirrored X.

On my robot, the right side did what it should and the left side moved the wrong way.

I could get the legs to work in one of two configurations. With the legs forward and backward, the left side was fine. With the legs out to the sides, the right side was correct and the left side was not correct. When I fixed one posture, the other broke.

The pose code sets each hip to an absolute angle. Here is runStandPose, from movement-sequences.h:

setServoAngle(R1, 135);
setServoAngle(R2, 45);
setServoAngle(L1, 45);
setServoAngle(L2, 135);

The left hips get the opposite angle of the right hips. The angle diagram in the Sesame build guide draws each hip as a dial from 0 to 180 degrees, with 90 pointing straight out from the body. In that diagram, every servo counts up counterclockwise when seen from above. With that rule, opposite angles on the left and right send the legs to mirrored positions and form an X.

Top-down diagram of the four hip servos in the STAND pose. On the build guide's robot the legs form an X. On my robot with stock firmware, the two left legs cross.

The stock commands moved my two left legs the wrong way. My motors sit in the frame the same way as in the build guide's motor install image. Here they are side by side. The shafts sit in the same positions on all four motors.

Left: the Sesame build guide's render of four servos mounted in the frame. Right: a photo of my frame with the four servos mounted the same way.

The left image comes from the Sesame project, which uses the Apache 2.0 license. Because my mounting matches the build guide, I can't point to a mounting mistake. I described the problem in the project's Discord and have not checked the project's issues.

Frame Too Tight​

The bottom of the frame has a void cut into it for one specific battery pack, and my battery was too large for it. The frame also had wire guides along the bottom.

The motor mounts leave very little clearance. The frame cut the wires of the first motor I tried to mount, because the frame sat too close for the motor to fit.

Why did the Lolin S2 Mini firmware upload fail?​

The first upload to the Lolin S2 Mini failed. The upload succeeded only after I pressed the RST and 0 buttons on the board.

The solutions I used​

Mirror the left hips in firmware​

One function sends every servo write, so I made the fix in that function:

void setServoAngle(uint8_t channel, int angle) {
if (channel < 8) {
if (channel == L1 || channel == L2) angle = 180 - angle; // left hips need the opposite direction on my build
int adjustedAngle = constrain(angle + servoSubtrim[channel], 0, 180);
servos[channel].write(adjustedAngle);
delayWithFace(motorCurrentDelay);
}
}

180 - angle flips a hip's direction around its center. REST sends 90 to everything, and 180 - 90 is still 90. The left legs therefore moved wrong only in STAND and when the robot walked.

The subtrim offset is added after the flip, so a trim value on a left hip applies in the physical direction.

After I added that line, STAND made an X and the walk cycle worked. The stock firmware assumes a motor geometry that is not how my motors rotate, and this line corrects for it.

I edited the frame STL to make it thinner. The edit removed the battery void and the wire guides and left a flat bottom, and a velcro strap now holds the battery under the belly. The thinner frame also makes motor mounting easier, and the motor wires are no longer cut.

The stock Internal-Frame-v121.stl is 15.7 mm tall, as I measured from the file. My edited minimal-frame.stl is 9.27 mm tall, and I rotated it to lie flat for printing. You can download my edited frame. The Sesame project uses the Apache 2.0 license, and my edited frame is a modified version of the project's frame.

Put the S2 Mini in DFU mode​

The Wemos Arduino guide for the S2 series describes the step. You put the board into Device Firmware Upgrade (DFU) mode before uploading:

  1. Hold the 0 button.
  2. Press the RST button.
  3. Release the 0 button when the USB connection drops and reconnects.

The Sesame build guide only says to be comfortable "resetting/entering boot mode", and its firmware troubleshooting suggests holding the BOOT button during upload. Neither names the S2 Mini's 0 and RST buttons.

What else I'd change​

  • Battery bay. The stock frame has a pocket sized for one battery pack. A flat bottom with a velcro strap, as in my edited frame, fits any pack. A mount above the frame would also work.
  • Lid size. My lid can't close with everything inside. A larger lid solves the closing problem.
  • Mount the circuitry on the lid. The power switch and the screen are both on the lid already. If the perfboard lived there too, the servo plugs would all connect in one place and the lid would be one removable unit.
  • Screen mounting holes. The printed holes didn't match my OLED module. The lid needs a design that holds the screen with a pressure fit when I insert the screen, and that accepts the screws 90 degrees from where they are today.
The lid with the power switch, with the battery visible underneath

Future ideas​

Joystick control over WiFi​

I want to connect the robot to my computer over WiFi and pilot it with an old joystick. A joystick is easier for my kids to use than the arrow buttons.

The firmware already runs a WiFi access point with an HTTP API. A request to /api/command accepts forward, backward, left and right. The web portal has four arrow buttons for these commands, and a gamepad stick maps to the same four commands, one direction at a time. Left and right are turns. A joystick program on the computer could send the same commands.

I would also add strafing, so the robot could step left and right and not turn. Strafing needs new movement steps in the firmware. The stick would then strafe on left and right, and turning would move to the twist or to buttons, depending on the joystick.

Diagram comparing the current four arrow commands with a planned joystick layout. The planned layout adds strafe left and strafe right on the stick, and moves turning to the twist or to buttons.

A motor alignment calibration sequence​

I want to add a motor alignment calibration sequence to the firmware. It would check that each motor is mounted correctly and set offsets where a motor needs them. A sequence like this would catch the type of problem I had with the left legs before the robot tries to walk. The firmware already has a servoSubtrim value for each servo, so the calibration could store its offsets there.

A speaker​

I want to add a speaker so I can route sound through the robot. It could talk, play music, or sing and dance. The firmware already has talking faces, so the display could match the sound.

A seat on top​

I also want to design a small seat on top of the robot, so my kids can put toy figures on it and give them a ride.