6 📐 Calibration and Final Assembly

"A miss is as good as a mile." 🎯

Calibration is vital for Bittle to work properly.

In the previous sections, we have prepared Bittle's body parts, but haven’t screwed them onto servos because we still need to calibrate body parts to be attached to servos at the right angles.

If we don’t calibrate the servos before attaching them, they may rotate to any direction, get stuck, cause damage to either the servos or body parts and cause robot limbs not to function properly.

The calibration has the following steps:

  1. Write constants to the board

  2. Power on the circuit, let servos rotate freely to zero angle/calibration state

  3. Attach body parts to the servos

  4. Fine-tune the body part placements and store the calibration results on board.

Please make sure you turn on the battery first.

The logic behind calibration can be found on the OpenCat forum. The principles are the same for Nybble and Bittle.

6.1 Write constants to NyBoard

6.1.1. Three types of constants to be saved to NyBoard:

  1. Assembly-related definitions, like joint mapping, rotation direction, sensor pins. They are pretty fixed and are mostly defined in OpenCat.h. They are even kept consistent with my future robots;

  2. Calibration-related parameters, like MPU6050 offsets and joint corrections. They are measured in realtime and are saved in the onboard EEPROM. They only need to be set up once;

  3. Skill-related data, like postures, gaits, and behaviors. They are mostly defined in InstinctBittle.h. You can add more customized skills too.

6.1.2. Upload and run WriteInstinct.ino.

The role for WriteInstinct.ino is to write constants to either onboard or I2C EEPROM, and save calibration values. It will be overwritten by the main sketch OpenCat.ino afterward.

You need to change the * on line#define NyBoard_V*_* in OpenCat.h to match your NyBoard’s version. The version number is printed beside the logo on the NyBoard.

Make sure to set the serial monitor as 115200 baud rate and no line ending.

You also need to dial the slide switch on NyBoard to Arduino rather than Pi!

After you upload WriteInstinct.ino via Arduino IDE, open the serial monitor. You will see several questions:

Reset all joint calibration? (Y/n)

If you have never calibrated the joints, or if you want to recalibrate the servos with a fresh start(zero state), type ‘Y’ to the question.

Do you need to update Instincts? (Y/n)

If you have modified the Instinct.h in any way, you should type ‘Y’. Though it’s not always necessary once you have a deeper understanding of memory management.

Calibrate MPU? (Y/n)

If you have never calibrated the MPU6050, i.e. the gyro/accelerometer sensor, type ‘Y’.

Sometimes the program could halt at the connection stage. You can close the serial monitor and reopen it, or press the reset button on NyBoard, to restart the program.

6.1.3. Upload OpenCat.ino

You also need to upload OpenCat.ino to save the last constants and activate the demo functionalities.

6.2 Initial calibration

6.2.1 Enter calibration mode via remote controller

You MUST plug in all the servos and battery for proper calibration.

Before we attach the legs, the servos' output shafts should be at the zero state.

6.2.2 Head and limb calibration

Take one assembled upper leg and keep Bittle in the calibration mode by pressing the “EQ” button on the IR remote controller. .

Attach the yellow side of the upper leg to the shoulder servo. Try to find the direction closest to the vertical angle. Don't rotate the servo during installation. Install the lower leg at a perpendicular angle to the upper leg. Then repeat to install all other limbs.

A visualization of the perfect zero(calibrated) state when you enter the calibration mode

You can use the included "L" shape tuner as a reference(see next section) for keeping things in line.

Next, insert the output shaft of the head servo into the servo arm of the neck. Try your best to attach the head to point straight ahead.

6.2.3 Testing and validations

Hold the body of Bittle in the air. Press the "1" button on the IR remote controller to make Bittle perform a few "stretches". Observe if all the limbs are moving fine.

If the movements look intuitively, Place Bittle on a flat floor. Press a few action buttons on the IR remote controller to make Bittle move around and check if its moves look fine.

Then press the "EQ" button to get back to the calibration mode. Observe if its upper legs and lower legs are perpendicular to each other and whether the lower legs are parallel to the ground.

If the legs/head are at the right positions, use the flat end screw to fix the limbs and head onto servos.

Otherwise, take off limbs to do a few rounds around of calibrations.

If you can't achieve good results, it's time to do precise calibration.

6.3 Precise calibration

6.3.1 Understand the zero state and the coordinate system

The zero state is defined as the middle point of the servo’s reachable range.

In calibration mode with all servos rotated to their zero states(zero angles), rotating the limbs counter-clockwise from their zero states will be positive (same as in polar coordinates). The only exception is the tilt angle for the head. It’s more natural to say head up, while it’s the result of rotating clockwise.

A visualization of the perfect zero(calibrated) state when you enter the calibration mode

If we take a closer look at the servo shaft, we can see it has a certain number of teeth. That’s for attaching the servo arms, and to avoid sliding in the rotational direction. In our servo sample, the gears are dividing 360 degrees to 25 sectors, each taking 14.4 degrees(offset of -7.2~7.2 degrees). That means we cannot always get exact perpendicular installation.

6.3.2 Understand the serial outputs via software-based calibration

Software-based calibration for servos can be done in either WriteInstinct.ino or OpenCat.ino. I recommend you do it with WriteInstinct.ino in case there’s something wrong with the constants.

Upload either file to Bittle via Arduino IDE. Then in the serial monitor, type ‘c’ to enter calibration mode.

The servos should rotate one by one with unnoticeable time intervals then stop. Depending on their initial shaft direction, some may travel larger angles until stopping at the middle point. There will be noise coming from the gear system of the servos. You will see a calibration table like the following:

The first row is the joint indexes, the second row is their calibration offsets:

Index

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

Offset

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

Initial values are “-1” or “0”, and should be changed by later calibration.

6.3.3 Fine-tune the calibration on the software side

The command for fine-tuning calibration (refer to the serial communication protocol for NyBoard) is formatted as cIndex Offset. Notice that there’s a space between cIndex and Offset.

Joint Indexes

For example,

  • c8 6 means giving the 8th servo an offset of 6 degrees.

  • c0 -4 means giving the 0th servo(the head) an offset of -4 degrees.

If you find the absolute value of offset is larger than 9, that means you are not attaching the limb closest to its zero state. That will result in a decreased reachable range of the servo on either side. Take off the limb and rotate it by one tooth. It will result in an opposite but smaller offset.

For example, if you have to use -9 as the calibration value, take the limb off, rotate by one tooth then attach back. The new calibration value should be around 5, i.e., they sum up to 14. Avoid rotating the servo shaft during this adjustment.

Find the best offset that can bring the limb to the zero state. It's a process of trial and error.

After calibration, remember to type ‘s’ to save the offsets. Otherwise, they will be forgotten when exiting the calibration state. You can even save every time after you’re done with one servo.

6.3.4 Use ‘L’ shaped joint tuner

When watching something, the observation will change from different perspectives. That’s why when measuring length, we always want to read directly above a referencing ruler.

It’s especially important that you keep a parallel perspective when calibrating Bittle. Use the 'L' shaped joint tuner as a parallel reference to avoid reading errors. Align the tips on the tuner with the center of the screws in the shoulder and knee joints, and the little hole on the tip of the foot. Look along the co-axis of the centers. For each leg, calibrate shoulder servos (index 8~11) first, then the knee servos(index 12~15). When calibrating the knee, use the matching triangle windows on both the tuner and shank to ensure parallel alignment.

Align the upper leg first
Pay attention to the reference edges for the lower leg

6.3.5 Testing and validation

After calibration, type ‘d’ or ‘kbalance’ to validate the calibration. It will result in Bittle symmetrically moving its limbs between rest and stand state.

Please refer to the previous testing & validation section for the process.

You may need to do a few rounds of calibrations to achieve optimal states.

6.3.6 Center of mass

Try to understand how Bittle keeps balance even during walking. If you are adding new components to Bittle, try your best to distribute its weight symmetrically about the spine. You may also need to slide the battery holder back and forth to find the best spot for balancing. Because the battery is heavier in the front, you can also insert it in a reversed direction to shift the center of mass more towards the back.

You may need to recalibrate if there's a change to the center of mass.

6.4 Finish assembling

6.4.1 Head

To lock in the head, use an M2x4 flat head screw to lock the servo shaft and the servo arm from the bottom side of the chassis.

6.4.2 Limbs(upper and lower legs)

Use the M2x4 screws to lock all the limbs.

6.4.3 Wire shield

There’re two snaps on both sides of the wire shield. Their relative height is different.

Flatting the wire of the lower leg to remove any coils. Then snap the wire shield to the upper leg.

The edge of the shield should be parallel to the surface of the upper leg.

You may need to recalibrate if more or less weight is put on Bittle or the center of mass has been changed.

Below shows the wrong installation configuration.

6.4.4 Body cover and tail

The 6-pin female socket is used for connecting the programmer and communication dongles. Carefully bend it forward in a smooth arc if you are not going to attach a Raspberry Pi.

Attach the tail to the pin on the cover.

Snap the cover from one side of the body. Organize the wires so that they don't get stuck between the cover and the body. Then push the cover down to the other side of the body. You should hear a clear snap sound.