LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
drive.hpp
Go to the documentation of this file.
1/*
2This Source Code Form is subject to the terms of the Mozilla Public
3License, v. 2.0. If a copy of the MPL was not distributed with this
4file, You can obtain one at http://mozilla.org/MPL/2.0/.
5*/
6
7#pragma once
8
9#include <functional>
10#include <iostream>
11#include <tuple>
12
17#include "light/motor_group.hpp"
18#include "light/motors.h"
19#include "light/units.hpp"
20
21using namespace light;
22
34namespace light {
35
37using PoseGetterFn = pose (*)();
39using PoseSetterFn = void (*)(pose);
40
55
72class Drive {
73 public:
80
84 pros::motor_brake_mode_e_t CURRENT_BRAKE = pros::E_MOTOR_BRAKE_COAST;
85
89 int CURRENT_MA = 2500;
90
95
99 std::vector<pros::Motor> left_motors;
100
104 std::vector<pros::Motor> right_motors;
105
109 std::vector<int> pto_active;
110
114 pros::Imu imu;
115
119 pros::adi::Encoder left_tracker;
120
124 pros::adi::Encoder right_tracker;
125
129 pros::Rotation left_rotation;
130
134 pros::Rotation right_rotation;
135
140
145
150
155
178
190
198 double friction_kS = 0.0;
199 double friction_kV = 0.0;
200 double friction_kQ = 0.0;
201
209 void friction_constants_set(double kS, double kV = 0.0, double kQ = 0.0);
210
214 std::vector<double> friction_constants_get();
215
220 double friction_ff(double v_target);
221
232 void slew_swing_constants_set(okapi::QLength distance, int min_speed);
233
244 void slew_swing_constants_forward_set(okapi::QLength distance, int min_speed);
245
256 void slew_swing_constants_backward_set(okapi::QLength distance, int min_speed);
257
268 void slew_swing_constants_set(okapi::QAngle distance, int min_speed);
269
280 void slew_swing_constants_forward_set(okapi::QAngle distance, int min_speed);
281
292 void slew_swing_constants_backward_set(okapi::QAngle distance, int min_speed);
293
304 void slew_turn_constants_set(okapi::QAngle distance, int min_speed);
305
316 void slew_drive_constants_forward_set(okapi::QLength distance, int min_speed);
317
328 void slew_drive_constants_backward_set(okapi::QLength distance, int min_speed);
329
340 void slew_drive_constants_set(okapi::QLength distance, int min_speed);
341
348 void slew_drive_set(bool slew_on);
349
356 void slew_drive_forward_set(bool slew_on);
357
362
369 void slew_drive_backward_set(bool slew_on);
370
375
382 void slew_swing_set(bool slew_on);
383
390 void slew_swing_forward_set(bool slew_on);
391
396
403 void slew_swing_backward_set(bool slew_on);
404
409
416 void slew_turn_set(bool slew_on);
417
422
429 void slew_odom_reenable(bool reenable);
430
435
440
449 void drive_mode_set(e_mode p_mode, bool stop_drive = true);
450
455
460
464 pros::Task ez_auto;
465
482 Drive(std::vector<int> left_motor_ports, std::vector<int> right_motor_ports, int imu_port, double wheel_diameter, double ticks, double ratio = 1.0);
483
504 Drive(std::vector<int> left_motor_ports, std::vector<int> right_motor_ports, int imu_port, double wheel_diameter, double ticks, double ratio, std::vector<int> left_tracker_ports, std::vector<int> right_tracker_ports) __attribute__((deprecated("Use the integrated encoder constructor with odom_tracker_left_set() and odom_tracker_right_set() instead!")));
505
528 Drive(std::vector<int> left_motor_ports, std::vector<int> right_motor_ports, int imu_port, double wheel_diameter, double ticks, double ratio, std::vector<int> left_tracker_ports, std::vector<int> right_tracker_ports, int expander_smart_port) __attribute__((deprecated("Use the integrated encoder constructor with odom_tracker_left_set() and odom_tracker_right_set() instead!")));
529
548 Drive(std::vector<int> left_motor_ports, std::vector<int> right_motor_ports, int imu_port, double wheel_diameter, double ratio, int left_rotation_port, int right_rotation_port) __attribute__((deprecated("Use the integrated encoder constructor with odom_tracker_left_set() and odom_tracker_right_set() instead!")));
549
554
556 //
557 // General Odometry
558 //
560
565
572 void odom_enable(bool input);
573
580
589 void drive_width_set(double input);
590
599 void drive_width_set(okapi::QLength p_input);
600
605
612 void odom_x_set(double x);
613
620 void odom_x_set(okapi::QLength p_x);
621
625 double odom_x_get();
626
633 void odom_y_set(double y);
634
641 void odom_y_set(okapi::QLength p_y);
642
646 double odom_y_get();
647
654 void odom_theta_set(double a);
655
662 void odom_theta_set(okapi::QAngle p_a);
663
668
675 void odom_pose_set(pose itarget);
676
684
693 void odom_xy_set(double x, double y);
694
703 void odom_xy_set(okapi::QLength p_x, okapi::QLength p_y);
704
715 void odom_xyt_set(double x, double y, double t);
716
727 void odom_xyt_set(okapi::QLength p_x, okapi::QLength p_y, okapi::QAngle p_t);
728
733
738
745 void odom_x_flip(bool flip = true);
746
753
760 void odom_y_flip(bool flip = true);
761
768
775 void odom_theta_flip(bool flip = true);
776
783
792 void odom_boomerang_dlead_set(double input);
793
798
805 void odom_boomerang_distance_set(double distance);
806
813 void odom_boomerang_distance_set(okapi::QLength p_distance);
814
819
828 void odom_turn_bias_set(double bias);
829
834
841 void odom_path_spacing_set(double spacing);
842
849 void odom_path_spacing_set(okapi::QLength p_spacing);
850
855
868 void odom_path_smooth_constants_set(double weight_smooth, double weight_data, double tolerance);
869
878 std::vector<double> odom_path_smooth_constants_get();
879
884
891 void odom_look_ahead_set(double distance);
892
899 void odom_look_ahead_set(okapi::QLength p_distance);
900
905
913
921
929
937
945
953
961
969
974
979
984
991 void pid_angle_behavior_tolerance_set(okapi::QAngle p_tolerance);
992
999 void pid_angle_behavior_tolerance_set(double tolerance);
1000
1005
1013
1018
1020 //
1021 // User Control
1022 //
1024
1033
1045
1057
1062
1071 void opcontrol_curve_default_set(double left, double right = 0);
1072
1076 std::vector<double> opcontrol_curve_default_get();
1077
1090 void opcontrol_drive_activebrake_set(double kp, double ki = 0.0, double kd = 0.0, double start_i = 0.0);
1091
1096
1101
1109
1116
1125 void opcontrol_curve_buttons_left_set(pros::controller_digital_e_t decrease, pros::controller_digital_e_t increase);
1126
1130 std::vector<pros::controller_digital_e_t> opcontrol_curve_buttons_left_get();
1131
1140 void opcontrol_curve_buttons_right_set(pros::controller_digital_e_t decrease, pros::controller_digital_e_t increase);
1141
1145 std::vector<pros::controller_digital_e_t> opcontrol_curve_buttons_right_get();
1146
1155 double opcontrol_curve_left(double x);
1156
1165 double opcontrol_curve_right(double x);
1166
1176
1181
1186
1195 void opcontrol_joystick_threshold_iterate(int l_stick, int r_stick);
1196
1198 //
1199 // PTO
1200 //
1202
1211 bool pto_check(pros::Motor check_if_pto);
1212
1221 void pto_add(std::vector<pros::Motor> pto_list);
1222
1229 void pto_remove(std::vector<pros::Motor> pto_list);
1230
1241 void pto_toggle(std::vector<pros::Motor> pto_list, bool toggle);
1242
1244 //
1245 // PROS Wrappers
1246 //
1248
1259 void drive_set(int left, int right);
1260
1264 std::vector<int> drive_get();
1265
1272 void drive_brake_set(pros::motor_brake_mode_e_t brake_type);
1273
1277 pros::motor_brake_mode_e_t drive_brake_get();
1278
1286
1291
1298 void pid_drive_toggle(bool toggle);
1299
1308
1315 void pid_print_toggle(bool toggle);
1316
1325
1327 //
1328 // Telemetry
1329 //
1331
1338
1345
1350
1355
1360
1367
1374
1379
1384
1389
1394
1401 void drive_imu_reset(double new_heading = 0);
1402
1407
1412
1421 void drive_imu_scaler_set(double scaler);
1422
1427
1434 bool drive_imu_calibrate(bool run_loading_animation = true);
1435
1442
1447
1455
1462
1470
1477
1479 //
1480 // Autonomous Functions
1481 //
1483
1494 void pid_odom_set(double target, int speed);
1495
1508 void pid_odom_set(double target, int speed, bool slew_on);
1509
1520 void pid_odom_set(okapi::QLength p_target, int speed);
1521
1536 void pid_odom_set(okapi::QLength p_target, int speed, bool slew_on);
1537
1544 void pid_odom_set(odom imovement);
1545
1554 void pid_odom_set(odom imovement, bool slew_on);
1555
1562 void pid_odom_ptp_set(odom imovement);
1563
1572 void pid_odom_ptp_set(odom imovement, bool slew_on);
1573
1581
1590 void pid_odom_boomerang_set(odom imovement, bool slew_on);
1591
1599
1608 void pid_odom_boomerang_set(united_odom p_imovement, bool slew_on);
1609
1617
1626 void pid_odom_ptp_set(united_odom p_imovement, bool slew_on);
1627
1634 void pid_odom_set(united_odom p_imovement);
1635
1644 void pid_odom_set(united_odom p_imovement, bool slew_on);
1645
1652 void pid_odom_set(std::vector<odom> imovements);
1653
1662 void pid_odom_set(std::vector<odom> imovements, bool slew_on);
1663
1670 void pid_odom_pp_set(std::vector<odom> imovements);
1671
1680 void pid_odom_pp_set(std::vector<odom> imovements, bool slew_on);
1681
1688 void pid_odom_injected_pp_set(std::vector<odom> imovements);
1689
1698 void pid_odom_injected_pp_set(std::vector<odom> imovements, bool slew_on);
1699
1706 void pid_odom_smooth_pp_set(std::vector<odom> imovements);
1707
1716 void pid_odom_smooth_pp_set(std::vector<odom> imovements, bool slew_on);
1717
1724 void pid_odom_smooth_pp_set(std::vector<united_odom> p_imovements);
1725
1734 void pid_odom_smooth_pp_set(std::vector<united_odom> p_imovements, bool slew_on);
1735
1742 void pid_odom_injected_pp_set(std::vector<united_odom> p_imovements);
1743
1752 void pid_odom_injected_pp_set(std::vector<united_odom> p_imovements, bool slew_on);
1753
1760 void pid_odom_pp_set(std::vector<united_odom> p_imovements);
1761
1770 void pid_odom_pp_set(std::vector<united_odom> p_imovements, bool slew_on);
1771
1778 void pid_odom_set(std::vector<united_odom> p_imovements);
1779
1788 void pid_odom_set(std::vector<united_odom> p_imovements, bool slew_on);
1789
1798 void pid_drive_set(okapi::QLength p_target, int speed);
1799
1812 void pid_drive_set(okapi::QLength p_target, int speed, bool slew_on, bool toggle_heading = true);
1813
1822 void pid_drive_set(double target, int speed);
1823
1836 void pid_drive_set(double target, int speed, bool slew_on, bool toggle_heading = true);
1837
1846 void pid_turn_set(pose itarget, drive_directions dir, int speed);
1847
1858 void pid_turn_set(pose itarget, drive_directions dir, int speed, bool slew_on);
1859
1870 void pid_turn_set(pose itarget, drive_directions dir, int speed, e_angle_behavior behavior);
1871
1884 void pid_turn_set(pose itarget, drive_directions dir, int speed, e_angle_behavior behavior, bool slew_on);
1885
1894 void pid_turn_set(united_pose p_itarget, drive_directions dir, int speed);
1895
1906 void pid_turn_set(united_pose p_itarget, drive_directions dir, int speed, bool slew_on);
1907
1918 void pid_turn_set(united_pose p_itarget, drive_directions dir, int speed, e_angle_behavior behavior);
1919
1932 void pid_turn_set(united_pose p_itarget, drive_directions dir, int speed, e_angle_behavior behavior, bool slew_on);
1933
1944 void pid_turn_set(double target, int speed);
1945
1956 void pid_turn_set(double target, int speed, e_angle_behavior behavior);
1957
1968 void pid_turn_set(double target, int speed, bool slew_on);
1969
1982 void pid_turn_set(double target, int speed, e_angle_behavior behavior, bool slew_on);
1983
1992 void pid_turn_set(okapi::QAngle p_target, int speed);
1993
2004 void pid_turn_set(okapi::QAngle p_target, int speed, e_angle_behavior behavior);
2005
2016 void pid_turn_set(okapi::QAngle p_target, int speed, bool slew_on);
2017
2030 void pid_turn_set(okapi::QAngle p_target, int speed, e_angle_behavior behavior, bool slew_on);
2031
2040 void pid_turn_relative_set(okapi::QAngle p_target, int speed);
2041
2052 void pid_turn_relative_set(okapi::QAngle p_target, int speed, e_angle_behavior behavior);
2053
2064 void pid_turn_relative_set(okapi::QAngle p_target, int speed, bool slew_on);
2065
2078 void pid_turn_relative_set(okapi::QAngle p_target, int speed, e_angle_behavior behavior, bool slew_on);
2079
2088 void pid_turn_relative_set(double target, int speed);
2089
2100 void pid_turn_relative_set(double target, int speed, e_angle_behavior behavior);
2101
2112 void pid_turn_relative_set(double target, int speed, bool slew_on);
2113
2126 void pid_turn_relative_set(double target, int speed, e_angle_behavior behavior, bool slew_on);
2127
2138 void pid_swing_set(e_swing type, double target, int speed);
2139
2152 void pid_swing_set(e_swing type, double target, int speed, e_angle_behavior behavior);
2153
2166 void pid_swing_set(e_swing type, double target, int speed, bool slew_on);
2167
2180 void pid_swing_set(e_swing type, double target, int speed, e_angle_behavior behavior, bool slew_on);
2181
2194 void pid_swing_set(e_swing type, double target, int speed, int opposite_speed);
2195
2208 void pid_swing_set(e_swing type, double target, int speed, int opposite_speed, e_angle_behavior behavior);
2209
2224 void pid_swing_set(e_swing type, double target, int speed, int opposite_speed, bool slew_on);
2225
2242 void pid_swing_set(e_swing type, double target, int speed, int opposite_speed, e_angle_behavior behavior, bool slew_on);
2243
2254 void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed);
2255
2268 void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, e_angle_behavior behavior);
2269
2282 void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, bool slew_on);
2283
2298 void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, e_angle_behavior behavior, bool slew_on);
2299
2312 void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed);
2313
2328 void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, e_angle_behavior behavior);
2329
2344 void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, bool slew_on);
2345
2362 void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, e_angle_behavior behavior, bool slew_on);
2363
2374 void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed);
2375
2386 void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, e_angle_behavior behavior);
2387
2398 void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, bool slew_on);
2399
2410 void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, e_angle_behavior behavior, bool slew_on);
2411
2424 void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed);
2425
2438 void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, e_angle_behavior behavior);
2439
2452 void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, bool slew_on);
2453
2466 void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, e_angle_behavior behavior, bool slew_on);
2467
2478 void pid_swing_relative_set(e_swing type, double target, int speed);
2479
2490 void pid_swing_relative_set(e_swing type, double target, int speed, e_angle_behavior behavior);
2491
2502 void pid_swing_relative_set(e_swing type, double target, int speed, bool slew_on);
2503
2514 void pid_swing_relative_set(e_swing type, double target, int speed, e_angle_behavior behavior, bool slew_on);
2515
2528 void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed);
2529
2542 void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed, e_angle_behavior behavior);
2543
2556 void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed, bool slew_on);
2557
2570 void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed, e_angle_behavior behavior, bool slew_on);
2571
2576
2580 void drive_angle_set(okapi::QAngle p_angle);
2581
2585 void drive_angle_set(double angle);
2586
2590 void pid_wait();
2591
2598 void pid_wait_until(okapi::QAngle target);
2599
2606 void pid_wait_until(okapi::QLength target);
2607
2614 void pid_wait_until(double target);
2615
2622
2631
2638 void pid_wait_until_index(int index);
2639
2647
2655
2663
2672 void pid_wait_until(pose target);
2673
2683
2689 bool interfered = false;
2690
2697 void drive_ratio_set(double ratio);
2698
2705 void drive_rpm_set(double rpm);
2706
2711
2716
2723 void pid_speed_max_set(int speed);
2724
2729
2742 void pid_turn_constants_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
2743
2748
2757 void pid_turn_chain_constant_set(okapi::QAngle input);
2758
2768
2773
2786 void pid_swing_constants_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
2787
2794
2807 void pid_swing_constants_forward_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
2808
2813
2826 void pid_swing_constants_backward_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
2827
2832
2841 void pid_swing_chain_constant_set(okapi::QAngle input);
2842
2851 void pid_swing_chain_forward_constant_set(okapi::QAngle input);
2852
2861 void pid_swing_chain_backward_constant_set(okapi::QAngle input);
2862
2872
2882
2887
2897
2902
2915 void pid_heading_constants_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
2916
2921
2934 void pid_drive_constants_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
2935
2942
2955 void pid_drive_constants_forward_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
2956
2961
2974 void pid_drive_constants_backward_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
2975
2980
2989 void pid_drive_chain_constant_set(okapi::QLength input);
2990
2999 void pid_drive_chain_forward_constant_set(okapi::QLength input);
3000
3009 void pid_drive_chain_backward_constant_set(okapi::QLength input);
3010
3020
3030
3035
3045
3050
3057 void pid_swing_min_set(int min);
3058
3065 void pid_turn_min_set(int min);
3066
3071
3076
3089 void pid_odom_angular_constants_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
3090
3103 void pid_odom_boomerang_constants_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
3104
3123 void pid_odom_drive_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);
3124
3143 void pid_odom_turn_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);
3144
3163 void pid_odom_turn_exit_condition_set(okapi::QTime p_small_exit_time, okapi::QAngle p_small_error, okapi::QTime p_big_exit_time, okapi::QAngle p_big_error, okapi::QTime p_velocity_exit_time, okapi::QTime p_mA_timeout, bool use_imu = true);
3164
3183 void pid_odom_drive_exit_condition_set(okapi::QTime p_small_exit_time, okapi::QLength p_small_error, okapi::QTime p_big_exit_time, okapi::QLength p_big_error, okapi::QTime p_velocity_exit_time, okapi::QTime p_mA_timeout, bool use_imu = true);
3184
3203 void pid_drive_exit_condition_set(okapi::QTime p_small_exit_time, okapi::QLength p_small_error, okapi::QTime p_big_exit_time, okapi::QLength p_big_error, okapi::QTime p_velocity_exit_time, okapi::QTime p_mA_timeout, bool use_imu = true);
3204
3223 void pid_turn_exit_condition_set(okapi::QTime p_small_exit_time, okapi::QAngle p_small_error, okapi::QTime p_big_exit_time, okapi::QAngle p_big_error, okapi::QTime p_velocity_exit_time, okapi::QTime p_mA_timeout, bool use_imu = true);
3224
3243 void pid_swing_exit_condition_set(okapi::QTime p_small_exit_time, okapi::QAngle p_small_error, okapi::QTime p_big_exit_time, okapi::QAngle p_big_error, okapi::QTime p_velocity_exit_time, okapi::QTime p_mA_timeout, bool use_imu = true);
3244
3263 void pid_drive_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);
3264
3283 void pid_turn_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);
3284
3303 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);
3304
3309
3314
3319
3324
3329
3336
3341
3349
3357
3362
3367
3375
3383
3391
3399
3404
3409
3414
3419
3426 void pid_tuner_full_enable(bool enable);
3427
3434
3436 std::string name = "";
3438 };
3439
3443 std::vector<const_and_name> pid_tuner_pids = {
3444 {"Drive PID Constants", &fwd_rev_drivePID.constants},
3445 {"Odom Angular PID Constants", &odom_angularPID.constants},
3446 {"Boomerang Angular PID Constants", &boomerangPID.constants},
3447 {"Heading PID Constants", &headingPID.constants},
3448 {"Turn PID Constants", &turnPID.constants},
3449 {"Swing PID Constants", &fwd_rev_swingPID.constants}};
3450
3454 std::vector<const_and_name> pid_tuner_full_pids = {
3455 {"Drive Forward PID Constants", &forward_drivePID.constants},
3456 {"Drive Backward PID Constants", &backward_drivePID.constants},
3457 {"Odom Angular PID Constants", &odom_angularPID.constants},
3458 {"Boomerang Angular PID Constants", &boomerangPID.constants},
3459 {"Heading PID Constants", &headingPID.constants},
3460 {"Turn PID Constants", &turnPID.constants},
3461 {"Swing Forward PID Constants", &forward_swingPID.constants},
3462 {"Swing Backward PID Constants", &backward_swingPID.constants}};
3463
3471
3476
3483 void opcontrol_arcade_scaling(bool enable);
3484
3489
3490 private:
3491 void opcontrol_drive_activebrake_targets_set();
3492 double odom_smooth_weight_smooth = 0.0;
3493 double odom_smooth_weight_data = 0.0;
3494 double odom_smooth_tolerance = 0.0;
3495 bool odom_use_left = true;
3496 double odom_ime_track_width_left = 0.0;
3497 double odom_ime_track_width_right = 0.0;
3498 bool imu_calibrate_took_too_long = false;
3499 bool is_full_pid_tuner_enabled = false;
3500 std::vector<const_and_name>* used_pid_tuner_pids;
3501 double opcontrol_speed_max = 127.0;
3502 bool arcade_vector_scaling = false;
3503 // odom privates
3504 std::vector<odom> pp_movements;
3505 std::vector<int> injected_pp_index;
3506 int pp_index = 0;
3507 std::vector<odom> smooth_path(std::vector<odom> ipath, double weight_smooth, double weight_data, double tolerance);
3508 double is_past_target(pose target, pose current);
3509 void raw_pid_odom_pp_set(std::vector<odom> imovements, bool slew_on);
3510 bool ptf1_running = false;
3511 std::vector<pose> find_point_to_face(pose current, pose target, drive_directions dir, bool set_global);
3512 void raw_pid_odom_ptp_set(odom imovement, bool slew_on);
3513 std::vector<odom> inject_points(std::vector<odom> imovements);
3514 std::vector<pose> point_to_face = {{0, 0, 0}, {0, 0, 0}};
3515 double turn_is_toleranced(double target, double current, double input, double longest, double shortest);
3516 double turn_short(double target, double current, bool print = false);
3517 double turn_long(double target, double current, bool print = false);
3518 double new_turn_target_compute(double target, double current, light::e_angle_behavior behavior);
3519 double turn_left(double target, double current, bool print = false);
3520 double turn_right(double target, double current, bool print = false);
3521 bool imu_calibration_complete = false;
3522 bool is_swing_slew_enabled(e_swing type, double target, double current);
3523 bool slew_reenables_when_max_speed_changes = true;
3524 int slew_min_when_it_enabled = 0;
3525 bool slew_will_enable_later = false;
3526 bool current_slew_on = false;
3527 bool is_odom_turn_bias_enabled = true;
3528 bool odom_turn_bias_enabled();
3529 void odom_turn_bias_enable(bool set);
3530 double angle_rad = 0.0;
3531 double global_track_width = 0.0;
3532 bool odometry_enabled = true;
3533 pose odom_target = {0.0, 0.0, 0.0};
3534 pose odom_current = {0.0, 0.0, 0.0};
3535 pose odom_second_to_last = {0.0, 0.0, 0.0};
3536 pose odom_start = {0.0, 0.0, 0.0};
3537 pose odom_target_start = {0.0, 0.0, 0.0};
3538 pose turn_to_point_target = {0.0, 0.0, 0.0};
3539 bool y_flipped = false;
3540 bool x_flipped = false;
3541 bool theta_flipped = false;
3542 double flip_angle_target(double target);
3543 double odom_imu_start = 0.0;
3544 int past_target = 0;
3545 double SPACING = 0.5;
3546 double LOOK_AHEAD = 7.0;
3547 double dlead = 0.5;
3548 double max_boomerang_distance = 12.0;
3549 double odom_turn_bias_amount = 1.375;
3550 drive_directions current_drive_direction = fwd;
3551 double h_last = 0.0, t_last = 0.0, l_last = 0.0, r_last = 0.0;
3552 pose l_pose{0.0, 0.0, 0.0};
3553 pose r_pose{0.0, 0.0, 0.0};
3554 pose central_pose{0.0, 0.0, 0.0};
3555 double xy_current_fake = 0.0;
3556 double xy_last_fake = 0.0;
3557 double xy_delta_fake = 0.0;
3558 double new_current_fake = 0.0;
3559 bool was_odom_just_set = false;
3560 std::pair<float, float> decide_vert_sensor(light::tracking_wheel* tracker, bool is_tracker_enabled, float ime = 0.0, float ime_track = 0.0);
3561 pose solve_xy_vert(float p_track_width, float current_t, float delta_vert, float delta_t);
3562 pose solve_xy_horiz(float p_track_width, float current_t, float delta_horiz, float delta_t);
3563 bool was_last_pp_mode_boomerang = false;
3564 bool global_forward_drive_slew_enabled = false;
3565 bool global_backward_drive_slew_enabled = false;
3566 bool global_forward_swing_slew_enabled = false;
3567 bool global_backward_swing_slew_enabled = false;
3568 double turn_tolerance = 3.0;
3569 bool global_turn_slew_enabled = false;
3570 e_angle_behavior current_angle_behavior = raw;
3571 e_angle_behavior default_swing_type = raw;
3572 e_angle_behavior default_turn_type = raw;
3573 e_angle_behavior default_odom_type = shortest;
3574 bool turn_biased_left = false;
3575 std::vector<odom> set_odoms_direction(std::vector<odom> inputs);
3576 odom set_odom_direction(odom input);
3577 pose flip_pose(pose input);
3578 bool odom_tracker_left_enabled = false;
3579 bool odom_tracker_right_enabled = false;
3580 bool odom_tracker_front_enabled = false;
3581 bool odom_tracker_back_enabled = false;
3582
3583 double chain_target_start = 0.0;
3584 double chain_sensor_start = 0.0;
3585 double drive_forward_motion_chain_scale = 0.0;
3586 double drive_backward_motion_chain_scale = 0.0;
3587 double swing_forward_motion_chain_scale = 0.0;
3588 double swing_backward_motion_chain_scale = 0.0;
3589 double turn_motion_chain_scale = 0.0;
3590 double used_motion_chain_scale = 0.0;
3591 bool motion_chain_backward = false;
3592
3593 double IMU_SCALER = 1.0;
3594
3595 bool drive_toggle = true;
3596 bool print_toggle = true;
3597 int swing_min = 0;
3598 int turn_min = 0;
3599 bool practice_mode_is_on = false;
3600 int swing_opposite_speed = 0;
3601 bool slew_swing_fwd_using_angle = false;
3602 bool slew_swing_rev_using_angle = false;
3603 bool slew_swing_using_angle = false;
3604 bool pid_tuner_terminal_b = false;
3605 bool pid_tuner_lcd_b = true;
3606 void pid_tuner_print();
3607 void pid_tuner_value_modify(float p, float i, float d, float start);
3608 void pid_tuner_value_increase();
3609 void pid_tuner_value_decrease();
3610 void pid_tuner_print_brain();
3611 void pid_tuner_print_terminal();
3612 void pid_tuner_brain_init();
3613 int column = 0;
3614 int row = 0;
3615 std::string arrow = " <--\n";
3616 bool last_controller_curve_state = false;
3617 bool last_auton_selector_state = false;
3618 bool pid_tuner_on = false;
3619 std::string complete_pid_tuner_output = "";
3620 float p_increment = 0.1, i_increment = 0.001, d_increment = 0.25, start_i_increment = 1.0;
3621
3625 void wait_until_drive(double target);
3626 void wait_until_turn_swing(double target);
3627
3636 void private_drive_set(int left, int right);
3637
3641 int clipped_joystick(int joystick);
3642
3646 bool heading_on = true;
3647
3651 double TICK_PER_REV;
3652 double TICK_PER_INCH;
3653 double CIRCUMFERENCE;
3654
3655 double CARTRIDGE;
3656 double RATIO;
3657 double WHEEL_DIAMETER;
3658
3662 int max_speed;
3663
3667 void drive_pid_task();
3668 void swing_pid_task();
3669 void turn_pid_task();
3670 void ez_auto_task();
3671 void ptp_task();
3672 void boomerang_task();
3673 void pp_task();
3674
3678 double l_start = 0;
3679 double r_start = 0;
3680
3684 bool disable_controller = true; // True enables, false disables.
3685
3689 bool is_tank;
3690
3691#define DRIVE_INTEGRATED 1
3692#define DRIVE_ADI_ENCODER 2
3693#define DRIVE_ROTATION 3
3694#define ODOM_TRACKER 4
3695
3699 int is_tracker = DRIVE_INTEGRATED;
3700
3704 void save_l_curve_sd();
3705 void save_r_curve_sd();
3706
3710 struct button_ {
3711 bool lock = false;
3712 bool release_reset = false;
3713 int release_timer = 0;
3714 int hold_timer = 0;
3715 int increase_timer;
3716 pros::controller_digital_e_t button;
3717 };
3718
3719 button_ l_increase_;
3720 button_ l_decrease_;
3721 button_ r_increase_;
3722 button_ r_decrease_;
3723
3727 void button_press(button_* input_name, int button, std::function<void()> changeCurve, std::function<void()> save);
3728
3732 double left_curve_scale;
3733 double right_curve_scale;
3734
3738 void l_decrease();
3739 void l_increase();
3740 void r_decrease();
3741 void r_increase();
3742
3746 bool is_reversed = false;
3747};
3748}; // namespace light
Tank-drive chassis class.
Definition drive.hpp:72
void opcontrol_arcade_standard(e_type stick_type)
Sets the chassis to controller joysticks using standard arcade control, where left stick is fwd/rev.
void odom_theta_flip(bool flip=true)
Flips the rotation axis.
void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, e_angle_behavior behavior)
Sets the robot to turn using only the left or right side relative to initial heading with okapi units...
void pid_wait_until_point(pose target)
Lock the code in a while loop until this point has been passed.
void pid_drive_exit_condition_set(okapi::QTime p_small_exit_time, okapi::QLength p_small_error, okapi::QTime p_big_exit_time, okapi::QLength p_big_error, okapi::QTime p_velocity_exit_time, okapi::QTime p_mA_timeout, bool use_imu=true)
Set's constants for drive exit conditions.
double opcontrol_curve_right(double x)
Outputs a curve from 5225A In the Zone.
void pid_wait_until(pose target)
Lock the code in a while loop until this point has been passed.
void pid_swing_chain_forward_constant_set(okapi::QAngle input)
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
void opcontrol_speed_max_set(int speed)
Sets the max speed for user control.
double drive_tick_per_inch()
Returns current tick_per_inch.
void drive_imu_scaler_set(double scaler)
Sets a new imu scaling factor.
void pid_odom_pp_set(std::vector< odom > imovements)
Takes in odom movements to go through multiple points.
void pid_turn_set(united_pose p_itarget, drive_directions dir, int speed, e_angle_behavior behavior, bool slew_on)
Sets the robot to turn face a point using PID and odometry.
void opcontrol_arcade_flipped(e_type stick_type)
Sets the chassis to controller joysticks using flipped arcade control, where right stick is fwd/rev.
void pid_turn_set(double target, int speed, e_angle_behavior behavior, bool slew_on)
Sets the robot to turn relative to initial heading using PID, using slew if enabled for this motion.
int drive_velocity_left()
The velocity of the left motor.
void pid_tuner_disable()
Disables PID Tuner.
void ez_tracking_task()
Tasks for tracking.
void pid_turn_set(united_pose p_itarget, drive_directions dir, int speed, e_angle_behavior behavior)
Sets the robot to turn face a point using PID and odometry.
void drive_width_set(okapi::QLength p_input)
Sets the width of the drive.
double friction_kS
Friction-feedforward coefficients in motor-command units (-127..127).
Definition drive.hpp:198
void pid_turn_relative_set(double target, int speed, bool slew_on)
Sets the robot to turn relative to current heading using PID without okapi units, using slew if enabl...
void pid_wait_until_point(united_pose target)
Lock the code in a while loop until this point has been passed, with okapi units.
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)
Set's constants for swing exit conditions.
void drive_rpm_set(double rpm)
Set the cartridge/wheel rpm of the robot.
void drive_angle_set(double angle)
Sets heading of imu and target of PID, takes double as an angle.
PID left_activebrakePID
Definition drive.hpp:176
void pid_tuner_print_terminal_set(bool input)
Toggle for printing the display of the PID Tuner to the terminal.
void slew_swing_forward_set(bool slew_on)
Sets the default slew for swing forward motions, can be overwritten in movement functions.
void drive_mode_set(e_mode p_mode, bool stop_drive=true)
Sets current mode of drive.
void pid_swing_set(e_swing type, double target, int speed, int opposite_speed, e_angle_behavior behavior)
Sets the robot to turn using only the left or right side relative to initial heading without okapi un...
void pid_swing_behavior_set(e_angle_behavior behavior)
Sets the default behavior for turns in swinging movements.
bool slew_drive_forward_get()
Returns true if slew is enabled for all drive forward movements, false otherwise.
void pid_odom_set(odom imovement)
Takes in an odom movement to go to a single point.
void pid_swing_set(e_swing type, double target, int speed, bool slew_on)
Sets the robot to turn using only the left or right side relative to initial heading without okapi un...
void pid_tuner_full_enable(bool enable)
Enables the full PID tuner with unique fwd/rev constants.
pros::adi::Encoder right_tracker
Deprecated right tracking wheel.
Definition drive.hpp:124
double drive_imu_get()
Returns the current imu rotation value in degrees.
void pid_speed_max_set(int speed)
Changes max speed during a drive motion.
std::vector< int > drive_get()
Gets the chassis to voltage, -127 to 127.
light::slew slew_right
Definition drive.hpp:183
bool opcontrol_curve_buttons_toggle_get()
Gets the current state of the toggle.
void slew_drive_set(bool slew_on)
Sets the default slew for drive forwards and backwards motions, can be overwritten in movement functi...
void odom_x_flip(bool flip=true)
Flips the X axis.
void pid_wait_until(double target)
Lock the code in a while loop until this position has passed for driving without okapi units.
void opcontrol_joystick_practicemode_toggle(bool toggle)
Practice mode for driver practice that shuts off the drive if you go max speed.
void pid_odom_pp_set(std::vector< odom > imovements, bool slew_on)
Takes in odom movements to go through multiple points.
light::slew slew_swing_forward
Definition drive.hpp:187
int opcontrol_speed_max_get()
Returns the max speed for user control.
void pid_swing_chain_forward_constant_set(double input)
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
void pid_odom_ptp_set(odom imovement, bool slew_on)
Takes in an odom movement to go to a single point.
void odom_boomerang_distance_set(double distance)
Sets how far away the carrot point can be from the target point.
void pid_odom_smooth_pp_set(std::vector< united_odom > p_imovements)
Takes in odom movements to go through multiple points, will inject and smooth the path.
void pid_wait()
Lock the code in a while loop until the robot has settled.
void pid_turn_relative_set(okapi::QAngle p_target, int speed, bool slew_on)
Sets the robot to turn relative to current heading using PID with okapi units, using slew if enabled ...
std::vector< double > odom_path_smooth_constants_get()
Returns the constants for smoothing out a path.
void pid_drive_set(okapi::QLength p_target, int speed)
Sets the robot to move forward using PID with okapi units, only using slew if globally enabled.
void pid_turn_constants_set(double p, double i=0.0, double d=0.0, double p_start_i=0.0)
Set the turn pid constants object.
double friction_kV
Definition drive.hpp:199
void pid_angle_behavior_set(e_angle_behavior behavior)
Sets the default behavior for turns in odom, swinging, and turning.
void friction_constants_set(double kS, double kV=0.0, double kQ=0.0)
Sets the friction-feedforward coefficients.
void opcontrol_curve_buttons_toggle(bool toggle)
Enables/disables modifying the joystick input curves with the controller.
tracking_wheel * odom_tracker_left
Left vertical tracking wheel.
Definition drive.hpp:139
void pid_drive_chain_forward_constant_set(double input)
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed)
Sets the robot to turn using only the left or right side relative to initial heading with okapi units...
double pid_tuner_increment_i_get()
Returns the value that PID Tuner increments I.
void drive_defaults_set()
Sets drive defaults.
void pid_drive_chain_backward_constant_set(okapi::QLength input)
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
void pid_turn_chain_constant_set(okapi::QAngle input)
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
PID internal_rightPID
Definition drive.hpp:175
void pid_turn_relative_set(okapi::QAngle p_target, int speed, e_angle_behavior behavior, bool slew_on)
Sets the robot to turn relative to current heading using PID with okapi units, using slew if enabled ...
void opcontrol_arcade_scaling(bool enable)
Toggles vector scaling for arcade control.
void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, e_angle_behavior behavior)
Sets the robot to turn using only the left or right side relative to initial heading with okapi units...
void odom_tracker_right_set(tracking_wheel *input)
Sets the parallel right tracking wheel for odometry.
void pid_turn_set(pose itarget, drive_directions dir, int speed, e_angle_behavior behavior)
Sets the robot to turn face a point using PID and odometry.
bool pid_tuner_enabled()
Checks if PID Tuner is enabled.
void opcontrol_curve_buttons_iterate()
Iterates modifying controller curves with the controller.
void slew_drive_constants_backward_set(okapi::QLength distance, int min_speed)
Sets constants for slew for driving backward.
bool pto_check(pros::Motor check_if_pto)
Checks if the motor is currently in pto_list.
void odom_xy_set(double x, double y)
Sets the current X and Y coordinate for the robot.
bool slew_turn_get()
Returns true if slew is enabled for all turn motions, false otherwise.
void pid_turn_set(united_pose p_itarget, drive_directions dir, int speed)
Sets the robot to turn face a point using PID and odometry.
void pid_swing_constants_backward_set(double p, double i=0.0, double d=0.0, double p_start_i=0.0)
Set the backward swing pid constants object.
void odom_tracker_front_set(tracking_wheel *input)
Sets the perpendicular front tracking wheel for odometry.
void odom_turn_bias_set(double bias)
A proportion of how prioritized turning is during odometry motions.
void odom_tracker_left_set(tracking_wheel *input)
Sets the parallel left tracking wheel for odometry.
void pid_targets_reset()
Resets all PID targets to 0.
PID backward_drivePID
Definition drive.hpp:164
void pid_drive_constants_forward_set(double p, double i=0.0, double d=0.0, double p_start_i=0.0)
Set the forward pid constants object.
void slew_odom_reenable(bool reenable)
Allows slew to reenable when the new input speed is larger than the current speed during pure pursuit...
PID odom_angularPID
Definition drive.hpp:173
void pid_tuner_enable()
Enables PID Tuner.
void pid_turn_exit_condition_set(okapi::QTime p_small_exit_time, okapi::QAngle p_small_error, okapi::QTime p_big_exit_time, okapi::QAngle p_big_error, okapi::QTime p_velocity_exit_time, okapi::QTime p_mA_timeout, bool use_imu=true)
Set's constants for turn exit conditions.
void opcontrol_drive_sensors_reset()
Resets drive sensors at the start of opcontrol.
int CURRENT_MA
Global current mA.
Definition drive.hpp:89
void pid_odom_set(std::vector< united_odom > p_imovements, bool slew_on)
Takes in odom movements to go through multiple points, will inject and smooth the path.
void pid_turn_set(pose itarget, drive_directions dir, int speed)
Sets the robot to turn face a point using PID and odometry.
PID current_a_odomPID
Definition drive.hpp:171
pose odom_pose_get()
Returns the current pose of the robot.
void odom_tracker_back_set(tracking_wheel *input)
Sets the perpendicular back tracking wheel for odometry.
void pid_odom_set(okapi::QLength p_target, int speed, bool slew_on)
Sets the robot to move forward using PID with okapi units, using slew if enabled for this motion.
PID::Constants pid_drive_constants_forward_get()
Returns PID constants with PID::Constants.
void odom_boomerang_dlead_set(double input)
Sets a new dlead.
void pid_swing_relative_set(e_swing type, double target, int speed, e_angle_behavior behavior, bool slew_on)
Sets the robot to turn only using the left or right side relative to current heading using PID withou...
pros::Rotation left_rotation
Deprecated left rotation tracker.
Definition drive.hpp:129
void odom_path_spacing_set(okapi::QLength p_spacing)
Sets the spacing between points when points get injected into the path.
void pid_angle_behavior_tolerance_set(okapi::QAngle p_tolerance)
Gives some wiggle room in shortest vs longest, so a 180.1 and 179.9 degree turns have consistent beha...
Drive(std::vector< int > left_motor_ports, std::vector< int > right_motor_ports, int imu_port, double wheel_diameter, double ticks, double ratio=1.0)
Creates a Drive Controller using internal encoders.
Drive(std::vector< int > left_motor_ports, std::vector< int > right_motor_ports, int imu_port, double wheel_diameter, double ticks, double ratio, std::vector< int > left_tracker_ports, std::vector< int > right_tracker_ports) __attribute__((deprecated("Use the integrated encoder const ructor with odom_tracker_left_set() and odom_tracker_right_set() instead!")))
Creates a Drive Controller using encoders plugged into the brain.
void pid_swing_chain_constant_set(okapi::QAngle input)
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
void pid_swing_exit_condition_set(okapi::QTime p_small_exit_time, okapi::QAngle p_small_error, okapi::QTime p_big_exit_time, okapi::QAngle p_big_error, okapi::QTime p_velocity_exit_time, okapi::QTime p_mA_timeout, bool use_imu=true)
Set's constants for swing exit conditions.
bool drive_current_right_over()
Return true when the motor is over current.
bool opcontrol_joystick_practicemode_toggle_get()
Gets current state of the toggle.
bool drive_imu_calibrated()
Checks if the imu calibrated successfully or if it took longer than expected.
void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, bool slew_on)
Sets the robot to turn using only the left or right side relative to initial heading with okapi units...
double odom_boomerang_distance_get()
Returns how far away the carrot point can be from target.
tracking_wheel * odom_tracker_front
Front horizontal tracking wheel.
Definition drive.hpp:149
double pid_tuner_increment_p_get()
Returns the value that PID Tuner increments P.
void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed)
Sets the robot to turn only using the left or right side relative to current heading using PID with o...
double drive_mA_right()
The watts of the right motor.
void pid_drive_toggle(bool toggle)
Toggles set drive in autonomous.
void opcontrol_tank()
Sets the chassis to controller joysticks using tank control.
void slew_swing_constants_backward_set(okapi::QLength distance, int min_speed)
Sets constants for slew for backward swing movements.
void pid_odom_set(united_odom p_imovement)
Takes in an odom movement to go to a single point.
tracking_wheel * odom_tracker_back
Back horizontal tracking wheel.
Definition drive.hpp:154
void odom_x_set(double x)
Sets the current X coordinate of the robot.
std::vector< double > opcontrol_curve_default_get()
Gets the default joystick curves, in {left, right}.
void pid_odom_boomerang_set(united_odom p_imovement)
Takes in an odom movement to go to a single point using boomerang.
int drive_sensor_right_raw()
The position of the right sensor.
void pid_swing_set(e_swing type, double target, int speed, int opposite_speed)
Sets the robot to turn using only the left or right side relative to initial heading without okapi un...
double drive_imu_accel_get()
Returns the current imu accel x + accel y value.
void pid_turn_set(united_pose p_itarget, drive_directions dir, int speed, bool slew_on)
Sets the robot to turn face a point using PID and odometry.
int drive_current_limit_get()
Gets the limit for the current on the drive.
void pid_drive_chain_constant_set(double input)
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
void odom_y_set(okapi::QLength p_y)
Sets the current Y coordinate of the robot.
double pid_swing_chain_forward_constant_get()
Returns the amount that the PID will overshoot target by to maintain momentum into the next motion fo...
e_angle_behavior pid_swing_behavior_get()
Returns the turn behavior for swings.
PID::Constants pid_turn_constants_get()
Returns PID constants with PID::Constants.
void pid_odom_set(double target, int speed, bool slew_on)
Sets the robot to move forward using PID without okapi units, using slew if enabled for this motion.
bool pid_tuner_print_terminal_enabled()
Returns true if printing to terminal is enabled.
void drive_angle_set(okapi::QAngle p_angle)
Sets heading of imu and target of PID, okapi angle.
void pid_tuner_increment_i_set(double i)
Sets the value that PID Tuner increments I.
void pid_wait_until_index_started(int index)
Lock the code in a while loop until this point becomes the target.
e_mode mode
Current mode of the drive.
Definition drive.hpp:439
Drive(std::vector< int > left_motor_ports, std::vector< int > right_motor_ports, int imu_port, double wheel_diameter, double ticks, double ratio, std::vector< int > left_tracker_ports, std::vector< int > right_tracker_ports, int expander_smart_port) __attribute__((deprecated("Use the integrated encoder const ructor with odom_tracker_left_set() and odom_tracker_right_set() instead!")))
Creates a Drive Controller using encoders plugged into a 3 wire expander.
int pid_turn_min_get()
Returns minimum power for turns when kI and startI are enabled.
void pid_swing_chain_constant_set(double input)
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
PID right_activebrakePID
Definition drive.hpp:177
void drive_imu_display_loading(int iter)
Loading display while the IMU calibrates.
double opcontrol_drive_activebrake_get()
Returns kP for active brake.
void pid_turn_relative_set(okapi::QAngle p_target, int speed, e_angle_behavior behavior)
Sets the robot to turn relative to current heading using PID with okapi units, only using slew if glo...
void pid_wait_quick_chain()
Lock the code in a while loop until the robot has settled.
double pid_tuner_increment_d_get()
Returns the value that PID Tuner increments D.
double pid_turn_chain_constant_get()
Returns the amount that the PID will overshoot target by to maintain momentum into the next motion fo...
void pid_swing_chain_backward_constant_set(okapi::QAngle input)
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
tracking_wheel * odom_tracker_right
Right vertical tracking wheel.
Definition drive.hpp:144
void drive_width_set(double input)
Sets the width of the drive.
void drive_current_limit_set(int mA)
Sets the limit for the current on the drive.
std::vector< pros::Motor > left_motors
Vector of pros motors for the left chassis.
Definition drive.hpp:99
void drive_set(int left, int right)
Sets the chassis to voltage.
void odom_path_spacing_set(double spacing)
Sets the spacing between points when points get injected into the path.
bool slew_drive_backward_get()
Returns true if slew is enabled for all drive backward movements, false otherwise.
void pid_odom_smooth_pp_set(std::vector< odom > imovements)
Takes in odom movements to go through multiple points, will inject and smooth the path.
void odom_x_set(okapi::QLength p_x)
Sets the current X coordinate of the robot.
double drive_width_get()
Returns the width of the drive.
bool slew_odom_reenabled()
Returns if slew will reenable when the new input speed is larger than the current speed during pure p...
PID::Constants pid_swing_constants_get()
Returns PID constants with PID::Constants.
void opcontrol_curve_default_set(double left, double right=0)
Sets the default joystick curves.
double odom_boomerang_dlead_get()
Returns the current dlead.
light::slew slew_turn
Definition drive.hpp:186
double odom_path_spacing_get()
Returns the spacing between points when points get injected into the path.
void pid_turn_set(pose itarget, drive_directions dir, int speed, e_angle_behavior behavior, bool slew_on)
Sets the robot to turn face a point using PID and odometry.
void pid_odom_ptp_set(odom imovement)
Takes in an odom movement to go to a single point.
void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, e_angle_behavior behavior, bool slew_on)
Sets the robot to turn only using the left or right side relative to current heading using PID with o...
void odom_theta_set(okapi::QAngle p_a)
Sets the current Theta of the robot.
pros::adi::Encoder left_tracker
Deprecated left tracking wheel.
Definition drive.hpp:119
void odom_xyt_set(double x, double y, double t)
Sets the current X, Y, and Theta values for the robot.
void pid_drive_set(okapi::QLength p_target, int speed, bool slew_on, bool toggle_heading=true)
Sets the robot to move forward using PID with okapi units, using slew if enabled for this motion.
void slew_drive_forward_set(bool slew_on)
Sets the default slew for drive forward motions, can be overwritten in movement functions.
void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, e_angle_behavior behavior)
Sets the robot to turn only using the left or right side relative to current heading using PID with o...
double pid_drive_chain_forward_constant_get()
Returns the amount that the PID will overshoot target by to maintain momentum into the next motion fo...
light::slew slew_left
Slew objects.
Definition drive.hpp:182
void pid_turn_set(pose itarget, drive_directions dir, int speed, bool slew_on)
Sets the robot to turn face a point using PID and odometry.
void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed)
Sets the robot to turn only using the left or right side relative to current heading using PID with o...
void slew_turn_set(bool slew_on)
Sets the default slew for turn motions, can be overwritten in movement functions.
double odom_y_get()
Returns the current Y coordinate of the robot in inches.
void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, e_angle_behavior behavior, bool slew_on)
Sets the robot to turn only using the left or right side relative to current heading using PID with o...
void pid_swing_set(e_swing type, double target, int speed, int opposite_speed, e_angle_behavior behavior, bool slew_on)
Sets the robot to turn using only the left or right side relative to initial heading without okapi un...
std::vector< pros::controller_digital_e_t > opcontrol_curve_buttons_right_get()
Returns a vector of pros controller buttons user for the right joystick curve, in {decrease,...
void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, bool slew_on)
Sets the robot to turn only using the left or right side relative to current heading using PID with o...
void drive_ratio_set(double ratio)
Set the ratio of the robot.
void pid_tuner_increment_start_i_set(double start_i)
Sets the value that PID Tuner increments Start I.
void pid_odom_injected_pp_set(std::vector< united_odom > p_imovements)
Takes in odom movements to go through multiple points, will inject into the path.
PID internal_leftPID
Definition drive.hpp:174
bool odom_x_direction_get()
Checks if X axis is flipped.
void pid_swing_set(e_swing type, double target, int speed)
Sets the robot to turn using only the left or right side relative to initial heading without okapi un...
void opcontrol_curve_buttons_left_set(pros::controller_digital_e_t decrease, pros::controller_digital_e_t increase)
Sets buttons for modifying the left joystick curve.
e_angle_behavior pid_angle_behavior_bias_get()
Returns the behavior when a turn is within its tolerance, you can have it bias left or right.
void pid_odom_boomerang_set(united_odom p_imovement, bool slew_on)
Takes in an odom movement to go to a single point using boomerang.
bool drive_imu_calibrate(bool run_loading_animation=true)
Calibrates the IMU, recommended to run in initialize().
void slew_drive_constants_set(okapi::QLength distance, int min_speed)
Sets constants for slew for driving.
double drive_imu_scaler_get()
Returns the current imu scaling factor.
void pid_drive_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)
Set's constants for drive exit conditions.
void odom_pose_set(united_pose itarget)
Sets the current pose of the robot.
std::vector< pros::Motor > right_motors
Vector of pros motors for the right chassis.
Definition drive.hpp:104
void pid_odom_injected_pp_set(std::vector< odom > imovements)
Takes in odom movements to go through multiple points, will inject into the path.
void pid_odom_set(std::vector< united_odom > p_imovements)
Takes in odom movements to go through multiple points, will inject and smooth the path.
pros::Imu imu
Inertial sensor.
Definition drive.hpp:114
void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed)
Sets the robot to turn using only the left or right side relative to initial heading with okapi units...
void pid_swing_constants_forward_set(double p, double i=0.0, double d=0.0, double p_start_i=0.0)
Set the forward swing pid constants object.
bool odom_enabled()
Returns whether the bot is tracking with odometry.
PID fwd_rev_swingPID
Definition drive.hpp:169
bool pid_drive_toggle_get()
Gets the current state of the toggle.
void pid_tuner_toggle()
Toggles PID tuner between enabled and disabled.
void pid_odom_injected_pp_set(std::vector< united_odom > p_imovements, bool slew_on)
Takes in odom movements to go through multiple points, will inject into the path.
void pid_wait_until(okapi::QLength target)
Lock the code in a while loop until this position has passed for driving with okapi units.
void pid_turn_chain_constant_set(double input)
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
void pid_odom_behavior_set(e_angle_behavior behavior)
Sets the default behavior for turns in odom turning movements.
void pid_odom_boomerang_set(odom imovement)
Takes in an odom movement to go to a single point using boomerang.
void pid_turn_set(okapi::QAngle p_target, int speed, e_angle_behavior behavior)
Sets the robot to turn relative to initial heading using PID with okapi units.
bool pid_tuner_full_enabled()
Returns if the full PID tuner with unique fwd/rev constants is enabled.
void pid_turn_set(double target, int speed)
Sets the robot to turn relative to initial heading using PID.
double opcontrol_curve_left(double x)
Outputs a curve from 5225A In the Zone.
void opcontrol_joystick_threshold_iterate(int l_stick, int r_stick)
Sets minimum value distance constants.
int drive_sensor_left_raw()
The position of the left sensor.
std::vector< pros::controller_digital_e_t > opcontrol_curve_buttons_left_get()
Returns a vector of pros controller buttons user for the left joystick curve, in {decrease,...
void pid_print_toggle(bool toggle)
Toggles printing in autonomous.
double friction_ff(double v_target)
Computes the friction-feedforward term for a target motor-cmd-unit velocity.
void pid_wait_until_index(int index)
Lock the code in a while loop until this point has been passed.
PID forward_drivePID
Definition drive.hpp:163
bool odom_theta_direction_get()
Checks if the rotation axis is flipped.
void pid_odom_set(std::vector< odom > imovements)
Takes in odom movements to go through multiple points, will inject and smooth the path.
void pid_swing_relative_set(e_swing type, double target, int speed, e_angle_behavior behavior)
Sets the robot to turn only using the left or right side relative to current heading using PID withou...
double drive_sensor_right()
The position of the right sensor in inches.
void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed, e_angle_behavior behavior, bool slew_on)
Sets the robot to turn only using the left or right side relative to current heading using PID withou...
void pid_turn_relative_set(double target, int speed, e_angle_behavior behavior, bool slew_on)
Sets the robot to turn relative to current heading using PID without okapi units, using slew if enabl...
void pid_odom_drive_exit_condition_set(okapi::QTime p_small_exit_time, okapi::QLength p_small_error, okapi::QTime p_big_exit_time, okapi::QLength p_big_error, okapi::QTime p_velocity_exit_time, okapi::QTime p_mA_timeout, bool use_imu=true)
Set's constants for odom driving exit conditions.
double drive_ratio_get()
Returns the ratio of the drive.
void pid_wait_quick()
Lock the code in a while loop until the robot has settled.
PID fwd_rev_drivePID
Definition drive.hpp:165
void pid_turn_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)
Set's constants for turn exit conditions.
void pid_drive_constants_backward_set(double p, double i=0.0, double d=0.0, double p_start_i=0.0)
Set the backwards pid constants object.
void pid_swing_chain_backward_constant_set(double input)
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
void pid_odom_smooth_pp_set(std::vector< odom > imovements, bool slew_on)
Takes in odom movements to go through multiple points, will inject and smooth the path.
void opcontrol_joystick_threshold_set(int threshold)
Sets a new threshold for the joystick.
void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, bool slew_on)
Sets the robot to turn only using the left or right side relative to current heading using PID with o...
e_mode drive_mode_get()
Returns current mode of drive.
void pid_odom_injected_pp_set(std::vector< odom > imovements, bool slew_on)
Takes in odom movements to go through multiple points, will inject into the path.
pros::Rotation right_rotation
Deprecated right rotation tracker.
Definition drive.hpp:134
void pid_swing_set(e_swing type, double target, int speed, int opposite_speed, bool slew_on)
Sets the robot to turn using only the left or right side relative to initial heading without okapi un...
void pid_turn_behavior_set(e_angle_behavior behavior)
Sets the default behavior for turns in turning movements.
bool odom_y_direction_get()
Checks if Y axis is flipped.
void pto_add(std::vector< pros::Motor > pto_list)
Adds motors to the pto list, removing them from the drive.
void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed, bool slew_on)
Sets the robot to turn only using the left or right side relative to current heading using PID withou...
void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, e_angle_behavior behavior)
Sets the robot to turn only using the left or right side relative to current heading using PID with o...
Drive(std::vector< int > left_motor_ports, std::vector< int > right_motor_ports, int imu_port, double wheel_diameter, double ratio, int left_rotation_port, int right_rotation_port) __attribute__((deprecated("Use the integrated encoder const ructor with odom_tracker_left_set() and odom_tracker_right_set() instead!")))
Creates a Drive Controller using rotation sensors.
void pid_angle_behavior_bias_set(e_angle_behavior behavior)
When a turn is within its tolerance, you can have it bias left or right.
void pid_odom_drive_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)
Set's constants for odom driving exit conditions.
PID::Constants pid_heading_constants_get()
Returns PID constants with PID::Constants.
void pid_turn_set(okapi::QAngle p_target, int speed)
Sets the robot to turn relative to initial heading using PID with okapi units.
int pid_speed_max_get()
Returns max speed of drive during autonomous.
void slew_drive_backward_set(bool slew_on)
Sets the default slew for drive backward motions, can be overwritten in movement functions.
void pid_tuner_increment_d_set(double d)
Sets the value that PID Tuner increments D.
light::slew slew_swing_backward
Definition drive.hpp:188
void slew_drive_constants_forward_set(okapi::QLength distance, int min_speed)
Sets constants for slew for driving forward.
void pid_odom_set(united_odom p_imovement, bool slew_on)
Takes in an odom movement to go to a single point.
PID boomerangPID
Definition drive.hpp:172
void odom_xy_set(okapi::QLength p_x, okapi::QLength p_y)
Sets the current X and Y coordinate for the robot.
void pid_tuner_increment_p_set(double p)
Sets the value that PID Tuner increments P.
void pid_swing_set(e_swing type, double target, int speed, e_angle_behavior behavior)
Sets the robot to turn using only the left or right side relative to initial heading without okapi un...
void pid_heading_constants_set(double p, double i=0.0, double d=0.0, double p_start_i=0.0)
Set the heading pid constants object.
void pid_odom_set(odom imovement, bool slew_on)
Takes in an odom movement to go to a single point.
void slew_swing_constants_forward_set(okapi::QAngle distance, int min_speed)
Sets constants for slew for swing forward movements.
void initialize()
Calibrates imu and initializes sd card to curve.
int opcontrol_joystick_threshold_get()
Gets the threshold for the joystick.
void pid_tuner_iterate()
Iterates through controller inputs to modify PID constants.
void slew_swing_set(bool slew_on)
Sets the default slew for swing forward and backward motions, can be overwritten in movement function...
double odom_theta_get()
Returns the current Theta of the robot in degrees.
double odom_turn_bias_get()
Returns the proportion of how prioritized turning is during odometry motions.
double odom_look_ahead_get()
Returns how far away the robot looks in the path during pure pursuits.
void pid_swing_min_set(int min)
Sets minimum power for swings when kI and startI are enabled.
void pid_odom_set(double target, int speed)
Sets the robot to move forward using PID without okapi units, only using slew if globally enabled.
void odom_pose_set(pose itarget)
Sets the current pose of the robot.
bool slew_swing_forward_get()
Returns true if slew is enabled for all swing forward motions, false otherwise.
void drive_sensor_reset()
Reset all the chassis motors and tracking wheels, recommended to run at the start of your autonomous ...
void pid_wait_until(united_pose target)
Lock the code in a while loop until this point has been passed, with okapi units.
void odom_y_set(double y)
Sets the current Y coordinate of the robot.
void pid_wait_until(okapi::QAngle target)
Lock the code in a while loop until this position has passed for turning or swinging with okapi units...
double pid_swing_chain_backward_constant_get()
Returns the amount that the PID will overshoot target by to maintain momentum into the next motion fo...
double pid_tuner_increment_start_i_get()
Returns the value that PID Tuner increments Start I.
int pid_swing_min_get()
Returns minimum power for swings when kI and startI are enabled.
void slew_swing_constants_set(okapi::QLength distance, int min_speed)
Sets constants for slew for swing movements.
light::slew slew_swing
Definition drive.hpp:189
void drive_imu_reset(double new_heading=0)
Resets the current imu value.
void pid_drive_chain_forward_constant_set(okapi::QLength input)
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
bool drive_current_left_over()
Return true when the motor is over current.
void pid_odom_set(std::vector< odom > imovements, bool slew_on)
Takes in odom movements to go through multiple points, will inject and smooth the path.
void opcontrol_curve_sd_initialize()
Initializes left and right curves with the SD card, recommended to run in initialize().
void pid_odom_turn_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)
Set's constants for odom turning exit conditions.
void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed, e_angle_behavior behavior)
Sets the robot to turn only using the left or right side relative to current heading using PID withou...
e_angle_behavior pid_turn_behavior_get()
Returns the turn behavior for turns.
void pid_turn_relative_set(okapi::QAngle p_target, int speed)
Sets the robot to turn relative to current heading using PID with okapi units, only using slew if glo...
bool pid_tuner_print_brain_enabled()
Returns true if printing to brain is enabled.
bool opcontrol_arcade_scaling_enabled()
Returns if vector scaling for arcade control is enabled.
std::vector< int > pto_active
Vector of pros motors that are disconnected from the drive.
Definition drive.hpp:109
void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed)
Sets the robot to turn only using the left or right side relative to current heading using PID withou...
void odom_enable(bool input)
Enables / disables tracking.
void pid_drive_set(double target, int speed)
Sets the robot to move forward using PID without okapi units, only using slew if globally enabled.
void pid_odom_ptp_set(united_odom p_imovement, bool slew_on)
Takes in an odom movement to go to a single point.
pros::motor_brake_mode_e_t drive_brake_get()
Returns the brake mode of the drive in pros_brake_mode_e_t_.
void odom_path_print()
Prints the current path the robot is following.
bool opcontrol_drive_reverse_get()
Gets current state of the toggle.
void opcontrol_curve_buttons_right_set(pros::controller_digital_e_t decrease, pros::controller_digital_e_t increase)
Sets buttons for modifying the right joystick curve.
void pid_odom_smooth_pp_set(std::vector< united_odom > p_imovements, bool slew_on)
Takes in odom movements to go through multiple points, will inject and smooth the path.
void pto_toggle(std::vector< pros::Motor > pto_list, bool toggle)
Adds/removes motors from drive.
std::vector< const_and_name > pid_tuner_full_pids
Vector used for the full PID Tuner.
Definition drive.hpp:3454
PID::Constants pid_swing_constants_backward_get()
Returns PID constants with PID::Constants.
double friction_kQ
Definition drive.hpp:200
double odom_x_get()
Returns the current X coordinate of the robot in inches.
void pid_angle_behavior_tolerance_set(double tolerance)
Gives some wiggle room in shortest vs longest, so a 180.1 and 179.9 degree turns have consistent beha...
void pid_odom_boomerang_constants_set(double p, double i=0.0, double d=0.0, double p_start_i=0.0)
Set the odom boomerang pid constants object.
PID forward_swingPID
Definition drive.hpp:167
void pid_drive_chain_backward_constant_set(double input)
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
void pid_odom_pp_set(std::vector< united_odom > p_imovements, bool slew_on)
Takes in odom movements to go through multiple points.
double drive_mA_left()
The watts of the left motor.
void slew_swing_backward_set(bool slew_on)
Sets the default slew for swing backward motions, can be overwritten in movement functions.
void pid_turn_relative_set(double target, int speed)
Sets the robot to turn relative to current heading using PID without okapi units, only using slew if ...
void odom_xyt_set(okapi::QLength p_x, okapi::QLength p_y, okapi::QAngle p_t)
Sets the current X, Y, and Theta values for the robot.
bool interfered
Autonomous interference detection.
Definition drive.hpp:2689
PID::Constants pid_drive_constants_backward_get()
Returns PID constants with PID::Constants.
void pid_odom_boomerang_set(odom imovement, bool slew_on)
Takes in an odom movement to go to a single point using boomerang.
void pid_drive_set(double target, int speed, bool slew_on, bool toggle_heading=true)
Sets the robot to move forward using PID without okapi units, using slew if enabled for this motion.
void pid_odom_pp_set(std::vector< united_odom > p_imovements)
Takes in odom movements to go through multiple points.
void pid_turn_set(double target, int speed, bool slew_on)
Sets the robot to turn relative to initial heading using PID, using slew if enabled for this motion.
void odom_reset()
Resets xyt to 0.
PID headingPID
PID objects.
Definition drive.hpp:159
void pid_swing_relative_set(e_swing type, double target, int speed, bool slew_on)
Sets the robot to turn only using the left or right side relative to current heading using PID withou...
void pid_odom_turn_exit_condition_set(okapi::QTime p_small_exit_time, okapi::QAngle p_small_error, okapi::QTime p_big_exit_time, okapi::QAngle p_big_error, okapi::QTime p_velocity_exit_time, okapi::QTime p_mA_timeout, bool use_imu=true)
Set's constants for odom turning exit conditions.
void pid_drive_chain_constant_set(okapi::QLength input)
Sets the amount that the PID will overshoot target by to maintain momentum into the next motion.
void opcontrol_drive_reverse_set(bool toggle)
Reversal for drivetrain in opcontrol that flips the left and right side and the direction of the driv...
std::vector< double > friction_constants_get()
Returns {kS, kV, kQ}.
void pid_turn_set(double target, int speed, e_angle_behavior behavior)
Sets the robot to turn relative to initial heading using PID.
void odom_look_ahead_set(double distance)
Sets how far away the robot looks in the path during pure pursuits.
double drive_sensor_left()
The position of the left sensor in inches.
void slew_turn_constants_set(okapi::QAngle distance, int min_speed)
Sets constants for slew for turns.
e_swing current_swing
Current swing type.
Definition drive.hpp:94
void drive_brake_set(pros::motor_brake_mode_e_t brake_type)
Changes the way the drive behaves when it is not under active user control.
void pid_odom_angular_constants_set(double p, double i=0.0, double d=0.0, double p_start_i=0.0)
Set the odom angular pid constants object.
void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, e_angle_behavior behavior, bool slew_on)
Sets the robot to turn using only the left or right side relative to initial heading with okapi units...
void pto_remove(std::vector< pros::Motor > pto_list)
Removes motors from the pto list, adding them to the drive.
void slew_swing_constants_backward_set(okapi::QAngle distance, int min_speed)
Sets constants for slew for swing backward movements.
void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, e_angle_behavior behavior, bool slew_on)
Sets the robot to turn only using the left or right side relative to initial heading using PID with o...
void pid_turn_set(okapi::QAngle p_target, int speed, bool slew_on)
Sets the robot to turn relative to initial heading using PID with okapi units, using slew if enabled ...
void odom_look_ahead_set(okapi::QLength p_distance)
Sets how far away the robot looks in the path during pure pursuits.
void pid_tuner_print_brain_set(bool input)
Toggle for printing the display of the PID Tuner to the brain.
void pid_odom_ptp_set(united_odom p_imovement)
Takes in an odom movement to go to a single point.
e_angle_behavior pid_odom_behavior_get()
Returns the turn behavior for odom turns.
void odom_theta_set(double a)
Sets the current angle of the robot.
bool pid_print_toggle_get()
Gets the current state of the toggle.
int drive_velocity_right()
The velocity of the right motor.
void odom_boomerang_distance_set(okapi::QLength p_distance)
Sets how far away the carrot point can be from the target point.
bool slew_swing_backward_get()
Returns true if slew is enabled for all swing backward motions, false otherwise.
void pid_swing_constants_set(double p, double i=0.0, double d=0.0, double p_start_i=0.0)
Set the swing pid constants object.
void slew_swing_constants_forward_set(okapi::QLength distance, int min_speed)
Sets constants for slew for forward swing movements.
void odom_path_smooth_constants_set(double weight_smooth, double weight_data, double tolerance)
Sets the constants for smoothing out a path.
std::vector< const_and_name > pid_tuner_pids
Vector used for a simplified PID Tuner.
Definition drive.hpp:3443
PID::Constants opcontrol_drive_activebrake_constants_get()
Returns all PID constants for active brake.
PID::Constants pid_swing_constants_forward_get()
Returns PID constants with PID::Constants.
void slew_swing_constants_set(okapi::QAngle distance, int min_speed)
Sets constants for slew for swing movements.
int JOYSTICK_THRESHOLD
Joysticks will return 0 when they are within this number.
Definition drive.hpp:79
void pid_turn_relative_set(double target, int speed, e_angle_behavior behavior)
Sets the robot to turn relative to current heading using PID without okapi units, only using slew if ...
double drive_rpm_get()
Returns the current cartridge / wheel rpm.
PID::Constants pid_drive_constants_get()
Returns PID constants with PID::Constants.
void pid_swing_set(e_swing type, double target, int speed, e_angle_behavior behavior, bool slew_on)
Sets the robot to turn using only the left or right side relative to initial heading without okapi un...
void pid_drive_constants_set(double p, double i=0.0, double d=0.0, double p_start_i=0.0)
Set the drive pid constants object.
pros::Task ez_auto
Tasks for autonomous.
Definition drive.hpp:464
pros::motor_brake_mode_e_t CURRENT_BRAKE
Global current brake mode.
Definition drive.hpp:84
void odom_y_flip(bool flip=true)
Flips the Y axis.
light::slew slew_backward
Definition drive.hpp:185
void pid_turn_set(okapi::QAngle p_target, int speed, e_angle_behavior behavior, bool slew_on)
Sets the robot to turn relative to initial heading using PID with okapi units, using slew if enabled ...
void pid_turn_min_set(int min)
The minimum power for turns when kI and startI are enabled.
void pid_swing_relative_set(e_swing type, double target, int speed)
Sets the robot to turn only using the left or right side relative to current heading using PID withou...
double pid_angle_behavior_tolerance_get()
Returns the wiggle room in shortest vs longest, so a 180.1 and 179.9 degree turns have consistent beh...
light::slew slew_forward
Definition drive.hpp:184
void opcontrol_drive_activebrake_set(double kp, double ki=0.0, double kd=0.0, double start_i=0.0)
Runs a PID loop on the drive when the joysticks are released.
double pid_drive_chain_backward_constant_get()
Returns the amount that the PID will overshoot target by to maintain momentum into the next motion fo...
void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, bool slew_on)
Sets the robot to turn using only the left or right side relative to initial heading with okapi units...
void pid_odom_set(okapi::QLength p_target, int speed)
Sets the robot to move forward using PID with okapi units, only using slew if globally enabled.
PID backward_swingPID
Definition drive.hpp:168
Discrete PID controller with rich exit-condition support.
Definition pid.hpp:30
Constants constants
Active PID gain constants (read/write).
Definition pid.hpp:154
Slew-rate limiter that ramps speed up linearly over a configurable distance.
Definition slew.hpp:29
Single tracking wheel for odometry.
#define DRIVE_INTEGRATED
Definition drive.hpp:3691
Public LightLib odometry / pose-estimation API.
Definition pid.hpp:22
e_type
Arcade joystick layout.
Definition util.hpp:63
e_angle_behavior
How to choose a turn direction when reaching an absolute heading.
Definition util.hpp:98
@ raw
Use signed delta as-is (no wrap).
Definition util.hpp:98
@ shortest
Pick the smaller of CW/CCW.
Definition util.hpp:107
@ longest
Definition util.hpp:108
pose(*)() PoseGetterFn
External pose getter used by register_pose_source().
Definition drive.hpp:37
e_swing
Direction for swing-turn motions.
Definition util.hpp:67
void(*)(pose) PoseSetterFn
External pose setter used by register_pose_source().
Definition drive.hpp:39
e_mode
Active chassis motion mode.
Definition util.hpp:79
drive_directions
Drive direction with multiple spelling aliases.
Definition util.hpp:88
@ fwd
Definition util.hpp:90
void register_pose_source(PoseGetterFn getter, PoseSetterFn setter)
Register an external pose source.
Discrete PID controller with rich exit-condition support.
Slew-rate limiter that ramps motor output up over a configurable distance.
PID::Constants * consts
Definition drive.hpp:3437
PID gain constants.
Definition pid.hpp:70
One waypoint of an odom-mode movement.
Definition util.hpp:130
2D pose: position (in) and heading (deg).
Definition util.hpp:116
One waypoint of an odom-mode movement, with okapi units.
Definition util.hpp:138
2D pose with okapi units.
Definition util.hpp:123
Wrapper around an ADI optical encoder or a smart pros::Rotation sensor that exposes the wheel's dista...
Shared types, enums, math helpers, and unit conversions used across LightLib.