@rbenasutti I just started setting up my code for programming autons. I’ve used this code in passed years just fine. The problem is after I setup the chassis controller the robot doesn’t drive or turn the right distances. I’ve tried several things but nothing seams to get better just different. I’ve attached my code and robot specs below and would like it if you’d read it and tell me if you see anything wrong with it.
Robot specs.
My chassis is built using 4 motor V5 motors with green cartridges in them. I’m using 4in omni wheels. two of them are direct drive and the other two are chain driven but they don’t have a ratio on them.
Chassis dimensions from center of wheel to center of wheel:
- 7.5in long
- 11.75in wide
Software Versions
VexOS 1.0.12
Kernel 3.3.1 pros-mainline
Okapilib 4.0.5 pros-mainline
Chassis declaration.
Motor frontLeftMotor(7, false, AbstractMotor::gearset::green, AbstractMotor::encoderUnits::degrees);
Motor backLeftMotor(8, false, AbstractMotor::gearset::green, AbstractMotor::encoderUnits::degrees);
Motor frontRightMotor(4, true, AbstractMotor::gearset::green, AbstractMotor::encoderUnits::degrees);
Motor backRightMotor(6, true, AbstractMotor::gearset::green, AbstractMotor::encoderUnits::degrees);
std::shared_ptr<OdomChassisController> chassis = ChassisControllerBuilder()
.withMotors(frontLeftMotor, frontRightMotor, backRightMotor, backLeftMotor)
.withMaxVelocity(70)
.withSensors(
ADIEncoder{'C', 'D'}, // Left encoder in ADI ports A & B
ADIEncoder{'A', 'B'} // Right encoder in ADI ports C & D (reversed)
)
.withGains(
{0.0025, 0, 0}, // Distance controller gains
{0.002, 0, 0}, // Turn controller gains
{0.002, 0, 0.00006} // Angle controller gains (helps drive straight)
)
.withDimensions(AbstractMotor::gearset::green, {{4_in, 12_in}, imev5GreenTPR})
.withOdometry({{4_in, 5.5_in}, quadEncoderTPR}, StateMode::FRAME_TRANSFORMATION) // use the same scales as the chassis (above)
.buildOdometry(); // build an odometry chassis
Auton Code.
chassis->moveDistance(4_ft);
chassis->turnAngle(-90_deg);
chassis->moveDistance(2_ft);
chassis->turnAngle(90_deg);
chassis->moveDistance(2_ft);
OutTake.moveVelocity(600);