Movements
Functions with Okapi Units​
pid_odom_set()​
Sets the robot to go forward/backward the distance you give it, but it uses odometry, without slew.
p_target
is in an okapi length unit.
speed
is 0 to 127. It's recommended to keep this at 110.
- 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.odom_odom_set(24_in, 110);
chassis.pid_wait();
}
void pid_odom_set(okapi::QLength p_target, int speed);
pid_odom_set()​
Sets the robot to go forward/backward the distance you give it, but it uses odometry.
p_target
is in an okapi length unit.
speed
is 0 to 127. It's recommended to keep this at 110.
slew_on
increases the speed of the drive gradually. You must set slew constants for this to work!
- 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.odom_odom_set(24_in, 110, true);
chassis.pid_wait();
}
void pid_odom_set(okapi::QLength p_target, int speed, bool slew_on);
pid_odom_set()​
Go to an xy coordinate without slew. This is a wrapper for pid_odom_ptp_set()
.
p_imovement
united_pose, expecting {0_in, 0_in}
- Prototype
- Example
void pid_odom_set(united_odom p_imovement);
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.odom_odom_set({{24_in, 24_in}, fwd, 110});
chassis.pid_wait();
}
pid_odom_set()​
Go to an xy coordinate with slew. This is a wrapper for pid_odom_ptp_set()
.
p_imovement
united_pose, expecting {0_in, 0_in}
slew_on
increases the speed of the drive gradually. You must set slew constants for this to work!
- Prototype
- Example
void pid_odom_set(united_odom p_imovement, 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
chassis.odom_odom_set({{24_in, 24_in}, fwd, 110}, true);
chassis.pid_wait();
}