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:
#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
#1 by roberto on 31 January 2014 - 06:55
Quote
i get an error with the Software Serial Instance on URMSerial.h
does anyone have the same problem?
#2 by michele on 22 October 2013 - 13:54
Quote
Ciao,
so che il progetto è vecchio ma poichè sono un neofita mi è molto utile; mi potresti per favore spiegare l’ultimo ciclo for che permette al robot di ruotare nella giusta direzione? si basa su dati empirici?Sto cercando di risolvere il problema di far ruotare di un determinato angolo il robot usando motoriDC/servo a rotazione continua. Grazie e complimento per i post (che terrò in considerazione quando sarò + esperto)
#3 by robottini on 22 October 2013 - 14:01
Quote
SOno dati empirici. Purtroppo bisogna fare molte prove fino a trovare la configurazione ottimale.
#4 by robottini on 20 July 2013 - 10:24
Quote
There are the links to the stores to buy the components.
#5 by good girl on 20 July 2013 - 08:44
Quote
can u tell me that where would I find all these objects to make this robot
#6 by Pedro Lizarraga on 2 March 2013 - 19:25
Quote
ciao, avete i piani per il robot? Ho bisogno di costruire uno e mi è piaciuto molto questo, è per un progetto scolastico
#7 by robottini on 2 March 2013 - 19:53
Quote
Sorry, all the information I have is written here. The robot is an old project so I don’t have other material.
#8 by Pedro Lizarraga on 2 March 2013 - 19:23
Quote
hello, you have the plans for the robot? I need to build one and I really liked this, it’s for a school project
#9 by Gianluca on 29 January 2013 - 15:43
Quote
Bella spiegazione.
Io ho provato a fare una cosa simile con dei motori dc e ho dei problemi a controllarli. Hai ezperienza a riguardo?
Fondamentalmente vanno troppo veloci.
Ciao
#10 by vito on 9 November 2012 - 17:59
Quote
ciao!! posso usare l’arduino UNO e il HC-SR04 come sensore di distanza ad ultrasuoni?? massima urgenza! grazie in anticipo!! ottimo lavoro!!!
#11 by robottini on 9 November 2012 - 18:19
Quote
No, il codice non funziona con HC-sr04
#12 by Kees van den Akker on 22 May 2012 - 11:26
Quote
Ciao Robottini ! Sto indovinando come far andare un piccolo robo come il tuo ma ero bloccato dallo sketch che avevo scritto. Il tuo sito mi ha dato nuove idee e possibilitá di provare.
Ti ringrazio !!
Buon divertimento technologico !!!!
Kees
#13 by robottini on 24 March 2012 - 08:34
Quote
Thes are the connections:
From the library “URMSerial.h”, for the ultrasonic sensor:
* Pin12 (Arduino) -> Pin 1 VCC (URM V3.2)
* GND (Arduino) -> Pin 2 GND (URM V3.2)
* Pin11 (Arduino) -> Pin 7 (URM V3.2)
* Pin 0 (Arduino) -> Pin 9 (URM V3.2)
* Pin 1 (Arduino) -> Pin 8 (URM V3.2)
For the servos:
* Pin 10 (Arduino) -> Left servo pin
* Pin 6 (Arduino) -> Right servo pin
* Pin 3 (Arduino) -> Ultrasonic sensor servo pin
#14 by ciapo on 22 March 2012 - 18:02
Quote
would be possible to have more information.
especially a circuit diagram of the connections
#15 by Philip on 2 December 2011 - 04:51
Quote
Thank you very much!
#16 by robottini on 30 November 2011 - 12:22
Quote
@Philip
From the library “URMSerial.h”, the connections are:
* Pin12 (Arduino) -> Pin 1 VCC (URM V3.2)
* GND (Arduino) -> Pin 2 GND (URM V3.2)
* Pin11 (Arduino) -> Pin 7 (URM V3.2)
* Pin 0 (Arduino) -> Pin 9 (URM V3.2)
* Pin 1 (Arduino) -> Pin 8 (URM V3.2)
#17 by Philip on 30 November 2011 - 04:17
Quote
Thank you very much for this information.
I am battling a bit to get a similar project going. I use an Arduino Uno (exactly the same pins as the Arduino Duomilanove you are using) with a URM 37. Could you please describe how and where to you connect Pin 7 of the URM37.
Thank you
Philip
#18 by chitarra godin on 1 October 2011 - 14:19
Quote
Hi, this is a great post! Thanks..
#19 by Antinajat on 16 September 2011 - 23:30
Quote
imparato molto