This repository is meant to be a space for programmers to work on code and experiment with using the Greenland Robotics Framework without having to worry about breaking or cluttering up their competition repo. I recommend using this repo to play with the basic robots that you have and learn things before the robot is built.
- If you are using the PlayStation controllers, use the button map below
PlayStation Gamepad(in code) X A O B △ Y □ X - In TeleOp, the following buttons are in use by the
implementDriveLogic()method(gamepad1 only)left_stick_xleft_stick_yright_stick_xright_bumperleft_triggerright_trigger
by using these in your teleop code, that one action will control both the driving and whatever you mapped it to
This documentation covers all classes and methods in TeamCode/src/main/java/gcsrobotics/framework for the GreenlandRoboticsFramework.
It includes explanations for:
- What each method does
- How and why to use them
- Common usage scenarios
Purpose:
AutoBase is an abstract class for autonomous robot operation modes.
It extends OpModeBase, providing accurate movement utilities and control structures for writing robust autonomous routines.
- Extend
AutoBasein your own autonomous OpMode. - Override
initSequence()(optional) for initialization logic. - Override
runSequence()for your autonomous sequence. - Use movement methods like
path(),chain(),simpleDrive().
Override to add code you want to run in the init phase.
Override to define the autonomous actions (your main logic).
Moves the robot simply in the specified direction ("vertical" or "horizontal") at a set power for a duration.
- Use: For short, direct movements (e.g., nudging into position).
- Example:
simpleDrive(Axis.X, 0.5, 1000);
Sets all drive motors to the same power.
- Use: To move all wheels together, usually straight.
Pauses execution for a number of milliseconds, updating odometry and telemetry.
- Use: Preferable to
sleep()in FTC, as it keeps robot feedback alive during the wait.
Accurate movement to a coordinate (targetX, targetY) with optional axis forgiveness.
- Use: For precise autonomous positioning.
forgiveAxis:Axis.Xor'Axis.Y'if you want to ignore error on that axis (e.g., just get close horizontally).
Fast movement to a coordinate (less accurate than path).
- Use: When speed is more important than precision.
Waits until a given condition is true.
- Use: For waiting on asynchronous events or sensor thresholds.
You don't need to worry about these, they are internal
pidDrivePower(double error, boolean isX)
Calculates PID-like drive power for pathing routines.setMotorPowers(double xPower, double yPower, double headingCorrection)
Sets individual wheel powers for advanced movement.sendTelemetry(String label, ...)Sends detailed telemetry for debugging pathing.stopMotors()Stops all drive motors.notStuck(double targetX, double targetY)Detects if the robot is stuck (not making progress).getX(), getY(), getAngle()Return current robot position/heading from odometry.
Purpose:
Central location for tunable constants (motor positions, PID values, setpoints, etc).
Example fields that many teams may use, feel free to delete them if they are unnecessary
clawClose,clawOpen: Servo positions for the claw.armUp,armMiddle,armDown: Encoder positions for arm levels.wristUp,wristDown: Servo positions for wrist.
These fields are required, and are needed for basic functions. Do NOT delete these.ENCODER_TOLERANCE: How close an encoder must be to target to count as "there".KpDrive,KdDrive,KpTurn,KdTurn: PID coefficients for drive and turn control.autoMaxPower: Max drive power for autonomous.- All constants are static and can be tuned live with FTC Dashboard.
Purpose:
A wrapper around FTC's DcMotor providing easier position control, power management, and utility operations.
public DcMotorEnhanced(DcMotor motor)
setPosAndWait(int targetPosition, OpModeBase opmode)- Moves to a position at default speed, waits until there.
setPosAndWait(int targetPosition, double speed, OpModeBase opmode)- Moves to a position at given speed, waits until there.
setPosition(int targetPosition)- Go to position at default speed (doesn’t wait).
setPosition(int targetPosition, double speed)- Go to position at specified speed.
setDefaultSpeed(double speed),getDefaultSpeed()setPower(double power),getPower()
reset()
Resets encoder, restoring previous mode.isAtTarget()
Returns true if withinENCODER_TOLERANCEof target.getCurrentPosition()isBusy()
setMode(DcMotor.RunMode mode),getMode()setZeroPowerBehavior(DcMotor.ZeroPowerBehavior behavior),getZeroPowerBehavior()setDirection(DcMotorSimple.Direction direction),getDirection()
getBaseMotor()
Returns the raw underlyingDcMotor.
Purpose:
Driver for the goBILDA® Pinpoint Odometry Computer.
Handles communication, configuration, and reading robot pose/velocity.
- Constructed by FTC SDK’s hardwareMap (
hardwareMap.get(GoBildaPinpointDriver.class,"odo")).
update()- Reads all odometry data (should be called each loop).
update(ReadData data)- Reads only the heading (for performance).
setOffsets(double xOffset, double yOffset)- Set pod offsets in mm (deprecated: see overload with
DistanceUnit).
- Set pod offsets in mm (deprecated: see overload with
setOffsets(double xOffset, double yOffset, DistanceUnit distanceUnit)setEncoderDirections(EncoderDirection x, EncoderDirection y)setEncoderResolution(GoBildaOdometryPods podType)setEncoderResolution(double ticks_per_mm)setEncoderResolution(double ticks_per_unit, DistanceUnit distanceUnit)
recalibrateIMU()- Zero the IMU (robot must be still).
resetPosAndIMU()- Zero position and IMU.
setPosition(Pose2D pos)setPosX(double posX, DistanceUnit unit)setPosY(double posY, DistanceUnit unit)setHeading(double heading, AngleUnit unit)getPosition()getAngle(),getAngle(AngleUnit),getAngle(UnnormalizedAngleUnit)getX(),getY(),getAngle()
getDeviceID(),getDeviceVersion()getDeviceStatus()getLoopTime(),getFrequency()getEncoderX(),getEncoderY()getYawScalar()
getVelX(),getVelX(DistanceUnit)getVelY(),getVelY(DistanceUnit)getHeadingVelocity(),getHeadingVelocity(UnnormalizedAngleUnit)getVelocity()
getXOffset(DistanceUnit),getYOffset(DistanceUnit)getPinpoint()
Purpose:
Abstract base for all OpModes (autonomous or teleop).
Handles hardware initialization and provides access to motors, servos, and odometry.
fl,fr,bl,br— Drivetrain motors (DcMotorEnhanced)arm— Arm motor (DcMotorEnhanced)claw— Claw servoodo— Odometry computer (GoBildaPinpointDriver)
Override for code to run in init phase.
Override for code to run once start is pressed.
Initializes all hardware.
- Configures motor/servo objects, odometry, directions.
Main entrypoint for OpMode.
- Sets up telemetry, hardware, runs
runInit(), waits for start, then runsrun().
Purpose:
Base for teleop OpModes.
Implements drive logic and framework for teleop control.
- Sets drivetrain motors to
RUN_WITHOUT_ENCODER(faster for teleop). - Calls
inInit()for your custom init code.
- Repeatedly calls
runLoop()while OpMode is active.
Override to add the main teleop loop logic.
Override to add code for the init phase of teleop.
- Set the drive speed multiplier.
- Implements full mecanum drive logic using gamepads.
- Handles horizontal locking, slow mode, and trigger overrides.
- Use: Call this in your
runLoop()to handle all drive movement.
- Create an OpMode (autonomous: extend
AutoBase; teleop: extendTeleOpBase) - Override the required abstract methods (
runSequence,runInit,runLoop, etc.) - Call movement and hardware methods to control your robot.
- Tune constants in
Constants.javaas needed (dashboard compatible). - Use odometry and drive utilities for accurate and efficient robot control.
- Each class and method is documented with purpose, usage, and scenarios.
- For detailed code reference, see the .java files.
- For FTC SDK integration, see FTC documentation.
- If nothing else works, ask Josh.