Slew
EZ-Template Slew Wrappers
slew_drive_constants_set()
Sets constants for slew during drive forward motions. This sets forward and backward constants. Robot will start at min_speed
and will be at the maximum set speed once distance
is traveled.
distance
is in an okapi distance unit.
min_speed
is 0 to 127.
- Prototype
- Example
void autonomous() {
chassis.drive_imu_reset();
chassis.drive_sensor_reset();
chassis.drive_brake_set(MOTOR_BRAKE_HOLD);
chassis.slew_drive_constants_set(5_in, 50);
chassis.pid_drive_set(12_in, 110, true);
chassis.pid_wait();
chassis.pid_drive_set(-12_in, 110, true);
chassis.pid_wait();
}
void slew_drive_constants_set(okapi::QLength distance, int min_speed);
slew_drive_constants_forward_set()
Sets constants for slew during drive forward motions. Robot will start at min_speed
and will be at the maximum set speed once distance
is traveled.
distance
is in an okapi distance unit.
min_speed
is 0 to 127.
- Prototype
- Example
void autonomous() {
chassis.drive_imu_reset();
chassis.drive_sensor_reset();
chassis.drive_brake_set(MOTOR_BRAKE_HOLD);
chassis.slew_drive_constants_forward_set(5_in, 50);
chassis.pid_drive_set(12_in, 110, true);
chassis.pid_wait();
}
void slew_drive_constants_forward_set(okapi::QLength distance, int min_speed);
slew_drive_constants_backward_set()
Sets constants for slew during drive forward motions. Robot will start at min_speed
and will be at the maximum set speed once distance
is traveled.
distance
is in an okapi distance unit.
min_speed
is 0 to 127.
- Prototype
- Example
void autonomous() {
chassis.drive_imu_reset();
chassis.drive_sensor_reset();
chassis.drive_brake_set(MOTOR_BRAKE_HOLD);
chassis.slew_drive_constants_backward_set(5_in, 50);
chassis.pid_drive_set(-12_in, 110, true);
chassis.pid_wait();
}
void slew_drive_constants_backward_set(okapi::QLength distance, int min_speed);
slew_turn_constants_set()
Sets constants for slew during turns. Robot will start at min_speed
and will be at the maximum set speed once distance
is traveled.
distance
is in an okapi angle unit.
min_speed
is 0 to 127.
- Prototype
- Example
void autonomous() {
chassis.drive_imu_reset();
chassis.drive_sensor_reset();
chassis.drive_brake_set(MOTOR_BRAKE_HOLD);
chassis.slew_turn_constants_set(5_deg, 50);
chassis.pid_turn_set(-90_deg, 110, true);
chassis.pid_wait();
}
void slew_turn_constants_set(okapi::QAngle distance, int min_speed);
slew_swing_constants_set()
Sets constants for slew during swing turns. This sets forward and backwards constants. Robot will start at min_speed
and will be at the maximum set speed once distance
is traveled.
distance
is in an okapi length unit.
min_speed
is 0 to 127.
- Prototype
- Example
void autonomous() {
chassis.drive_imu_reset();
chassis.drive_sensor_reset();
chassis.drive_brake_set(MOTOR_BRAKE_HOLD);
chassis.slew_swing_constants_set(5_in, 50);
chassis.pid_swing_set(ez::LEFT_SWING, 90_deg, 110, 0, true);
chassis.pid_wait();
}
void slew_swing_constants_set(okapi::QLength distance, int min_speed);
slew_swing_constants_set()
Sets constants for slew during swing turns. This sets forward and backwards constants. Robot will start at min_speed
and will be at the maximum set speed once distance
is traveled.
distance
is in an okapi angle unit.
min_speed
is 0 to 127.
- Prototype
- Example
void autonomous() {
chassis.drive_imu_reset();
chassis.drive_sensor_reset();
chassis.drive_brake_set(MOTOR_BRAKE_HOLD);
chassis.slew_swing_constants_set(7_deg, 50);
chassis.pid_swing_set(ez::LEFT_SWING, 90_deg, 110, 0, true);
chassis.pid_wait();
}
void slew_swing_constants_set(okapi::QAngle distance, int min_speed);
slew_swing_constants_forward_set()
Sets constants for slew during forward swing turns. Robot will start at min_speed
and will be at the maximum set speed once distance
is traveled.
distance
is in an okapi length unit.
min_speed
is 0 to 127.
- Prototype
- Example
void autonomous() {
chassis.drive_imu_reset();
chassis.drive_sensor_reset();
chassis.drive_brake_set(MOTOR_BRAKE_HOLD);
chassis.slew_swing_constants_forward_set(5_in, 50);
chassis.pid_swing_set(ez::LEFT_SWING, 90_deg, 110, 0, true);
chassis.pid_wait();
}
void slew_swing_constants_forward_set(okapi::QLength distance, int min_speed);
slew_swing_constants_forward_set()
Sets constants for slew during forward swing turns. Robot will start at min_speed
and will be at the maximum set speed once distance
is traveled.
distance
is in an okapi angle unit.
min_speed
is 0 to 127.
- Prototype
- Example
void autonomous() {
chassis.drive_imu_reset();
chassis.drive_sensor_reset();
chassis.drive_brake_set(MOTOR_BRAKE_HOLD);
chassis.slew_swing_constants_forward_set(7_deg, 50);
chassis.pid_swing_set(ez::LEFT_SWING, 90_deg, 110, 0, true);
chassis.pid_wait();
}
void slew_swing_constants_forward_set(okapi::QAngle distance, int min_speed);
slew_swing_constants_backward_set()
Sets constants for slew during backward swing turns. Robot will start at min_speed
and will be at the maximum set speed once distance
is traveled.
distance
is in an okapi length unit.
min_speed
is 0 to 127.
- Prototype
- Example
void autonomous() {
chassis.drive_imu_reset();
chassis.drive_sensor_reset();
chassis.drive_brake_set(MOTOR_BRAKE_HOLD);
chassis.slew_swing_constants_backward_set(5_in, 50);
chassis.pid_swing_set(ez::LEFT_SWING, -90_deg, 110, 0, true);
chassis.pid_wait();
}
void slew_swing_constants_backward_set(okapi::QLength distance, int min_speed);
slew_swing_constants_backward_set()
Sets constants for slew during backward swing turns. Robot will start at min_speed
and will be at the maximum set speed once distance
is traveled.
distance
is in an okapi angle unit.
min_speed
is 0 to 127.
- Prototype
- Example
void autonomous() {
chassis.drive_imu_reset();
chassis.drive_sensor_reset();
chassis.drive_brake_set(MOTOR_BRAKE_HOLD);
chassis.slew_swing_constants_backward_set(7_deg, 50);
chassis.pid_swing_set(ez::LEFT_SWING, -90_deg, 110, 0, true);
chassis.pid_wait();
}
void slew_swing_constants_backward_set(okapi::QAngle distance, int min_speed);
Slew Class
slew()
Creates a slew object with constants. Robot will start at min_speed
and will be at the maximum set speed once distance
is traveled.
distance
distance to travel until maximum speed is reached.
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 maximum speed is reached.
minimum_speed
starting speed.
- Prototype
- Example
PID 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 target speed for the robot to reach.
target
the distance to reach before max speed is hit.
current
the current sensor value.
- Prototype
- Example
PID 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
PID 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
PID 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
PID 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? %f\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? %f\n", lift_slew.enabled()); // Returns false
}
double output();
speed_max_set()
Sets the max speed slew can be.
speed
maximum speed the output can be
- Prototype
- Example
PID 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_set()
Returns the max speed slew can be.
- Prototype
- Example
PID 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();
/**
- Sets the max speed the slew can be
- \param speed
- maximum speed */ void speed_max_set(double speed);
/**
- Returns the max speed the slew can be */ double speed_max_get();