CENTERSTAGE My Second Autonomous Program

This is a tutorial on creating a second FIRST Tech Challenge (FTC) autonomous program for the CENTERSTAGE game.

Visit the FTC docs page on Creating Op Modes in blocks if you need help getting started and to create your first driver controlled program.

The first program scores from the rear starting positions, but some robots have to start from the front starting position. If your partner has a better autonomous that can score more than 11 points from a rear starting position, then they should start in the rear.

This program will start in the front starting location.

Prerequisites/Assumptions

This tutorial assumes:

  • a robot with two driving wheels, possibly a basic robot from the FIRST robot building resources page. These are sometimes called pushbots,
  • some way to push pixels around. This robot has a square opening at the front into which a pixel can fit,
  • A webcam is not required for this program,
  • some familiarity with Blocks, possibly a Blocks tutorial.
  • a first autonomous program. That program runs from the rear starting positions.

You can probably follow along even if you’re new to Blocks, however this tutorial doesn’t explain how to program in Blocks.

Plan

The plan is to push pixels to the backstage but from the front starting position (tile F2 on the red alliance) and move to the backstage (tile F6).

Since we assume our partner’s robot is moving from the rear starting position, we should wait as long as we can so that their robot moves out of the starting location and hopefully completes their autonomous program before we start start driving.

We’ll start by driving straight, but it would actually be better if the robot drives in a curve as indicated in the diagram. That way it doesn’t hit the trusses that support the rigging in tile F3 and it doesn’t hit the backdrop, and it also ends up parked in tile F6.

For now we are going to assume are alliance partner is NOT parked in F6.

MyFirstAuto2

1. Start by connecting your laptop to your robot and starting the Block programming tool.

2. Then click the checkbox on the MyFirstAuto1 program and click the Copy Selected OpMode button to copy your first opMode and set the Op Mode Name to MyFirstAuto2.

3. Verify that you created the new op mode. You should see your newly created op mode opened for editing in your web browser’s main screen. Let’s change how long this drives from 3000 to 6000. Note: we’ll add a delay in a later step.

4. Save your op mode. You should see the message “Save completed successfully.” displayed for a few seconds.

5. Run it and see what happens. Place your robot in a front starting position, pointed towards the rear corner. The robot should drive towards the back corner tile, drop off the pixels and park backstage. You may have to adjust the time up or down, ideally you want the robot to just touch the backwall and then backup.

What you should notice is that it’s hard to not hit the backdrop. You have to set up the robot with the back corner of the robot touching the perimeter wall, but you have to angle the front of the robot so you don’t hit the truss that is against the same wall. What we can do is make the robot drive in a curve. That way we can point the robot towards the backdrop, but the robot path curves as it drives and the robot ends up in the corner tile.

If you don’t have a field, there are four tiles between the front starting position and the rear wall. Test having your robot drive 4×2′ = 8 feet.

6. Try setting the motor power level for the right motor to be just a bit less. Maybe try 0.45, I tried 0.45 and then went to 0.43 to get just a bit more of a curve. By supplying less power the wheel doesn’t rotate as fast and therefore the robot turns in that direction.

Test various power levels and amount of time until the robot curves towards the corner and parks in tile F7.

7. Finally, we add a Sleep block just after the Put run blocks here comment. This will make the robot wait, but still leave us enough time to park in the backstage area. For testing you can temporarily disable this block since it’s annoying to have to wait 20 seconds for every test, just remember to enable it afterwards.

Here’s the completed Blocks program:

Here’s the program in action:

MyFirstAuto2 Red Front

Note: the video above does not include the 20 second delay.

Blue Front Starting Position

It turns out we can use this same program from the blue front starting location. One issue with our program is that our alliance partner robot might want to park in the corner tile of the backstage area. That is a natural place to park for most robots starting from the rear starting location. So it would be nice to have a program that also parks on the other side of the backdrop.

We can use the same program and a similar setup from the blue starting position A2. The left rear corner of the robot needs to touch the wall and we angle slightly to avoid the truss leg against the wall. The robot will drive in a curve, but NOT into the blue corner. Instead it should park in tile C6. The robot probably won’t be entirely in tile C6, but the pixels should be in and probably half the robot. You just need to break the vertical outside edge of the backstage taped lines to be considered “in” the backstage area.

Note: the alignment of the robot in the blue starting position is a little more tricky, we need to avoid both the front and rear truss legs around tile A3, and we hope we don’t hit the backdrop in tile B6. As you can see in the video, the robot comes pretty close. You may find you want to reduce the amount of curve to make starting in the blue position a bit easier.

MyFirstAuto2 Blue Front

Note: most of the 20 second delay was removed from the video above.

Now we can redraw our diagram for our MyFirstAuto2 program to indicate that we can use it from the red side or the blue side and show where it ends up in either case.

MyFirstAuto3

We should add one more program which we could call MyFirstAuto3. Our next program should be a copy of this program, but we swap the power on the long movement so that the left wheel has less power and the robot curves to the left.

MyFirstAuto3 program would drive into the blue corner tile A6 from the front blue starting position. It would also drive onto tile D3 from the front red starting position.

We’ll leave the MyFirstAuto3 program as an exercise for the reader.

MyFirstAuto2 and MyFirstAuto3 together allow you to start from both front starting positions and park in four different backstage locations. Together with MyFirstAuto1 you now have a complete set of autonomous programs for a simple robot.


Next Steps

Vision processing would let your robot score many more points in autonomous. For example, if the robot can reliably place the purple pixel on the randomized target spike mark AND park backstage you can earn 15 points. Check out our tutorial page on creating a TensorFlow autonomous program.

But first you might want to check out our page on driving the robot using motor encoders. Time-based movement can vary depending on the voltage level of the robot’s battery, it drives less distance as the battery drains. We’ll want accurate driving in order to place a pixel on the spike marks.

Getting Help

It is often possible to use Google (or other search engine) to get help or solve problems. There are lots of resources online. If you’re still stuck you can ask for help here.