Comment on page
Starter Bot - Programming Teleop
Our strategy for teleoperated mode was to make driving the robot as intuitive and precise as possible. Navigating carefully through the grid of Junctions is important for gameplay so we decided to use Split Arcade Drive this year.
Since the Junctions are mounted on springs and can move or change height freely, we found the best method to control the Lift mechanism was to not use preset levels. This allows us to easily raise cones to any height needed.
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:
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 the POWERPLAY Starter Bot would be driven with Split Arcade Drive for advantages in precision while driving.
- Which input makes the most sense? Would pressing up on the d-pad be more intuitive for moving your arm up or down?
- We chose to assign our D-Pad inputs to raising and lowering our lift and the right bumper to releasing Cones from the intake.
POWERPLAY Starter Bot controller layout:
Not all controllers have buttons labeled the same way. Check the manufacturer's documentation for accurate button mapping.
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.
We opted to use split arcade drive during the POWERPLAY season because it allows for forward and reverse movement without worrying about accidentally pushing the joystick in the X-Axis. The POWERPLAY field requires precise movements, and split arcade drive allows teams to have more control and precision.
Similar to the traditional arcade style driving tutorial, we will use the Dual Motor block to assign power values to our motors.
POWERPLAY Starter Bot Drive Code (Blocks)
Remember to reverse one of the motors and negate the values on the Y-Axis of your joysticks.
The control of our lift arm is done by running two Core Hex Motors (REV-41-1300) on a Reverse Virtual Four Bar Linkage. Unlike the joystick, the DPad on a gamepad inputs are Boolean data,
FALSE/TRUE. In order to tell the arm to move when DPad Up or DPad Down are selected, an
if/elsestatement needs to be used.
For all of our button inputs we used an
if/elsestatement. In the image below you can see the code for pressing the DPad. When DPadUp is pressed, both Core Hex Motors set power to -1, which moves the lift upwards. When DPadDown is pressed, the Core Hex Motors change their power to 0.8, which moves the lift downwards.
Remember that when it comes to coding your robot, the Y-Axis is -1 at its topmost point, and +1 at its bottommost point, unless you negate values.
POWERPLAY Starter Bot Lift Code (Blocks)
The Starter Bot's compact active roller intake features one servo motor-driven roller paired with a free spinning roller. To make sure we keep a good grip on the Cone, the intake is always running inwards. This means we need to reverse the direction of the servo to release the Cone once the robot is in position to place it.
For the intake, we chose to use the RightBumper to control the direction and speed of the motor spinning the mechanism. In order to tell the intake to increase power when RightBumper is pressed, an
if/elsestatement needs to be used.
POWERPLAY Starter Bot Intake Code (Blocks)
As you can see, if you press the RightBumper, the intake sets its power to max. Otherwise, the intake power is set to 0.3.
Below is the complete Blocks Program for the POWERPLAY Starter Bot.
POWERPLAY Starter Bot Complete Code (Blocks)