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