Okapi odometry with rotation sensors not working

Hello. I am trying to use okapi’s odometry function with the new rotation sensor and when I turn the robot 90 deg manually, the odometry does not actually output a 90 deg turn. Here is the code I am using:

std::shared_ptr<OdomChassisController> chassis = ChassisControllerBuilder()
    .withMotors(leftDrive, rightDrive)
        {0.001, 0, 0.0001}, // Distance controller gains (note: not tuned yet)
        {0.001, 0.0, 0.0001}, // Turn controller gains
        {0.001, 0, 0}  // Angle controller gains (helps drive straight)
    .withDimensions({AbstractMotor::gearset::blue, 3.0/7.0}, {{4.125_in, 13.2_in}, imev5BlueTPR}) //13.2_in center to center distance
    .withSensors(LOdom, ROdom)
    .withOdometry({{2.8_in, 4.7_in}, quadEncoderTPR}, StateMode::CARTESIAN) //4.7_in center to center distance on tracking wheels

What am I doing wrong here?

I dont know if you can use te rotation sensor with the okapi´s odometry.

But i think that maybe is a good practice, if you try to program you own odometry program, with that you can learn more about odometry and custom your own algorithm with the things that you wanna do, for this case using the rotation sensor.

Here is a documentation that you can use, for develop your own program.
pilons-position-tracking.pdf (437.5 KB)

According to this post, you should be able to. My guess is that quadEncoderTPR has to be something different.

I have created my own odom algorithm in vexcode before, but I want to try okapi and see what it can do before recreating it pros.

1 Like

I’d make sure:

  1. Make sure the odometry gets straight line distance movements correct. This will validate that your tracking wheel diameter is correct
  2. Perform the robot pivot (ideally 360 or 720 degree turns) and adjust the wheel track distance so that what it reports matches observation

did anyone figure out how to do this? I understand how to add the rotation sensors as sensors in the chassis builder, but im not sure that the TPR (ticks per revolution) of the red optical shaft encoders would match up with the rotation sensor values… can someone please confirm this?

The TPR for the rotation sensors is 360 if you are using an okapi rotation sensor as the get() method returns the value in degrees. If you are using a pros rotation sensor, then it would be 36000, since the get_angle() method returns the value in centidegrees.
The TPR for an optical shaft encoder should be 360. The link provided is taken from the Okapi Github, so I would assume it is pretty reliable (also the fact that I have always used 360 as the TPR for the quad encoders).

1 Like