Programming Teleop

Configuration

Before getting started with programming we needed to create a configuration file. Below is an overview of how the robot is configured for the teleop code to function as expected:

Port Type
Port Number
Device Type
Name

Motor

0

REV Robotics Ultraplanetary HD Hex Motor

rightDrive

Motor

1

REV Robotics Ultraplanetary HD Hex Motor

leftDrive

Motor

2

REV Robotics Core Hex Motor

rightarm

Motor

3

REV Robotics Core Hex Motor

leftarm

Servo

0

Servo

wrist

Servo

1

Servo

gripper

Configuration file download

To put this configuration file on your robot, drag this file into the "FIRST" folder of your Control Hub's file system.

For more in-depth information on the configuration process check out Hello Robot - Configuration!

Wiring Diagram

Device Name
Device Type
Port

rightDrive

UltraPlanetary Gearbox Kit and HD Hex Motor

Motor/Encoder Port 0

leftDrive

UltraPlanetary Gearbox Kit and HD Hex Motor

Motor/Encoder Port 1

armright

Core Hex Motor

Motor/Encoder Port 2

armleft

Core Hex Motor

Motor/Encoder Port 3

wrist

Smart Robot Servo

Servo Port 0

gripper

Smart Robot Servo

Servo Port 1

Gamepad Setup

Items to consider when mapping out your gamepad:

  • What kind of input does the mechanism need?

    • Joysticks and Triggers input floating point data to your code allowing you to adjust the speed of a motor based on the pressure applied to the trigger or position of the joystick.

    • Buttons, Bumpers, and D-Pad provide boolean data to your code and are ideal for triggering an action such as rotating a motor to a set position.

  • What drivetrain are you using and what driving style do you want to use?

    • We decided our robot for CENTERSTAGE would be driven with Split Arcade Drive for advantages in precision while driving.

  • Which input makes the most sense?

    • There are multiple buttons in play for this year's Starter Bot. Both bumpers control the gripper's ability to pick up Pixels. The wrist servo is bound to the "A/Cross" and "B/Circle" buttons for rotating between the intake and home position. Lastly, this year's arm is controlled by the triggers.

Not all gamepads have buttons labeled the same way. Check the manufacturer's documentation for accurate button mapping.

2023-24 REV DUO FTC Starter Bot Gamepad Layout:

2023-24 Starter Bot Gamepad Control Bindings
Gamepad Input
Function

Right Joystick

Turn Left and Right

Left Joystick

Drive Forward and Reverse

Right and/or Left Bumper

Gripper Close

A/Cross

Arm & Wrist Move to Home Position

  • Arm Down, Wrist Up

B/Circle

Arm & Wrist Move to Intake Position

  • Arm Down, Wrist Down

Y/Triangle

Arm & Wrist Move to Scoring Position

  • Arm Back, Wrist Up

Option

Zero Encoder for Arm

Left Trigger

Lower Arm

Right Trigger

Raise Arm

More information on programming gamepads for use with your robot can be found at Hello Robot - Using Gamepads.

Programming Teleop - Blocks

This section makes the assumption that you have learned some of the FTC programming basics by going through the Hello Robot guide. If you have not gone through this guide please walk through it before proceeding.

In Hello Robot- Basics of Programming Drivetrains we covered how to program arcade drive with one joystick. For this example, we will be programming arcade drive using two joysticks. This type of drive is called "split arcade". In split arcade drive, the left joystick will control forward and reverse motion of the robot, and the right joystick will control turning. This is similar to how some RC cars are driven and video games are played.

Copy of the full Blocks code!

Let's break down the Blocks Code for CENTERSTAGE!

Establishing Variables:

This year's Starter Bot makes use of a lot of variables.

Variable
Purpose

homearmposition

Tells the arm where it should sit when set to "home position"

armIntakePosition

Tells the arm where it should sit to intake pixels

armScorePosition

Tells the arm where it should be for scoring

manualMode

Used for checks of if the arm is being manually controlled with the triggers or using the preset positions

armShutdownThreshold

Used in the watchdog check for if the motors are running and when to shutdown

wristUpPosition

Sets the value for when the wrist is in the up position

wristDownPosition

Sets the value for when the wrist is in the down position

gripperClosedPosition

Sets the default gripper position

gripperOpenPosition

Sets the position for where the gripper should move to when the bumpers are pressed

running

Used in the watchdog check for if the motors are in "run_to_position" mode

Variables for the 2023-24 Starter Bot

Setting Up Encoders:

This code runs AFTER the initialization is activated, but BEFORE the play button is clicked.

This section allows the encoder on the arm Core Hex Motors to be reset to zero on start up and establishes their default behavior. Additionally, this sets two of the motors to run in reverse, one on the drivetrain and one of the arm motors.

This code will run ONCE after the play button is activated.

This section acts as an additional check for resetting the arm's power and position as well as setting the Core Hex Motors to "RUN_TO_POSITION" mode as default when the play button is clicked.

Split Arcade Drive:

The following sections all run REPEATEDLY in the "while loop" once the play button is activated.

Let's begin with programming our Split Arcade Drive. This code will take input from the right and left joysticks to determine the robot's movement. The left joystick controls forward and back, while the right stick controls left and right turning movement.

Arcade Split Drive Code

Manual Arm Movement:

The triggers on the controller determine the direction of the arm's rotation. The arm's power is determined by how far down both triggers are pressed. Additionally, the if/then statement switches the arm between manual drive and being ready to run the preset positions.

Arm and Wrist Preset Positions:

There are three preset positions for the arm and wrist on the Starter Bot- intake, home, and scoring.

Controller Button
Position

A/Cross

Arm moves to the down position, Wrist moves up

B/Circle

Arm moves to the down position, Wrist moves down

Y/Triangle

Arm moves up to behind the robot, Wrist moves to up - the arm should adjust to its final scoring position

Re-zero Encoder:

When you re-zero the encoder the arm and wrist should be in the HOME position.

Watchdog to Shutdown Motor in Home Position:

This check prevents the Core Hex Motors from continuing to run while in home position to prevent potential overheating.

Let's take a closer look at all the parts of this if/then statement:

This if/then statement will only run if all the following are met:

  • The arm is not currently moving in manual mode from the triggers being pressed

  • The motors are actively on

  • The left Core Hex Motor's current and target position are less than or equal to the threshold (currently set to five)

    • Home position's value is set to 0 while Intake is set to 10

Gripper Controls:

When either or both of the bumpers on the controller are held down the gripper will open fully. When released it will return to the closed position to secure the fingers around the pixel.

Programming Teleop - OnBot Java

This section makes the assumption that you have learned some of the FTC programming basics by going through the Hello Robot guide. If you have not gone through this guide please walk through it before proceeding.

In Hello Robot- Basics of Programming Drivetrains we covered how to program arcade drive with one joystick. For this example, we will be programming arcade drive using two joysticks. This type of drive is called "split arcade". In split arcade drive, the left joystick will control forward and reverse motion of the robot, and the right joystick will control turning. This is similar to how some RC cars are driven and video games are played.

Full Robot Code

To use this code with your Starter Bot, copy and paste it into a new OnBot Java OP Mode!

Last updated

Was this helpful?