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?
- 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 a 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 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:
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)
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.
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)