Pedro Pathing 1.1.0 has released! If you haven't already, migrate now.
Pedro Pathing LogoPedro Pathing

OTOS

A localizer that uses the SparkFun Optical Tracking Odometry Sensor

Prerequisites

Ensure that the OTOS is properly mounted and connected, and the yellow kapton tape has been pulled off the sensor. The OTOS should be connected to a REV Hub through an I2C cable (not to port 0 beacuse the IMU is there).

Default Values

In Constants.java, add an instance of OTOSConstants. Make sure to replace the pinpoint hardware map name with the actual name. If you are using the quickstart, this instance should already be there.

Constants.java
public static OTOSConstants localizerConstants = new OTOSConstants()
            .hardwareMapName("otos")
            .linearUnit(DistanceUnit.INCH)
            .angleUnit(AngleUnit.RADIANS)
            .offset(new SparkFunOTOS.Pose2D(0, 0, Math.PI / 2))
            .linearScalar(1.0)
            .angularScalar(1.0);

Then, add .OTOSLocalizer to createFollower:

Constants.java
return new FollowerBuilder(followerConstants, hardwareMap)
    .OTOSLocalizer(localizerConstants)
    /* other builder steps */
    .build();

Offsets

You must define the sensors position relative to the center of the robot. Measure the X and Y coordinates, and then change the value of .offset(). If you want to change the units of measure for linear and/orangular, you can change .linearUnit() and .angleUnit(). The default is inches and radians

REMEMBER: Left/right is the y axis and forward/backward is the x axis, with left being positive y and forward being positive x. PI/2 radians is facing forward, and clockwise rotation is negative rotation.

Tip

It is recommended that you run these tests multiple times and average the results, as it can result in more accurate localization.

Forward Tuner

We will now adjust multipliers that convert encoder ticks into real-world measurements: inches. This ensures your localizer's readings are accurate.

Since the OTOS has only one linear scalar. You can run either Forward or Lateral Tuner, as they will result in very similar values.

Option 1

In the tuning OpMode, under localization, select and start the forward tuner. Then, push the robot forward 48 inches (exactly 2 field tiles). This distance is configurable if needed. Once you push the robot forward, two numbers will be displayed on telemetry:

  • The distance the robot thinks it has traveled
  • The linear scalar; this is the number you want.

Add the linear scalar to your OTOSConstants (or modify the value in the quickstart) by doing the following.

Constants.java
.linearScalar(multiplier)

Option 2

In the tuning OpMode, under localization, select and start the lateral tuner. Then, push the robot left 48 inches (exactly 2 field tiles). This distance is configurable if needed. Once you push the robot forward, two numbers will be displayed on telemetry:

  • The distance the robot thinks it has traveled
  • The linear scalar; this is the number you want.

Add the linear scalar to your OTOSConstants (or modify the value in the quickstart) by doing the following.

Constants.java
.linearScalar(multiplier)

Turn Tuner

The turn tuner is similar to both the forward tuner and lateral tuner, except it is rotational. Place the robot so it aligns to a fixed reference point (eg. edge of a field tile). In the tuning OpMode, under localization, select and start the lateral tuner. Rotate the robot counterclockwise 48 inches (exactly 2 field tiles). Note that the distance is in radians rather than degrees.

Add the angular scalar to your OTOSConstants (or modify the value in the quickstart) by doing the following.

Constants.java
.angularScalar(multiplier)

Testing the localizer

Once you have completed the tuning steps, you can test your localizer as described on the localization page.

Congratulations on successfully tuning your localizer!

Troubleshooting

If you have any problems, see the (troubleshooting page)[/docs/pathing/tuning/troubleshooting].

Last updated on