PROS Hold Brake Type?

#1

Hello,

I wish to know if there is a way to stop motors in PROS and have them hold, similar to the way that it can be done in VCS(see example below). The reason for this is to allow all drivetrain motors on a robot to essentially “lock,” where the bot cannot be moved because current is supplied to the motor to hold them in place.

driveLFMotor.stop(vex::brakeType::hold);
driveLBMotor.stop(vex::brakeType::hold);
driveRFMotor.stop(vex::brakeType::hold);
driveRBMotor.stop(vex::brakeType::hold);

Is there any built-in way I can do this in PROS? Or would I have to make a function to spin the motor slightly opposite to what it is originally turning?

0 Likes

Braking and holding
#2

First you’ll want to set the brake mode: motor.set_brake_mode(pros::E_MOTOR_BRAKE_HOLD);
Then you tell the motor to stop moving: motor.move_velocity(0);
Note that you cannot use a voltage movement function such as move(0) to get the braking to work.

2 Likes

Braking and holding
#3

Ah, I must have missed the option where I can set the brake mode. Much thanks.

Is there any specific reason that a function such as move(0) cannot be used? Just curious.

0 Likes

#4

If you think about the ideas behind the functions it makes more sense.
move_velocity(0); tells the motor to not move - make sure its velocity stays at 0. Therefore the motor will resist movement in accordance with the braking setting.
move(0); which is equivalent to move_voltage(0); tells the motor not to apply any voltage - to do nothing. This means that the motor will not resist any changes in position, because it has been told to do nothing.

2 Likes

#5

Sorry to revive an old thread, but would it work if say, i only use move_velocity() to stop, and move() for everything else?

IE:
if (speed == 0) { motor.move_velocity(0); } else { motor.move(speed); }

Sorry I can’t figure out how to get newlines in the code formatting stuff

0 Likes

#6

I would stick with the same command here. I tried mixing commands like this at one point for fun and for some reason, it didn’t stop the motor. I had to set both to 0 for it to work. Is there a particular reason you’re wanting to do it this way?

0 Likes

#7

Not really ig, we’ve just been using move() before, and you just have to multiply to make the values for the controller equal to the different values for move_velocity()

0 Likes

#8

I mean if you multiply by 1.57480315 (200 / 127), it should technically scale it.

0 Likes

#9

Yes, this should be fine. IIRC this is what I did on my drive.

0 Likes