-
Notifications
You must be signed in to change notification settings - Fork 0
Controller
Controllers are used to control one or more Components.
IController
| void activate(Settings settings);
| void deactivate();
| void update();
update
- Called once each periodic update and should be used for updating each component the controller uses.
activate
- Called when the robot is first active. A Settings
is used to supplied the controller with external settings. This method should be used to initialize all values in the controller.
deactivate
- Called when the robot deactivates. This method should be used to stop any tasks that are running and run any deactivation procedures for that controller.
public class ArmController extends IController {
public ArmController() { ... }
public void activate(Settings settings) { ... }
public void deactivate() { ... }
public void update() { ... }
}
The controllers constructor method can be used to add components from the arguments. This is demonstrated in the "Using a Controller" section.
public class ArmController extends IController {
private Arm arm;
private Xbox xbox;
private double rotateSpeed = 1.0;
public ArmController(Arm arm, Xbox xbox) {
this.arm = arm;
this.controller = controller;
}
public void activate(Settings settings) {
rotateSpeed = Settings.get<Double>("ArmRotSpd");
}
public void deactivate() {
arm.Stop();
}
public void update() {
arm.rotate(xbox.Get(Xbox.Axis.RightX) * rotateSpeed);
}
}
The ArmController
doesn't need to have any extra methods besides the ones implemented by IController
. If a method needs to be implemented, it should always be done through components and not controllers.