How do I cap rpm on PROS? I am using a 600 rpm base right now but I want to cap it at 350.
I tried using move_velocity but it seems like the base is running at the same speed still.
How do I cap rpm on PROS? I am using a 600 rpm base right now but I want to cap it at 350.
I tried using move_velocity but it seems like the base is running at the same speed still.
I’m assuming you mean in driver control.
First what you would do in the while(true) loop, make an variable (integer) that is equal to the joystick. Then after that have an if statement that checks if that variable is over 350. If it is, the set the variable to 350. Also have another if statement that checks if that variable is below -350. If it is, set the variable to -350.
Did you set the gearing with pros::Motor.set_gearing() ?
https://pros.cs.purdue.edu/v5/api/cpp/motors.html#set-gearing
pros::Motor.move_velocity() takes values from ±100, ±200, or ±600 depending on the motor’s gearset
I set the gearing like this:
Motor leftf (LEFT_FRONT, MOTOR_GEARSET_6, true, MOTOR_ENCODER_DEGREES);
Motor leftb (LEFT_BACK, MOTOR_GEARSET_6, true, MOTOR_ENCODER_DEGREES);
Motor rightf (RIGHT_FRONT, MOTOR_GEARSET_6, MOTOR_ENCODER_DEGREES);
Motor rightb (RIGHT_BACK, MOTOR_GEARSET_6, MOTOR_ENCODER_DEGREES);
is it the same as doing it through set_gearing()
You could just divide all your values by 1.7, because 600/1.7 is 350. This will let you use all your joystick instead of only half like the capping method does
Well yeah, but then won’t you basically be making a chunk of your joystick not do anything?
OkapiLib handles that. it reports the output of the joystick as -1 to 1 then multiplies that by the maxVelocity.
(ed. I haven’t actually tested for driver control (just auton) but the code in skidsteer support it.)
Cool, good luck in your endeavors!
FYI, I finally got around to trying my suggestion. And found that OkapiLib’s setMaxVelocity
is not used by the chassis model Arcade or Tank drive or Voltage movement commands.
For those, use setMaxVoltage. This is not exactly the same since it does not guarantee a velocity.
I thought I should clarify that.