Slew
Click here for documentation on slew for each movement in EZ-Template!
Slew Class
slew()
Creates a slew object with constants. Robot will start at min_speed and ramp up to full speed (127) once distance is traveled, capped at the movement's maximum speed.
distance distance to travel until full speed (127) is reached. The ramp rate does not depend on the movement's maximum speed.
minimum_speed starting speed.
- Prototype
- Example
ez::slew lift_Slew(100, 60);
slew(double distance, int minimum_speed);
constants_set()
Sets slew constants.
distance distance to travel until full speed (127) is reached. The ramp rate does not depend on the movement's maximum speed.
minimum_speed starting speed.
- Prototype
- Example
ez::slew lift_slew;
void initialize() {
lift_slew.constants_set(100, 50);
}
void constants_set(double distance, int minimum_speed);
initialize()
Setup for slew. Keeps track of where the starting sensor value is and what the maximum target speed is.
enabled true if you want slew to run, false if you don't.
maximum_speed the most speed slew is allowed to output for this movement. This caps the output, it does not change how fast slew ramps up.
target the target position for the movement.
current the current sensor value.
- Prototype
- Example
ez::slew lift_slew;
pros::Motor lift(1);
void initialize() {
lift_slew.constants_set(100, 50);
lift_slew.initialize(true, 127, 500, lift.get_position());
}
void initialize(bool enabled, double maximum_speed, double target, double current);
iterate()
Iterates slew calculation and returns what the current max speed should be.
current the current sensor value.
- Prototype
- Example
ez::slew lift_slew;
pros::Motor lift(1);
void initialize() {
lift_slew.constants_set(100, 50);
lift_slew.initialize(true, 127, 500, lift.get_position());
}
void autonomous() {
while (lift.get_position() <= 500) {
lift = lift_slew.iterate(lift.get_position());
pros::delay(10);
}
lift = 0;
}
double iterate(double current);
output()
Returns what the current max speed should be.
- Prototype
- Example
ez::slew lift_slew;
pros::Motor lift(1);
void initialize() {
lift_slew.constants_set(100, 50);
lift_slew.initialize(true, 127, 500, lift.get_position());
}
void autonomous() {
while (lift.get_position() <= 500) {
lift_slew.iterate(lift.get_position());
lift = lift_slew.output();
pros::delay(10);
}
lift = 0;
}
double output();
enabled()
Returns if slew is currently active or not.
- Prototype
- Example
ez::slew lift_slew;
pros::Motor lift(1);
void initialize() {
lift_slew.constants_set(100, 50);
lift_slew.initialize(true, 127, 500, lift.get_position());
}
void autonomous() {
printf("Slew Enabled? %i\n", lift_slew.enabled()); // Returns true
while (lift.get_position() <= 500) {
lift_slew.iterate(lift.get_position());
lift = lift_slew.output();
pros::delay(10);
}
lift = 0;
printf("Slew Enabled? %i\n", lift_slew.enabled()); // Returns false
}
bool enabled();
speed_max_set()
Sets the max speed slew can be.
speed maximum speed the output can be
- Prototype
- Example
ez::slew lift_slew;
pros::Motor lift(1);
void initialize() {
lift_slew.constants_set(100, 50);
lift_slew.initialize(true, 127, 500, lift.get_position());
}
void autonomous() {
while (lift.get_position() <= 500) {
if (lift.get_position() < 100)
lift_slew.speed_max_set(50);
else
lift_slew.speed_max_set(127);
lift_slew.iterate(lift.get_position());
lift = lift_slew.output();
pros::delay(10);
}
lift = 0;
}
void speed_max_set(double speed);
speed_max_get()
Returns the max speed slew can be.
- Prototype
- Example
ez::slew lift_slew;
pros::Motor lift(1);
void initialize() {
lift_slew.constants_set(100, 50);
lift_slew.initialize(true, 127, 500, lift.get_position());
}
void autonomous() {
while (lift.get_position() <= 500) {
if (lift.get_position() < 100)
lift_slew.speed_max_set(50);
else
lift_slew.speed_max_set(127);
printf("%.2f", lift_slew.speed_max_get());
lift_slew.iterate(lift.get_position());
lift = lift_slew.output();
pros::delay(10);
}
lift = 0;
}
double speed_max_get();