Drivetrain or individual motors?

New team/coach here. We’re almost ready to start programming driver control (using block-based Vexcode) and are trying to decide whether we should add a drivetrain device or add and program individual motors. What are the pros and cons of each approach?
With individual motors, I think we’d be able to set them up for tank drive or for arcade drive, depending on my drivers’ preference. Do you get the same flexibility with a drivetrain, or does it come hard-coded for tank drive?
My guess is a drivetrain would be better suited for programming skills matches. Your thoughts?

Using VEXCode and the controller configuration, you can configure it for tank or arcade.

Here’s the relevant KB article

Oh, got it, is this how you’d do it?

What do more experienced teams do? Do they go with a drivetrain device and configure their controller? Or do they program individual motors to achieve the same result?

Even for my experienced teams, they’ll stick with ease of use and use the graphical configuration.

My very very experienced teams have drivetrains that don’t necessarily fit the use cases serviced by this tool.

Using the Drivetrain device configuration also allows easy control in autonomous as well.

2 Likes

I’m using PROS with Okapilib not Vexcode, but I use the built-in Okapilib drivetrain object.

edit, continued (left halfway bc switching classes):
So, unless you have a specific bug or know exactly what features you’re going to add, don’t create a new one just for the sake of making a new one. (except for learning purposes, but not competitively)

Being new to programming with VEX block code, I’ve come across the same problem many times in the past year. I still haven’t figured out how to program the joysticks for anything other than the drivetrain. Just this morning actually, this problem came up again when I tried to change my program due to a motor being outside the drive chain. My problem was that the two motors opposed each other and tried to rip the chain apart, so I tried to program one motor to turn backwards but found no way of doing that.
Here is a quick sketch of my drivetrain if you care to understand:
image
Upon seeing this mess of an image I should probably rethink the drive, but for learning’s sake, does anyone know of a fix to the opposing motor problem, and also to my joystick programming problem?

And to answer the original thread question - I’ve gotten this far with only using the drivetrain feature, so it’s definitely doable if you don’t over complicate things like I’m trying to do here.

You should be able to reverse one of the motors when you set the drivetrain up.

Blocks programming hits the 80 / 20 rule where 80% of the programs can be created using the basic blocks applications and 20% fall outside if its capabilities.

  • The easiest way would be to adjust your physical drive chain path so that both motors turn the same direction.

  • Next option would be to remove the drivetrain and manually program your chassis control with motor groups. The negative being that you lose the features of the Drivetrain (IE: The inertial sensor in autonomous).
    image

  • Finally you can switch to VEXcode Pro and customize your own Drivetrain. The example below is code for a six motor drivetrain with an inertial sensor. Drivetrains in code can take advantage of motor groups. Perhaps that is a feature Vex can add to blocks in the future. This gives you the options that you need but can be more difficult to create and maintain.

//Hudsonville Robotics - 6 motor Drivetrain

brain  Brain;
controller Controller1 = controller(primary);

// 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 );


void DriverControl() {
    int leftSpeed;
    int rightSpeed;
    LeftDriveGroup.spin(forward);
    RightDriveGroup.spin(forward);

    while (true) {
        wait(20, msec);

        //Arcade control
        leftSpeed  = Controller1.Axis3.position() + Controller1.Axis4.position();
        rightSpeed = Controller1.Axis3.position() - Controller1.Axis4.position();

        LeftDriveGroup.setVelocity(leftSpeed, percent);
        RightDriveGroup.setVelocity(rightSpeed, percent);
    }
} 

void Autonomous() {
    //Be sure to Initialize if you are using a Inertial sensor.
    Drivetrain.setTimeout(5, timeUnits::sec);
    Drivetrain.setDriveVelocity(50, velocityUnits::pct);
    Drivetrain.setTurnVelocity(50, velocityUnits::pct);
    Drivetrain.setStopping(brakeType::brake);  //coast, hold

    //Begin movements 
    Drivetrain.driveFor(24, distanceUnits::in, true); //Drive forward for 24 inches
    Drivetrain.turnFor(45, rotationUnits::deg, true);  //Turn 45 degrees (right).

}
3 Likes

THANK YOU SO MUCH
I have had this issue for so long, you don’t know how great if feels to finally have the solution to a programming problem after a YEAR!
The vex forum is a great tool! :smiley:

2 Likes

I’ve just been using sublime or VSCode to open robot-config.cpp and then setting the motor I want to be reversed as reversed. I use a different text editor because I can’t edit robot-config.cpp in VEXcode Pro because the file is locked and to unlock it you have to surrender the right to using the GUI tools.

That’s pretty far over my head, but thank you. I’ll bookmark your reply and come back to it later this year when a teammate and I move on to VEXcode Pro. :slight_smile: