Skip to content

Romi Robots

Caleb Fynewever edited this page Oct 2, 2023 · 2 revisions

Now that your feeling a little more comfortable with Java programming we are going to program our first robot! We are going to use Romi Robots, which are like mini FRC robots. They use the same code we run on our big robots so they are great for getting started with robots!

Assignment A: Running the sample project

  1. Go to docs.wpilib.org and follow the instructions to create a new project.
  2. Once you have set up your project, go to Run > Run without debugging to run your code.
  3. Connect a joystick to your computer (one of the silver and black 3-axis joysticks)
  4. When the robot simulator window opens up drag your joystick from "system joysticks" on the left over to Joysticks[0] in the middle like so:

image

Then switch the robot mode to "Teleoperated" in the top left. Your robot should be ready to drive!

Assignment B: Tank Drive

Our default Romi project uses "Arcade Drive", which means we control the robot using a single joystick.

An alternative method of controlling a robot is "Tank Drive", which uses two joysticks. In Tank Drive, each joystick's Y-axis controls one wheel. To go forward you push both joysticks forward. To turn right you push just the left joystick forward (or push the left joystick forward and pull the right joystick back to rotate in place).

In this lesson you will update your Romi to drive using Tank Drive instead of Arcade Drive.

  1. Open the DriveTrain class and create a new tankDrive() method. It will look similar to the arcadeDrive() method, but instead of an x-axis speed and a z-axis/rotation it will take a leftSpeed and rightSpeed.
  2. Create a new class called TankDrive. It should look similar to ArcadeDrive, but it should also take different variables and it will call our new tankDrive() method instead of arcadeDrive().
  3. Open RobotContainer and add a new method called getTankDriveCommand() that creates a new instance of TankDrive. This method will look similar to getArcadeDriveCommand().
  4. Update configureButtonBindings() to call getTankDriveCommand() instead of getArcadeDriveCommand().

Assignment C: Autonomous mode

This assignment is a little more free-form!

First, set up an obstacle course using whatever materials you have available.

Then create a new class called AutonomousObstacleCommand and follow the pattern from the existing AutonomousTime class to program your robot to get through the obstacle course. Note that AutonomousTime is a SequentialCommandGroup - it runs one or more commands in sequence (one after thee other), and then it is done.

The sample project comes with four commands that you can use to help:

  • DriveTime will drive for a fixed amount of time
  • DriveDistance will drive a specified distance
  • TurnTime will turn the robot for a fixed amount of time
  • TurnDegrees will turn the robot a specified number of degrees

Make sure to update the configureButtonBindings() method in RobotContainer to add your autonomous mode to the list of automonous modes on the dashboard.