2.2.0 -> 3.0.0
v3.x has breaking changes from v2.x. This document is intended to help migrate your existing v2.x project.
Function Names​
Inspired by LVGL, all functions have been renamed for improved searchability with autocomplete. Instead of set_
showing you everything that can be set, you can now type drive_
and see everything possible with the drive. If you want to see input curve functions, you can type opcontrol_curve_
and autocomplete will show you those functions.
In VScode, ctrl
+ shift
+ F
allows you to search for and replace every instance of a function call in your project across multiple files. This is the easiest way to upgrade your function calls.
Be sure to check what you're replacing to avoid unintentionally breaking your code.
drive.hpp​
v2.x Name | v3.x Name |
---|---|
tank() | opcontrol_tank() |
arcade_standard() | opcontrol_arcade_standard() |
arcade_flipped() | opcontrol_arcade_flipped() |
init_curve_sd() | opcontrol_curve_sd_initialize() |
set_curve_default() | opcontrol_curve_default_set() |
modify_curve_with_controller() | opcontrol_curve_buttons_iterate() |
toggle_modify_curve_with_controller() | opcontrol_curve_buttons_toggle() |
set_left_curve_buttons() | opcontrol_curve_buttons_left_set() |
set_right_curve_buttons() | opcontrol_curve_buttons_right_set() |
left_curve_function() | opcontrol_curve_left() |
right_curve_function() | opcontrol_curve_right() |
reset_drive_sensors_opcontrol() | opcontrol_drive_sensors_reset() |
set_active_brake() | opcontrol_drive_activebrake_set() |
set_joystick_threshold() | opcontrol_joystick_threshold_set() |
joy_thresh_opcontrol() | opcontrol_joystick_threshold_opcontrol() |
toggle_practice_mode() | opcontrol_joystick_practicemode_toggle() |
set_tank() | drive_set() |
set_drive_brake() | drive_brake_set() |
reset_drive_sensor() | drive_sensor_reset() |
right_sensor() | drive_sensor_right() |
raw_right_sensor() | drive_sensor_right_raw() |
left_sensor() | drive_sensor_left() |
raw_left_sensor() | drive_sensor_left_raw() |
right_velocity() | drive_velocity_right() |
left_velocity() | drive_velocity_left() |
right_mA() | drive_mA_right() |
left_mA() | drive_mA_left() |
right_over_current() | drive_current_right_over() |
left_over_current() | drive_current_left_over() |
reset_gyro() | drive_imu_reset() |
get_gyro() | drive_imu_get() |
set_mode() | drive_mode_set() |
get_mode() | drive_mode_get() |
imu_calibrate() | drive_imu_calibrate() |
imu_loading_display() | drive_imu_display_loading() |
set_angle() | drive_angle_set() |
get_tick_per_inch() | drive_tick_per_inch() |
set_defaults() | drive_defaults_set() |
set_ratio() | drive_ratio_set() |
set_drive_current_limit() | drive_current_limit_set() |
set_drive_pid() | pid_drive_set() |
set_turn_pid() | pid_turn_set() |
set_swing_pid() | pid_swing_set() |
reset_pid_targets() | pid_targets_reset() |
wait_drive() | pid_wait() |
wait_until() | pid_wait_until() |
set_max_speed() | pid_speed_max_set() |
set_swing_min() | pid_swing_min_set() |
set_turn_min() | pid_turn_min_set() |
toggle_auto_drive() | pid_drive_toggle() |
toggle_auto_print() | pid_print_toggle() |
set_drive_exit_condition() | pid_drive_exit_condition_set() |
set_turn_exit_condition() | pid_durn_exit_condition_set() |
set_swing_exit_condition() | pid_swing_exit_condition_set() |
get_swing_min() | pid_swing_min_get() |
get_turn_min() | pid_turn_min_get() |
pid.hpp​
v2.x Name | v3.x Name |
---|---|
set_constants() | constants_set() |
get_constants() | constants_get() |
set_target() | target_set() |
get_target() | target_get() |
set_name() | name_set() |
is_name() | name_active() |
print_exit() | exit_condition_print() |
set_exit_condition() | exit_condition_set() |
reset_variables() | variables_reset() |
reset_timers() | timers_reset() |
auton_selector.hpp​
v2.x Name | v3.x Name |
---|---|
call_selected_auton() | selected_auton_call() |
print_selected_auton() | selected_auton_print() |
add_autons() | autons_add() |
current_auton_page() | auton_page_current() |
Drive PID Constants​
In v2.x, all sensor data for the drive was handled in raw ticks. This stopped the user from being able to add tracking wheels retroactively easily without completely retuning all constants. v3.x handles drive sensor data in inches. This means if a user adds tracking wheels retroactively, all PID constants will be transferable.
This means drive forward PID, backward PID, and active brake are not transferable to v3.x.
Set PID Constants​
Setting PID constants has been changed to have a function per PID object.
void default_constants() {
// Drive Constants
chassis.pid_drive_constants_set(10, 0, 100); // Sets forward and backward
chassis.pid_drive_constants_forward_set(10, 0, 100);
chassis.pid_drive_constants_backward_set(10, 0, 100);
chassis.pid_heading_constants_set(3, 0, 20);
// Turn Constants
chassis.pid_turn_constants_set(3, 0, 20);
// Swing Constants
chassis.pid_swing_constants_set(5, 0, 30); // Sets forward and backward
chassis.pid_swing_constants_forward_set(5, 0, 30);
chassis.pid_swing_constants_backward_set(5, 0, 30);
}
Set Slew Constants​
Slew has been extracted into a class and has been implemented into every type of movement.
void default_constants() {
// Drive Constants
chassis.slew_drive_constants_set(7_in, 80); // Sets forward and backward
chassis.slew_drive_constants_forward_set(7_in, 80);
chassis.slew_drive_constants_backward_set(7_in, 80);
// Turn Constants
chassis.slew_turn_constants_set(5_deg, 50);
// Swing Constants with Angle
chassis.slew_swing_constants_set(5_deg, 50); // Sets forward and backward
chassis.slew_swing_constants_forward_set(5_deg, 50);
chassis.slew_swing_constants_backward_set(5_deg, 50);
// Swing Constants with Distance
chassis.slew_swing_constants_set(7_in, 50); // Sets forward and backward
chassis.slew_swing_constants_forward_set(7_in, 50);
chassis.slew_swing_constants_backward_set(5_in, 50);
}