Log 7: The whole leg on the bench

· A build log for LocksleyFox, a home-built robot dog

Up to now each motor had been tested alone on a stand. This is the first time the full leg came together: the hip motor in its printed mount, the knee motor inside the printed thigh, and the shank and foot below it. Everything is still the gray PLA fit-check print of leg 1.0e.

The night before, I put the knee motor into the thigh on its own and found its range by hand. With the shank against its end stop the motor reads 2.721 rad, and the design allows 120° of bend from there. Then came the first powered knee moves: 30°, 73° and 113°, each slow, held for two seconds and brought back. After that, a smooth back-and-forth sweep up to 4 rad/s. No faults, and the motor stayed at 15 °C.

For the full leg I clamped a board to the workbench and hung the hip mount underneath it, so the leg swings freely in the air with nothing to hit. Both motors share one CAN bus from the Teensy.

The PLA leg hanging under a board clamped to a workbench, with the Teensy and CAN board on a breadboard beside the hip motor
The bench rig: hip mount under a clamped board, knee motor in the thigh, Teensy and CAN board on the breadboard

The first scan only found the new hip motor, still on its factory ID of 127. The knee motor didn't answer at all. The cause was the plug between the two motors, which wasn't fully seated. After re-seating it both answered, and I gave them their permanent IDs, 1 for the hip and 2 for the knee. They kept them after a power cycle.

Then the first moves with the whole leg: the hip alone lifting the thigh 30° and back, then both motors at once. After that I wrote a simple walking motion, with the hip swinging back and forth while the knee lifts the foot on each forward swing. It ran four times for the camera, speeding up to one stride a second, with no faults and both motors at 20 °C.

The leg swinging under the board during the first walking motion
The first walking motion, in the afternoon (video)

Watching the video afterwards, it didn't look like walking. The hip went out to one side and straight back, and the knee folded most at the far end of that swing. I fixed the timing, but the evening video was still wrong in a different way. The thigh hung straight down and the knee stayed bent, so the shank stuck out sideways. The foot never came under the hip or anywhere near where the ground would be.

The thigh hanging straight down with the shank sticking out sideways
Before: each joint moved on its own, and the foot never got near the ground
The thigh leaning back and the foot planted under the hip
After: the foot path is planned first, and the foot stays on a flat line under the hip

The real problem was the approach. I had been moving each joint on its own and hoping the foot ended up in the right place. The fix was to plan the foot instead. In stance, the part of the step where the foot is on the ground, the foot slides straight back along a flat line 224 mm below the hip. That's the standing height from the simulation. In swing it lifts and comes forward. The Teensy turns each foot position into hip and knee angles 100 times a second using the leg's geometry (two 140 mm links). This is called inverse kinematics.

Before running it, I checked the geometry with a still pose. Both joints moved to the standing position and held it. The front tip of the foot ended up right below the hip motor, with the foot pad almost flat, tipped down only 2 or 3 degrees at the toe. So the leg matches its own math closely.

The first planned gait used a short 40 mm step, because I had guessed the hip's range too small. I moved the leg by hand to show how far back the hip can really go, and with the corrected limit the step grew to 80 mm with a 40 mm lift. Then I ramped it from a quarter stride a second up to 1.58 strides a second. That's about twice the earlier speed, and as fast as the knee can go under the software's 6 rad/s safety cap.

Video frame: the leg stepping on the left, and on the right a panel with strides per second, pace in km/h, the planned and measured foot path, hip and knee angles, torque and motor temperature
From the gait video: the leg next to a live data panel (video)

I ran it a second time with logging at 20 samples a second, so the graphs show real measurements:

  • The measured foot path sits right on the planned one. At slow speed the foot was within about 4 mm of the plan on average. At top speed it trailed by up to about 17 mm, cutting the top of the swing a little short.
  • Torque stayed small, about 1.2 N·m at the hip and 0.5 N·m at the knee. That's under 10% of what the motors can do, since the leg is only moving its own weight.
  • Both motors stayed at 19 °C the whole time.

How fast would that be for a whole dog? Each foot pushes 80 mm back while it's on the ground, which is 60% of each stride. At 1.58 strides a second, four legs like this would carry the body at about 0.21 m/s, or 0.76 km/h. That's a slow walk. The limit is the cautious speed cap, and the motors have plenty left.

One recurring annoyance: the Teensy has dropped off USB five times so far. Re-seating the cable and pressing its program button brought it back each time. The cable or the connector is the next thing to replace.