11#include " globals.h"
22#include " pros/abstract_motor.hpp"
3+ #include " pros/adi.hpp"
34#include " pros/misc.hpp"
45#include " pros/motors.hpp"
56#include " pros/optical.hpp"
67#include " pros/vision.h"
7- #include " pros/vision.hpp"
88
99/*
1010 * Although the following constants belong in their own seperate
@@ -23,29 +23,35 @@ namespace Globals {
2323pros::Controller controller (pros::E_CONTROLLER_MASTER);
2424pros::Controller partner (pros::E_CONTROLLER_PARTNER);
2525
26- pros::Motor RightFront (13 , pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
27- pros::Motor LeftFront (-19 , pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
28- pros::Motor LeftBack (-18 , pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
29- pros::Motor RightBack (12 , pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
30- pros::Motor LeftMid (20 , pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
31- pros::Motor RightMid (-11 , pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
32- pros::Motor IntakeMotor (-9 , pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
33- pros::Motor HookMotor (7 , pros::v5::MotorGears::green, pros::v5::MotorUnits::degrees);
34- pros::Motor LadyBrownMotor (-3 , pros::v5::MotorGears::green, pros::v5::MotorUnits::degrees);
26+ pros::Motor RightFront (16 , pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
27+ pros::Motor LeftFront (-13 , pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
28+ pros::Motor LeftBack (-11 , pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
29+ pros::Motor RightBack (14 , pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
30+ pros::Motor LeftMid (12 , pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
31+ pros::Motor RightMid (-15 , pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
32+ pros::Motor IntakeMotor (-4 , pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
33+ pros::Motor HookMotor (3 , pros::v5::MotorGears::green, pros::v5::MotorUnits::degrees);
34+ pros::Motor LadyBrownMotor (-10 , pros::v5::MotorGears::green, pros::v5::MotorUnits::degrees);
3535
3636pros::adi::Pneumatics LatchControl (' A' , false );
3737pros::adi::Pneumatics SweeperControl (' B' , false );
38+ pros::adi::Pneumatics IntakeLift (' D' , false );
3839
39- pros::Distance distance_sensor (10 );
40- pros::Rotation lateral_sensor (16 );
41- pros::Rotation horizontal_sensor (17 );
40+ pros::adi::DigitalIn HookSwitch (' C' );
4241
43- pros::Rotation LadyBrownRotation (8 );
4442
45- pros::Imu inertial_sensor (15 );
43+ pros::Distance distance_sensor (6 );
44+ pros::Rotation lateral_sensor (-19 );
45+ pros::Rotation horizontal_sensor (-20 );
46+
47+ pros::Rotation LadyBrownRotation (9 );
48+ pros::Rotation HookRotation (2 );
49+
50+
51+ pros::Imu inertial_sensor (17 );
4652
4753// Vision sensor configuration
48- pros::Optical colorSensor (4 );
54+ pros::Optical colorSensor (5 );
4955
5056pros::vision_signature_s_t RED_SIG =
5157 pros::c::vision_signature_from_utility (1 , -4653 , -3619 , -4136 , 9831 , 11725 , 10778 , 2.5 , 0 );
@@ -62,15 +68,15 @@ pros::MotorGroup drive_({LeftFront.get_port(), RightFront.get_port(), LeftMid.ge
6268 LeftBack.get_port (), RightBack.get_port ()});
6369
6470// Lemlib objects - Used by lemlib drive and odometry functions
65- lemlib::TrackingWheel horizontal_tracking_wheel (&horizontal_sensor, 2 , - 2.75 );
66- lemlib::TrackingWheel vertical_tracking_wheel (&lateral_sensor, 2 , -1 );
71+ lemlib::TrackingWheel horizontal_tracking_wheel (&horizontal_sensor, 2 , 0.25 );
72+ lemlib::TrackingWheel vertical_tracking_wheel (&lateral_sensor, 2 , -0.625 );
6773
6874// Describes the lemlib objects that are used to control the autonomous
6975// functions of the robot.
7076lemlib::Drivetrain drivetrain{
7177 &drive_left, // left drivetrain motors
7278 &drive_right, // right drivetrain motors
73- 12.25 , // track width
79+ 10.8 , // track width
7480 lemlib::Omniwheel::OLD_325,
7581 450 , // drivetrain rpm is 450
7682 2 // horizontal drift is 2
@@ -86,38 +92,56 @@ lemlib::OdomSensors sensors{
8692
8793// forward/backward PID
8894// lateral PID controller
89- lemlib::ControllerSettings lateral_controller (6.5 , // proportional gain (kP)
95+ lemlib::ControllerSettings lateral_controller (6.4 , // proportional gain (kP)
9096 0 , // integral gain (kI)
9197 35 , // derivative gain (kD)
92- 0 , // anti windup
98+ 3 , // anti windup
9399 0.5 , // small error range, in inches
94100 100 , // small error range timeout, in milliseconds
95- 3 , // large error range, in inches
101+ 2 , // large error range, in inches
96102 500 , // large error range timeout, in milliseconds
97- 20 // maximum acceleration (slew)
103+ 115 // maximum acceleration (slew)
98104);
99105
100- // angular PID controller
101- lemlib::ControllerSettings angular_controller (2.1 , // proportional gain (kP)
106+ // 0, // anti windup
107+ // 0.5, // small error range, in inches
108+ // 100, // small error range timeout, in milliseconds
109+ // 3, // large error range, in inches
110+ // 500, // large error range timeout, in milliseconds
111+ // 20
112+
113+ // angular PID controller 2.2 17 Last test: kp 13 kd 75, kp was just before full oscilation, kd was just before jittering
114+ lemlib::ControllerSettings angular_controller (3.27 , // proportional gain (kP)
102115 0 , // integral gain (kI)
103- 14 , // derivative gain (kD)
104- 0 , // anti windup
105- 0.5 , // small error range, in degrees
106- 100 , // small error range timeout, in milliseconds
107- 2 , // large error range, in degrees
116+ 27.5 , // derivative gain (kD)
117+ 3 , // anti windup
118+ 2 , // small error range, in degrees
119+ 90 , // small error range timeout, in milliseconds
120+ 3 , // large error range, in degrees
108121 500 , // large error range timeout, in milliseconds
109- 0 // maximum acceleration (slew)
122+ 0 // maximum acceleration (slew)
110123);
111124
112- lemlib::ExpoDriveCurve throttle_curve (3 , // joystick deadband out of 127
113- 50 , // minimum output where drivetrain will move out of 127
114- 0.992 // expo curve gain
125+ // 2, // small error range, in degrees
126+ // 80, // small error range timeout, in milliseconds
127+ // 3, // large error range, in degrees
128+ // 500, // large error range timeout, in milliseconds
129+ // 0
130+
131+ lemlib::ExpoDriveCurve throttle_curve (1 , // joystick deadband out of 127
132+ 35 , // minimum output where drivetrain will move out of 127
133+ 1.002 // expo curve gain
115134);
116135
117136// input curve for steer input during driver control
118- lemlib::ExpoDriveCurve steer_curve (3 , // joystick deadband out of 127
119- 17 , // minimum output where drivetrain will move out of 127
120- 1 // expo curve gain
137+ lemlib::ExpoDriveCurve steer_curve (1 , // joystick deadband out of 127
138+ 16 , // minimum output where drivetrain will move out of 127
139+ 1.0084 // expo curve gain
140+ );
141+
142+ lemlib::ExpoDriveCurve arcade_turn_curve (1 , // joystick deadband out of 127
143+ 8 , // minimum output where drivetrain will move out of 127
144+ 1.016 // expo curve gain
121145);
122146
123147lemlib::Chassis chassis (drivetrain, lateral_controller, angular_controller, sensors, &throttle_curve, &steer_curve);
0 commit comments