My odometry is pretty accurate when I have two tracking wheels. However, when I add in the middle one it becomes much less accurate. I would like to have this third tracking wheel for accuracy, but if I can’t have it so be it. I made sure that my measurements for the third wheel were accurate and they are. Here’s my code.
#include "main.h"
using namespace okapi;
Motor frontLeftMotor(1, false, AbstractMotor::gearset::green, AbstractMotor::encoderUnits::degrees);
Motor frontRightMotor(2, true, AbstractMotor::gearset::green, AbstractMotor::encoderUnits::degrees);
Motor backRightMotor(3, true, AbstractMotor::gearset::green, AbstractMotor::encoderUnits::degrees);
Motor backLeftMotor(4, false, AbstractMotor::gearset::green, AbstractMotor::encoderUnits::degrees);
ADIEncoder leftEncoder('A', 'B', true);
ADIEncoder rightEncoder('C', 'D');
ADIEncoder middleEncoder('E', 'F', true);
pros::Imu Inertial(5);
std::shared_ptr<OdomChassisController> chassis = ChassisControllerBuilder()
.withMotors(frontLeftMotor, frontRightMotor, backRightMotor, backLeftMotor)
.withMaxVelocity(150)
.withSensors(leftEncoder, rightEncoder, middleEncoder)
.withGains(
{0.0035, 0, 0}, // Distance controller gains
{0.006, 0, 0}, // Turn controller gains
{0.002, 0, 0.00006} // Angle controller gains (helps drive straight)
)
.withDimensions(AbstractMotor::gearset::green, {{2.75_in, 10_in, 3_in, 2.75_in}, quadEncoderTPR})//gearset, diameter, track, ticks
.withOdometry()
.buildOdometry(); // build an odometry chassis
std::shared_ptr<okapi::XDriveModel> driveTrain = std::dynamic_pointer_cast<XDriveModel>(chassis->getModel());
Controller master;
void initialize() {//runs when program starts
pros::lcd::initialize();
}
void disabled() {
chassis->moveDistance(0_in);
}//runs when disabled
void competition_initialize() {}//after initialize before auton
void autonomous() {//after start comp
chassis->setState({0_in, 0_in, 0_deg});
chassis->driveToPoint({1_ft, 1_ft});
chassis->turnToPoint({0_ft, 0_ft});
chassis->driveToPoint({0_ft, 0_ft});
chassis->turnToAngle(0_deg);
}
void opcontrol() {//after auton
chassis->moveDistance(0_in);
driveTrain->setBrakeMode(AbstractMotor::brakeMode::coast);
while (true) {
driveTrain->xArcade(master.getAnalog(ControllerAnalog::leftX),
master.getAnalog(ControllerAnalog::leftY),
master.getAnalog(ControllerAnalog::rightX),
0.3);
pros::delay(20);
}
}