There is an older thread about my rover, but I decided to start a clean one. In this thread, you will find details, source code and useful information if you want to make a quad-rover.
Here is a video of RV1 working:
RV-1 Autonomous Rover Robot using an ArduinoI will start with the chassis. It's constructed from 4 plates of Etalbond. In case you never heard of it, it's made out of 1 sheet of plastic covered on the sides by 2 sheets of aluminium. Here is more information on the material:
http://en.wikipedia.org/wiki/EtalbondI have a bottom piece with front and rear walls, 2 side panels onto which the 4 servos are attached, and a top panel to cover up the wiring.
The brain's role is taken by an arduino Diecimila, soon to be replaced with a "$50 robot board "
I have 2 separate sources for the arduino and the servos. A 9V is powering the arduino and a 6V gel-cell battery pack supplying 4A is powering the motors.
4 Hitec HSR-1422CR Continuous Rotation servos(They are not controlled individually. I have 2 pairs of 2...left and right) move the robot towards a clear place, which takes me to the next part...Sensors:
1 sharp IR rangefiner(20cm-80cm) is placed on 2 micro heli servos that allow it to "scan" 360 degrees. I am going to place 2 more sensors in the front of the wheels(It needs them).
Programming:
The code is written for the Arduino IDE, for AVR MicroControllers(ATMega8, 48, 168, 328, etc).
#include <SoftwareServo.h>
SoftwareServo sp1, sp2, sa, sb;
int pin_sp1, pin_sp2, pin_sa, pin_sb;
byte pin_ir1, pin_ir2, pin_ir3;
float read_cm(byte pin) {
int tmp;
tmp = analogRead(pin);
if (tmp < 3)
return -1; // invalid value
return (6787.0 /((float)tmp - 3.0)) - 4.0;
}
void fwd(void) {
if(!(sp1.attached()))
sp1.attach(pin_sp1);
if(!(sp2.attached()))
sp2.attach(pin_sp2);
sp1.write(180);
sp2.write(0);
for(int i = 0; i < 50; i++) {
SoftwareServo::refresh();
delay(15);
}
}
void back(void) {
if(!(sp1.attached()))
sp1.attach(pin_sp1);
if(!(sp2.attached()))
sp2.attach(pin_sp2);
sp1.write(0);
sp2.write(180);
for(int i = 0; i < 50; i++) {
SoftwareServo::refresh();
delay(15);
}
}
void left(void) {
sp2.detach();
if(!(sp1.attached()))
sp1.attach(pin_sp1);
sp1.write(180);
for(int i = 0; i < 50; i++) {
SoftwareServo::refresh();
delay(15);
}
}
void right(void) {
sp1.detach();
if(!(sp2.attached()))
sp2.attach(pin_sp2);
sp2.write(0);
for(int i = 0; i < 50; i++) {
SoftwareServo::refresh();
delay(15);
}
}
void servo_delay() {
int t;
for(t = 0; t < 10; t++) {
SoftwareServo::refresh();
delay(50);
}
}
void center() {
sa.write(95);
sb.write(65);
SoftwareServo::refresh();
}
int scan() {
float val_s, val_r, val_l, val_d;
val_s = val_r = val_l = val_d = 0;
sa.write(95);
servo_delay();
val_s = read_cm(pin_ir1);
sa.write(145);
servo_delay();
val_l = read_cm(pin_ir1);
sa.write(45);
servo_delay();
val_r = read_cm(pin_ir1);
center();
if(val_s < 20 || val_l < 20 || val_r < 20) back();
if(val_l > val_r) left();
else right();
}
void setup() {
pin_sp1 = 3;
pin_sp2 = 6;
pin_sa = 2;
pin_sb = 4;
pin_ir1 = 0;
pin_ir2 = 2;
pin_ir3 = 4;
sp1.attach(pin_sp1);
sp2.attach(pin_sp2);
sa.attach(pin_sa);
sb.attach(pin_sb);
digitalWrite(13, HIGH);
Serial.begin(9600);
}
void loop() {
scan();
}