Setting Up Your OTOS Localizer
Prerequisites
- Ensure the OTOS sensor is connected to an I2C port on your control hub.
- Verify the protective film on the sensor is removed before use.
Default Values
These are the default values of the OTOSConstants. You can copy and paste this into your static{}
block within LConstants
:
OTOSConstants.useCorrectedOTOSClass = false;
OTOSConstants.hardwareMapName = "sensor_otos";
OTOSConstants.linearUnit = DistanceUnit.INCH;
OTOSConstants.angleUnit = AngleUnit.RADIANS;
OTOSConstants.offset = new SparkFunOTOS.Pose2D(0, 0, Math.PI / 2);
OTOSConstants.linearScalar = 1.0;
OTOSConstants.angularScalar = 1.0;
Steps
1. Setup
- Open the file
LConstants
and navigate to yourstatic{}
block. - Ensure the OTOS sensor is connected to an I2C port on your control hub (not port 0, which is reserved for the built-in imu).
- If you are using the corrected OTOS class, set
OTOSConstants.useCorrectedOTOSClass
totrue
. - If you are using the original OTOS class, set
OTOSConstants.useCorrectedOTOSClass
tofalse
. - Make sure that the I2C port that you are using is the same class as the one you are using, determined by above.
- If you are using the corrected OTOS class, set
- Modify or add your hardware map name for the OTOS sensor:
- Add the port name connected to your OTOS sensor by changing the value of
OTOSConstants.hardwareMapName
. - The default value is
"sensor_otos"
.
- Add the port name connected to your OTOS sensor by changing the value of
- Define the sensor's position relative to the center of the robot:
- Measure the X, Y coordinates (in inches) and then change the value of
OTOSConstants.offset
. -
- The default value is
new SparkFunOTOS.Pose2D(0, 0, Math.PI / 2)
.
- The default value is
- 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.
- Measure the X, Y coordinates (in inches) and then change the value of
- If you want to change the units for your linear and angular measurements, you can do so by changing
OTOSConstants.linearUnit
andOTOSConstants.angleUnit
in thestatic{}
block ofLConstants
.- The default linear unit is
DistanceUnit.INCH
and the default angle unit isAngleUnit.RADIANS
.
- The default linear unit is
2. Localizer Tuning
a) Linear Scalar (Forward or Lateral Tuning)
Since OTOS has only one linear scalar, you can run either Forward or Lateral Localizer Tuner. The result should be very similar, but not the same as there will be very small, negligible differences.
Option 1: Forward Tuning
- Align a ruler alongside your robot.
- Push the robot forward by the default distance (48 inches) or a custom set value.
- Observe the tuner outputs:
- First number: The distance the robot estimates it has moved.
- Second number: The linear scalar to update.
Option 2: Lateral Tuning
-
Align a ruler alongside your robot.
-
Push the robot 48 inches laterally to the right (default distance) or a custom set value.
-
Observe the tuner outputs:
- First number: The distance the robot estimates it has moved.
- Second number: The linear scalar to update.
-
Add the linear scalar value in
LConstants
in the static block:- On a new line, add (or modify if using the quickstart)
OTOSConstants.linearScalar = [LINEARSCALAR]
, where [LINEARSCALAR] is the outputted value. - By replacing in
- On a new line, add (or modify if using the quickstart)
-
(Optional): Run multiple tests and average the scalars for better accuracy.
b) Angular Scalar (Turn Tuning)
- Place your robot, so it faces a fixed, recognizable reference point (e.g., aligning an edge with a field tile).
- Run the Turn Localizer Tuner:
- By default, rotate the robot counterclockwise one full rotation.
- Alternatively, you can set a custom angle in the tuner.
- After the rotation:
- First number: The distance the robot estimates it as rotated.
- Second number: The angular scalar you need to input.
- Replace the angular scalar value in
OTOSLocalizer.java
(line 78) with the new scalar:- Ensure you replace the value, not add to or multiply the existing one.
- (Optional): Run multiple tests to average the scalars for improved accuracy.
Testing Your Localizer
After completing the tuning steps, you can test your localizer's accuracy.
-
Go to
Localization Test
and drive your robot around. -
Open the FTC Dashboard at http://192.168.43.1:8080/dash.
-
Switch the view to "field view" from the top right corner dropdown.
-
The dashboard should display the robot's position on the field.
-
Observe the movements, moving the robot forward should make
x
increase and strafing left should makey
increase.
Congratulations!
You have successfully tuned your OTOS Localizer. If you encounter any issues, revisit the steps above or reach out for support.