1516X High Stakes 2.0
Codebase for 1516X High Stakes season
Loading...
Searching...
No Matches
globals.cpp
Go to the documentation of this file.
1#include "globals.h"
2#include "pros/abstract_motor.hpp"
3#include "pros/misc.hpp"
4#include "pros/motors.hpp"
5#include "pros/optical.hpp"
6#include "pros/vision.h"
7#include "pros/vision.hpp"
8
9/*
10 * Although the following constants belong in their own seperate
11 * files(auton.cpp, drivetriain.cpp), they're put here in order to maintain a
12 * common location for all of the constants used by the program to belong in.
13 * NOTE: This is the location where these variables are put into memory, but
14 * they can be otherwise modified throughout the program.
15 */
16
17// Defines the objects that are used by the program for each of the individual
18// subsystems.
19
20namespace Robot {
21namespace Globals {
22
23pros::Controller controller(pros::E_CONTROLLER_MASTER);
24pros::Controller partner(pros::E_CONTROLLER_PARTNER);
25
26pros::Motor RightFront(13, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
27pros::Motor LeftFront(-19, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
28pros::Motor LeftBack(-18, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
29pros::Motor RightBack(12, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
30pros::Motor LeftMid(20, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
31pros::Motor RightMid(-11, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
32pros::Motor IntakeMotor(-9, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees);
33pros::Motor HookMotor(7, pros::v5::MotorGears::green, pros::v5::MotorUnits::degrees);
34pros::Motor LadyBrownMotor(-3, pros::v5::MotorGears::green, pros::v5::MotorUnits::degrees);
35
36pros::adi::Pneumatics LatchControl('A', false);
37pros::adi::Pneumatics SweeperControl('B', false);
38
39pros::Distance distance_sensor(10);
40pros::Rotation lateral_sensor(16);
41pros::Rotation horizontal_sensor(17);
42
43pros::Rotation LadyBrownRotation(8);
44
45pros::Imu inertial_sensor(15);
46
47// Vision sensor configuration
48pros::Optical colorSensor(4);
49
50pros::vision_signature_s_t RED_SIG =
51 pros::c::vision_signature_from_utility(1, -4653, -3619, -4136, 9831, 11725, 10778, 2.5, 0);
52
53pros::vision_signature_s_t BLUE_SIG =
54 pros::c::vision_signature_from_utility(2, 9187, 12161, 10674, -375, 1327, 476, 2.5, 0);
55pros::vision_signature_s_t BLUE_DARK_SIG =
56 pros::c::vision_signature_from_utility(3, -4793, -4173, -4483, 1069, 2765, 1917, 3, 0);
57
58// Pros motor groups - most used by lemlib
59pros::MotorGroup drive_left({LeftFront.get_port(), LeftMid.get_port(), LeftBack.get_port()});
60pros::MotorGroup drive_right({RightFront.get_port(), RightMid.get_port(), RightBack.get_port()});
61pros::MotorGroup drive_({LeftFront.get_port(), RightFront.get_port(), LeftMid.get_port(), RightMid.get_port(),
62 LeftBack.get_port(), RightBack.get_port()});
63
64// Lemlib objects - Used by lemlib drive and odometry functions
65lemlib::TrackingWheel horizontal_tracking_wheel(&horizontal_sensor, 2, -2.75);
66lemlib::TrackingWheel vertical_tracking_wheel(&lateral_sensor, 2, -1);
67
68// Describes the lemlib objects that are used to control the autonomous
69// functions of the robot.
70lemlib::Drivetrain drivetrain{
71 &drive_left, // left drivetrain motors
72 &drive_right, // right drivetrain motors
73 12.25, // track width
74 lemlib::Omniwheel::OLD_325,
75 450, // drivetrain rpm is 450
76 2 // horizontal drift is 2
77};
78
79lemlib::OdomSensors sensors{
80 &vertical_tracking_wheel, // vertical tracking wheel 1
81 nullptr, // vertical tracking wheel 2
82 &horizontal_tracking_wheel, // horizontal tracking wheel 1
83 nullptr, // we don't have a second tracking wheel, so we set it to nullptr
84 &inertial_sensor // inertial sensor
85};
86
87// forward/backward PID
88// lateral PID controller
89lemlib::ControllerSettings lateral_controller(6.5, // proportional gain (kP)
90 0, // integral gain (kI)
91 35, // derivative gain (kD)
92 0, // anti windup
93 0.5, // small error range, in inches
94 100, // small error range timeout, in milliseconds
95 3, // large error range, in inches
96 500, // large error range timeout, in milliseconds
97 20 // maximum acceleration (slew)
98);
99
100// angular PID controller
101lemlib::ControllerSettings angular_controller(2.1, // proportional gain (kP)
102 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
108 500, // large error range timeout, in milliseconds
109 0 // maximum acceleration (slew)
110);
111
112lemlib::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
115);
116
117// input curve for steer input during driver control
118lemlib::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
121);
122
124
125} // namespace Globals
126
127} // namespace Robot
pros::MotorGroup drive_({LeftFront.get_port(), RightFront.get_port(), LeftMid.get_port(), RightMid.get_port(), LeftBack.get_port(), RightBack.get_port()})
lemlib::OdomSensors sensors
Definition globals.cpp:79
pros::adi::Pneumatics LatchControl('A', false)
lemlib::ControllerSettings lateral_controller(6.5, 0, 35, 0, 0.5, 100, 3, 500, 20)
pros::Motor LeftMid(20, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees)
pros::Motor RightFront(13, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees)
pros::MotorGroup drive_right({RightFront.get_port(), RightMid.get_port(), RightBack.get_port()})
lemlib::ExpoDriveCurve throttle_curve(3, 50, 0.992)
pros::Motor IntakeMotor(-9, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees)
pros::Motor LeftFront(-19, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees)
pros::adi::Pneumatics SweeperControl('B', false)
pros::vision_signature_s_t BLUE_DARK_SIG
Definition globals.cpp:55
lemlib::TrackingWheel horizontal_tracking_wheel & horizontal_sensor
Definition globals.cpp:65
pros::Motor HookMotor(7, pros::v5::MotorGears::green, pros::v5::MotorUnits::degrees)
lemlib::Chassis chassis(drivetrain, lateral_controller, angular_controller, sensors, &throttle_curve, &steer_curve)
pros::Motor RightMid(-11, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees)
pros::Optical colorSensor(4)
pros::Rotation LadyBrownRotation(8)
pros::Motor LeftBack(-18, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees)
lemlib::TrackingWheel vertical_tracking_wheel & lateral_sensor
Definition globals.cpp:66
pros::Controller controller(pros::E_CONTROLLER_MASTER)
pros::Controller partner(pros::E_CONTROLLER_PARTNER)
pros::Distance distance_sensor(10)
lemlib::ControllerSettings angular_controller(2.1, 0, 14, 0, 0.5, 100, 2, 500, 0)
pros::vision_signature_s_t BLUE_SIG
Definition globals.cpp:53
pros::vision_signature_s_t RED_SIG
Definition globals.cpp:50
lemlib::Drivetrain drivetrain
Definition globals.cpp:70
pros::Motor LadyBrownMotor(-3, pros::v5::MotorGears::green, pros::v5::MotorUnits::degrees)
pros::Motor RightBack(12, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees)
pros::MotorGroup drive_left({LeftFront.get_port(), LeftMid.get_port(), LeftBack.get_port()})
lemlib::ExpoDriveCurve steer_curve(3, 17, 1)
pros::Imu inertial_sensor(15)
Definition auton.h:10