|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
motors
This class does all the handling of the robot motors and sensors.
The functions rotate(), track(), GrabObject(), and ReleaseObject() are the functions which get
called by the main Seeker class. All other functions are internal to the motors class to enable
it to accomplish it's goals.
The state machine diagrams for how this class operates are Tracking, Left Bumper Hit,
Rght Bumper Hit, and Rotation.
| Field Summary | |
(package private) static TouchSensor |
Armb
Lego touch sensor for arm (when raised to max height) |
(package private) boolean |
backupdone
While fixing bumpers, tracks whether the backup state is done |
(package private) boolean |
bArmIsDown
Arm state flag |
(package private) boolean |
bArmIsUp
Arm state flag |
(package private) boolean |
bHandIsClosed
Arm state flag |
(package private) boolean |
bHandIsOpen
Arm state flag |
(package private) static com.ajile.components.OneShotTimer |
ChangeStallTimer
Change Stall Timer Variable |
(package private) static CameraImage |
cImage
external camera class |
(package private) static com.ajile.components.OneShotTimer |
ColorTimer
Color Tracking timer |
(package private) boolean |
colorTimerDone
Color Tracking flag |
(package private) int |
currentstate
State Variables |
(package private) static boolean |
Debug
Debug Flag |
(package private) static int |
degrees20
Rotation count for 20 degrees |
(package private) static int |
degrees90
Rotation count for 90 degrees |
(package private) boolean |
deltaevent
Data event flag |
(package private) int |
dir
Direction Variable |
(package private) boolean |
done
Tracks whether the 20 degree rotation is complete |
(package private) static int |
findColorTime
Time interval to wait before declare no colors were found. |
(package private) boolean |
fixBackup
Flags for when we need to perform certain actions. |
(package private) boolean |
fixed
Tracks whether the bumper fixes are complete |
(package private) boolean |
fixForward
Flags for when we need to perform certain actions. |
(package private) boolean |
fixLeftTurn
Flags for when we need to perform certain actions. |
(package private) boolean |
fixRightTurn
Flags for when we need to perform certain actions. |
(package private) boolean |
forwarddone
While fixing bumpers, tracks whether the forward state is done |
(package private) boolean |
handstall
Hand stall flag |
(package private) static int |
HandStallTime
Time interval to wait for no movement before assuming a stall has occured |
(package private) static com.ajile.components.OneShotTimer |
HandStallTimer
Hand Stall Timer Variable |
(package private) static TouchSensor |
leftb
Lego touch sensor for left bumper |
(package private) boolean |
leftbHit
Set true if the left bumper is pressed Set false otherwise |
(package private) static Motor |
mArm
Lego control for arm motor |
(package private) static Motor |
mHand
Lego control for hand motor |
(package private) static Motor |
mLeft
Lego control for left motor |
(package private) static int |
motorArm
Lego motor speed for arm movement |
(package private) static int |
motorForwFast
Lego motor speed for fast forward |
(package private) static int |
motorForwSlow
Lego motor speed for slow forward |
(package private) static int |
motorHand
Lego motor speed for hand movement |
(package private) static int |
motorRealSlow
Lego motor speed for real slow |
(package private) static int |
motorTurnFast
Lego motor speed for fast turn |
(package private) static int |
motorTurnSlow
Lego motor speed for slow turn |
(package private) static int |
movement
Rotation count for forward movement |
(package private) static Motor |
mRight
Lego control for right motor |
(package private) int |
nextstate
State Variables |
(package private) boolean |
noColor
Color Tracking flag |
(package private) static GpioField |
PortA
Port A control (used for turning on buzzer) |
(package private) int |
prevstate
State Variables |
(package private) static TouchSensor |
rightb
Lego touch sensor for right bumper |
(package private) boolean |
rightbHit
Set true if the right bumper is pressed Set false otherwise |
(package private) boolean |
rot20left
Flags for when we need to perform certain actions. |
(package private) boolean |
rot20right
Flags for when we need to perform certain actions. |
(package private) static RotationSensor |
sArm
Lego rotation sensor for arm |
(package private) static RotationSensor |
sHand
Lego rotation sensor for hand |
(package private) static RotationSensor |
sLeft
Lego rotation sensor for left wheel |
(package private) static RotationSensor |
sRight
Lego rotation sensor for right wheel |
(package private) boolean |
stall
Stall flag |
(package private) boolean |
stallfixed
Stall fixed flag |
(package private) static int |
stallFixInterval
Time interval to wait before the stall variable can be changed. |
(package private) static com.ajile.components.OneShotTimer |
StallFixTimer
Stall Fix Timer Variable |
(package private) static int |
stallInterval
Time interval to wait before the stall variable can be changed. |
(package private) int |
stallleftcount
Left stall counter |
(package private) boolean |
stallread
Stall read flag |
(package private) int |
stallrightcount
Right stall counter |
(package private) static int |
stallTime
Time interval to wait for no movement before assuming a stall has occured |
(package private) static com.ajile.components.OneShotTimer |
StallTimer
Stall Timer Variable |
(package private) boolean |
stalltimeup
Stall time over flag |
(package private) static int |
timeInterval
Time interval between polls of direction |
(package private) boolean |
timeIntervalDone
Tracks whether the timeInterval has passed |
(package private) static com.ajile.components.OneShotTimer |
timer
Timer to use for the time intervals between polls |
(package private) boolean |
turndone
While fixing the bumpers, tracks whether the 90 degree turns are complete |
| Constructor Summary | |
motors(CameraImage camera)
Sets default values for all class members Also, sets up the event listeners for the multiple input sensors. |
|
| Method Summary | |
void |
dataEvent(int Count)
If motors are suppose to be moving, but the rotation count is not changing, a stall timer will start. |
private void |
fixLeft()
Runs a small sequence to fix left bumper hit save rotation value Turn 90 degrees Right while checking for right bumper hits If right bumper hits, back up until it no longer hits Once 90, travel forward a few inches Turn 90 degrees Left while checking for left bumper hits If left bumper hits, recursively call fixLeft, otherwise retrieve old rotation values and return |
private void |
fixRight()
Runs a small sequence to fix right bumper hit. Save rotation value Turn 90 degree Left while checking for left bumper hits If left bumper hits, back up until it no longer hits Once 90, travel forward a few inches Turn 90 degrees Right while checking for right bumper hits If right bumper hits, recursively call fixRight, otherwise retrieve old rotation values and return |
void |
GrabObject()
Runs through the sequence of commands to pick up an object. |
static void |
main(java.lang.String[] args)
Main Function Will use for debugging and unit testing |
void |
ReleaseObject()
Opens the gripper to release the object. |
void |
reset()
Initializes all the flags and variables used by the class to make sure everything is in the initial state. |
void |
rotate(int dir)
Sets the motors to rotate the robot 20 degrees in the given direction. |
boolean |
track()
Set the motors to correctly track an object. Calls GetTrackDirection() to determine which direction to rotate to as well as whether to move forward or not. Will handle wall/object collision by turning 90 degrees opposite of collision moving a few inches, and swing back to the original orientation. The state machine diagrams for how this class operates are Tracking, Left Bumper Hit, and Rght Bumper Hit. |
| Field Detail |
static final Motor mRight
static final Motor mLeft
static final Motor mArm
static final Motor mHand
static int motorRealSlow
static int motorHand
static int motorArm
static int motorTurnSlow
static int motorTurnFast
static int motorForwSlow
static int motorForwFast
static boolean Debug
static int timeInterval
static int stallTime
static int HandStallTime
static int stallInterval
static int stallFixInterval
static int findColorTime
static int degrees90
static int degrees20
static int movement
static final RotationSensor sLeft
static final RotationSensor sRight
static final RotationSensor sArm
static final RotationSensor sHand
static final TouchSensor rightb
static final TouchSensor leftb
static final TouchSensor Armb
static final GpioField PortA
static com.ajile.components.OneShotTimer timer
int dir
int currentstate
int nextstate
int prevstate
boolean done
boolean turndone
boolean backupdone
boolean forwarddone
boolean fixed
boolean fixLeftTurn
boolean fixRightTurn
boolean fixForward
boolean fixBackup
boolean rot20right
boolean rot20left
boolean rightbHit
boolean leftbHit
boolean timeIntervalDone
static CameraImage cImage
boolean bArmIsUp
boolean bArmIsDown
boolean bHandIsClosed
boolean bHandIsOpen
static com.ajile.components.OneShotTimer ColorTimer
boolean noColor
boolean colorTimerDone
static com.ajile.components.OneShotTimer StallTimer
static com.ajile.components.OneShotTimer HandStallTimer
static com.ajile.components.OneShotTimer ChangeStallTimer
static com.ajile.components.OneShotTimer StallFixTimer
boolean stall
boolean handstall
boolean stalltimeup
boolean stallfixed
boolean stallread
boolean deltaevent
int stallrightcount
int stallleftcount
| Constructor Detail |
public motors(CameraImage camera)
camera - Reference to the camera class which will be used for getting the tracking direction| Method Detail |
public void reset()
public static void main(java.lang.String[] args)
args - Input arguments passed from the OSpublic void rotate(int dir)
dir - Direction of rotation. 0=Right, 1=Leftpublic boolean track()
private void fixLeft()
private void fixRight()
public void dataEvent(int Count)
Count - The angular movement of the left rotation sensorpublic void GrabObject()
public void ReleaseObject()
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||