Assignment 1:
Vacuum Cleaner Robot Simulation
Did you ever wonder if the roomba vacuum cleaner (see for example here or, better, here) could be made more
efficient? Here is the chance for you to do so!
This assignment gives you the task to
program an autonomous cleaning robot. You will be given a JAVA simulation
environment. To insert your robot into this environment, you only have to
extend an existing class with your own robot, write the logic, and watch.
Your robot is a differential robot, which means it has a left and a right wheel,
which can be steered independently. The only thing you need to do to make this
robot run is to set the speeds of the left and right wheel.
In order to let this robot interact with
its environment, it is equipped with two sensors:
·
the robot odometry. A robot-wheel-based sensor, which tells the robot
where it is, relative to its starting pose (a pose is x,y-position
in mm, and heading in degrees). In our simulation case, the pose is perfect,
i.e. the physical robot position matches the sensor data. (In real robotics,
this is not true, which causes all of the trouble robot-navigation is dealing
with). This sensor might be of interest if you want to map the environment, and
make a really advanced cleaning robot.
·
a laser scanner.
This particular model is equipped with a laser scanner that has a 270 degree,
40m range with a resolution of 0.5 degrees (it's a simulation of a SICK LMS100
laser scanner, click here
for a video about its operating principle). The laser scanner shoots 541 rays
from -135 to 135 degrees, and offers the distance to the closest objects in the
respective direction (in mm).
Your task in simple steps:
1.
Download the
Simulation Project. It comes as a Netbeans project,
with everything you need, even an example of a Cleaning Robot.
2.
Start the project
and watch. The current project is written for Java 1.6. If Netbeans
complains that it does not find an appropriate JAVA environment, right click on
your project, Properties -> Libraries and change the Java platform. That
should do it.
3.
The project has a
Main class. In there you will see that an instance of a HappyWallRobot
is created. This is the example robot. When you have created your own robot
(see below), change this declaration to instantiate your own robot.
4.
Create your own
robot (details below)
5.
run.
6.
test.
7.
improve.
8.
goto 5
Creating your own robot
In order to make your own robot work with
the simulation environment, it needs to be extended from the abstract class
"VacuumRobotControl". Please look at the
source of that class, too.
Since I wrote the simulation in a way that
it uses the mainloop for its own purposes, you need
to start your own thread to do anything useful. The best thing to do is to
implement the "Runnable" interface in your
own class. Extending your class from VacuumRobotControl
already forced you to implement a "run" method. Hence it's only
natural to just declare that your class also implements "Runnable" (yes, i could have
done that in VacuumRobotControl, but i wanted you to type it yourself).
Look at the example implementation "HappyWallRobot".
The logic sits in the state machine. That's
where your own task really starts. Design and implement a state machine for the
robot such that it is more efficient than the HappyWallRobot!
Robot Control, Laser Reading
You can control the robot using the method
·
setMotorSpeedLR(double left, double right)
that you inherit from VacuumRobotControl.
It sents the left and right motor's speed in mm/s (i.e.
if you set thesetMotorSpeedLR(200, 200) the robot will go forward with 200 mm/s). In this project,
the max motorspeed of a single motor is 1200mm/s.
The robot needs some time to get up to
speed, and especially, to go back to 0! It breaks quite slowly, which will give
you some headache, i promise. Take the
acceleration/deceleration into account!
The robot has a built in safety stop, and
safety stop recovery. When it predicts that it will crash into a wall soon, it
automatically slows down or makes a hard stop (physically, i.e. in the real
world, this is a painfully hard stop, which slams the brakes, and usually rips
cables, lasers and laptops off the robot. Do not make the robot stop hard too
often, please!)
You can monitor the robot's speed using the
method
·
double [] getMotorSpeedLR()
that you inherit from VacuumRobotControl.
It returns a double array {leftspeed, rightspeed}.
You can monitor the robot's pose using the
method
·
double [] mc.robot.getPose()
"mc" is a MainControl
object, that you inherit from VacuumRobotControl.
"robot" is an Object of type "AbstractDifferentialRobot",
if that's of interest. The robot pose is in the robot's own, local coordinate
system. The first pose, when you start the robot, is (0,0,0), meaning that the
robot heads towards its own x-axis.
You can read the laser using the method
·
double [] mc.laser.readPolar(false)
·
or double [][] mc.laser.readCartesian(false)
The laser sits on the middle of the robot,
its angular measuring range is -135 to 135 degrees. In order to see what's
directly in front of the robot, you need to read the distance from reading 270:
double [ ]
distances = mc.laser.readPolar(false);
double distanceInFront = distances[270];
The TA will explain more about the laser
readings. Have in mind that the laser has its own coordinate system (which is
the same as the robot's, but different to the global map's system!)
Files
You need the Netbeans
project. Download it from HERE.
Optional: The project contains lots of jar
files. If you want to see how the simulation itself works, you can look into
the sources these jar-files were created from.
It might be of interest to see such sources -- they are a serious project. In
"basicrobotcontrol" you might find some
interesting methods which could be of help to steer the robot better. Most
robot related routines would be in AbstractDifferentialRobot.
The control-core is MainControl. The laser-sources
are in Abstract2DLaser and LMS100.
Grading
The project has an auto-scoring system. It shows
the total percentage covered, and the average percentage covered over time. The
TA will grade based on the average percentage, after running the simulation for
10 minutes. Make your robot clean as much as possible fast! If your robot
performs worse than the happywallrobot, your project
will be scored 0 points!! (since you already have the happywallrobot,
the minimum work is to improve it!)