How to code 6 motor drive base with inertia sensor?

Im not sure if I tagged it right but I think its ok. Anyway we are having trouble with this and was wondering if there would be a certain code to do this. Thanks for any help at all. :slight_smile:

Here is some boilerplate code to get you started.

// Left Motors and motor group
motor leftMotorA = motor(PORT1, ratio18_1, false);
motor leftMotorB = motor(PORT2, ratio18_1, false);
motor leftMotorC = motor(PORT3, ratio18_1, false);
motor_group LeftDriveGroup = motor_group(leftMotorA, leftMotorB, leftMotorC);

// Right Motors and motor group
motor rightMotorA = motor(PORT11, ratio18_1, true);
motor rightMotorB = motor(PORT12, ratio18_1, true);
motor rightMotorC = motor(PORT13, ratio18_1, true);
motor_group RightDriveGroup = motor_group(rightMotorA, rightMotorB, rightMotorC);

// Drivetrain control
distanceUnits units = distanceUnits::in;  //Imperial measurements - inches.
double wheelTravel = 4 * M_PI;  //Circumference of the drive wheels (4" x PI)
double trackWidth = 18;         //Distance between the left and right center of wheel. 
double wheelBase = 15;          //Distince between the center of the front and back axle. 
double gearRatio = 1;           //Ratio of motor rotations to wheel rotations if using gears.


//Drivetrain code if using an Inertial Sensor
inertial DrivetrainInertial = inertial(PORT21);
smartdrive robotDrive = smartdrive(LeftDriveGroup, RightDriveGroup, DrivetrainInertial, wheelTravel, gearRatio);

//Use the following Drivetrain code if NOT using an Inertial Sensor
//drivetrain robotDrive(LeftDriveGroup, RightDriveGroup, wheelTravel, trackWidth, wheelBase, distanceUnits::in );
3 Likes