View Single Post
  #18   Spotlight this post!  
Unread 28-11-2012, 13:56
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 434
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Command Based JAVA - Basic Tutorial

Quote:
Originally Posted by apalrd View Post
Do subsystems get poked by run() also? Or does run() just poke all of the active commands?
The scheduler only interfaces with the commands. Commands then interface with the methods of a subsystem.

Quote:
Originally Posted by apalrd View Post
Is the architecture designed for the subsystems to store the subsystem state, or for the commands to store subsystem state?
The state of a subsystem is kept track of by the subsystem.
The state of a command sequence is kept track of by the commands and scheduler.

A subsystem only knows how to interact with itself. It can turn a motor on/off, it can read the status of a sensor. Alone, it doesn't do you much good. The subsystem alone is not intended to be completing complex tasks.
The command keeps track of state through it's methods (previously mentioned). The command has something it needs to do, in the execute() method. Then a check is performed to see if a terminating condition is met, in the isFinished() method. So the command itself has a notion of what needs to be done and when it should consider the task complete.

Multiple commands can be linked together (series or parallel execution) in a Command Group. This allows more complex tasks to be built up from a simple set of commands, simply by calling the commands in the right order.

For example if you wanted to aquire a ball from a made up robot with a drop down intake, a lift system which moved balls vertically,you may have the following subsystems and methods within them:
Dropdown_Intake()
raise()
isRaised()
lower()
isLowered()
collect()
discard()
Elevator_Lift()
driveUp()
driveDown()
isBallPresent()
The above subsystems and methods strictly set output values and read input values.

You may then create the following commands:
RaiseIntake()
LowerIntake()
CollectIntake()
And then the following Command Group to aquire one ball:
RaiseLiftUntilBallPresent()
it could execute the following commands in sequence
LowerIntake()
ElevatorUp()
CollectIntake()
and the group of commands could terminate when ElevatorLift.isBallPresent() returns true.

Other command groups could then be created as necessary re-using some of the above commands for other teleop or autonomous functions.
__________________
http://team2168.org