Lesson 04 – Calibrate Legs & Feet

What is OTTO DIY – Otto is completely open source, Arduino compatible, 3D printable robot which you can put together yourself. This is robotics and opensource at it’s best. The robot was designed by Camilloa Parra as a social impact mission to create an inclusive environment for all kids. Learn more about OTTO DIY and grab a kit at www.ottodiy.com.

Software Required : You will need either Otto Blockly or the Arduino IDE to work on this tutorial. Head over to the following page to learn how to get Otto Blockly or the Arduino IDE installed on your machine – https://learning.kidzcancode.com/lesson/lesson-03-programming-your-otto-robot/ . Once you have the tools installed, launch the relevant application i.e. Otto Blockly or the Arduino IDE and get started using the code shown below.

Uploading code to the Otto DIY Robot : Here’s the process to upload code to the Otto DIY Biped robot.

  1. To upload the code to the Arduino Nano (brain of your Otto DIY Biped Robot) you will need to make sure you have the Otto DIY robot connected to your laptop/desktop using the correct cable.
  2. Then select the right COM (Communication Port) and type of Arduino board using the drop down menus provided at the top of the screen.
  3. Once that’s sorted hit the “tick mark” icon to validate your code and make sure you do not see any errors pop-up.
  4. Finally hit the “right arrow” icon to have the code uploaded to the Arduino Nano housed within the Otto DIY robot.

Tutorial : As part of this tutorial you will calibrate the servos connected to the OTTO DIY Biped robot. Please take your time and work through the content in this section.

!!! Very Important !!!!! Calibration of the servos!!!!!!!

Calibration of the servos is a very critical component of the build process, so please make sure you read through the documentation provided, view the videos and come back to the learning content here as many times as you need to. Calibration is the process of ensuring that the horn (shaft of the servo) is –

  1. At the 90 degrees (In the centre of its deflection capability) when idle
  2. You are not manually needing to position any of the servos on the leg, feet at startup every time to ensure they are all aligned at the 90 degree position

PLEASE DO NOT FORCE the servo horn at any point beyond its free sphere of rotation. You can very easily break the servo if you do that. If you are not sure please get someone to assist you with the build of the OTTO DIY robot.

!!! Very Important !!!!! Calibration of the servos!!!!!!!

  1. Before you embed the Arduino Nano, Arduino Nano Extension board, servos and the other sensors into the 3D printed head/body of the robot please take a few minutes to calibrate the servos.
  2. Calibration of the servos ensures that all of them spin their heads in the same direction, at the same time.
  3. You know you’ve been successful when you are able to see all the servos spinning their heads in the same direction with the same amount of travel each time.
  4. If in doubt, look up the manual and revisit the video below.

Check out the tutorial below to calibrate the sensors before you connect them up to the robot.


Option 1 – Here’s a simple, approach to calibrating your servos.

  1. Step 1 : Grab one of the servos, place the servo horn on top of the servo head as show in the 90 degree position (Servos mostly ship with the head set in the 90 degree position)
  2. Step 2 : Wire up your servo, connect it to the relevant pins on the Arduino Expansion board
  3. Step 3 : Program the Arduino Nano using the code from Lesson 5 (Testing out the servos)
  4. Step 4 : Power up the Arduino Nano, you should now see your servo horn moving from 0 degrees, to 90 degrees, to 180 degrees
  5. Step 5 : You might need to realign servo horn as required. However, let the program on the Arduino bring the servo head to 90 degree before you pull the power.
  6. Step 6 : Once you are sure that the servo head is at 90 degree, pull the power, unscrew the servo horn and replace in the correct position.

Note : The SG90 are cheap 2$ servos, please DO NOT expect it to be perfectly aligned at 0, 90 or 180 degrees. I’ve mostly found an error of 2-3 degree at at-least one position i.e. 0, 90, 180, for most of the servos i have worked with.

Hopefully this simple approach works for you as well.

Option 2 – Camillo Parra and the OTTO team have developed a new tool to make it easy to calibrate the robot. Check out the following video to learn how to use the tools. You’ll need to download the software from the following link – Otto Servo Calibration Software (Github link). You will need to download the calibration software 32 or 64 bit version, along with the bloc code which you’ll need to upload onto the OTTO DIY Biped robot for the application to work.

Before you can use the calibration software you will need to upload the calibration program into the Arduino Nano.

Download Otto Block code here – <Link to Otto Blockly Code>

Check out the following video to see the calibration software in action.

Option 3 – This article recommends an alternate approach to calibration of the servos – https://www.ottodiy.com/blog/calibration

Once you are done with the build, calibration of the OTTO DIY robot you are good to move onto the next tutorial, download the software and prepare to start programming your robot.

See Arduino code provided below.

 
#include <Otto.h> //Requires you to have the Otto libraries installed within the Arduino IDE
Otto Otto;
#include <EEPROM.h>
int i = 0;
int v = 0;
  int positions[] = {90, 90, 90, 90};
  int8_t trims[4] = {0,0,0,0};
#define LeftLeg 2 // left leg pin, servo[0]
#define RightLeg 3 // right leg pin, servo[1]
#define LeftFoot 4 // left foot pin, servo[2]
#define RightFoot 5 // right foot pin, servo[3]
#define Buzzer 13 //buzzer pin

void readChar(char ch) {
  switch (ch) {
  case '0'...'9':
    v = (v * 10 + ch) - 48;
    break;
   case 'a':
    trims[0] = v-90;
    setTrims();
    v = 0;
    break;
   case 'b':
    trims[1] = v-90;
    setTrims();
    v = 0;
    break;
   case 'c':
    trims[2] = v-90;
    setTrims();
    v = 0;
    break;
   case 'd':
    trims[3] = v-90;
    setTrims();
    v = 0;
    break;
   case 'w':
    for (int count=0 ; count<4 ; count++) {
      Otto.walk(1,1000,1); // FORWARD
    }
    break;
   case 's':
    for (i = 0; i <= 3; i++) {
      EEPROM.write(i,trims[i]);
    }
    delay(500);
    Otto.sing(S_superHappy);
    Otto.crusaito(1, 1000, 25, -1);
    Otto.crusaito(1, 1000, 25, 1);
    Otto.sing(S_happy_short);
    break;
  }
}
void setTrims() {
  Otto.setTrims(trims[0],trims[1],trims[2],trims[3]);
   Otto._moveServos(10, positions);}

void setup() {
  Otto.init(LeftLeg, RightLeg, LeftFoot, RightFoot, true, Buzzer);
Otto.home();
  Serial.begin(9600);
    // 1. Upload this code to your robot, wait until is successful
  // 2. Unplug the USB connection and close Otto Blockly.
  // 3. Download, Unzip and Run the calibration app
  // 4. Plug the USB again into Otto (the red cross will turn into a green tick)
  // 5. Now adjust the servo positions so the the legs and feet are correctly aligned in the robot on your table.
  // 6. When the servos on Otto are correctly aligned, click on 'Walk Test' to see how Otto moves.  If does not wlak straight, iterate step 5
  // 7. Once you are happy with the calibration, click 'Save'.
  v = 0;
}
void loop() {
    if (Serial.available()) {
      readChar((Serial.read()));
    }
}

Purchasing the OTTO DIY Robot : To learn more about the Otto DIY robot or purchase a off the shelf kit please head over to the OTTO DIY website at www.ottodiy.com. By purchasing the kit you will be supporting Camillo Parra and the rest of the OTTO DIY Robot team. At the OTTO DIY website www.ottodiy.com you also have the option to purchase the kit without the 3D printed parts, print the parts yourself using your own 3D printer at home.

For those interested in downloading the 3D models for printing using your own 3D printer, you will find a number of OTTO DIY robot re-mixes (3D print models) along with the original project at the Printables website (hosted by the guys who own Prusa). So head over to the 3D models hosted at Printables.com website to see all the different variants of the OTTO DIY robot listed there. If you are just wanting to download the parts for the basic Otto DIY Biped Robot then check out the following link at the main OTTO DIY Biped Robot page at the Prusa website.

For Makers, Creators & Innovators – If you are a maker, hacker and want to put together your own 3D printed robot using off the shelf components then check out this article at DIYODE – 2 Legged 3D Printed Robot. You can source all the components, parts listed above from Ebay/Amazon. If you do that, you are responsible for identifying and sourcing relevant parts, however if you purchase the kit from the OTTO DIY website www.ottodiy.com you will get quality parts including support from the OTTO DIY team.

Learn more about the OTTO Biped Project and join the OTTO DIY Robot community here – https://wikifactory.com/+OttoDIY/otto-diy  and here https://wikifactory.com/+OttoDIY/otto-diy-plus

Questions