All pages
Powered by GitBook
1 of 1

Loading...

Starter Bot - Programming TeleOp

Basic TeleOp Strategy

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.

Configuration and Wiring

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

Device Name/Function
Device Type
Port

Items to consider when mapping out your gamepad:

  • What kind of input does the mechanism need?

    • 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 a action such as rotating a motor to a set position.

POWERPLAY Starter Bot controller layout:

More information on programming gamepads for use with your robot can be found at.

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.

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.

The control of our lift arm is done by running two Core Hex Motors () 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/else statement needs to be used.

For all of our button inputs we used an if/else statement. 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.

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/else statement needs to be used.

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.

Motor/Encoder Port 1

Drive (L)

HD Hex Motor

Motor/Encoder Port 2

Drive (R)

Core Hex Motor

Motor/Encoder Port 3

Intake

Smart Robot Servo

Servo Port 0

  • 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.

  • Reverse Intake (Let go of Cones)

    D-Pad Up

    Raise Lift

    D-Pad Down

    Lower Lift

    Port Number

    Device Type

    Name

    Motor

    0

    REVRoboticsCoreHexMotor

    Lift (L)

    Motor

    1

    REVRoboticsCoreHexMotor

    Lift (R)

    Motor

    2

    REVRoboticsUltraplantary

    Drive (L)

    Motor

    3

    REVRoboticsUltraplantary

    Drive (R)

    Servo

    0

    Servo, Continuous Rotation

    Intake

    I2C

    0

    IMU

    imu

    Lift (L)

    Core Hex Motor

    Motor/Encoder Port 0

    Lift (R)

    Input

    Function

    Right Joystick

    Turn Left and Right

    Left Joystick

    Drive Forward and Reverse

    For more in depth information on the configuration process check out !

    Wiring Diagram

    Assigning Controls to a Gamepad/Controller

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

    Programming Teleop - Blocks

    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.

    Drive Code

    Remember to reverse one of the motors and negate the values on the Y-Axis of your joysticks.

    Lift Code

    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.

    Intake Code

    Complete Blocks Program

    REV-41-1300
    Click here to download the POWERPLAY Starter Bot Blocks code.
    POWERPLAY Starter Bot Drive Code (Blocks)
    POWERPLAY Starter Bot Lift Code (Blocks)
    POWERPLAY Starter Bot Intake Code (Blocks)
    POWERPLAY Starter Bot Complete Code (Blocks)

    Core Hex Motor

    Right Bumper

    floating point data
    boolean data
    Hello Robot - Using Gamepads
    Hello Robot- Basics of Programming Drivetrains
    Hello Robot - Configuration
    Hello Robot