OkapiLib Mecanum Drive using XDriveModel

I am using OkapiLib in pros and am trying to get a mecanum drive working. I have been doing lots of research on vexforum and used the OkapiLib API and created this code. It has no errors, but when I run it the robot doesn’t move. Any thoughts or help would be appreciated.

void opcontrol() {
	Motor frontLeftMotor(1, false, AbstractMotor::gearset::green, AbstractMotor::encoderUnits::invalid);
	Motor frontRightMotor(2, true, AbstractMotor::gearset::green, AbstractMotor::encoderUnits::invalid);
	Motor backRightMotor(3, true, AbstractMotor::gearset::green, AbstractMotor::encoderUnits::invalid);
	Motor backLeftMotor(4, false, AbstractMotor::gearset::green, AbstractMotor::encoderUnits::invalid);

	ADIEncoder leftEncoder('A', 'B');
	ADIEncoder rightEncoder('C', 'D');
	ADIEncoder middleEncoder('E', 'F');

	auto chassis = ChassisControllerBuilder()
		.withMotors(frontLeftMotor, frontRightMotor, backRightMotor, backLeftMotor)
  	.withDimensions(AbstractMotor::gearset::green, {{4_in, 11.5_in}, imev5GreenTPR})
		.withSensors(leftEncoder, rightEncoder, middleEncoder)
  	.build();

	auto xModel = std::dynamic_pointer_cast<ThreeEncoderXDriveModel>(chassis->getModel());

	Controller controller (ControllerId::master);

	while (true) {
  	xModel->xArcade(
		controller.getAnalog(ControllerAnalog::leftY),
		controller.getAnalog(ControllerAnalog::leftX),
		controller.getAnalog(ControllerAnalog::rightX));

    pros::delay(20);
	}
}

This is my teams implementation of this. It also has field centric driving using the inertial sensor. Whats the invalid in the motor encoder Units about?

4 Likes

Thank you so much for the code, it worked! The invalid value was from a member of my team that’s NOT a coder.