Ok, lets look at an example, this is very easy to test.
I created the following graphical configuration
One motor, one motor_group and a two motor drivetrain.
Lets look at (some of) the code it generates.
motor and motor_group code
// check the ButtonL1/ButtonL2 status to control MotorGroup1
if (Controller1.ButtonL1.pressing()) {
MotorGroup1.spin(forward);
Controller1LeftShoulderControlMotorsStopped = false;
} else if (Controller1.ButtonL2.pressing()) {
MotorGroup1.spin(reverse);
Controller1LeftShoulderControlMotorsStopped = false;
} else if (!Controller1LeftShoulderControlMotorsStopped) {
MotorGroup1.stop();
// set the toggle so that we don't constantly tell the motor to stop when the buttons are released
Controller1LeftShoulderControlMotorsStopped = true;
}
// check the ButtonR1/ButtonR2 status to control Motor3
if (Controller1.ButtonR1.pressing()) {
Motor3.spin(forward);
Controller1RightShoulderControlMotorsStopped = false;
} else if (Controller1.ButtonR2.pressing()) {
Motor3.spin(reverse);
Controller1RightShoulderControlMotorsStopped = false;
} else if (!Controller1RightShoulderControlMotorsStopped) {
Motor3.stop();
// set the toggle so that we don't constantly tell the motor to stop when the buttons are released
Controller1RightShoulderControlMotorsStopped = true;
}
you can see the motor and motor_group code is only using Motor.spin(forward), Motor.spin(reverse) and Motor.stop(). This means that they will both use the default velocity for motors which, as I said, is 50 rpm. If these motors have green gears then they will be running at 25% of their maximum free speeds (ie. 25% of 200rpm).
You can change this by adding setVelocity commands at the beginning of the code. I was using a C++ project, so that could be (block would be essentially the same).
int main() {
Motor3.setVelocity( 100, percent );
MotorGroup1.setVelocity( 100, percent );
}
easy.
Now lets look at the drivetrain code, a bit more complicated (and really verbose and messy, that’s always a problem with auto generated code).
drivetrain control
// calculate the drivetrain motor velocities from the controller joystick axies
// left = Axis3 + Axis4
// right = Axis3 - Axis4
int drivetrainLeftSideSpeed = Controller1.Axis3.position() + Controller1.Axis4.position();
int drivetrainRightSideSpeed = Controller1.Axis3.position() - Controller1.Axis4.position();
// check if the values are inside of the deadband range
if (abs(drivetrainLeftSideSpeed) < 5 && abs(drivetrainRightSideSpeed) < 5) {
// check if the motors have already been stopped
if (DrivetrainNeedsToBeStopped_Controller1) {
// stop the drive motors
LeftDriveSmart.stop();
RightDriveSmart.stop();
// tell the code that the motors have been stopped
DrivetrainNeedsToBeStopped_Controller1 = false;
}
} else {
// reset the toggle so that the deadband code knows to stop the motors next time the input is in the deadband range
DrivetrainNeedsToBeStopped_Controller1 = true;
}
// only tell the left drive motor to spin if the values are not in the deadband range
if (DrivetrainNeedsToBeStopped_Controller1) {
LeftDriveSmart.setVelocity(drivetrainLeftSideSpeed, percent);
LeftDriveSmart.spin(forward);
}
// only tell the right drive motor to spin if the values are not in the deadband range
if (DrivetrainNeedsToBeStopped_Controller1) {
RightDriveSmart.setVelocity(drivetrainRightSideSpeed, percent);
RightDriveSmart.spin(forward);
}
Ignore all the DrivetrainNeedsToBeStopped_Controller1 stuff, the important parts are these
int drivetrainLeftSideSpeed = Controller1.Axis3.position() + Controller1.Axis4.position();
LeftDriveSmart.setVelocity(drivetrainLeftSideSpeed, percent);
LeftDriveSmart.spin(forward);
you can see that drivetrainLeftSideSpeed is sent as a percentage to setVelocity which is followed by spin(forward). This means that there’s no point in using setDriveVelocity or setTurnVelocity when in driver control with the drivetrain mapped to the controller joystick, you are getting all the speed from the motors that is available.