CSCI 235 - Intelligent Robotics
Spring 2017
Project #2: Conditions and Modes
State Machines
As discussed in class, for this assignment we will be using a Java library
for representing robot behavior as a state machine. For each program,
this requires defining the following:
- What are the robot's behavior modes?
- What conditions trigger a change in mode?
- What new mode does the robot employ upon triggering each condition?
- What sensors are going to be used?
- What sensor values correspond to the specified conditions?
Library
The modeselection
library we will be using has the following
classes:
-
ModeSelector.java
: Objects of this class represent an integrated controller. Sensors, transitions, and actions are set up using various methods. The constructor requires three parameters:
- The run-time type of the Condition flags.
- The run-time type of the Mode flags.
- The starting Mode.
This class has the following methods:
-
sensor()
: Add a SensorFlagger
.
-
flagger()
: Add a MotorFlagger
.
-
mode()
: Add a mode. Specify the Mode, its Transitions, and the action to take when the mode starts.
-
control()
: Start the defined controller. It will stop when the Escape button is pressed.
-
Transitions.java
: These objects represent a block of transitions. In some cases, different modes can share the same transitions; in other cases, their transitions will be distinct. A transition between a condition and mode is specified using the add()
method.
-
SensorFlagger.java
: These objects represent sensors. Each sensor should have one SensorFlagger. Each SensorFlagger can flag as many conditions as desired. The add()
method specifies a Condition that becomes true if the given boolean expression is true. The add2()
method specifies one Condition that is true if the given boolean expression is true, and another Condition that is true if the expression is false.
-
MotorFlagger.java
: These objects monitor motor tachometer counts. They have the same methods as SensorFlagger
objects.
Sample Programs
Each of these three projects is a complete example using the above library:
Assignment
Implement each of these programs. Use the modeselection
library for each of them.
-
Avoid2Way
: An obstacle avoider that uses both the bumpers and the sonar. Turns should not monitor the motor encoders. When a bumper is pressed, the robot should turn in a direction that helps the robot avoid further collisions. When the sonar senses a close object, it should turn in the same direction that the most recent bumper hit induced. If a bumper has not yet been hit, it does not matter which direction it turns.
-
Avoid2WayDelay
: This obstacle avoider will be similar to Avoid2Way
, except that when turning the robot should monitor the motor encoders to enable it to take a longer turn. Experiment with different turn durations until you find one that performs well.
-
Patrol
: The robot should patrol along a line. It should drive for two meters, followed by a 180 degree turn. This behavior should repeat indefinitely.
-
PatrolStop
: This program is similar to Patrol
, except that the robot will begin its turn early if it senses an obstacle (either from the bumpers or sonar).
Questions
- Using the same metrics you used from Project 1, which works better:
Avoid2Way
or Avoid2WayDelay
?
- A traversal of the patrol line consists of driving the full two meters out, followed by returning to the original location. Run the
Patrol
robot for each number of traversals given below. How close does it get to the original starting point? How might you characterize the loss of precision from repeated traversals?
- What might be an application of the concept of the
PatrolStop
robot?
- From your experience of this lab, what advantages and
disadvantages did you find for the state-machine approach to programming?