The first robot presented is called “Geronimo” and it is a simple autonomous robot with an ultrasonic sensor for obstacles avoindance.
This robot can be built by a newbie of robotics.

 

 

Components:

The robot is assembled starting from these components:

arduino duemilanove
robot chassis (link)
‘L’ support for servos   (link)
servos Hitec HRS
1422CR with continuous rotation (link)
Hitec wheels for servos (link)
ball caster  (link)
ultrasonic sensor DFRobot URM37 V 3.2 (link)
servo for ultrasonic sensor (the cheapest in ebay)
400 contacts breadboard (link)
batteries, jumpers, screw and other simple hardware

 

Functionalities:

The robot, very basic and simple, goes straight and verifies if there are obstacles. If it found some obstacle, it turns the ‘head’ and sees at the right and at the left in order to verify where the street is more free.

Then it goes where the street is more free. Nothing of special. This is a short video to see how the robot goes in a  path with obstacles:

Another video:

 

I liked very much the ultrasonic URM37. Libraries (link) that drive the sensor are available and they are easy to use. The sensor is advanced: in fact it can offer these functionalities:

– distance measurement between 4 cm and 3 meters

– temperature measurement

– sensor servo driving and control

This is the sensor:

At the beginning it seemed very interesting the functionality of servo driving offered out-of-the-box by the sensor,  however making some test I couldn’t to drive well the servo, that it went from a part to another part at maximum speed. So, I used directly Arduino to drive also the sensor servo. I think that spending more time, it is sure possible to make something better.

For other components, some comments:

  • Chassis and ‘L’ supports. Perfect, nothing to say
  • Servos Hitec: not very well. Unfortunely they don’t have a pot to regulate the stall (I mean to stop them), so I have tried with some tests. Finally I discovered the stall value. Another issue consist in turning the servos to a precise angle. The only method that I could use is many, many tentatives. I know that is a common problem for continuous rotation servos.
  • Batteries and Arduino: I used two batteries, because the Arduino hasn’t enough current to feed the servos.  When I divided the power, I hadn’t problems.

Some photo of robot process building:

 

 

 


 

This is the Arduino Code used for robot programming:
#include "URMSerial.h"
#include <Servo.h>
Servo sservo;
Servo dservo;
Servo uservo;
int ang=0;
int angolomax=0;
int distmax=0;
int value=100;
int ind=0;
int rotazione=0;

// Definizione delle misure - Measures definition
#define DISTANCE 1
#define TEMPERATURE 2
#define ERROR 3
#define NOTREADY 4

//angolo di riposo dei servi delle ruote - wheels stop angle
#define RIPOSOS 94
#define RIPOSOD 93

// inizializza l'oggetto della libreria urm del sensore ultrasuoni - initialize urm library 
URMSerial urm;

void setup()
{
  Serial.begin(9600);  // baud rate at 9600 
  urm.begin(9,10,9600); // RX Pin, TX Pin, Baud Rate
  sservo.attach(6);   // left servo to pin 10
  dservo.attach(5);    // Right servo to pin 9
  uservo.attach(3);    // Ultrasonic servo to pin 3
  uservo.write(90);    // put ultrasonic servo straight
  delay(100);
}

void loop()
{
//   sservo.write(RIPOSOS); // stop the robot
//   dservo.write(RIPOSOD); // stop the robot
  sservo.write(RIPOSOS + 90); // go straight
  dservo.write(RIPOSOD - 90); // go straight
 // Richiedi la distanza al sensore ad ultrasuoni - ask ultrasonic sensor for distance
 urm.requestMeasurement(DISTANCE);
 delay(50); // attendi allineamento dei servi - wait for servos alignement
 if(urm.hasReading())
  {
     switch(urm.getMeasurement(value)) // Verifica che il valore letto sia una distanza 
     {
      case DISTANCE: // Ulteriore verifica che sia una distanza - verify that read is a distance
        if (value < 20 & value > 0)  // se il valore e' < 20 cm stiamo per sbattere - if < 20 cm turn
        {
          angolomax=0; // imposta l'angolo di migliore uscita a zero - set best exit angle to zero
          distmax=0; // imposta la distanza di uscita migliore a zero - set best distance exit to zero
          sservo.write(RIPOSOS);  // ferma il servo in posizione di riposo - stop servo
          dservo.write(RIPOSOD);  // ferma il servo in posizione di riposo - stop servo
          delay(100);

          for (ang=0; ang<180; ang +=5) // obstacles control
            {
              uservo.write(ang); // set ultrasonic sensor on ang value
              urm.requestMeasurement(DISTANCE); //ask for new reading
              delay(20);
              if(urm.hasReading()) // verifica se ha letto - verify the reading
                {
                  switch(urm.getMeasurement(value))
                    {
                      case DISTANCE:
                        if (value > distmax) // verify if distance is > max
                          {
                             angolomax=ang;  // set new max angle
                             distmax=value;  // set new distance max
                           } //end if (value > distmax)
                      break;
                    } // end switch
                 } // end if(urm.hasReading())
            } //end for (ang=0; ang<180; ang +=5)         

        uservo.write(90); //set the URM servo straight
        delay(135);
        // write angle read in the serial port
        Serial.print("Angolo max \t");
        Serial.println(angolomax);

        //set servos to max distance

        if (angolomax > 180)
          angolomax=180;
        if (angolomax < 0)
          angolomax=0;

        rotazione=abs(angolomax-90); 

        // write value to serial port
        Serial.print("Angolo inviato ai servi \t");
        Serial.println(RIPOSOS+angolomax-90);
        Serial.print("Valore di rotazione \t");
        Serial.println(rotazione / 9);
        // go servos to max angle and max distance
        for (ind=1; ind < rotazione / 4; ind+=1)
         {
           sservo.write(RIPOSOS+angolomax-90);
           dservo.write(RIPOSOD+angolomax-90);
           delay (40);
         } // end for (ind=1; ind < rotazione / 9; ind+=1)
        } //  end if (value < 20 & value > 0)
        break;
     } // end switch
  } // end if(urm.hasReading())

} //end loop

Tags: , , ,