Package com.crossbotics.ftchelper.robot
Class Turret
- All Implemented Interfaces:
Subsystem
A turret on one motor that turns inside its limits, by hand or following the goal with a
Camera. Angles in degrees, counterclockwise +, 0 = straight forward (where it points when
the program starts).
turret = add(Turret.motor("turret", "gobilda-5203-117").gearRatio(5).follows(camera)); // Robot.java
public static class Turret { // Tunables.java
public static double min = -90, max = 90; // its range: it never turns past these
public static double kP = 0.02, kI = 0, kD = 0.001;
public static double maxPower = 0.8, tolerance = 1.0, cameraOffset = 0;
}
Follow mode (followMode(), on from START when follows(com.crossbotics.ftchelper.robot.Camera) is used): every
loop it turns toward the camera's goal. A goal past the range: it waits at the limit and the
Driver Station says "goal out of turret range". The stick takes over while it is moved, then
following goes on.
Suggested buttons: operator right stick X turns it by hand; operator BACK switches following on and off. Docs: docs/modules/robot.md (section "Turret")
-
Method Summary
Modifier and TypeMethodDescriptionvoidThe part's telemetry line; each module adds its own.voidaimAt(double deg) Turns to an angle (inside the limits) and stops following.doubleangle()The angle now, degrees.The camera is on the robot's body, not on the turret.Following the camera's goal: switch it with a button (g2.back.toggle(robot.turret.followMode())).Follows this camera's goal (follow mode on from START).gearRatio(double motorTurnsPerTurretTurn) Motor turns per turret turn (the gears or belt).booleanisAimed()True when it points where it should (within the tolerance).booleanTrue when the goal is past its range (it waits at the limit).voidmanual(double power) By hand, -1 to 1 (a stick, every loop).static TurretA turret on this motor.part()The launcher.Turret inside, for anything this module does not offer.reversed()Positive power turns the other way (if + turns it clockwise).voidstop()Stops all motion.voidupdate()Called once every loop.
-
Method Details
-
motor
A turret on this motor.- Parameters:
motor- the motor's configuration namemotorId- the motor's parts-catalog id (seeMotors)
-
gearRatio
Motor turns per turret turn (the gears or belt). Default 1. -
reversed
Positive power turns the other way (if + turns it clockwise). -
follows
Follows this camera's goal (follow mode on from START). The camera turns with the turret. -
cameraOnBody
The camera is on the robot's body, not on the turret. -
followMode
Following the camera's goal: switch it with a button (g2.back.toggle(robot.turret.followMode())). -
aimAt
public void aimAt(double deg) Turns to an angle (inside the limits) and stops following.- Parameters:
deg- robot-relative, counterclockwise +, 0 = forward
-
manual
public void manual(double power) By hand, -1 to 1 (a stick, every loop). While it is moved, following pauses.- Parameters:
power- + = counterclockwise
-
isAimed
public boolean isAimed()True when it points where it should (within the tolerance). -
isOutOfRange
public boolean isOutOfRange()True when the goal is past its range (it waits at the limit). -
angle
public double angle()The angle now, degrees. -
part
The launcher.Turret inside, for anything this module does not offer. -
update
public void update()Description copied from interface:SubsystemCalled once every loop. Do the hardware work here. Must be quick: no sleep, no waiting. While update() waits, the whole robot is frozen (no driving, no limits, no STOP). -
stop
public void stop()Description copied from interface:SubsystemStops all motion. Called at the end of every OpMode. -
addTelemetry
Description copied from class:ModuleThe part's telemetry line; each module adds its own.- Specified by:
addTelemetryin interfaceSubsystem- Overrides:
addTelemetryin classModule<Turret>
-