Road Runner Getting Started - RobotGirls/FTC-Team-25 GitHub Wiki

Update Orientation of Control Hub on Robot

  • Specify the physical orientation of the Hub on the robot
  • If we are are using a mecanum drive train, we can update the control hub physical orientation on the hub in the following file: ~/Desktop/FIRST/25-FtcRobotController/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/MecanumDrive.java
    • In MecanumDrive.java, search for TODO and change the following UsbFacingDirection to BACKWARD if the usb ports are facing the back of the Robot
      • public RevHubOrientationOnRobot.UsbFacingDirection usbFacingDirection = RevHubOrientationOnRobot.UsbFacingDirection.FORWARD;
      • MecanumDrive-usbPortOrientation

Start Running Tuning Tests documented in Road Runner Tuning Guide - Section Drive Classes

* In MecanumDrive.java you can also look at line 240
  * Reference: [Road Runner V1 Tuning - see Drive Classes section](https://rr.brott.dev/docs/v1-0/tuning)
  *         localizer = new DriveLocalizer(); (CINDY: try with this first)
  * Since we are using 2 DEAD WHEELS, we should change it to 
  *         localizer = new TwoDeadWheelLocalizer(hardwareMap, lazyImu.get(), PARAMS.inPerTick)
  * The code expects the parallel, forward-pointing deadwheel encoder to be named "par" and the perpendicular one to be named "perp".  For more info about these dead wheels, see the documentation below.

Update right side of DRIVE_CLASS below if your drive train is not a mechanum drive train (e.g., if it is a TankDrive.class

  • ~/Desktop/FIRST/25-FtcRobotController/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tuning/TuningOpModes/MecanumDrive.java
  • public final class TuningOpModes { // TODO: change this to TankDrive.class if you're using tank public static final Class<?> DRIVE_CLASS = MecanumDrive.class;

Next connect the robot to the driver station

  • Make sure you configure the phone to specify the wheels (frontRight, backRight, fromtLeft, backLeft) and the imu which is on the hub (revhub and/or control hub)
    • MecanumDrive: The class assumes your four wheel motors are named "leftFront", "leftBack", "rightBack", and "rightFront" and your IMU is named "imu" (see NOTE below for motors whose encoder ports are used for deadwheels)
      • Reference: RoadRunner V1 Tuning - see Drive Classes section

      • IMPORTANT NOTE: According to documentation in Reference above,

        • If you choose to use dead wheels, drive encoders are not needed (i.e., you can unplug the encoder cables from the encoder ports associated with the motors connected to the wheels), and those encoder ports can be used to plug in the dead wheel encoders. You can change the names in TwoDeadWheelLocalizer to reflect the motor names of the slots the encoders were connected to.
        • Two (dead) wheel: Change the right-hand-side of localizer = to new TwoDeadWheelLocalizer(hardwareMap, lazyImu.get(), PARAMS.inPerTick). The code expects the parallel, forward-pointing encoder to be named "par" and the perpendicular one to be named "perp".
        • Note that, for technical reasons, ports 0 and 3 on REV hubs are more accurate at high speeds and should be used for the parallel dead wheels.
        • So, I unplugged the leftFront wheel motor encoder from the drive encoder port 0 and plugged in the encoder cable from the "perp" deadwheel and in the phone configuration, changed the leftFront motor name from "leftFront" to "perp" for the ControlHub port 0, rev ultraplanetary hex motor and also updated the name in the MecanumDrive.java file where the
          • leftFront = hardwareMap.get(DcMotorEx.class, "perp");
        • I also unplugged the rightBack wheel motor encoder from the drive encoder port 3 and plugged in the encoder cable from the "par" deadwheel and in the phone configuration, changed the rightBack motor name from "rightBack" to "par" for the ControlHub port 3, rev ultraplanetary hex motor and also updated the name in the MecanumDrive.java file
          • rightBack = hardwareMap.get(DcMotorEx.class, "par");
      • Robot configuration of the IMU is automatic, and shouldn’t need changes. But here’s how to confirm or rename your configured IMU.

        • Reference: Universal IMU Interface - see Configure Imu section
        • In a connected DS app, touch the 3-dots icon at top right, then touch Configure Robot. For any new or existing Configuration, touch Control Hub Portal, then select the Hub with the IMU you want to use. Typically this will be the Control Hub
          • The internal IMU is (always) connected at I2C Bus 0, Port 0. (make sure you name it "imu")
          • The default IMU type shown will reflect the actual unit in this Hub; fix this only if it was incorrectly modified. Your IMU OpModes require a correct choice here.
            • If you don't know which type of IMU is in your control hub, do the following
              • connect your robot to your phone
              • set your laptop wifi to the robot direct wifi (e.g., TestRig4)
              • then for the phone go to the following URL: 192.168.43.1:8080
                • and go to the manage tab

Next connect adb

  • make sure your phone configuration has been set up correctly for the imu, wheel motors, and dead wheels to the correct ports and make sure that configuration is selected
    • Currently I am using 'swbot5218' on the phone marked "Main phone java"
  • make sure that your phone is connected to the robot
  • make sure your laptop is connected to the the direct wifi for your control hub
  • adb connect 192.168.43.1:5555
  • then push play to upload your Tuning opmodes to your robot

Then connect to Dashboard, to help you with your tuning

Next Check that all the Motors spin in the right direciton

  • Reference: Road Runner V1 Tuning - see Drive Classes Section
  • Check that the motors spin in the right direction.
    • Positive power on all wheels should move the robot forward.
    • And if you’re using drive encoders, the ticks recorded should increase in a positive direction.
    • Once you have made all the changes to MecanumDrive.java and TuningOpMode.java as specified above
    • Then in Android Studio, do a build (click on the hammer icon) and make sure it builds successfully
    • If the build is successful, then connect to adb as described above
    • Then push the tuning opmodes to the Robot

Test that you have configured your Mecanum Wheels to go in the right direction.

  • Reference: Road Runner V1 Tuning - see Drive Classes Section
  • On your driver station phone, click on the Teleop Opmodes and select MecanumMotorDirectionDebugger
  • Don't forget to connect the gamepad to your phone
  • Now if you tilt your gamepad 45 degrees to the right, you will see the gamepad buttons align with the wheels (i.e., Y is frontRight, B is backRight; X is frontLeft, A is backLeft
  • Make sure that all the wheels are going forward. If not, just go to MecanumDrive.java and search for REVERSE and set the wheels that need to be reversed.
    • // TODO: reverse motor directions if needed
      //   leftFront.setDirection(DcMotorSimple.Direction.REVERSE);
      rightFront.setDirection(DcMotorSimple.Direction.REVERSE);
      rightBack.setDirection(DcMotorSimple.Direction.REVERSE);
      

Test that you have configured your dead wheels Wheels to go in the right direction.

  • Reference: Road Runner V1 Tuning - see Drive Classes Section
  • On your driver station phone, click on the Teleop Opmodes and select DeadWheelDirectionDebugger
  • then move the dead wheels to make sure that the encoders are increasing appropriately.
  • IMPORTANT: Note that the dead wheel telemetry may not be visible on the driver station phone display because you have to scroll down to see it, so make sure you swipe up so you can see the encoder values for the dead wheels.
  • If the deadwheel encoder values are increasing in the reverse direction when you spin the dead wheels, then reverse their direction in only ONE of TWO possible places, MecanumDrive.java or TwoDeadWheelLocalizer.java :
    • DriverLocalizer() in MecanumDrive.java
      • NOTE: note that in the DriverLocalizer(), leftFront is getting the encoder (which has the deadwheel encoder cable plugged into the encoder port for the leftFront wheel motor)
      • leftFront = new OverflowEncoder(new RawEncoder(MecanumDrive.this.leftFront)); // TODO: reverse encoders if needed // leftFront.setDirection(DcMotorSimple.Direction.REVERSE);
    • TwoDeadWheelLocalizer() constructor in TwoDeadWheelLocalizer.java
      • par = new OverflowEncoder(new RawEncoder(hardwareMap.get(DcMotorEx.class, "par"))); perp = new OverflowEncoder(new RawEncoder(hardwareMap.get(DcMotorEx.class, "perp")));

        // TODO: reverse encoder directions if needed // par.setDirection(DcMotorSimple.Direction.REVERSE);

Start Running Tuning Tests documented in Road Runner Tuning Guide - Section Forward Push Test

  • On driver station phone, select ForwardPushTest from Teleop pull-down menu and follow directions from reference above in tuning guide

DC Motor Feed Forward

https://github.com/odacindy/wiki-images/blob/main/ultraplanetary-HD-hex-motor.png

  • note for the ultraplanetary HD hex motor, there are 28 ticks per revolution at the motor but then there is a 3:1 and 5:1 gear ratio (see side of the motor for the gear ratio) for a combined 15:1
    • Therefore, there are 2835 = 420 ticks per revolution
    • since the Encoder Counts per Revolution At the motor - 28 counts/revolution
  • HD hex motor
    • Free Speed: 6000 rpm
    • since the gear ratio is 15:1, then the rpm per revolution is 6000/15 = 400 RPM

Creating Drive Constant File

  • DriveConstants file creator. Click on "Configure Me"
  • https://github.com/odacindy/wiki-images/blob/main/DriveConstant-usingOwnDriveTrain.png
    • For the "Are you using your own drive train?" select "I'm using my own"
  • For the "What type of motors are you using?", select "Bare Motor". (Note that we were using ultraplanetary REV HD hex motor" with gear ration 15:1 (which is 3:1, 5:1 for a total of 15:1) see side of motor for gear ratios selected)
  • For "Gear Ratio (output:input)" put "15:1"
  • Wheel used is "96 millimeter mecanum" which has a wheel radius of 1.8898 inches
  • track wheel estimate is "14 inches"
  • Using drive encoders, mark as "no"

How to Get Parallel and Perpendicular X/Y positions of Your Deadwheels

  • Parallel/Perpendicular X/&
  • https://github.com/odacindy/wiki-images/blob/main/perpPar-xy-position-deadwheels.png
    • So, we find the center of rotation of the robot from the bottom. and then get the X,Y position of the deadwheels
    • public final class TwoDeadWheelLocalizer implements Localizer { public static class Params { public double parYTicks = 0.0; // y position of the parallel encoder (in tick units) public double perpXTicks = 0.0; // x position of the perpendicular encoder (in tick units) }
    • so you have to calculate the parYTicks and the perpXTicks w.r.t. to the center of rotation of the robot and doing the translation from inches to ticks.
      • how many inches to the left (+) or right (-) is the parallel dead wheel "par"
      • how many inches to the front (+) or the back (-) is the perpendicular dead wheel "perp"
      • NOTE: we had inPerTick. and lateralInPerTick. Elyse's notes on the tuning values
        • convert from parY inches to ticks using inPerTick
        • convert from perpX inches to ticks using lateralInPerTick

Troubleshooting

  • If you try to run Lateral Ramp Logger or Angular Ramp Logger and get a red Type Error
  • Then run the DeadWheel debugger, which will likely spit out that the firmware needs to be updated. Update it if necessary.
  • If that doesn't fix the issue, then get rid of the //sdcard/RoadRunner directory using adb since there could be old file timestamps (look at second from last comment in this issue https://github.com/acmerobotics/road-runner-quickstart/issues/345 indicating that there may be a time stamping issue, so remove the RoadRunner directory)

Useful Trajectory Links

image

Building a Trajectory Trajectories vs Paths Centerstage Autonomous Example# Assume we have already integrated RoadRunner into team-number-FtcRobotController