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
58extern int DRIVE_SPEED;
59extern int TURN_SPEED;
60extern int SWING_SPEED;
61
78class Drive {
79 public:
86
90 pros::motor_brake_mode_e_t CURRENT_BRAKE = pros::E_MOTOR_BRAKE_COAST;
91
95 int CURRENT_MA = 2500;
96
101
105 std::vector<pros::Motor> left_motors;
106
110 std::vector<pros::Motor> right_motors;
111
115 std::vector<int> pto_active;
116
120 pros::Imu imu;
121
125 pros::adi::Encoder left_tracker;
126
130 pros::adi::Encoder right_tracker;
131
135 pros::Rotation left_rotation;
136
140 pros::Rotation right_rotation;
141
146
151
156
161
184
196
204 double friction_kS = 0.0;
205 double friction_kV = 0.0;
206 double friction_kQ = 0.0;
207
215 void friction_constants_set(double kS, double kV = 0.0, double kQ = 0.0);
216
220 std::vector<double> friction_constants_get();
221
226 double friction_ff(double v_target);
227
238 void slew_swing_constants_set(okapi::QLength distance, int min_speed);
239
250 void slew_swing_constants_forward_set(okapi::QLength distance, int min_speed);
251
262 void slew_swing_constants_backward_set(okapi::QLength distance, int min_speed);
263
274 void slew_swing_constants_set(okapi::QAngle distance, int min_speed);
275
286 void slew_swing_constants_forward_set(okapi::QAngle distance, int min_speed);
287
298 void slew_swing_constants_backward_set(okapi::QAngle distance, int min_speed);
299
310 void slew_turn_constants_set(okapi::QAngle distance, int min_speed);
311
322 void slew_drive_constants_forward_set(okapi::QLength distance, int min_speed);
323
334 void slew_drive_constants_backward_set(okapi::QLength distance, int min_speed);
335
346 void slew_drive_constants_set(okapi::QLength distance, int min_speed);
347
354 void slew_drive_set(bool slew_on);
355
362 void slew_drive_forward_set(bool slew_on);
363
368
375 void slew_drive_backward_set(bool slew_on);
376
381
388 void slew_swing_set(bool slew_on);
389
396 void slew_swing_forward_set(bool slew_on);
397
402
409 void slew_swing_backward_set(bool slew_on);
410
415
422 void slew_turn_set(bool slew_on);
423
428
435 void slew_odom_reenable(bool reenable);
436
441
446
455 void drive_mode_set(e_mode p_mode, bool stop_drive = true);
456
461
466
470 pros::Task ez_auto;
471
488 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);
489
510 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!")));
511
534 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!")));
535
554 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!")));
555
560
562 //
563 // General Odometry
564 //
566
571
578 void odom_enable(bool input);
579
586
595 void drive_width_set(double input);
596
605 void drive_width_set(okapi::QLength p_input);
606
611
618 void odom_x_set(double x);
619
626 void odom_x_set(okapi::QLength p_x);
627
631 double odom_x_get();
632
639 void odom_y_set(double y);
640
647 void odom_y_set(okapi::QLength p_y);
648
652 double odom_y_get();
653
660 void odom_theta_set(double a);
661
668 void odom_theta_set(okapi::QAngle p_a);
669
674
681 void odom_pose_set(pose itarget);
682
690
699 void odom_xy_set(double x, double y);
700
709 void odom_xy_set(okapi::QLength p_x, okapi::QLength p_y);
710
721 void odom_xyt_set(double x, double y, double t);
722
733 void odom_xyt_set(okapi::QLength p_x, okapi::QLength p_y, okapi::QAngle p_t);
734
739
744
751 void odom_x_flip(bool flip = true);
752
759
766 void odom_y_flip(bool flip = true);
767
774
781 void odom_theta_flip(bool flip = true);
782
789
798 void odom_boomerang_dlead_set(double input);
799
804
811 void odom_boomerang_distance_set(double distance);
812
819 void odom_boomerang_distance_set(okapi::QLength p_distance);
820
825
834 void odom_turn_bias_set(double bias);
835
840
847 void odom_path_spacing_set(double spacing);
848
855 void odom_path_spacing_set(okapi::QLength p_spacing);
856
861
874 void odom_path_smooth_constants_set(double weight_smooth, double weight_data, double tolerance);
875
884 std::vector<double> odom_path_smooth_constants_get();
885
890
897 void odom_look_ahead_set(double distance);
898
905 void odom_look_ahead_set(okapi::QLength p_distance);
906
911
919
927
935
943
951
959
967
975
980
985
990
997 void pid_angle_behavior_tolerance_set(okapi::QAngle p_tolerance);
998
1005 void pid_angle_behavior_tolerance_set(double tolerance);
1006
1011
1019
1024
1026 //
1027 // User Control
1028 //
1030
1039
1051
1063
1068
1077 void opcontrol_curve_default_set(double left, double right = 0);
1078
1082 std::vector<double> opcontrol_curve_default_get();
1083
1096 void opcontrol_drive_activebrake_set(double kp, double ki = 0.0, double kd = 0.0, double start_i = 0.0);
1097
1102
1107
1115
1122
1131 void opcontrol_curve_buttons_left_set(pros::controller_digital_e_t decrease, pros::controller_digital_e_t increase);
1132
1136 std::vector<pros::controller_digital_e_t> opcontrol_curve_buttons_left_get();
1137
1146 void opcontrol_curve_buttons_right_set(pros::controller_digital_e_t decrease, pros::controller_digital_e_t increase);
1147
1151 std::vector<pros::controller_digital_e_t> opcontrol_curve_buttons_right_get();
1152
1161 double opcontrol_curve_left(double x);
1162
1171 double opcontrol_curve_right(double x);
1172
1182
1187
1192
1201 void opcontrol_joystick_threshold_iterate(int l_stick, int r_stick);
1202
1204 //
1205 // PTO
1206 //
1208
1217 bool pto_check(pros::Motor check_if_pto);
1218
1227 void pto_add(std::vector<pros::Motor> pto_list);
1228
1235 void pto_remove(std::vector<pros::Motor> pto_list);
1236
1247 void pto_toggle(std::vector<pros::Motor> pto_list, bool toggle);
1248
1250 //
1251 // PROS Wrappers
1252 //
1254
1265 void drive_set(int left, int right);
1266
1270 std::vector<int> drive_get();
1271
1278 void drive_brake_set(pros::motor_brake_mode_e_t brake_type);
1279
1283 pros::motor_brake_mode_e_t drive_brake_get();
1284
1292
1297
1304 void pid_drive_toggle(bool toggle);
1305
1314
1321 void pid_print_toggle(bool toggle);
1322
1331
1333 //
1334 // Telemetry
1335 //
1337
1344
1351
1356
1361
1366
1373
1380
1385
1390
1395
1400
1407 void drive_imu_reset(double new_heading = 0);
1408
1413
1418
1427 void drive_imu_scaler_set(double scaler);
1428
1433
1440 bool drive_imu_calibrate(bool run_loading_animation = true);
1441
1448
1453
1461
1468
1476
1483
1485 //
1486 // Autonomous Functions
1487 //
1489
1500 void pid_odom_set(double target, int speed);
1501
1514 void pid_odom_set(double target, int speed, bool slew_on);
1515
1526 void pid_odom_set(okapi::QLength p_target, int speed);
1527
1542 void pid_odom_set(okapi::QLength p_target, int speed, bool slew_on);
1543
1550 void pid_odom_set(odom imovement);
1551
1560 void pid_odom_set(odom imovement, bool slew_on);
1561
1568 void pid_odom_ptp_set(odom imovement);
1569
1578 void pid_odom_ptp_set(odom imovement, bool slew_on);
1579
1587
1596 void pid_odom_boomerang_set(odom imovement, bool slew_on);
1597
1605
1614 void pid_odom_boomerang_set(united_odom p_imovement, bool slew_on);
1615
1623
1632 void pid_odom_ptp_set(united_odom p_imovement, bool slew_on);
1633
1640 void pid_odom_set(united_odom p_imovement);
1641
1650 void pid_odom_set(united_odom p_imovement, bool slew_on);
1651
1658 void pid_odom_set(std::vector<odom> imovements);
1659
1668 void pid_odom_set(std::vector<odom> imovements, bool slew_on);
1669
1676 void pid_odom_pp_set(std::vector<odom> imovements);
1677
1686 void pid_odom_pp_set(std::vector<odom> imovements, bool slew_on);
1687
1694 void pid_odom_injected_pp_set(std::vector<odom> imovements);
1695
1704 void pid_odom_injected_pp_set(std::vector<odom> imovements, bool slew_on);
1705
1712 void pid_odom_smooth_pp_set(std::vector<odom> imovements);
1713
1722 void pid_odom_smooth_pp_set(std::vector<odom> imovements, bool slew_on);
1723
1730 void pid_odom_smooth_pp_set(std::vector<united_odom> p_imovements);
1731
1740 void pid_odom_smooth_pp_set(std::vector<united_odom> p_imovements, bool slew_on);
1741
1748 void pid_odom_injected_pp_set(std::vector<united_odom> p_imovements);
1749
1758 void pid_odom_injected_pp_set(std::vector<united_odom> p_imovements, bool slew_on);
1759
1766 void pid_odom_pp_set(std::vector<united_odom> p_imovements);
1767
1776 void pid_odom_pp_set(std::vector<united_odom> p_imovements, bool slew_on);
1777
1784 void pid_odom_set(std::vector<united_odom> p_imovements);
1785
1794 void pid_odom_set(std::vector<united_odom> p_imovements, bool slew_on);
1795
1804 void pid_drive_set(okapi::QLength p_target, int speed = DRIVE_SPEED);
1805
1818 void pid_drive_set(okapi::QLength p_target, int speed, bool slew_on, bool toggle_heading = true);
1819
1828 void pid_drive_set(double target, int speed = DRIVE_SPEED);
1829
1842 void pid_drive_set(double target, int speed, bool slew_on, bool toggle_heading = true);
1843
1852 void pid_turn_set(pose itarget, drive_directions dir, int speed = TURN_SPEED);
1853
1864 void pid_turn_set(pose itarget, drive_directions dir, int speed, bool slew_on);
1865
1876 void pid_turn_set(pose itarget, drive_directions dir, int speed, e_angle_behavior behavior);
1877
1890 void pid_turn_set(pose itarget, drive_directions dir, int speed, e_angle_behavior behavior, bool slew_on);
1891
1900 void pid_turn_set(united_pose p_itarget, drive_directions dir, int speed = TURN_SPEED);
1901
1912 void pid_turn_set(united_pose p_itarget, drive_directions dir, int speed, bool slew_on);
1913
1924 void pid_turn_set(united_pose p_itarget, drive_directions dir, int speed, e_angle_behavior behavior);
1925
1938 void pid_turn_set(united_pose p_itarget, drive_directions dir, int speed, e_angle_behavior behavior, bool slew_on);
1939
1950 void pid_turn_set(double target, int speed = TURN_SPEED);
1951
1962 void pid_turn_set(double target, int speed, e_angle_behavior behavior);
1963
1974 void pid_turn_set(double target, int speed, bool slew_on);
1975
1988 void pid_turn_set(double target, int speed, e_angle_behavior behavior, bool slew_on);
1989
1998 void pid_turn_set(okapi::QAngle p_target, int speed = TURN_SPEED);
1999
2010 void pid_turn_set(okapi::QAngle p_target, int speed, e_angle_behavior behavior);
2011
2022 void pid_turn_set(okapi::QAngle p_target, int speed, bool slew_on);
2023
2036 void pid_turn_set(okapi::QAngle p_target, int speed, e_angle_behavior behavior, bool slew_on);
2037
2046 void pid_turn_relative_set(okapi::QAngle p_target, int speed);
2047
2058 void pid_turn_relative_set(okapi::QAngle p_target, int speed, e_angle_behavior behavior);
2059
2070 void pid_turn_relative_set(okapi::QAngle p_target, int speed, bool slew_on);
2071
2084 void pid_turn_relative_set(okapi::QAngle p_target, int speed, e_angle_behavior behavior, bool slew_on);
2085
2094 void pid_turn_relative_set(double target, int speed);
2095
2106 void pid_turn_relative_set(double target, int speed, e_angle_behavior behavior);
2107
2118 void pid_turn_relative_set(double target, int speed, bool slew_on);
2119
2132 void pid_turn_relative_set(double target, int speed, e_angle_behavior behavior, bool slew_on);
2133
2144 void pid_swing_set(e_swing type, double target, int speed = SWING_SPEED);
2145
2158 void pid_swing_set(e_swing type, double target, int speed, e_angle_behavior behavior);
2159
2172 void pid_swing_set(e_swing type, double target, int speed, bool slew_on);
2173
2186 void pid_swing_set(e_swing type, double target, int speed, e_angle_behavior behavior, bool slew_on);
2187
2200 void pid_swing_set(e_swing type, double target, int speed, int opposite_speed);
2201
2214 void pid_swing_set(e_swing type, double target, int speed, int opposite_speed, e_angle_behavior behavior);
2215
2230 void pid_swing_set(e_swing type, double target, int speed, int opposite_speed, bool slew_on);
2231
2248 void pid_swing_set(e_swing type, double target, int speed, int opposite_speed, e_angle_behavior behavior, bool slew_on);
2249
2260 void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed = SWING_SPEED);
2261
2274 void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, e_angle_behavior behavior);
2275
2288 void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, bool slew_on);
2289
2304 void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, e_angle_behavior behavior, bool slew_on);
2305
2318 void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed);
2319
2334 void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, e_angle_behavior behavior);
2335
2350 void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, bool slew_on);
2351
2368 void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, e_angle_behavior behavior, bool slew_on);
2369
2380 void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed);
2381
2392 void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, e_angle_behavior behavior);
2393
2404 void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, bool slew_on);
2405
2416 void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, e_angle_behavior behavior, bool slew_on);
2417
2430 void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed);
2431
2444 void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, e_angle_behavior behavior);
2445
2458 void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, bool slew_on);
2459
2472 void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed, e_angle_behavior behavior, bool slew_on);
2473
2484 void pid_swing_relative_set(e_swing type, double target, int speed);
2485
2496 void pid_swing_relative_set(e_swing type, double target, int speed, e_angle_behavior behavior);
2497
2508 void pid_swing_relative_set(e_swing type, double target, int speed, bool slew_on);
2509
2520 void pid_swing_relative_set(e_swing type, double target, int speed, e_angle_behavior behavior, bool slew_on);
2521
2534 void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed);
2535
2548 void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed, e_angle_behavior behavior);
2549
2562 void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed, bool slew_on);
2563
2576 void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed, e_angle_behavior behavior, bool slew_on);
2577
2582
2586 void drive_angle_set(okapi::QAngle p_angle);
2587
2591 void drive_angle_set(double angle);
2592
2596 void pid_wait();
2597
2604 void pid_wait_until(okapi::QAngle target);
2605
2612 void pid_wait_until(okapi::QLength target);
2613
2620 void pid_wait_until(double target);
2621
2628
2637
2644 void pid_wait_until_index(int index);
2645
2653
2661
2669
2678 void pid_wait_until(pose target);
2679
2689
2695 bool interfered = false;
2696
2703 void drive_ratio_set(double ratio);
2704
2711 void drive_rpm_set(double rpm);
2712
2717
2722
2729 void pid_speed_max_set(int speed);
2730
2735
2748 void pid_turn_constants_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
2749
2754
2763 void pid_turn_chain_constant_set(okapi::QAngle input);
2764
2774
2779
2792 void pid_swing_constants_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
2793
2800
2813 void pid_swing_constants_forward_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
2814
2819
2832 void pid_swing_constants_backward_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
2833
2838
2847 void pid_swing_chain_constant_set(okapi::QAngle input);
2848
2857 void pid_swing_chain_forward_constant_set(okapi::QAngle input);
2858
2867 void pid_swing_chain_backward_constant_set(okapi::QAngle input);
2868
2878
2888
2893
2903
2908
2921 void pid_heading_constants_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
2922
2927
2940 void pid_drive_constants_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
2941
2948
2961 void pid_drive_constants_forward_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
2962
2967
2980 void pid_drive_constants_backward_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
2981
2986
2995 void pid_drive_chain_constant_set(okapi::QLength input);
2996
3005 void pid_drive_chain_forward_constant_set(okapi::QLength input);
3006
3015 void pid_drive_chain_backward_constant_set(okapi::QLength input);
3016
3026
3036
3041
3051
3056
3063 void pid_swing_min_set(int min);
3064
3071 void pid_turn_min_set(int min);
3072
3077
3082
3095 void pid_odom_angular_constants_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
3096
3109 void pid_odom_boomerang_constants_set(double p, double i = 0.0, double d = 0.0, double p_start_i = 0.0);
3110
3129 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);
3130
3149 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);
3150
3169 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);
3170
3189 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);
3190
3209 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);
3210
3229 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);
3230
3249 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);
3250
3269 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);
3270
3289 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);
3290
3309 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);
3310
3315
3320
3325
3330
3335
3342
3348
3355
3360
3368
3376
3381
3386
3394
3402
3410
3418
3423
3428
3433
3438
3445 void pid_tuner_full_enable(bool enable);
3446
3453
3455 std::string name = "";
3457 };
3458
3462 std::vector<const_and_name> pid_tuner_pids = {
3463 {"Drive PID Constants", &fwd_rev_drivePID.constants},
3464 {"Odom Angular PID Constants", &odom_angularPID.constants},
3465 {"Boomerang Angular PID Constants", &boomerangPID.constants},
3466 {"Heading PID Constants", &headingPID.constants},
3467 {"Turn PID Constants", &turnPID.constants},
3468 {"Swing PID Constants", &fwd_rev_swingPID.constants}};
3469
3473 std::vector<const_and_name> pid_tuner_full_pids = {
3474 {"Drive Forward PID Constants", &forward_drivePID.constants},
3475 {"Drive Backward PID Constants", &backward_drivePID.constants},
3476 {"Odom Angular PID Constants", &odom_angularPID.constants},
3477 {"Boomerang Angular PID Constants", &boomerangPID.constants},
3478 {"Heading PID Constants", &headingPID.constants},
3479 {"Turn PID Constants", &turnPID.constants},
3480 {"Swing Forward PID Constants", &forward_swingPID.constants},
3481 {"Swing Backward PID Constants", &backward_swingPID.constants}};
3482
3490
3495
3502 void opcontrol_arcade_scaling(bool enable);
3503
3508
3509 private:
3510 void opcontrol_drive_activebrake_targets_set();
3511 double odom_smooth_weight_smooth = 0.0;
3512 double odom_smooth_weight_data = 0.0;
3513 double odom_smooth_tolerance = 0.0;
3514 bool odom_use_left = true;
3515 double odom_ime_track_width_left = 0.0;
3516 double odom_ime_track_width_right = 0.0;
3517 bool imu_calibrate_took_too_long = false;
3518 bool is_full_pid_tuner_enabled = false;
3519 std::vector<const_and_name>* used_pid_tuner_pids;
3520 double opcontrol_speed_max = 127.0;
3521 bool arcade_vector_scaling = false;
3522 // odom privates
3523 std::vector<odom> pp_movements;
3524 std::vector<int> injected_pp_index;
3525 int pp_index = 0;
3526 std::vector<odom> smooth_path(std::vector<odom> ipath, double weight_smooth, double weight_data, double tolerance);
3527 double is_past_target(pose target, pose current);
3528 void raw_pid_odom_pp_set(std::vector<odom> imovements, bool slew_on);
3529 bool ptf1_running = false;
3530 std::vector<pose> find_point_to_face(pose current, pose target, drive_directions dir, bool set_global);
3531 void raw_pid_odom_ptp_set(odom imovement, bool slew_on);
3532 std::vector<odom> inject_points(std::vector<odom> imovements);
3533 std::vector<pose> point_to_face = {{0, 0, 0}, {0, 0, 0}};
3534 double turn_is_toleranced(double target, double current, double input, double longest, double shortest);
3535 double turn_short(double target, double current, bool print = false);
3536 double turn_long(double target, double current, bool print = false);
3537 double new_turn_target_compute(double target, double current, light::e_angle_behavior behavior);
3538 double turn_left(double target, double current, bool print = false);
3539 double turn_right(double target, double current, bool print = false);
3540 bool imu_calibration_complete = false;
3541 bool is_swing_slew_enabled(e_swing type, double target, double current);
3542 bool slew_reenables_when_max_speed_changes = true;
3543 int slew_min_when_it_enabled = 0;
3544 bool slew_will_enable_later = false;
3545 bool current_slew_on = false;
3546 bool is_odom_turn_bias_enabled = true;
3547 bool odom_turn_bias_enabled();
3548 void odom_turn_bias_enable(bool set);
3549 double angle_rad = 0.0;
3550 double global_track_width = 0.0;
3551 bool odometry_enabled = true;
3552 pose odom_target = {0.0, 0.0, 0.0};
3553 pose odom_current = {0.0, 0.0, 0.0};
3554 pose odom_second_to_last = {0.0, 0.0, 0.0};
3555 pose odom_start = {0.0, 0.0, 0.0};
3556 pose odom_target_start = {0.0, 0.0, 0.0};
3557 pose turn_to_point_target = {0.0, 0.0, 0.0};
3558 bool y_flipped = false;
3559 bool x_flipped = false;
3560 bool theta_flipped = false;
3561 double flip_angle_target(double target);
3562 double odom_imu_start = 0.0;
3563 int past_target = 0;
3564 double SPACING = 0.5;
3565 double LOOK_AHEAD = 7.0;
3566 double dlead = 0.5;
3567 double max_boomerang_distance = 12.0;
3568 double odom_turn_bias_amount = 1.375;
3569 drive_directions current_drive_direction = fwd;
3570 double h_last = 0.0, t_last = 0.0, l_last = 0.0, r_last = 0.0;
3571 pose l_pose{0.0, 0.0, 0.0};
3572 pose r_pose{0.0, 0.0, 0.0};
3573 pose central_pose{0.0, 0.0, 0.0};
3574 double xy_current_fake = 0.0;
3575 double xy_last_fake = 0.0;
3576 double xy_delta_fake = 0.0;
3577 double new_current_fake = 0.0;
3578 bool was_odom_just_set = false;
3579 std::pair<float, float> decide_vert_sensor(light::tracking_wheel* tracker, bool is_tracker_enabled, float ime = 0.0, float ime_track = 0.0);
3580 pose solve_xy_vert(float p_track_width, float current_t, float delta_vert, float delta_t);
3581 pose solve_xy_horiz(float p_track_width, float current_t, float delta_horiz, float delta_t);
3582 bool was_last_pp_mode_boomerang = false;
3583 bool global_forward_drive_slew_enabled = false;
3584 bool global_backward_drive_slew_enabled = false;
3585 bool global_forward_swing_slew_enabled = false;
3586 bool global_backward_swing_slew_enabled = false;
3587 double turn_tolerance = 3.0;
3588 bool global_turn_slew_enabled = false;
3589 e_angle_behavior current_angle_behavior = raw;
3590 e_angle_behavior default_swing_type = raw;
3591 e_angle_behavior default_turn_type = raw;
3592 e_angle_behavior default_odom_type = shortest;
3593 bool turn_biased_left = false;
3594 std::vector<odom> set_odoms_direction(std::vector<odom> inputs);
3595 odom set_odom_direction(odom input);
3596 pose flip_pose(pose input);
3597 bool odom_tracker_left_enabled = false;
3598 bool odom_tracker_right_enabled = false;
3599 bool odom_tracker_front_enabled = false;
3600 bool odom_tracker_back_enabled = false;
3601
3602 double chain_target_start = 0.0;
3603 double chain_sensor_start = 0.0;
3604 double drive_forward_motion_chain_scale = 0.0;
3605 double drive_backward_motion_chain_scale = 0.0;
3606 double swing_forward_motion_chain_scale = 0.0;
3607 double swing_backward_motion_chain_scale = 0.0;
3608 double turn_motion_chain_scale = 0.0;
3609 double used_motion_chain_scale = 0.0;
3610 bool motion_chain_backward = false;
3611
3612 double IMU_SCALER = 1.0;
3613
3614 bool drive_toggle = true;
3615 bool print_toggle = true;
3616 int swing_min = 0;
3617 int turn_min = 0;
3618 bool practice_mode_is_on = false;
3619 int swing_opposite_speed = 0;
3620 bool slew_swing_fwd_using_angle = false;
3621 bool slew_swing_rev_using_angle = false;
3622 bool slew_swing_using_angle = false;
3623 bool pid_tuner_terminal_b = false;
3624 bool pid_tuner_lcd_b = true;
3625 void pid_tuner_print();
3626 void pid_tuner_value_modify(float p, float i, float d, float start);
3627 void pid_tuner_value_increase();
3628 void pid_tuner_value_decrease();
3629 void pid_tuner_print_brain();
3630 void pid_tuner_print_terminal();
3631 void pid_tuner_brain_init();
3632 int column = 0;
3633 int row = 0;
3634 std::string arrow = " <--\n";
3635 bool last_controller_curve_state = false;
3636 bool last_auton_selector_state = false;
3637 bool pid_tuner_on = false;
3638 std::string complete_pid_tuner_output = "";
3639 float p_increment = 0.1, i_increment = 0.001, d_increment = 0.25, start_i_increment = 1.0;
3640
3644 void wait_until_drive(double target);
3645 void wait_until_turn_swing(double target);
3646
3655 void private_drive_set(int left, int right);
3656
3660 int clipped_joystick(int joystick);
3661
3665 bool heading_on = true;
3666
3670 double TICK_PER_REV;
3671 double TICK_PER_INCH;
3672 double CIRCUMFERENCE;
3673
3674 double CARTRIDGE;
3675 double RATIO;
3676 double WHEEL_DIAMETER;
3677
3681 int max_speed;
3682
3686 void drive_pid_task();
3687 void swing_pid_task();
3688 void turn_pid_task();
3689 void ez_auto_task();
3690 void ptp_task();
3691 void boomerang_task();
3692 void pp_task();
3693
3697 double l_start = 0;
3698 double r_start = 0;
3699
3703 bool disable_controller = true; // True enables, false disables.
3704
3708 bool is_tank;
3709
3710#define DRIVE_INTEGRATED 1
3711#define DRIVE_ADI_ENCODER 2
3712#define DRIVE_ROTATION 3
3713#define ODOM_TRACKER 4
3714
3718 int is_tracker = DRIVE_INTEGRATED;
3719
3723 void save_l_curve_sd();
3724 void save_r_curve_sd();
3725
3729 struct button_ {
3730 bool lock = false;
3731 bool release_reset = false;
3732 int release_timer = 0;
3733 int hold_timer = 0;
3734 int increase_timer;
3735 pros::controller_digital_e_t button;
3736 };
3737
3738 button_ l_increase_;
3739 button_ l_decrease_;
3740 button_ r_increase_;
3741 button_ r_decrease_;
3742
3746 void button_press(button_* input_name, int button, std::function<void()> changeCurve, std::function<void()> save);
3747
3751 double left_curve_scale;
3752 double right_curve_scale;
3753
3757 void l_decrease();
3758 void l_increase();
3759 void r_decrease();
3760 void r_increase();
3761
3765 bool is_reversed = false;
3766};
3767}; // namespace light
Tank-drive chassis class.
Definition drive.hpp:78
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:204
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:182
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:130
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:189
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:193
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_turn_set(double target, int speed=TURN_SPEED)
Sets the robot to turn relative to initial heading using PID.
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:205
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:145
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.
double pid_tuner_increment_i_get()
Returns the value that PID Tuner increments I.
void pid_turn_set(okapi::QAngle p_target, int speed=TURN_SPEED)
Sets the robot to turn relative to initial heading using PID with okapi units.
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:181
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_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:170
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:179
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:95
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.
PID current_a_odomPID
Definition drive.hpp:177
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:135
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:155
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:160
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.
void pid_drive_set(okapi::QLength p_target, int speed=DRIVE_SPEED)
Sets the robot to move forward using PID with okapi units, only using slew if globally enabled.
e_mode mode
Current mode of the drive.
Definition drive.hpp:445
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.
void pid_swing_set(e_swing type, double target, int speed=SWING_SPEED)
Sets the robot to turn using only the left or right side relative to initial heading without okapi un...
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:183
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:150
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:105
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:192
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:125
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:188
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 pid_tuner_refresh()
Force a refresh of the PID Tuner brain/terminal output with current constant values.
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:180
bool odom_x_direction_get()
Checks if X axis is flipped.
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:110
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:120
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:175
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.
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:169
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:171
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...
void pid_tuner_column_set(int idx)
Set which PID the tuner UI displays (index into pid_tuner_pids / pid_tuner_full_pids).
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:140
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.
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:194
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:178
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_swing_set(e_swing type, okapi::QAngle p_target, int speed=SWING_SPEED)
Sets the robot to turn using only the left or right side relative to initial heading with okapi units...
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:195
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:115
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_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:3473
PID::Constants pid_swing_constants_backward_get()
Returns PID constants with PID::Constants.
double friction_kQ
Definition drive.hpp:206
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:173
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:2695
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:165
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:100
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:3462
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:85
void pid_drive_set(double target, int speed=DRIVE_SPEED)
Sets the robot to move forward using PID without okapi units, only using slew if globally enabled.
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:470
void pid_turn_set(united_pose p_itarget, drive_directions dir, int speed=TURN_SPEED)
Sets the robot to turn face a point using PID and odometry.
pros::motor_brake_mode_e_t CURRENT_BRAKE
Global current brake mode.
Definition drive.hpp:90
void odom_y_flip(bool flip=true)
Flips the Y axis.
void pid_turn_set(pose itarget, drive_directions dir, int speed=TURN_SPEED)
Sets the robot to turn face a point using PID and odometry.
light::slew slew_backward
Definition drive.hpp:191
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:190
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:174
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:3710
Initialize once via init(); poll getPose/setPose from any task.
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
int TURN_SPEED
e_mode
Active chassis motion mode.
Definition util.hpp:79
int SWING_SPEED
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.
int DRIVE_SPEED
Default speeds used when a pid_drive_set / pid_turn_set / pid_swing_set call omits the speed argument...
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:3456
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.