I am getting the exact same error that was mentioned in this thread. But I saw that he was not able to fix the issue. Both of my encoders are working as expected. I’m not sure what the issue is and any help would be greatly appreciated.
#include "subsystems/drivetrain.h"
#include "okapi/api/odometry/odomState.hpp"
#include "okapi/api/odometry/odometry.hpp"
#include "okapi/api/util/logging.hpp"
#include "okapi/api/util/mathUtil.hpp"
#include "okapi/impl/device/motor/motorGroup.hpp"
#include "pros/motors.h"
ADIEncoder leftEncoder = ADIEncoder ('A', 'B', true);
ADIEncoder rightEncoder = ADIEncoder ('C', 'D', true);
ADIEncoder middleEncoder('E', 'F');
Motor topLeft(1);
Motor bottomLeft(2);
Motor topRight(-5);
Motor bottomRight(-10);
MotorGroup leftDrive = MotorGroup({topLeft, topRight});
MotorGroup rightDrive = MotorGroup({bottomLeft, bottomRight});
auto chassis = ChassisControllerBuilder()
.withMotors(leftDrive, rightDrive)
// .withGains(
// {0.001, 0, 0.0001}, // distance controller gains
// {0.001, 0, 0.0001}, // turn controller gains
// {0.001, 0, 0.0001} // angle controller gains (helps drive straight)
// )
.withSensors(leftEncoder, rightEncoder)
.withLogger(defaultLogger)
.withDimensions(AbstractMotor::gearset::green, {{3.25_in, 8_in}, quadEncoderTPR})
.withOdometry() // use the same scales as the chassis (above)
.buildOdometry(); // build an odometry chassis
void drivetrain::dosomething() {
// set the state to zero
defaultLogger->info(chassis->getState());
chassis->setState({0_in, 0_in, 0_deg});
defaultLogger->info(chassis->getState());
chassis->driveToPoint({10_in, 10_in});
}
I had this same error (I switched to using RyanLib bc i couldn’t figure this out) but I think I got rid of the error by deleting the .withGains if I remember correctly.
That error is probably happening if you are running the terminal by being connected to the controller. It does not have enough bandwidth to print a message every 10 milliseconds. Try 50ms and the errors should go away.
It *should * fix the issue Ian is having. Sorry, I am not familiar with okapi so I’m not sure how to resolve the error. To answer your question about odometry, this PDF by Pilons explains the math and idea behind it very well. I would recommend reading it if you want to learn more about how it works.