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)
.withGains(
{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
.buildOdometry();
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.
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).