My teammate and I have made the switch to using PROS for developing our programs. We decided we wanted to have a joystick curve such that our drive train does not jump to 100% speed (or in this case max voltage) and instead gradually approaches that max. To do this , we found that - at least in our experience - we had to move by voltage. We found this fine, until we realized that we could not use brake commands.
Our driver strongly prefers operating the robot with brake methods, so how can we go about resolving this issue? Here is our code in question:
void opcontrol() {
// left side motor group
pros::Motor leftMotorBack(3);
pros::Motor leftMotorFront(8);
pros::Motor_Group leftDriveSmart({leftMotorBack,leftMotorFront});
// right side motor group
pros::Motor rightMotorBack(4);
pros::Motor rightMotorFront(7);
pros::Motor_Group rightDriveSmart({rightMotorFront, rightMotorBack});
// controller initialization
pros::Controller master(pros::E_CONTROLLER_MASTER);
// parse input from controller - arcade driving method
float acceleration;
float timeElapsed = 0;
while (true) {
// grab input from controller
float rightInputX = master.get_analog(ANALOG_RIGHT_X);
float leftInputY = master.get_analog(ANALOG_LEFT_Y);
// detect if leftInputY is forward
if (leftInputY > 100) {
timeElapsed = timeElapsed + 0.55;
} else if (rightInputX < -100) {
timeElapsed = -(timeElapsed + 0.55);
} else {
timeElapsed = 0;
}
// detect if rightInputY is backwards
// adjust acceleration
acceleration = -pow((timeElapsed-5),2)+25;
// control wheels
float left = acceleration + rightInputX * 40;
float right = acceleration - rightInputX * 40;
leftDriveSmart.move_voltage(left);
rightDriveSmart.move_voltage(-right);
// set voltage to 0 when -5 < joystick < 5
if ((master.get_analog(ANALOG_LEFT_Y)) > -5 && (master.get_analog(ANALOG_LEFT_Y)) < 5) {
leftDriveSmart.move_velocity(0);
rightDriveSmart.move_velocity(0);
}
// prevent system from overworking
pros::delay(2);
}
}