Programming Teleop
Last updated
Was this helpful?
Last updated
Was this helpful?
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:
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
To put this configuration file on your robot, drag this file into the "FIRST" folder of your Control Hub's file system.
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
Items to consider when mapping out your gamepad:
What kind of input does the mechanism need?
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.
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
Let's break down the Blocks Code for CENTERSTAGE!
This year's Starter Bot makes use of a lot of variables.
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
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 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.
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.
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.
There are three preset positions for the arm and wrist on the Starter Bot- intake, home, and scoring.
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
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
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.
To use this code with your Starter Bot, copy and paste it into a new OnBot Java OP Mode!
Joysticks and Triggers input 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 to your code and are ideal for triggering an action such as rotating a motor to a set position.
More information on programming gamepads for use with your robot can be found at.
This section makes the assumption that you have learned some of the FTC programming basics by going through the guide. If you have not gone through this guide please walk through it before proceeding.
In 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.
in your kit for accurate gripper and wrist movement!
This section makes the assumption that you have learned some of the FTC programming basics by going through the guide. If you have not gone through this guide please walk through it before proceeding.
In 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.