Can chassis controller work with more than 2 motors?

https://pros.cs.purdue.edu/v5/okapi/tutorials/walkthrough/autonomous-movement-basic.html

Is there a way to set more than 1 port for each?

const int DRIVE_MOTOR_LEFT = 1;
const int DRIVE_MOTOR_RIGHT = 2;

Use motor groups.

Like okapi::MotorGroup leftBase (1, 2);

auto chassis = ChassisControllerFactory::create(
DRIVE_MOTOR_LEFT, DRIVE_MOTOR_RIGHT,

so this becomes this:

auto chassis = ChassisControllerFactory::create(
leftBase, rightbase,

How does it know what is left and right?

Here is the example for two motors driving each side of the chassis(link to page).
It’s hard to find b/c it is under motion profiling.

using namespace okapi;

auto myChassis = ChassisControllerFactory::create(
  {-1, -2}, // Left motors
  {3, 4},   // Right motors
  AbstractMotor::gearset::red, // Torque gearset
  {4_in, 12.5_in} // 4 inch wheels, 12.5 inch wheelbase width
);

BTW, I haven’t tried it this code.

Also if you are using okapi for drive you should also use it for the joysticks.

    myChassis.tank(joy1.getAnalog(ControllerAnalog::leftY),
                  joy1.getAnalog(ControllerAnalog::rightY),
                  CHASSIS_THRESHOLD);

It looks similar to PROS functions but return a value of -1 to 1 which is what tank uses.

1 Like

could u just make 2 chasis , one for front, one for back

That’s not a good idea for a variety of reasons, especially when you could just use one and motor groups.