Difference between revisions of "Czechbot"

Overview

Country: Czech Republic
Date: 12.08.2009-14.8.2009
Activity: Centrobot Robotic Summer School 2009
Location: Vienna, Austria
Hardware: LEGO Mindstorms NXT

Abstract

General Idea:

Make a robot which can find a goal in a non-cycled maze (only with dead end tracks) of black lines by going left on every intersection.

Thoughts:

At first we tried robot only with two sensors and he did quite well. But finally we had to rewrite a source code for three sensors robot in a very short time because of troubles with implementation of two sensors ancestor. And that was the whole problem.

Results:

Our robot can follow the black line, he can recognize blind tracks and turn himself back to line. The only problem is with marking the intersections. Because robot hasn´t a ideal movement, there are still some inaccuracies. Theoreticaly we have some thoughts how to clean up, but we didn´t have enough of time to implement it right. So our robot can`t recognize intersections properly and that is the reason why he makes so many mistakes.

Project Files

```import lejos.navigation.TachoNavigator;

import lejos.nxt.*;

@SuppressWarnings("deprecation")
public class TEst {
LightSensor left,right,middle;
TachoNavigator navi;

public static void main(String[] args) throws Exception {
TEst l=new TEst();
l.run();
}

public TEst() {
//init
right = new LightSensor(SensorPort.S3);
middle = new LightSensor(SensorPort.S2);
left = new LightSensor(SensorPort.S4);
navi = new TachoNavigator(5.6f, 11.5f, Motor.C, Motor.A);
}

public boolean isRightDark() {
}

public boolean isLeftDark() {
}

public boolean isMiddleDark() {
}

public void findIntersection() {
navi.setSpeed(120);
navi.travel(1);
if (isLeftDark()) {
if (isRightDark()) {
navi.travel(4);
if (isMiddleDark()) {
Sound.twoBeeps();
navi.travel(2);
navi.rotate(92);
}
else {
navi.travel(2);
navi.rotate(92);
}
}
// leve T nebo leva zatacka
else {
navi.travel(4);
if (isMiddleDark()) {
Sound.twoBeeps();
navi.travel(2);
navi.rotate(92);
}
else {
navi.travel(2);
navi.rotate(92);
}
}
}

else if (isRightDark()) {
if (isLeftDark()) {
navi.travel(4);
if (isMiddleDark()) {
Sound.twoBeeps();
navi.travel(2);
navi.rotate(92);
}
}
// pravy T nebo prava zatacka
else {
navi.rotate(-5);
navi.travel(4);
if (isMiddleDark()) {
navi.travel(2);
Sound.beep();
}
else {
navi.travel(2);
navi.rotate(-80);
}
}
}
}

public void followLine() {
int dig = 0;
Motor.C.setSpeed(270);
Motor.A.setSpeed(270);
Motor.A.stop();
Motor.C.forward();

dig = Motor.C.getTachoCount();
if (Math.abs(dig) > 270) {
Motor.C.rotate(-dig);
navi.setSpeed(360);
navi.travel(8);
navi.rotate(185);
}

}
else if (middle.readValue() <= 45) {
Motor.C.stop();
Motor.A.forward();
Motor.C.resetTachoCount();
}
}

public void run() throws InterruptedException {
while (!Button.ESCAPE.isPressed()) {
followLine();
if (isLeftDark()) {
navi.stop();
Motor.A.rotate(-5);
Motor.C.rotate(5);
findIntersection();
}
else if (isRightDark()) {
navi.stop();
Motor.A.rotate(5);
Motor.C.rotate(-5);
findIntersection();
}