Академический Документы
Профессиональный Документы
Культура Документы
IterativeRobot
A function is called periodically when a mode is Enabled
autonomousPeriodic()
RobotBuilder App
FRC provides a very nice RobotBuilder application. Identify commands / subsystems, sensors, actuators. Execute commands from joystick buttons. It creates basic code outline. You still need to write functionality.
What is a Subsystem?
Subsystem part of the robot that does something:
Claw, drive-train, Frisbee launcher
State Machines
Parts you need to write:
Store internal state in class member variables. Public accessor functions to get state (isMotorOn). Public mutator functions to change state (turnMotorOn).
What is a Command?
A way to tell the robot to do something: Fire a frisbee, load a frisbee, drive with joysticks. Commands require a subsystem to execute on. When a command is executed: Initialize(): Check if the command can be executed, change state of subsystem. Execute(): Periodic call to subsystem (joystick inputs to drive-train). isFinished(): Periodically check if the command finished?
Has the subsystem reached the desired state: isClawOpen() Is the command a single-shot: true Is the command time-based or running to long: isTimedOut()
6. Review Java Project Directory in MyRobot 7. Export -> Java 8. Open project in NetBeans
MotorRelay.java
What state information do we need?
Motor on in forward or off. Add state members and accessor methods to class:
toggleMotorRelayFwd.java
isFinished() return true, the command is always finished (fire and forget). End() and interrupted() empty
The command cant be interrupted and no special end state is required (like turning off the motor).
Execute() empty
The command doesnt need to periodically check/change anything.
Things To Do
Make a timedMotorRelayFwd command:
Have the command turn the motor relay on for 5 seconds.
Hint use setTimeout in initialized and check isTimedOut for your finished condition. Hint with multiple commands using the same subsystem, you have to worry about what happens when your command is interrupted
Hints
Use lots of System.out.println() for testing/debugging. Check out team2168.org/javadoc/ for javadoc info on WPILib Check out
http://wpilib.screenstepslive.com/s/3120/m/7952