Swinging
Functions with Units
pid_swing_set()
Sets the robot to turn using only one side of the drive with PID relative to initial heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
p_target target value, in units
speed 0 to 127, max speed during motion
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_set(ez::LEFT_SWING, 22.5, 110);
chassis.pid_wait();
}
void pid_swing_set(e_swing type, ez::QAngle p_target, int speed);
pid_swing_set()
Sets the robot to turn using only one side of the drive with PID relative to initial heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
p_target target value, in units
speed 0 to 127, max speed during motion
behavior changes what direction the robot will turn. can be ez::ccw, ez::cw, ez::shortest, ez::longest, ez::raw
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_set(ez::LEFT_SWING, 22.5, 110, ez::longest);
chassis.pid_wait();
}
void pid_swing_set(e_swing type, ez::QAngle p_target, int speed, e_angle_behavior behavior);
pid_swing_set()
Sets the robot to turn using only one side of the drive with PID relative to initial heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
p_target target value, in units
speed 0 to 127, max speed during motion
slew_on ramp up from a lower speed to your target speed
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_set(ez::LEFT_SWING, 22.5, 110, true);
chassis.pid_wait();
}
void pid_swing_set(e_swing type, ez::QAngle p_target, int speed, bool slew_on);
pid_swing_set()
Sets the robot to turn using only one side of the drive with PID relative to initial heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
p_target target value, in units
speed 0 to 127, max speed during motion
behavior changes what direction the robot will turn. can be ez::ccw, ez::cw, ez::shortest, ez::longest, ez::raw
slew_on ramp up from a lower speed to your target speed
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_set(ez::LEFT_SWING, 22.5, 110, ez::longest, true);
chassis.pid_wait();
}
void pid_swing_set(e_swing type, ez::QAngle p_target, int speed, e_angle_behavior behavior, bool slew_on);
pid_swing_set()
Sets the robot to turn using only one side of the drive with PID and the opposite side at up to opposite_speed, scaled down as the swing slows, relative to initial heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
p_target target value, in units
speed 0 to 127, max speed during motion
opposite_speed -127 to 127, max speed of the opposite side of the drive during the swing. this is used for arcs
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_set(ez::LEFT_SWING, 22.5, 110, 30);
chassis.pid_wait();
}
void pid_swing_set(e_swing type, ez::QAngle p_target, int speed, int opposite_speed);
pid_swing_set()
Sets the robot to turn using only one side of the drive with PID and the opposite side at up to opposite_speed, scaled down as the swing slows, relative to initial heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
p_target target value, in units
speed 0 to 127, max speed during motion
opposite_speed -127 to 127, max speed of the opposite side of the drive during the swing. this is used for arcs
behavior changes what direction the robot will turn. can be ez::ccw, ez::cw, ez::shortest, ez::longest, ez::raw
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_set(ez::LEFT_SWING, 22.5, 110, 30, ez::longest);
chassis.pid_wait();
}
void pid_swing_set(e_swing type, ez::QAngle p_target, int speed, int opposite_speed, e_angle_behavior behavior);
pid_swing_set()
Sets the robot to turn using only one side of the drive with PID and the opposite side at up to opposite_speed, scaled down as the swing slows, relative to initial heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
p_target target value, in units
speed 0 to 127, max speed during motion
opposite_speed -127 to 127, max speed of the opposite side of the drive during the swing. this is used for arcs
slew_on ramp up from a lower speed to your target speed
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_set(ez::LEFT_SWING, 22.5, 110, 30, true);
chassis.pid_wait();
}
void pid_swing_set(e_swing type, ez::QAngle p_target, int speed, int opposite_speed, bool slew_on);
pid_swing_set()
Sets the robot to turn using only one side of the drive with PID and the opposite side at up to opposite_speed, scaled down as the swing slows, relative to initial heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
p_target target value, in units
speed 0 to 127, max speed during motion
opposite_speed -127 to 127, max speed of the opposite side of the drive during the swing. this is used for arcs
behavior changes what direction the robot will turn. can be ez::ccw, ez::cw, ez::shortest, ez::longest, ez::raw
slew_on ramp up from a lower speed to your target speed
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_set(ez::LEFT_SWING, 22.5, 110, 30, ez::longest, true);
chassis.pid_wait();
}
void pid_swing_set(e_swing type, ez::QAngle p_target, int speed, int opposite_speed, e_angle_behavior behavior, bool slew_on);
pid_swing_relative_set()
Sets the robot to turn using only one side of the drive with PID relative to the last heading target, not the robot's measured heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
p_target target value, in units
speed 0 to 127, max speed during motion
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Swing to 90 deg
chassis.pid_swing_relative_set(ez::LEFT_SWING, 90, 110);
chassis.pid_wait();
// Swing -45 from the previous target, to 45 deg
chassis.pid_swing_relative_set(ez::RIGHT_SWING, -45, 110);
chassis.pid_wait();
}
void pid_swing_relative_set(e_swing type, ez::QAngle p_target, int speed);
pid_swing_relative_set()
Sets the robot to turn using only one side of the drive with PID relative to the last heading target, not the robot's measured heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
p_target target value, in units
speed 0 to 127, max speed during motion
slew_on ramp up from a lower speed to your target speed
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Swing to 90 deg
chassis.pid_swing_relative_set(ez::LEFT_SWING, 90, 110, true);
chassis.pid_wait();
// Swing -45 from the previous target, to 45 deg
chassis.pid_swing_relative_set(ez::RIGHT_SWING, -45, 110, true);
chassis.pid_wait();
}
void pid_swing_relative_set(e_swing type, ez::QAngle p_target, int speed, bool slew_on);
pid_swing_relative_set()
Sets the robot to turn using only one side of the drive with PID relative to the last heading target, not the robot's measured heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
p_target target value, in units
speed 0 to 127, max speed during motion
behavior changes what direction the robot will turn. can be ez::ccw, ez::cw, ez::shortest, ez::longest, ez::raw
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Swing to 90 deg
chassis.pid_swing_relative_set(ez::LEFT_SWING, 90, 110, ez::shortest);
chassis.pid_wait();
// Swing to 45 deg (-45 from the previous target), taking the long way around
chassis.pid_swing_relative_set(ez::RIGHT_SWING, -45, 110, ez::longest);
chassis.pid_wait();
}
void pid_swing_relative_set(e_swing type, ez::QAngle p_target, int speed, e_angle_behavior behavior);
pid_swing_relative_set()
Sets the robot to turn using only one side of the drive with PID relative to the last heading target, not the robot's measured heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
p_target target value, in units
speed 0 to 127, max speed during motion
behavior changes what direction the robot will turn. can be ez::ccw, ez::cw, ez::shortest, ez::longest, ez::raw
slew_on ramp up from a lower speed to your target speed
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Swing to 90 deg
chassis.pid_swing_relative_set(ez::LEFT_SWING, 90, 110, ez::shortest, true);
chassis.pid_wait();
// Swing to 45 deg (-45 from the previous target), taking the long way around
chassis.pid_swing_relative_set(ez::RIGHT_SWING, -45, 110, ez::longest, true);
chassis.pid_wait();
}
void pid_swing_relative_set(e_swing type, ez::QAngle p_target, int speed, e_angle_behavior behavior, bool slew_on);
pid_swing_relative_set()
Sets the robot to turn using only one side of the drive with PID and the opposite side at up to opposite_speed, scaled down as the swing slows, relative to the last heading target, not the robot's measured heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
p_target target value, in units
speed 0 to 127, max speed during motion
opposite_speed -127 to 127, max speed of the opposite side of the drive during the swing. this is used for arcs
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Swing to 90 deg
chassis.pid_swing_relative_set(ez::LEFT_SWING, 90, 110, 30);
chassis.pid_wait();
// Swing -45 from the previous target, to 45 deg
chassis.pid_swing_relative_set(ez::RIGHT_SWING, -45, 110, 30);
chassis.pid_wait();
}
void pid_swing_relative_set(e_swing type, ez::QAngle p_target, int speed, int opposite_speed);
pid_swing_relative_set()
Sets the robot to turn using only one side of the drive with PID and the opposite side at up to opposite_speed, scaled down as the swing slows, relative to the last heading target, not the robot's measured heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
p_target target value, in units
speed 0 to 127, max speed during motion
opposite_speed -127 to 127, max speed of the opposite side of the drive during the swing. this is used for arcs
slew_on ramp up from a lower speed to your target speed
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Swing to 90 deg
chassis.pid_swing_relative_set(ez::LEFT_SWING, 90, 110, 30, true);
chassis.pid_wait();
// Swing -45 from the previous target, to 45 deg
chassis.pid_swing_relative_set(ez::RIGHT_SWING, -45, 110, 30, true);
chassis.pid_wait();
}
void pid_swing_relative_set(e_swing type, ez::QAngle p_target, int speed, int opposite_speed, bool slew_on);
pid_swing_relative_set()
Sets the robot to turn using only one side of the drive with PID and the opposite side at up to opposite_speed, scaled down as the swing slows, relative to the last heading target, not the robot's measured heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
p_target target value, in units
speed 0 to 127, max speed during motion
opposite_speed -127 to 127, max speed of the opposite side of the drive during the swing. this is used for arcs
behavior changes what direction the robot will turn. can be ez::ccw, ez::cw, ez::shortest, ez::longest, ez::raw
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Swing to 90 deg
chassis.pid_swing_relative_set(ez::LEFT_SWING, 90, 110, 30, ez::shortest);
chassis.pid_wait();
// Swing to 45 deg (-45 from the previous target), taking the long way around
chassis.pid_swing_relative_set(ez::RIGHT_SWING, -45, 110, 30, ez::longest);
chassis.pid_wait();
}
void pid_swing_relative_set(e_swing type, ez::QAngle p_target, int speed, int opposite_speed, e_angle_behavior behavior);
pid_swing_relative_set()
Sets the robot to turn using only one side of the drive with PID and the opposite side at up to opposite_speed, scaled down as the swing slows, relative to the last heading target, not the robot's measured heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
p_target target value, in units
speed 0 to 127, max speed during motion
opposite_speed -127 to 127, max speed of the opposite side of the drive during the swing. this is used for arcs
behavior changes what direction the robot will turn. can be ez::ccw, ez::cw, ez::shortest, ez::longest, ez::raw
slew_on ramp up from a lower speed to your target speed
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Swing to 90 deg
chassis.pid_swing_relative_set(ez::LEFT_SWING, 90, 110, 30, ez::shortest, true);
chassis.pid_wait();
// Swing to 45 deg (-45 from the previous target), taking the long way around
chassis.pid_swing_relative_set(ez::RIGHT_SWING, -45, 110, 30, ez::longest, true);
chassis.pid_wait();
}
void pid_swing_relative_set(e_swing type, ez::QAngle p_target, int speed, int opposite_speed, e_angle_behavior behavior, bool slew_on);
pid_swing_exit_condition_set()
Set's constants for swing exit conditions.
p_small_exit_time time to exit when within small_error, in ms
p_small_error small timer will start when error is within this, in degrees
p_big_exit_time time to exit when within big_error, in ms
p_big_error big timer will start when error is within this, in degrees
p_velocity_exit_time velocity timer will start when velocity is 0 after the robot has moved (or after 1 second if it never moves), in ms
p_mA_timeout mA timer will start when the first motor on the side(s) being driven is over its current limit, in ms
use_imu true adds a second velocity exit timer based on the imu's acceleration (exits if either the main sensor or the imu reports no movement for p_velocity_exit_time), false uses only the main sensor
- Prototype
- Example
void initialize() {
chassis.pid_swing_exit_condition_set(300, 3, 500, 7, 750, 750);
}
void pid_swing_exit_condition_set(int p_small_exit_time, double p_small_error, int p_big_exit_time, double p_big_error, int p_velocity_exit_time, int p_mA_timeout, bool use_imu = true);
pid_swing_exit_condition_set()
Set's constants for swing exit conditions.
p_small_exit_time time to exit when within small_error, in units
p_small_error small timer will start when error is within this, in units
p_big_exit_time time to exit when within big_error, in units
p_big_error big timer will start when error is within this, in units
p_velocity_exit_time velocity timer will start when velocity is 0 after the robot has moved (or after 1 second if it never moves), in units
p_mA_timeout mA timer will start when the first motor on the side(s) being driven is over its current limit, in units
use_imu true adds a second velocity exit timer based on the imu's acceleration (exits if either the main sensor or the imu reports no movement for p_velocity_exit_time), false uses only the main sensor
- Prototype
- Example
void initialize() {
chassis.pid_swing_exit_condition_set(300_ms, 3_deg, 500_ms, 7_deg, 750_ms, 750_ms);
}
void pid_swing_exit_condition_set(ez::QTime p_small_exit_time, ez::QAngle p_small_error, ez::QTime p_big_exit_time, ez::QAngle p_big_error, ez::QTime p_velocity_exit_time, ez::QTime p_mA_timeout, bool use_imu = true);
pid_swing_chain_constant_set()
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
This sets forward and backwards swing constants.
input angle unit
- Prototype
- Example
void initialize() {
chassis.pid_swing_chain_constant_set(5_deg);
}
void pid_swing_chain_constant_set(ez::QAngle input);
pid_swing_chain_forward_constant_set()
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
This only sets forward swing constants.
input angle unit
- Prototype
- Example
void initialize() {
chassis.pid_swing_chain_forward_constant_set(5_deg);
}
void pid_swing_chain_forward_constant_set(ez::QAngle input);
pid_swing_chain_backward_constant_set()
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
This only sets backward swing constants.
input angle unit
- Prototype
- Example
void initialize() {
chassis.pid_swing_chain_backward_constant_set(5_deg);
}
void pid_swing_chain_backward_constant_set(ez::QAngle input);
slew_swing_constants_set()
Sets constants for slew for swing movements.
Slew ramps up the speed of the robot from min_speed to full speed (127) over the set distance. A motion with a lower max speed is capped at that speed, so it stops ramping sooner.
distance the distance the robot travels to ramp up to full speed (127), a distance unit
min_speed the starting speed for the movement, 0 - 127
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
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(ez::QLength distance, int min_speed);
slew_swing_constants_forward_set()
Sets constants for slew for forward swing movements.
Slew ramps up the speed of the robot from min_speed to full speed (127) over the set distance. A motion with a lower max speed is capped at that speed, so it stops ramping sooner.
distance the distance the robot travels to ramp up to full speed (127), a distance unit
min_speed the starting speed for the movement, 0 - 127
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
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(ez::QLength distance, int min_speed);
slew_swing_constants_backward_set()
Sets constants for slew for backward swing movements.
Slew ramps up the speed of the robot from min_speed to full speed (127) over the set distance. A motion with a lower max speed is capped at that speed, so it stops ramping sooner.
distance the distance the robot travels to ramp up to full speed (127), a distance unit
min_speed the starting speed for the movement, 0 - 127
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
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(ez::QLength distance, int min_speed);
slew_swing_constants_set()
Sets constants for slew for swing movements.
Slew ramps up the speed of the robot from min_speed to full speed (127) over the set distance. A motion with a lower max speed is capped at that speed, so it stops ramping sooner.
distance the distance the robot travels to ramp up to full speed (127), an angle unit
min_speed the starting speed for the movement, 0 - 127
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
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(ez::QAngle distance, int min_speed);
slew_swing_constants_forward_set()
Sets constants for slew for forward swing movements.
Slew ramps up the speed of the robot from min_speed to full speed (127) over the set distance. A motion with a lower max speed is capped at that speed, so it stops ramping sooner.
distance the distance the robot travels to ramp up to full speed (127), an angle unit
min_speed the starting speed for the movement, 0 - 127
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
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(ez::QAngle distance, int min_speed);
slew_swing_constants_backward_set()
Sets constants for slew for backward swing movements.
Slew ramps up the speed of the robot from min_speed to full speed (127) over the set distance. A motion with a lower max speed is capped at that speed, so it stops ramping sooner.
distance the distance the robot travels to ramp up to full speed (127), an angle unit
min_speed the starting speed for the movement, 0 - 127
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
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(ez::QAngle distance, int min_speed);
Functions without Units
pid_swing_set()
Sets the robot to turn using only one side of the drive with PID relative to initial heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
target target value in degrees
speed 0 to 127, max speed during motion
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_set(ez::LEFT_SWING, 22.5, 110);
chassis.pid_wait();
}
void pid_swing_set(e_swing type, double target, int speed);
pid_swing_set()
Sets the robot to turn using only one side of the drive with PID relative to initial heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
target target value in degrees
speed 0 to 127, max speed during motion
behavior changes what direction the robot will turn. can be ez::ccw, ez::cw, ez::shortest, ez::longest, ez::raw
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_set(ez::LEFT_SWING, 22.5, 110, ez::longest);
chassis.pid_wait();
}
void pid_swing_set(e_swing type, double target, int speed, e_angle_behavior behavior);
pid_swing_set()
Sets the robot to turn using only one side of the drive with PID relative to initial heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
target target value in degrees
speed 0 to 127, max speed during motion
slew_on ramp up from a lower speed to your target speed
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_set(ez::LEFT_SWING, 22.5, 110, true);
chassis.pid_wait();
}
void pid_swing_set(e_swing type, double target, int speed, bool slew_on);
pid_swing_set()
Sets the robot to turn using only one side of the drive with PID relative to initial heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
target target value in degrees
speed 0 to 127, max speed during motion
behavior changes what direction the robot will turn. can be ez::ccw, ez::cw, ez::shortest, ez::longest, ez::raw
slew_on ramp up from a lower speed to your target speed
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_set(ez::LEFT_SWING, 22.5, 110, ez::longest, true);
chassis.pid_wait();
}
void pid_swing_set(e_swing type, double target, int speed, e_angle_behavior behavior, bool slew_on);
pid_swing_set()
Sets the robot to turn using only one side of the drive with PID and the opposite side at up to opposite_speed, scaled down as the swing slows, relative to initial heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
target target value in degrees
speed 0 to 127, max speed during motion
opposite_speed -127 to 127, max speed of the opposite side of the drive during the swing. this is used for arcs
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_set(ez::LEFT_SWING, 22.5, 110, 30);
chassis.pid_wait();
}
void pid_swing_set(e_swing type, double target, int speed, int opposite_speed);
pid_swing_set()
Sets the robot to turn using only one side of the drive with PID and the opposite side at up to opposite_speed, scaled down as the swing slows, relative to initial heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
target target value in degrees
speed 0 to 127, max speed during motion
opposite_speed -127 to 127, max speed of the opposite side of the drive during the swing. this is used for arcs
behavior changes what direction the robot will turn. can be ez::ccw, ez::cw, ez::shortest, ez::longest, ez::raw
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_set(ez::LEFT_SWING, 22.5, 110, 30, ez::longest);
chassis.pid_wait();
}
void pid_swing_set(e_swing type, double target, int speed, int opposite_speed, e_angle_behavior behavior);
pid_swing_set()
Sets the robot to turn using only one side of the drive with PID and the opposite side at up to opposite_speed, scaled down as the swing slows, relative to initial heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
target target value in degrees
speed 0 to 127, max speed during motion
opposite_speed -127 to 127, max speed of the opposite side of the drive during the swing. this is used for arcs
slew_on ramp up from a lower speed to your target speed
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_set(ez::LEFT_SWING, 22.5, 110, 30, true);
chassis.pid_wait();
}
void pid_swing_set(e_swing type, double target, int speed, int opposite_speed, bool slew_on);
pid_swing_set()
Sets the robot to turn using only one side of the drive with PID and the opposite side at up to opposite_speed, scaled down as the swing slows, relative to initial heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
target target value in degrees
speed 0 to 127, max speed during motion
opposite_speed -127 to 127, max speed of the opposite side of the drive during the swing. this is used for arcs
behavior changes what direction the robot will turn. can be ez::ccw, ez::cw, ez::shortest, ez::longest, ez::raw
slew_on ramp up from a lower speed to your target speed
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_set(ez::LEFT_SWING, 22.5, 110, 30, ez::longest, true);
chassis.pid_wait();
}
void pid_swing_set(e_swing type, double target, int speed, int opposite_speed, e_angle_behavior behavior, bool slew_on);
pid_swing_relative_set()
Sets the robot to turn using only one side of the drive with PID relative to the last heading target, not the robot's measured heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
target target value in degrees
speed 0 to 127, max speed during motion
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Swing to 90 deg
chassis.pid_swing_relative_set(ez::LEFT_SWING, 90, 110);
chassis.pid_wait();
// Swing -45 from the previous target, to 45 deg
chassis.pid_swing_relative_set(ez::RIGHT_SWING, -45, 110);
chassis.pid_wait();
}
void pid_swing_relative_set(e_swing type, double target, int speed);
pid_swing_relative_set()
Sets the robot to turn using only one side of the drive with PID relative to the last heading target, not the robot's measured heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
target target value in degrees
speed 0 to 127, max speed during motion
slew_on ramp up from a lower speed to your target speed
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Swing to 90 deg
chassis.pid_swing_relative_set(ez::LEFT_SWING, 90, 110, true);
chassis.pid_wait();
// Swing -45 from the previous target, to 45 deg
chassis.pid_swing_relative_set(ez::RIGHT_SWING, -45, 110, true);
chassis.pid_wait();
}
void pid_swing_relative_set(e_swing type, double target, int speed, bool slew_on);
pid_swing_relative_set()
Sets the robot to turn using only one side of the drive with PID relative to the last heading target, not the robot's measured heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
target target value in degrees
speed 0 to 127, max speed during motion
behavior changes what direction the robot will turn. can be ez::ccw, ez::cw, ez::shortest, ez::longest, ez::raw
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Swing to 90 deg
chassis.pid_swing_relative_set(ez::LEFT_SWING, 90, 110, ez::shortest);
chassis.pid_wait();
// Swing to 45 deg (-45 from the previous target), taking the long way around
chassis.pid_swing_relative_set(ez::RIGHT_SWING, -45, 110, ez::longest);
chassis.pid_wait();
}
void pid_swing_relative_set(e_swing type, double target, int speed, e_angle_behavior behavior);
pid_swing_relative_set()
Sets the robot to turn using only one side of the drive with PID relative to the last heading target, not the robot's measured heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
target target value in degrees
speed 0 to 127, max speed during motion
behavior changes what direction the robot will turn. can be ez::ccw, ez::cw, ez::shortest, ez::longest, ez::raw
slew_on ramp up from a lower speed to your target speed
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Swing to 90 deg
chassis.pid_swing_relative_set(ez::LEFT_SWING, 90, 110, ez::shortest, true);
chassis.pid_wait();
// Swing to 45 deg (-45 from the previous target), taking the long way around
chassis.pid_swing_relative_set(ez::RIGHT_SWING, -45, 110, ez::longest, true);
chassis.pid_wait();
}
void pid_swing_relative_set(e_swing type, double target, int speed, e_angle_behavior behavior, bool slew_on);
pid_swing_relative_set()
Sets the robot to turn using only one side of the drive with PID and the opposite side at up to opposite_speed, scaled down as the swing slows, relative to the last heading target, not the robot's measured heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
target target value in degrees
speed 0 to 127, max speed during motion
opposite_speed -127 to 127, max speed of the opposite side of the drive during the swing. this is used for arcs
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Swing to 90 deg
chassis.pid_swing_relative_set(ez::LEFT_SWING, 90, 110, 30);
chassis.pid_wait();
// Swing -45 from the previous target, to 45 deg
chassis.pid_swing_relative_set(ez::RIGHT_SWING, -45, 110, 30);
chassis.pid_wait();
}
void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed);
pid_swing_relative_set()
Sets the robot to turn using only one side of the drive with PID and the opposite side at up to opposite_speed, scaled down as the swing slows, relative to the last heading target, not the robot's measured heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
target target value in degrees
speed 0 to 127, max speed during motion
opposite_speed -127 to 127, max speed of the opposite side of the drive during the swing. this is used for arcs
slew_on ramp up from a lower speed to your target speed
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Swing to 90 deg
chassis.pid_swing_relative_set(ez::LEFT_SWING, 90, 110, 30, true);
chassis.pid_wait();
// Swing -45 from the previous target, to 45 deg
chassis.pid_swing_relative_set(ez::RIGHT_SWING, -45, 110, 30, true);
chassis.pid_wait();
}
void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed, bool slew_on);
pid_swing_relative_set()
Sets the robot to turn using only one side of the drive with PID and the opposite side at up to opposite_speed, scaled down as the swing slows, relative to the last heading target, not the robot's measured heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
target target value in degrees
speed 0 to 127, max speed during motion
opposite_speed -127 to 127, max speed of the opposite side of the drive during the swing. this is used for arcs
behavior changes what direction the robot will turn. can be ez::ccw, ez::cw, ez::shortest, ez::longest, ez::raw
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Swing to 90 deg
chassis.pid_swing_relative_set(ez::LEFT_SWING, 90, 110, 30, ez::shortest);
chassis.pid_wait();
// Swing to 45 deg (-45 from the previous target), taking the long way around
chassis.pid_swing_relative_set(ez::RIGHT_SWING, -45, 110, 30, ez::longest);
chassis.pid_wait();
}
void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed, e_angle_behavior behavior);
pid_swing_relative_set()
Sets the robot to turn using only one side of the drive with PID and the opposite side at up to opposite_speed, scaled down as the swing slows, relative to the last heading target, not the robot's measured heading.
type ez::LEFT_SWING or ez::RIGHT_SWING
target target value in degrees
speed 0 to 127, max speed during motion
opposite_speed -127 to 127, max speed of the opposite side of the drive during the swing. this is used for arcs
behavior changes what direction the robot will turn. can be ez::ccw, ez::cw, ez::shortest, ez::longest, ez::raw
slew_on ramp up from a lower speed to your target speed
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Swing to 90 deg
chassis.pid_swing_relative_set(ez::LEFT_SWING, 90, 110, 30, ez::shortest, true);
chassis.pid_wait();
// Swing to 45 deg (-45 from the previous target), taking the long way around
chassis.pid_swing_relative_set(ez::RIGHT_SWING, -45, 110, 30, ez::longest, true);
chassis.pid_wait();
}
void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed, e_angle_behavior behavior, bool slew_on);
pid_swing_constants_set()
Set PID constants for forward and backward swings.
p proportional term
i integral term
d derivative term
p_start_i error threshold to start integral
- Prototype
- Example
void initialize() {
chassis.pid_swing_constants_set(5, 0, 30);
}
void pid_swing_constants_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
pid_swing_constants_forward_set()
Set PID constants for forward swings.
p proportional term
i integral term
d derivative term
p_start_i error threshold to start integral
- Prototype
- Example
void initialize() {
chassis.pid_swing_constants_forward_set(5, 0, 30);
}
void pid_swing_constants_forward_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
pid_swing_constants_backward_set()
Set PID constants for backward swings.
p proportional term
i integral term
d derivative term
p_start_i error threshold to start integral
- Prototype
- Example
void initialize() {
chassis.pid_swing_constants_backward_set(5, 0, 30);
}
void pid_swing_constants_backward_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
pid_swing_chain_constant_set()
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
This sets forward and backwards swing constants.
input angle in degrees
- Prototype
- Example
void initialize() {
chassis.pid_swing_chain_constant_set(5);
}
void pid_swing_chain_constant_set(double input);
pid_swing_chain_forward_constant_set()
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
This only sets forward swing constants.
input angle in degrees
- Prototype
- Example
void initialize() {
chassis.pid_swing_chain_forward_constant_set(5);
}
void pid_swing_chain_forward_constant_set(double input);
pid_swing_chain_backward_constant_set()
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
This only sets backward swing constants.
input angle in degrees
- Prototype
- Example
void initialize() {
chassis.pid_swing_chain_backward_constant_set(5);
}
void pid_swing_chain_backward_constant_set(double input);
slew_swing_set()
Sets the default slew for swing forward and backward motions, can be overwritten in movement functions.
slew_on true enables, false disables
- Prototype
- Example
void slew_swing_set(bool slew_on);
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Set the default slew state to true
chassis.slew_swing_set(true);
// This will not use slew because we explicitly told the robot to not slew
chassis.pid_swing_set(ez::LEFT_SWING, 90_deg, 110, false);
chassis.pid_wait();
// This will slew because it's the default state
chassis.pid_swing_set(ez::LEFT_SWING, 0_deg, 110);
chassis.pid_wait();
}
slew_swing_forward_set()
Sets the default slew for swing forward motions, can be overwritten in movement functions.
slew_on true enables, false disables
- Prototype
- Example
void slew_swing_forward_set(bool slew_on);
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Set the default slew state to true
chassis.slew_swing_forward_set(true);
// This will not use slew because we explicitly told the robot to not slew
chassis.pid_swing_set(ez::LEFT_SWING, 90_deg, 110, false);
chassis.pid_wait();
// This will slew because that's the default forward state
chassis.pid_swing_set(ez::LEFT_SWING, 180_deg, 110);
chassis.pid_wait();
// This will not slew because we haven't set the default backward state
chassis.pid_swing_set(ez::LEFT_SWING, 0_deg, 110);
chassis.pid_wait();
}
slew_swing_backward_set()
Sets the default slew for swing backward motions, can be overwritten in movement functions.
slew_on true enables, false disables
- Prototype
- Example
void slew_swing_backward_set(bool slew_on);
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Set the default slew state to true
chassis.slew_swing_backward_set(true);
// This will not use slew because we explicitly told the robot to not slew
chassis.pid_swing_set(ez::RIGHT_SWING, 90_deg, 110, false);
chassis.pid_wait();
// This will slew because that's the default backward state
chassis.pid_swing_set(ez::RIGHT_SWING, 180_deg, 110);
chassis.pid_wait();
// This will not slew because we haven't set the default forward state
chassis.pid_swing_set(ez::RIGHT_SWING, 0_deg, 110);
chassis.pid_wait();
}
pid_swing_min_set()
When kI and startI are enabled, sets the maximum output allowed while error is inside startI, for swings larger than startI. This lets I accumulate without overshoot. Despite the name this is a cap on the output, not a floor.
min new clipped speed
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_min_set(30);
chassis.pid_swing_set(ez::LEFT_SWING, 45, 110);
chassis.pid_wait();
}
void pid_swing_min_set(int min);
pid_swing_behavior_set()
Sets the default behavior for turns in swinging movements.
behavior ez::shortest, ez::longest, ez::ccw, ez::cw, ez::raw
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_behavior_set(ez::longest); // Set the robot to take the longest path there
// This will make the robot go the long way around to get to 90 degrees
chassis.pid_swing_set(ez::LEFT_SWING, 90_deg, 110);
chassis.pid_wait();
}
void pid_swing_behavior_set(e_angle_behavior behavior);
Getter
pid_swing_constants_get()
Returns the PID constants for swings, as a PID::Constants with kp, ki, kd and start_i. If the forward and backward constants were set to different values, this prints Forward and Reverse constants are not the same! and returns {-1, -1, -1, -1}. Use the forward and backward getters when they differ.
- Prototype
- Example
void initialize() {
chassis.pid_swing_constants_set(6.0, 0.0, 65.0);
ez::PID::Constants c = chassis.pid_swing_constants_get();
printf("kp %.2f ki %.2f kd %.2f start_i %.2f\n", c.kp, c.ki, c.kd, c.start_i); // Prints kp 6.00 ki 0.00 kd 65.00 start_i 0.00
}
PID::Constants pid_swing_constants_get();
pid_swing_constants_forward_get()
Returns the PID constants for forward swings, as a PID::Constants with kp, ki, kd and start_i.
- Prototype
- Example
void initialize() {
chassis.pid_swing_constants_forward_set(6.0, 0.0, 65.0);
ez::PID::Constants c = chassis.pid_swing_constants_forward_get();
printf("kp %.2f ki %.2f kd %.2f start_i %.2f\n", c.kp, c.ki, c.kd, c.start_i); // Prints kp 6.00 ki 0.00 kd 65.00 start_i 0.00
}
PID::Constants pid_swing_constants_forward_get();
pid_swing_constants_backward_get()
Returns the PID constants for backward swings, as a PID::Constants with kp, ki, kd and start_i.
- Prototype
- Example
void initialize() {
chassis.pid_swing_constants_backward_set(6.0, 0.0, 65.0);
ez::PID::Constants c = chassis.pid_swing_constants_backward_get();
printf("kp %.2f ki %.2f kd %.2f start_i %.2f\n", c.kp, c.ki, c.kd, c.start_i); // Prints kp 6.00 ki 0.00 kd 65.00 start_i 0.00
}
PID::Constants pid_swing_constants_backward_get();
slew_swing_forward_get()
Returns true if slew is enabled for all swing forward motions, false otherwise.
- Prototype
- Example
bool slew_swing_forward_get();
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Set the default slew state to true
chassis.slew_swing_forward_set(true);
if (chassis.slew_swing_forward_get())
printf("Slew Forward is Enabled!\n");
// This will not use slew because we explicitly told the robot to not slew
chassis.pid_swing_set(ez::LEFT_SWING, 90_deg, 110, false);
chassis.pid_wait();
// This will slew because that's the default forward state
chassis.pid_swing_set(ez::LEFT_SWING, 180_deg, 110);
chassis.pid_wait();
// This will not slew because we haven't set the default backward state
chassis.pid_swing_set(ez::LEFT_SWING, 0_deg, 110);
chassis.pid_wait();
}
slew_swing_backward_get()
Returns true if slew is enabled for all swing backward motions, false otherwise.
- Prototype
- Example
bool slew_swing_backward_get();
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
// Set the default slew state to true
chassis.slew_swing_backward_set(true);
if (chassis.slew_swing_backward_get())
printf("Slew Backward is Enabled!\n");
// This will not use slew because we explicitly told the robot to not slew
chassis.pid_swing_set(ez::RIGHT_SWING, 90_deg, 110, false);
chassis.pid_wait();
// This will slew because that's the default backward state
chassis.pid_swing_set(ez::RIGHT_SWING, 180_deg, 110);
chassis.pid_wait();
// This will not slew because we haven't set the default forward state
chassis.pid_swing_set(ez::RIGHT_SWING, 0_deg, 110);
chassis.pid_wait();
}
pid_swing_chain_forward_constant_get()
Returns the amount that the PID will overshoot target by to maintain momentum into the next motion for swinging forward.
- Prototype
- Example
void initialize() {
chassis.pid_swing_chain_constant_set(5_deg);
printf("%.2f\n", chassis.pid_swing_chain_forward_constant_get());
}
double pid_swing_chain_forward_constant_get();
pid_swing_chain_backward_constant_get()
Returns the amount that the PID will overshoot target by to maintain momentum into the next motion for swinging backward.
- Prototype
- Example
void initialize() {
chassis.pid_swing_chain_constant_set(5_deg);
printf("%.2f\n", chassis.pid_swing_chain_backward_constant_get());
}
double pid_swing_chain_backward_constant_get();
pid_swing_min_get()
Returns the maximum output allowed while error is inside startI, for swings larger than startI, when kI and startI are enabled.
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_min_set(30);
printf("Swing Min: %i", chassis.pid_swing_min_get());
}
int pid_swing_min_get();
pid_swing_behavior_get()
Returns the turn behavior for swings.
- Prototype
- Example
void autonomous() {
chassis.pid_targets_reset(); // Resets PID targets to 0
chassis.drive_imu_reset(); // Reset gyro position to 0
chassis.drive_sensor_reset(); // Reset drive sensors to 0
chassis.odom_xyt_set(0_in, 0_in, 0_deg); // Set the current position, you can start at a specific position with this
chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency
chassis.pid_swing_behavior_set(ez::longest); // Set the robot to take the longest path there
if (chassis.pid_swing_behavior_get() == ez::longest) {
printf("Current behavior is ez::longest!\n");
} else {
printf("Current behavior is not ez::longest!\n");
}
// This will make the robot go the long way around to get to 90 degrees
chassis.pid_swing_set(ez::LEFT_SWING, 90_deg, 110);
chassis.pid_wait();
}
e_angle_behavior pid_swing_behavior_get();