Wombatics Otto Robot

by WombaticsCo in Circuits > Arduino

4286 Views, 48 Favorites, 0 Comments

Wombatics Otto Robot

Wombatics Otto Kits.jpg
00-Wombatics-Otto.jpg

"Wombatics Otto" is to make an Otto DIY Robot with built-in BLE, Motion Sensing and Lithium Battery Charger. The body and head have been changed for easier access to the mainboard and no more hanging wiring.

Source Code & 3D Files for this project are in Github

https://github.com/wombatics/wombatics-otto

The Wombatics SAM01 mainboard is built for projects which need to work with mobile app, servos and motion tracking in mind. With onboard Bluetooth Low Energy (BLE) module, it is compatible with both Android and iOS.
It is ideal for building your own robot such as Otto. This project is a remix of Otto with Wombatics mainboard. More details of Wombatics board.

https://www.wombatics.com

https://github.com/wombatics/sam01

https://www.wombatics.com

3D Printing

00-Wombatics-3D-Print.png

3D Printing Setting

Layer Height : 0.2mm
Outline Shells : 3
Fill : 10%
Supports: No

STL Files
2 x OttoDIY_foot_v08.stl
2 x OttoDIY_Leg_v08.stl
1 x Wombatics Otto Body.stl
1 x Wombatics Otto Head.stl

Setup the 4 Servos

Wombatics_OTTO_Step_01.png

Connect the servos to D3, D4, D5 and D6 to the mainboard as the diagram below. Connect the mainboard and computer with a micro usb cable.

Arduino Setup

02-Arduino-IDE.png

Open Arduino IDE under Tools, pick Board: Arduino Nano, Processor: ATmega328P (Old Bootloader) and the correct Port. (USB driver for the wombatics mainboard: http://bit.ly/cp2112-usb-serial )

Servo Test

Test whether the servos are working with the (OTTO_Servo_Setup.ino). Leave it at 90 degree at the end for assembling the robot.

#include <Servo.h> 
#include <Oscillator.h>


/*
                 --------------- 
                |     O   O     |
                |---------------|
RIGHT LEG 4==>  |               | <== LEFT LEG 3
                 --------------- 
                    ||     ||
RIGHT FOOT 6==>   -----   ------  <== LEFT FOOT 5
                 |-----   ------|
*/

#define PIN_LEFT_LEG   3   
#define PIN_RIGHT_LEG  4  
#define PIN_LEFT_FOOT  5  
#define PIN_RIGHT_FOOT 6 

#define N_SERVOS 4 // There are four servos 
Oscillator servo[N_SERVOS];

void setup()
{
  servo[0].attach(PIN_LEFT_LEG); 
  servo[1].attach(PIN_RIGHT_LEG); 
  servo[2].attach(PIN_LEFT_FOOT); 
  servo[3].attach(PIN_RIGHT_FOOT); 

  //Test 45 degree
  servo[0].SetPosition(45);
  servo[1].SetPosition(45);
  servo[2].SetPosition(45);
  servo[3].SetPosition(45);
  delay(1000);

  //Test 90 degree
  servo[0].SetPosition(90);
  servo[1].SetPosition(90);
  servo[2].SetPosition(90);
  servo[3].SetPosition(90);
  delay(1000);  

  //Test 135 degree
  servo[0].SetPosition(135);
  servo[1].SetPosition(135);
  servo[2].SetPosition(135);
  servo[3].SetPosition(135);
  delay(1000);  

  // Set Final position to 90 degree for assembly
  servo[0].SetPosition(90);
  servo[1].SetPosition(90);
  servo[2].SetPosition(90);
  servo[3].SetPosition(90);
  
  delay(1000);
  
}

void loop() 
{

}

Assembling Part 1 - 3D Printing Parts and Servos

01-Body-with-Servo.jpg
02-Leg-Body.jpg
03-Leg-Servo.jpg
04-Leg-Servo.jpg
05-Leg-Servo-Wires.jpg
06-Leg-Servo-Wires.jpg
07-Foot.jpg
08-Foot.jpg
09-Foot.jpg

Put two servos into the body and secure them with the screws come with the servos

Join the leg to the body with the servo horn

Put the two servos into the leg, and put the hood onto the leg servos while keeping the servos at 90 degree.

Put the servo wires up to the body through the holes at the bottom of the body

Slide the foot on the leg servo

Assembling Part 2 - Mainboard, Servos, Ultrasonic Sensor and Battery

10-Mainboard-Battery.jpg
11-Mainboard-Mounting-Tape.jpg
12-Ultrasonic-Sensor.jpg
13-Ultrasonic-Sensor.jpg
13-Wiring.png
14-Connecting.jpg
15-Battery.jpg
16-Tidy-up.jpg

We are going to connect all the electronics to the mainboard and stick the mainboard on the servos with some thick mounting tape.

Here are the two components that we are going to put it. The mainboard and battery.

We'll need this strong mounting tape to fix the mainboard on top of the servos

Put the Ultrasonic sensor in and make sure the wiring are CORRECT! (This is very important, as incorrect wiring can burn the ultrasonic sensor)

Connecting the servos and ultrasonic sensor.

Below show the servo numbers when the robot is facing you. Connect the servos to D3,D4,D5 & D6 with the orange wire on the S pin and brown wire on the - pin.

For the ultrasonic sensor:
- Green wire (Vcc) to any + pin
- Blue wire (Trig) to S pin of D7
- Purple wire (Echo) to S pin of D8
- Grey wire (Gnd) to S any - pin

Connect the battery to the mainboard and hide it inside the body

Stick the mainboard to the servos and tidy up the wiring

Testing - Servos

17-Servo-Test.GIF

Test again with OTTO_Servo_Setup.ino file and check whether the servo move correctly and return to centre position. It is ok for not returning to exactly

Testing - Ultrasonic Sensor

Below is a simple test for the ultrasonic sensor. It will print out the distance measured from the sensor. If the object in front is less than 20cm, it'll turn on the built-in LED (Pin 13) and also play a tone with the built-in buzzer (Pin 12).

/* 
 * Wombatics OTTO - Ultrasonic Test
 * https://www.wombatics.com/
 * https://www.facebook.com/wombaticsco/ 
 * https://github.com/wombatics/
*/

#define trigPin 7
#define echoPin 8
#define led     13
#define buzzer  12


void setup() 
{
  Serial.begin (9600);
  ultrasonicSetup();
  
  pinMode(led, OUTPUT);
  pinMode(buzzer, OUTPUT);
  
}

void loop() 
{
  long distance;

  distance = ultrasonicDistance();

  Serial.print(distance);
  Serial.println(" cm");

  if( distance < 20)
  {
    digitalWrite(led, HIGH);
    tone(buzzer, 100, 10);
  }
  else
  {
    digitalWrite(led, LOW);
  }
  
  delay(100);
}

// Functions for Ultrasonic
void ultrasonicSetup()
{
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

long ultrasonicDistance()
{
  long duration, distance;

  digitalWrite(trigPin, LOW);  
  delayMicroseconds(2); 
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10); 
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH, 24000);
  distance =  duration / 58;
  
  if (distance >= 400 || distance <= 0)
  {
    distance = 9999;
  }

  return distance;
}

18-Ultrasonic-IDE.png
20-Ultrasonic-Serial.GIF
19-Ultrasonic-LED.GIF

In Arduino IDE, Open "Tools->Serial Monitor". The distance measured from the ultrasonic sensor will be printed out.

Adding Otto Arduino Libraries and Moonwalk

Now we are ready to put everything to work.

First, we need to add Otto Arduino libraries to Arduino libraries. (Documents/Arduino/libraries) Download the "libraries.zip", unzip it and copy the directories to your Arduino libraries directory.

── libraries
│   ├── BatReader
│   ├── EnableInterrupt
│   ├── LedMatrix
│   ├── Oscillator
│   ├── Otto
│   ├── OttoSerialCommand
│   └── US

Upload Moonwalking Code

21-Moon-Walk.GIF

Next, upload the following code ( OTTO_dance.ino ) and it will start moonwalking.

/* 
 * Wombatics OTTO - Moonwalk Dance
 * https://www.wombatics.com/
 * https://www.facebook.com/wombaticsco/ 
 * https://github.com/wombatics/
*/

#include <Servo.h> 
#include <Oscillator.h>
#include <US.h>
#include <Otto.h>

/*
                 --------------- 
                |     O   O     |
                |---------------|
RIGHT LEG 4==>  |               | <== LEFT LEG 3
                 --------------- 
                    ||     ||
RIGHT FOOT 6==>   -----   ------  <== LEFT FOOT 5
                 |-----   ------|
*/

#define PIN_LEFT_LEG   3   
#define PIN_RIGHT_LEG  4  
#define PIN_LEFT_FOOT  5  
#define PIN_RIGHT_FOOT 6 

#define PIN_TRIGGER 7
#define PIN_ECHO    8
#define PIN_LED     13
#define PIN_BUZZER  12

#define TRIM_LEFT_LEG   0 
#define TRIM_RIGHT_LEG  0
#define TRIM_LEFT_FOOT  0
#define TRIM_RIGHT_FOOT 0

Otto Otto;  //This is Otto!

void setup()
{
  Serial.begin(9600);
  
  //Set the servo pins
  Otto.init(PIN_LEFT_LEG,PIN_RIGHT_LEG,PIN_LEFT_FOOT,PIN_RIGHT_FOOT,true, A6, PIN_BUZZER, PIN_TRIGGER, PIN_ECHO);
  Otto.setTrims(TRIM_LEFT_LEG,TRIM_RIGHT_LEG, TRIM_LEFT_FOOT, TRIM_RIGHT_FOOT);
  Otto.home();
  delay(2000);
 
}


void loop()
{
 
  Otto.moonwalker(10);

  delay(3000);
}

Avoid Obstacles

22-Avoid-Obstacles.GIF

Here we can teach Otto how to avoid obstacles. Otto will walk backward and turn when obstacle is detected in front. ( OTTO_avoid.ino )

/* 
 * Wombatics OTTO - Avoid Obstacles
 * https://www.wombatics.com/
 * https://www.facebook.com/wombaticsco/ 
 * https://github.com/wombatics/
*/

#include <Servo.h> 
#include <Oscillator.h>
#include <US.h>
#include <Otto.h>

/*
                 --------------- 
                |     O   O     |
                |---------------|
RIGHT LEG 4==>  |               | <== LEFT LEG 3
                 --------------- 
                    ||     ||
RIGHT FOOT 6==>   -----   ------  <== LEFT FOOT 5
                 |-----   ------|
*/

#define PIN_LEFT_LEG   3   
#define PIN_RIGHT_LEG  4  
#define PIN_LEFT_FOOT  5  
#define PIN_RIGHT_FOOT 6 

#define PIN_TRIGGER 7
#define PIN_ECHO    8
#define PIN_LED     13
#define PIN_BUZZER  12

#define TRIM_LEFT_LEG   0 
#define TRIM_RIGHT_LEG  0
#define TRIM_LEFT_FOOT  0
#define TRIM_RIGHT_FOOT 0

Otto Otto;  //This is Otto!

void setup()
{
  Serial.begin(9600);
  
  //Set the servo pins
  Otto.init(PIN_LEFT_LEG,PIN_RIGHT_LEG,PIN_LEFT_FOOT,PIN_RIGHT_FOOT,true, A6, PIN_BUZZER, PIN_TRIGGER, PIN_ECHO);
  Otto.setTrims(TRIM_LEFT_LEG,TRIM_RIGHT_LEG, TRIM_LEFT_FOOT, TRIM_RIGHT_FOOT);
  Otto.home();
  delay(2000);
 
}

///////////////////////////////////////////////////////////////////
//-- Principal Loop ---------------------------------------------//
///////////////////////////////////////////////////////////////////
void loop() 
{
  bool obstacleDetected = false;
  
  obstacleDetected = obstacleDetector(); 
  
  if(obstacleDetected)
  { 
        Otto.sing(S_surprise); 
        Otto.walk(10,1000,BACKWARD); 
        delay(1000);
        Otto.sing(S_happy);
        Otto.turn(10,1000,RIGHT);                
        delay(2000); 
          
   }        
   else
   { 
          Otto.walk(1,1000,FORWARD);  
    }          
 }  

///////////////////////////////////////////////////////////////////
//-- Function to read distance sensor 
bool obstacleDetector()
{
   int distance = Otto.getDistance();
   
   Serial.println(distance);
   
   if(distance<15)
   {
      return true;
   }
   else
   {
      return false;
   }

}