When using PROS okapilib’s built in 3-wheel odometry chassis controller, calling a turnAngle function produces a turn approximately half the rotation specified. I don’t think that the controller is even really using the tracking wheels for turning properly anyway so any help with the code would be appreciated. The drive is geared 60:36 on 3.25" omnis. For example, the following code is set to turn -135 degrees during the program but actually turns about 90 degrees. Some parts such as the 2d motion profiling controller are commented out. Sorry about the rushed post.
#include "main.h"
#include "okapi/api.hpp"
using namespace okapi;
std::shared_ptr<OdomChassisController> chassis = ChassisControllerBuilder()
.withMotors(1, -4, 3, -2)
.withDimensions(AbstractMotor::gearset::green, {{4_in, 212_mm}, 665})
.withSensors
(
ADIEncoder{'A', 'B'},
ADIEncoder{'E', 'F', true},
ADIEncoder{'C', 'D'}
)
.withOdometry({{2.75_in, 212_mm, 214_mm, 2.75_in}, quadEncoderTPR})
.buildOdometry();
void initialize() {}
void disabled() {}
void competition_initialize() {}
void autonomous()
{
chassis->setState({0_in, 0_in, 0_deg});
pros::Motor br (7, pros::E_MOTOR_GEARSET_06, true);
pros::Motor tr (9, pros::E_MOTOR_GEARSET_06, false);
pros::Motor il (11, pros::E_MOTOR_GEARSET_06, false);
pros::Motor ir (12, pros::E_MOTOR_GEARSET_06, true);
pros::Optical bo (19);
pros::Optical to (18);
/*
auto profile1 = AsyncMotionProfileControllerBuilder()
.withLimits({1.00, 1.00, 5.00})
.withOutput(chassis)
.buildMotionProfileController();
profile1->generatePath({
{0_ft, 0_ft, 0_deg},
{3_ft, 0_ft, 0_deg}},
"A");*/
int timeout = 0;
tr.move(127);
il.move(127);
ir.move(127);
chassis->setMaxVelocity(100);
chassis->moveDistance(23_in);
tr.move(0);
br.move(127);
pros::delay(200);
br.move(0);
chassis->turnAngle(-135_deg);
il.move(0);
ir.move(0);
chassis->moveDistance(24_in);
//chassis->waitUntilSettled();
il.move(127);
ir.move(127);
tr.move(127);
br.move(127);
for (int i = 0; i < 2; i++)
{
timeout = pros::millis() + 1500;
while ((to.get_hue() < 80 || to.get_proximity() < 180) && (pros::millis() < timeout))
{
pros::delay(10);
}
tr.move(-127);
timeout = pros::millis() + 1500;
while ((to.get_hue() > 120 && to.get_proximity() > 180) && (pros::millis() < timeout))
{
pros::delay(10);
}
}
il.move(0);
ir.move(0);
tr.move(0);
br.move(0);
}
void opcontrol()
{
pros::Motor lf (1, pros::E_MOTOR_GEARSET_18, false);
pros::Motor lb (2, pros::E_MOTOR_GEARSET_18, true);
pros::Motor rb (3, pros::E_MOTOR_GEARSET_18, false);
pros::Motor rf (4, pros::E_MOTOR_GEARSET_18, true);
pros::Motor br (7, pros::E_MOTOR_GEARSET_06, true);
pros::Motor tr (9, pros::E_MOTOR_GEARSET_06, false);
pros::Motor il (11, pros::E_MOTOR_GEARSET_06, false);
pros::Motor ir (12, pros::E_MOTOR_GEARSET_06, true);
pros::Optical bo (19);
pros::Optical to (18);
lf.set_brake_mode(pros::E_MOTOR_BRAKE_COAST);
lb.set_brake_mode(pros::E_MOTOR_BRAKE_COAST);
rf.set_brake_mode(pros::E_MOTOR_BRAKE_COAST);
rb.set_brake_mode(pros::E_MOTOR_BRAKE_COAST);
pros::Controller master (pros::E_CONTROLLER_MASTER);
int stick_thresh = 5;
tr.move(127);
pros::delay(250);
tr.move(0);
while (true)
{
if (abs(master.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y)) > stick_thresh)
{
lf = (master.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y));
lb = (master.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y));
}
else
{
lf = 0;
lb = 0;
}
if (abs(master.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y)) > stick_thresh)
{
rf = (master.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y));
rb = (master.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y));
}
else
{
rf = 0;
rb = 0;
}
if (master.get_digital(pros::E_CONTROLLER_DIGITAL_R1) == 1)
{
il = 127;
ir = 127;
}
else if (master.get_digital(pros::E_CONTROLLER_DIGITAL_B) == 1)
{
il = -127;
ir = -127;
}
else
{
il = 0;
ir = 0;
}
if (master.get_digital(pros::E_CONTROLLER_DIGITAL_L1) == 1)
{
tr = 127;
br = 127;
}
else if (master.get_digital(pros::E_CONTROLLER_DIGITAL_L2) == 1)
{
tr = -127;
}
else if (master.get_digital(pros::E_CONTROLLER_DIGITAL_R2) == 1)
{
if (bo.get_proximity() > 150 || to.get_proximity() > 150)
{
tr = 30;
br = 50;
}
else
{
//tr = -50;
}
}
else
{
tr = 0;
}
if (master.get_digital(pros::E_CONTROLLER_DIGITAL_R2) == 1 || master.get_digital(pros::E_CONTROLLER_DIGITAL_L2) == 1)
{
br = 127;
}
else
{
br = 0;
}
if (to.get_hue() > 120 && to.get_proximity() > 180)
{
tr = -127;
br = 127;
pros::delay(50);
}
pros::lcd::set_text(0, std::to_string(to.get_hue()));
pros::lcd::set_text(1, std::to_string(to.get_proximity()));
pros::delay(10);
}
}