Okapi: Not Expected Outcome

Hello! I am trying to use Okapi this year and I am stuck on what I need to do to fix my program. It is suppose to move forward 1 foot and it does this:
Demo video
This is my code:

void autonomous() {
	std::shared_ptr<OdomChassisController> chassis =
	    .withMotors(20, -15, -1, 8) // left motor is 1, right motor is 2 (reversed)
	        {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)
	        ADIEncoder{'A', 'B'}, // left encoder in ADI ports A & B
	        ADIEncoder{'C', 'D',true}  // right encoder in ADI ports C & D (reversed)
	    // green gearset, tracking wheel diameter (2.75 in), track (7 in), and TPR (360)
	    // 1 inch middle encoder distance, and 2.75 inch middle wheel diameter
	    .withDimensions(AbstractMotor::gearset::green, {{2.75_in, 14_in}, quadEncoderTPR})
	    .withOdometry() // use the same scales as the chassis (above)
	    .buildOdometry(); // build an odometry chassis

			chassis->setState({0_in, 0_in, 0_deg});

It is a x-drive, any ideas?

I got it to drive straight, I had the wrong encoder reversed…

Now it is not stopping when it goes forward

First step to solve the configuration problem (which it is) is to just print the encoder values to see that they are reversed properly.

Now it is not stopping when it goes forward

This sounds like it is caused because now the encoders are reversed improperly, so the further the robot tries to drive forward the more it thinks it is driving in the wrong direction.

After you have established that your encoders are correct, the next step is to use chassis->forward and chassis->turn to confirm that your motor configuration is correct. Test them out separately one at a time. You can also use chassis->arcade with a joystick for this step.

There might also be a problem with your PID gains (the angle gain is way too high and the distance too low) which might be causing this.


Okay, so I found out that the Gains is what is giving me the problem. I know that because when I take them out the problem went away. When I do arcade it works very well. How should I re-add the gains in, or do I even need them? Thanks!

So, what actually happens is that when you take out the gains, you switch from a CCPID controller (Chassis Controller PID) to a CCI controller (Chassis Controller Integrated), which actually executes the movements completely differently. Without gains and a CCI, your external encoders are not used for moveDistance or any other movement function, the only thing your encoders are used for is knowing where you are for odometry. You also need to adjust your dimensions as per the tutorial.

If you do want to use your external encoders for movements, you will need a CCPID instance, and therefore need gains.

Therefore, I am not sure if your problem comes from bad gains or something wrong with the sensors/configuration.


I think it is coming from bad gains, because when I put it in op control and make it arcade drive, it drives fine. I know what encoder is reversed due to printing out the value of them to the brain.

It stopped driving forever now, but it goes three times the distance that I put In, I think I know what it is, I will check back if it works or not. Thanks for the help!