DONE!
This commit is contained in:
85
README.org
85
README.org
@@ -1,7 +1,84 @@
|
|||||||
* RyABI
|
* RyABI (/Robótica y Aprendizaje Bio-Inspirado/ - Robotics and Bio-Inspired Learning)
|
||||||
|
|
||||||
** Abstract
|
** Abstract
|
||||||
RyABI (/Robótica y Aprendizaje Bio-Inspirado/ - Robotics and Bio-Inspired Learning) is a control program for LEGO Mindstorms NXT using the LeJOS NXJ
|
|
||||||
firmware. It is developed as part of the homonimous course being taught at the Computer Sciences School of the UCV.
|
|
||||||
|
|
||||||
Future verions of this README file will include a technical report on the development of the project.
|
RyABI is a control program for LEGO Mindstorms NXT using the LeJOS NXJ firmware. The controller is based on the
|
||||||
|
subsumption reactive control architecture.
|
||||||
|
|
||||||
|
** Objective
|
||||||
|
|
||||||
|
The controller assumes an environment like the following:
|
||||||
|
|
||||||
|
#+BEGIN_SRC ditaa :file environment.png :cmdline -o -E
|
||||||
|
. +-----------+
|
||||||
|
. | |
|
||||||
|
. |cBLK |
|
||||||
|
+----+ +------+----+
|
||||||
|
| | | |
|
||||||
|
| | | |
|
||||||
|
| | +---------+ | |
|
||||||
|
| | | | | |
|
||||||
|
| | | | | |
|
||||||
|
| | | | | |
|
||||||
|
| | | | | |
|
||||||
|
| | +-----+ | | | |
|
||||||
|
| | |Robot| | | | |
|
||||||
|
| | |cGRE | | | | |
|
||||||
|
| | +-----+ | | | |
|
||||||
|
| | | | | |
|
||||||
|
| | | | +---------+ | |
|
||||||
|
| | | cBLK | | | | | +-----+
|
||||||
|
| | +---------+ | | | | |Ball |
|
||||||
|
| | | | | | |cYEL |
|
||||||
|
| | | | | | +-----+
|
||||||
|
| | | | | |
|
||||||
|
| | | | | |
|
||||||
|
| | | | | |
|
||||||
|
| | | | | |
|
||||||
|
| | | cBLK | | |
|
||||||
|
| | +---------+ | |
|
||||||
|
| | | |
|
||||||
|
| | | |
|
||||||
|
| | | |
|
||||||
|
| | | |
|
||||||
|
|cBLU| |cPNK|
|
||||||
|
+----+ +------+----+
|
||||||
|
. | |
|
||||||
|
. |cBLK |
|
||||||
|
. +-----------+
|
||||||
|
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
#+RESULTS:
|
||||||
|
[[file:environment.png]]
|
||||||
|
|
||||||
|
The goal of the controller is to find a ball (in yellow) that is located on one side of a goal line (in pink),
|
||||||
|
while avoiding any obstacles (in black) it can find. Once the ball is found, or the robot has collided with any
|
||||||
|
of the two obstacles at the sides of the goal line, the controller will return to the starting line (in blue).
|
||||||
|
|
||||||
|
The floor and the start/goal lines must be of constrasting colors. Contrary to what the diagram implies, both
|
||||||
|
the start and goal lines *must* be of a similar color.
|
||||||
|
|
||||||
|
** Robot
|
||||||
|
|
||||||
|
The robot is based on a differential drive and must use the following motors:
|
||||||
|
|
||||||
|
* Motors A and C :: Attached to the wheels. Used to move and steer the robot.
|
||||||
|
* Motor B :: Attached to a gripper claw. Used to catch the ball.
|
||||||
|
|
||||||
|
It must also use the following sensors:
|
||||||
|
|
||||||
|
* Ultrasonic ranger :: Used to find the ball. Attached to port 1.
|
||||||
|
* Touch bumper :: Used to detect obstacles. Attached to port 2.
|
||||||
|
* HiTechnic compass :: Used to steer and move with some precission. Attached to port 3.
|
||||||
|
* Greyscale light detector :: Used to find the start and goal lines. Attached to port 4.
|
||||||
|
|
||||||
|
** Subsumption
|
||||||
|
|
||||||
|
The controller uses the following five behaviors:
|
||||||
|
|
||||||
|
* Wander :: Simply moves the robot forward.
|
||||||
|
* Search :: When the goal line is found the robot will start searching for the ball using the range sensor.
|
||||||
|
* Catch :: When the ball has been found the robot will attempt to grab it with it's gripper.
|
||||||
|
* Victory :: When the start line is crossed the robot will stop moving a play a little tune.
|
||||||
|
* Avoid :: If the robot bumped against an obstacle then the robot will move a bit to the right to avoid it. It may take many attempts to clear a wide obstacle.
|
||||||
|
|||||||
BIN
environment.png
Normal file
BIN
environment.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.9 KiB |
@@ -46,7 +46,7 @@ import ve.ucv.ciens.cicore.icaro.ryabi.utils.QuitButtonListener;
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class RyABI {
|
public class RyABI {
|
||||||
private static final float WHEEL_DIAMETER = 56.0f;
|
private static final float WHEEL_DIAMETER = 56.0f;
|
||||||
private static final float TRACK_WIDTH = 155.0f;
|
private static final float TRACK_WIDTH = 144.0f;
|
||||||
|
|
||||||
private static ArcRotateMoveController pilot;
|
private static ArcRotateMoveController pilot;
|
||||||
private static UltrasonicSensor sonar;
|
private static UltrasonicSensor sonar;
|
||||||
|
|||||||
@@ -53,14 +53,15 @@ public class CatchBallBehavior extends BaseBehavior {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void action() {
|
public void action() {
|
||||||
pilot.travel(65);
|
pilot.travel(60);
|
||||||
Motor.B.backward();
|
Motor.B.backward();
|
||||||
try { Thread.sleep(2000); } catch(InterruptedException e) { };
|
try { Thread.sleep(2000); } catch(InterruptedException e) { };
|
||||||
Motor.B.stop(true);
|
Motor.B.stop(true);
|
||||||
|
Motor.B.suspendRegulation();
|
||||||
/* Turn towards the start line and start moving. */
|
/* Turn towards the start line and start moving. */
|
||||||
Rotations.rotate90(compass, pilot);
|
Rotations.rotate90(compass, pilot);
|
||||||
Rotations.rotate90(compass, pilot);
|
Rotations.rotate90(compass, pilot);
|
||||||
pilot.travel(200);
|
pilot.travel(350);
|
||||||
state.setState(States.WANDER);
|
state.setState(States.WANDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,18 +63,19 @@ public class SearchBallBehavior extends BaseBehavior {
|
|||||||
@Override
|
@Override
|
||||||
public boolean takeControl() {
|
public boolean takeControl() {
|
||||||
/* If the ball has already been found then this behavior should not take control again. */
|
/* If the ball has already been found then this behavior should not take control again. */
|
||||||
if(ballFound)
|
if(ballFound) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* If the current state is SEARCH_BALL then set the detectors and take control. */
|
/* If the current state is SEARCH_BALL then set the detectors and take control. */
|
||||||
if(state.getState() == States.SEARCH_BALL) {
|
if(state.getState() == States.SEARCH_BALL && !ballFound) {
|
||||||
setDetectors();
|
setDetectors();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the state is not SEARCH_BALL but there is at least one light feature detected
|
/* If the state is not SEARCH_BALL but there is at least one light feature detected
|
||||||
* indicating that the finish line has been reached then set the detectors and take control. */
|
* indicating that the finish line has been reached then set the detectors and take control. */
|
||||||
if(queue.hasNextLightSensorEvent()) {
|
if(queue.hasNextLightSensorEvent() && !ballFound) {
|
||||||
state.setState(States.SEARCH_BALL);
|
state.setState(States.SEARCH_BALL);
|
||||||
setDetectors();
|
setDetectors();
|
||||||
|
|
||||||
@@ -91,6 +92,7 @@ public class SearchBallBehavior extends BaseBehavior {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void action() {
|
public void action() {
|
||||||
|
boolean _ballFound = false;
|
||||||
boolean obstacleFound = false;
|
boolean obstacleFound = false;
|
||||||
|
|
||||||
/* Discard unneeded touch events. */
|
/* Discard unneeded touch events. */
|
||||||
@@ -106,9 +108,11 @@ public class SearchBallBehavior extends BaseBehavior {
|
|||||||
pilot.stop();
|
pilot.stop();
|
||||||
|
|
||||||
if(!obstacleFound) {
|
if(!obstacleFound) {
|
||||||
ballFound = searchBall();
|
_ballFound = searchBall();
|
||||||
if(ballFound)
|
if(_ballFound) {
|
||||||
|
ballFound = true;
|
||||||
state.setState(States.BALL_FOUND);
|
state.setState(States.BALL_FOUND);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ballFound = true;
|
ballFound = true;
|
||||||
Rotations.rotate90(compass, pilot);
|
Rotations.rotate90(compass, pilot);
|
||||||
@@ -127,7 +131,7 @@ public class SearchBallBehavior extends BaseBehavior {
|
|||||||
private void setDetectors() {
|
private void setDetectors() {
|
||||||
detectorHandler.enableTouchDetector();
|
detectorHandler.enableTouchDetector();
|
||||||
detectorHandler.disableLightDetector();
|
detectorHandler.disableLightDetector();
|
||||||
detectorHandler.disableRangeDetector();
|
detectorHandler.enableRangeDetector();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveLeft() {
|
private void moveLeft() {
|
||||||
@@ -157,17 +161,17 @@ public class SearchBallBehavior extends BaseBehavior {
|
|||||||
private boolean searchBall() {
|
private boolean searchBall() {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
|
||||||
detectorHandler.enableRangeDetector();
|
while(queue.hasNextRangeSensorEvent())
|
||||||
activeWait(1000);
|
queue.getNextRangeSensorEvent();
|
||||||
|
|
||||||
|
try { Thread.sleep(2000); } catch(InterruptedException e) { };
|
||||||
if(queue.hasNextRangeSensorEvent()) {
|
if(queue.hasNextRangeSensorEvent()) {
|
||||||
/* If the pedestal has been found then stop the robot and set the state to BALL_FOUND. */
|
found = true;
|
||||||
state.setState(States.BALL_FOUND);
|
|
||||||
|
|
||||||
/* Discard unneeded range features. */
|
/* Discard unneeded range features. */
|
||||||
while(queue.hasNextRangeSensorEvent())
|
while(queue.hasNextRangeSensorEvent())
|
||||||
queue.getNextRangeSensorEvent();
|
queue.getNextRangeSensorEvent();
|
||||||
}
|
}
|
||||||
detectorHandler.disableRangeDetector();
|
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
@@ -188,12 +192,4 @@ public class SearchBallBehavior extends BaseBehavior {
|
|||||||
|
|
||||||
return obstacleFound;
|
return obstacleFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void activeWait(long milliseconds) {
|
|
||||||
long then = System.currentTimeMillis(), now;
|
|
||||||
System.out.println("Waiting.");
|
|
||||||
do {
|
|
||||||
now = System.currentTimeMillis();
|
|
||||||
} while(now - then < 1000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public final class FeatureDetectorsHandler {
|
|||||||
/**
|
/**
|
||||||
* Gets the singleton instance of this class.
|
* Gets the singleton instance of this class.
|
||||||
*
|
*
|
||||||
* @return the instacne.
|
* @return the instance.
|
||||||
*/
|
*/
|
||||||
public static FeatureDetectorsHandler getInstance() {
|
public static FeatureDetectorsHandler getInstance() {
|
||||||
return SingletonHolder.INSTANCE;
|
return SingletonHolder.INSTANCE;
|
||||||
|
|||||||
Reference in New Issue
Block a user