First I added comments to all the new systems.
Second I finished all the color sorter code, like finishing the function to call when you want to look for a color. Next we had the scotts county competition so I made custom auton routes for us to run at the competition. These will be changed later.
This commit is contained in:
1 parent
c9f7db1011
commit
3bbad07dea
8 files changed
+668
-61
No files matched your search
@@ -6,12 +6,16 @@
|
||||
#include "pros/colors.hpp"
|
||||
|
||||
namespace ez {
|
||||
|
||||
/**
|
||||
* Structure to hold two optical sensor pointers.
|
||||
*/
|
||||
struct OpticalSensors {
|
||||
pros::Optical* leftColorSensor;
|
||||
pros::Optical* rightColorSensor;
|
||||
};
|
||||
|
||||
/**
|
||||
* Enumeration to hold colors we want to select.
|
||||
*/
|
||||
enum wanted_color {
|
||||
red,
|
||||
blue,
|
||||
@@ -19,32 +23,45 @@ namespace ez {
|
||||
green,
|
||||
purple
|
||||
};
|
||||
|
||||
/**
|
||||
* Enumeration to hold the two different time of a match.
|
||||
*/
|
||||
enum control_period {
|
||||
driver,
|
||||
auton
|
||||
};
|
||||
|
||||
/**
|
||||
* Color sensor class
|
||||
*/
|
||||
class ColorSensors {
|
||||
private:
|
||||
|
||||
public:
|
||||
int led_brightness;
|
||||
|
||||
ColorSensors();
|
||||
|
||||
/**
|
||||
* Creates a color sorter to allow you to detect colors with sensors
|
||||
*
|
||||
* \param sensorNum
|
||||
* \param c_sensor
|
||||
* the sensor we want to use for the reading
|
||||
* \param period
|
||||
* the current control period where in
|
||||
* \param selected_color
|
||||
* the color we want to look for
|
||||
* \param led_brightness
|
||||
* sets the how bright the leds are on the sensors
|
||||
* \param looped
|
||||
* do we want to continusly check for that color
|
||||
*/
|
||||
void color_sorter(const OpticalSensors& c_sensor, control_period period, wanted_color selected_color, bool looped);
|
||||
void color_sorter(pros::Optical* c_sensor, control_period period, wanted_color selected_color, int led_brightness, bool looped);
|
||||
|
||||
void DisplayColor();
|
||||
};
|
||||
/**
|
||||
* Declares a variable that can be used anywhere to access information
|
||||
* from inside the structure.
|
||||
*/
|
||||
extern OpticalSensors mySensors;
|
||||
};
|
||||
@@ -6,40 +6,60 @@
|
||||
#include "pros/motor_group.hpp"
|
||||
|
||||
namespace ez {
|
||||
|
||||
/**
|
||||
* Enumeration to hold the current part of a match were in.
|
||||
*/
|
||||
enum class ControlPeriodM {
|
||||
driver,
|
||||
auton
|
||||
};
|
||||
|
||||
/**
|
||||
* Enumeration to hold the different controllers avalable.
|
||||
*/
|
||||
enum class ControllerM {
|
||||
master,
|
||||
slave
|
||||
};
|
||||
|
||||
/**
|
||||
* Enumeration to hold the different buttons to use.
|
||||
*/
|
||||
enum class ButtonsM {
|
||||
arrow_buttons,
|
||||
Y_B_buttons,
|
||||
left_shoulder_buttons,
|
||||
right_shoulder_buttons
|
||||
};
|
||||
|
||||
/**
|
||||
* Enumeration to hold all the motors and motor groups available
|
||||
*/
|
||||
enum class MotorGroups {
|
||||
lift_MG,
|
||||
claw_M,
|
||||
roller_M
|
||||
};
|
||||
|
||||
/**
|
||||
* Motor mechanism class
|
||||
*/
|
||||
class Mechanisms {
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
float fw_motor_speed = 0;
|
||||
float rev_motor_speed = 0;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
Mechanisms();
|
||||
|
||||
/**
|
||||
* Allows you to control your motors
|
||||
*
|
||||
* \param controlPeriodM
|
||||
* The current control period were in
|
||||
*
|
||||
*
|
||||
*/
|
||||
void motor_control(enum ControlPeriodM, enum ControllerM, enum ButtonsM, enum MotorGroups, float fw_motor_speed, float rev_motor_speed);
|
||||
|
||||
float get_motor_speed();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "EZ-Template/piston.hpp"
|
||||
|
||||
namespace ez {
|
||||
/**
|
||||
/**
|
||||
* Enumeration to hold the current part of a match were in.
|
||||
*/
|
||||
enum class ControlPeriodP {
|
||||
@@ -37,7 +37,6 @@ namespace ez {
|
||||
};
|
||||
|
||||
class Pneumatics{
|
||||
|
||||
private:
|
||||
bool pistonState;
|
||||
|
||||
|
||||
+8
-8
@@ -5,14 +5,14 @@ void default_constants();
|
||||
/**
|
||||
* Personal auton routes
|
||||
*/
|
||||
void leftMain(std::string side);
|
||||
void rightMain(std::string side);
|
||||
void Skills();
|
||||
void BlueRight();
|
||||
void BlueLeft();
|
||||
void RedRight();
|
||||
void RedLeft();
|
||||
void testMain(std::string side);
|
||||
void quick_right_blue();
|
||||
void quick_right_red();
|
||||
void blue_left_3pin();
|
||||
void blue_right_4pin();
|
||||
void blue_right_3pin();
|
||||
void red_left_3pin();
|
||||
void red_right_3pin();
|
||||
void red_right_4pin();
|
||||
void Test();
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -402,7 +402,7 @@
|
||||
"compress_bin": true,
|
||||
"description": "",
|
||||
"remote_name": "EZ-Template",
|
||||
"slot": 1,
|
||||
"slot": 3,
|
||||
"icon": "pizza"
|
||||
},
|
||||
"use_early_access": false
|
||||
|
||||
@@ -4,45 +4,64 @@ using namespace ez;
|
||||
|
||||
ColorSensors::ColorSensors() {}
|
||||
|
||||
void ColorSensors::color_sorter(const OpticalSensors& c_sensor, control_period period, wanted_color selected_color, bool looped) {
|
||||
/**
|
||||
* Coler sorter function, allows you to take the value of a sensor
|
||||
* and complete a task based on the selected color.
|
||||
*/
|
||||
void ColorSensors::color_sorter(pros::Optical* c_sensor, control_period period, wanted_color selected_color, int led_brightness, bool looped) {
|
||||
// Sets the sensors leds to a certain brightness
|
||||
c_sensor->set_led_pwm(led_brightness);
|
||||
colorSensorTwo.set_led_pwm(led_brightness);
|
||||
|
||||
// loop that makes sure sensor values are always being updated and the function doesn't exit till a result is reached
|
||||
while (looped == true) {
|
||||
// Gets the current color of the selected sensors
|
||||
double main_hue = c_sensor->get_hue();
|
||||
double backup_hue = colorSensorTwo.get_hue();
|
||||
|
||||
// Makes a bool value to turn true when it sees blue
|
||||
bool main_is_blue = (main_hue >= 160 && main_hue <= 280);
|
||||
bool backup_is_blue = (backup_hue >= 160 && backup_hue <= 280);
|
||||
|
||||
// Makes a bool value to turn true when is ses red
|
||||
bool main_is_red = (main_hue <= 20 || main_hue >= 340);
|
||||
bool backup_is_red = (backup_hue <= 20 || backup_hue >= 340);
|
||||
|
||||
// A switch to easily check what color we want to look for
|
||||
switch (selected_color)
|
||||
{
|
||||
case wanted_color::blue:
|
||||
// If both sensors see the same color exit the loop and stop doing the code
|
||||
if (main_is_blue == true && backup_is_blue == true) {
|
||||
roller.move(0);
|
||||
looped = false;
|
||||
}
|
||||
else {
|
||||
// Code to run when the sensors don't see the right color
|
||||
roller.move(60);
|
||||
}
|
||||
break;
|
||||
|
||||
case wanted_color::red:
|
||||
// If both sensors see the same color exit the loop and stop doing the code
|
||||
if (main_is_red == true && backup_is_red == true) {
|
||||
roller.move(0);
|
||||
looped = false;
|
||||
}
|
||||
else {
|
||||
// Code to run when the sensors don't see the right color
|
||||
roller.move(65);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
pros::delay(100); // Delay to allow the cpu to catch up
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
void Opticalcarter::color_sorter(control_period period, wanted_color selected_color, bool looped) {
|
||||
switch (selected_color)
|
||||
{
|
||||
case wanted_color::blue:
|
||||
while (looped == true) {
|
||||
pros::delay(100);
|
||||
while (!colorSensorOne.get_hue() >= 160 && !colorSensorOne.get_hue() <=280 && !colorSensorTwo.get_hue() >= 160 && !colorSensorTwo.get_hue() <=280) {
|
||||
roller.move(127);
|
||||
if (colorSensorOne.get_hue() >= 160 && colorSensorOne.get_hue() <=280 && colorSensorTwo.get_hue() >= 160 && colorSensorTwo.get_hue() <=280) {
|
||||
roller.move(0);
|
||||
looped = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case wanted_color::red:
|
||||
while (looped == true) {
|
||||
pros::delay(100);
|
||||
while (!colorSensorOne.get_hue() <= 20 || !colorSensorOne.get_hue() >=340 && !colorSensorTwo.get_hue() <= 20 || !colorSensorTwo.get_hue() >=340) {
|
||||
roller.move(127);
|
||||
if (colorSensorOne.get_hue() <= 20 || colorSensorOne.get_hue() >=340 && colorSensorTwo.get_hue() <= 20 || colorSensorTwo.get_hue() >=340) {
|
||||
roller.move(0);
|
||||
looped = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
|
||||
/*while (looped == true) {
|
||||
if (sensorNum == 1 && period == auton) {
|
||||
pros::delay(100);
|
||||
|
||||
+530
@@ -11,6 +11,9 @@ const int DRIVE_SPEED = 110;
|
||||
const int TURN_SPEED = 90;
|
||||
const int SWING_SPEED = 110;
|
||||
|
||||
//Default Objects
|
||||
ColorSensors sorter;
|
||||
|
||||
///
|
||||
// Constants
|
||||
///
|
||||
@@ -52,7 +55,534 @@ void default_constants() {
|
||||
///
|
||||
// Custom auton routes
|
||||
//
|
||||
void quick_right_blue() {
|
||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::blue, 100, true);
|
||||
|
||||
lift.move(80);
|
||||
pros::delay(420);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -59.3_deg, SWING_SPEED, -7);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_drive_set(15.7_in, 100, true);
|
||||
chassis.pid_wait_until(9_in);
|
||||
chassis.pid_speed_max_set(30);
|
||||
chassis.pid_wait();
|
||||
|
||||
pros::delay(200);
|
||||
lift.move(-30);
|
||||
pros::delay(110);
|
||||
lift.move(0);
|
||||
claw.move(90);
|
||||
lift.move(-30);
|
||||
pros::delay(100);
|
||||
lift.move(0);
|
||||
pros::delay(500);
|
||||
|
||||
chassis.pid_drive_set(-3_in, 100);
|
||||
chassis.pid_wait_quick_chain();
|
||||
}
|
||||
|
||||
void quick_right_red() {
|
||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::red, 100, true);
|
||||
|
||||
lift.move(80);
|
||||
pros::delay(420);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -59.6_deg, SWING_SPEED, -7);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_drive_set(15.7_in, 100, true);
|
||||
chassis.pid_wait_until(9_in);
|
||||
chassis.pid_speed_max_set(30);
|
||||
chassis.pid_wait();
|
||||
|
||||
pros::delay(200);
|
||||
lift.move(-30);
|
||||
pros::delay(110);
|
||||
lift.move(0);
|
||||
claw.move(90);
|
||||
lift.move(-30);
|
||||
pros::delay(100);
|
||||
lift.move(0);
|
||||
pros::delay(500);
|
||||
|
||||
chassis.pid_drive_set(-3_in, 100);
|
||||
chassis.pid_wait_quick_chain();
|
||||
}
|
||||
|
||||
void blue_left_3pin() {
|
||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::blue, 100, true);
|
||||
|
||||
lift.move(80);
|
||||
pros::delay(420);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_swing_set(ez::LEFT_SWING, 60_deg, SWING_SPEED, -7);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_drive_set(15.7_in, 100, true);
|
||||
chassis.pid_wait_until(9_in);
|
||||
chassis.pid_speed_max_set(30);
|
||||
chassis.pid_wait();
|
||||
|
||||
pros::delay(200);
|
||||
lift.move(-30);
|
||||
pros::delay(110);
|
||||
lift.move(0);
|
||||
claw.move(90);
|
||||
lift.move(-30);
|
||||
pros::delay(100);
|
||||
lift.move(0);
|
||||
pros::delay(500);
|
||||
|
||||
chassis.pid_drive_set(-3_in, 100);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_swing_set(ez::LEFT_SWING, 20_deg, SWING_SPEED, -0);
|
||||
chassis.pid_wait();
|
||||
|
||||
claw.move(-127);
|
||||
lift.move(-80);
|
||||
pros::delay(200);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_drive_set(18_in, 100);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_swing_set(ez::LEFT_SWING, 40_deg, 60, 7);
|
||||
chassis.pid_wait();
|
||||
|
||||
lift.move(100);
|
||||
pros::delay(200);
|
||||
lift.move(0);
|
||||
pros::delay(300);
|
||||
|
||||
chassis.pid_turn_set(-112.4_deg, TURN_SPEED);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_drive_set(30_in, DRIVE_SPEED);
|
||||
chassis.pid_wait();
|
||||
|
||||
lift.move(100);
|
||||
pros::delay(900);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_drive_set(5_in, 70);
|
||||
chassis.pid_wait();
|
||||
|
||||
pros::delay(200);
|
||||
lift.move(-50);
|
||||
pros::delay(100);
|
||||
claw.move(127);
|
||||
pros::delay(500);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_drive_set(-3_in, 100);
|
||||
chassis.pid_wait();
|
||||
}
|
||||
|
||||
void blue_right_4pin() {
|
||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::blue, 100, true);
|
||||
|
||||
lift.move(80);
|
||||
pros::delay(420);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -59.3_deg, SWING_SPEED, -7);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_drive_set(15.7_in, 100, true);
|
||||
chassis.pid_wait_until(9_in);
|
||||
chassis.pid_speed_max_set(30);
|
||||
chassis.pid_wait();
|
||||
|
||||
pros::delay(200);
|
||||
lift.move(-30);
|
||||
pros::delay(110);
|
||||
lift.move(0);
|
||||
claw.move(90);
|
||||
lift.move(-30);
|
||||
pros::delay(100);
|
||||
lift.move(0);
|
||||
pros::delay(500);
|
||||
|
||||
chassis.pid_drive_set(-3_in, 100);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -20_deg, SWING_SPEED, -0);
|
||||
chassis.pid_wait();
|
||||
|
||||
claw.move(-127);
|
||||
lift.move(-80);
|
||||
pros::delay(200);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_drive_set(18_in, 100);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -40_deg, 60, 7);
|
||||
chassis.pid_wait();
|
||||
|
||||
lift.move(100);
|
||||
pros::delay(1000);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -210_deg, SWING_SPEED, -20);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_turn_set(-215_deg, SWING_SPEED);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_drive_set(10_in, 100);
|
||||
chassis.pid_wait();
|
||||
|
||||
pros::delay(200);
|
||||
lift.move(-50);
|
||||
pros::delay(100);
|
||||
claw.move(127);
|
||||
pros::delay(500);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_drive_set(-3_in, 80);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
lift.move(-80);
|
||||
pros::delay(200);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -134_deg, SWING_SPEED, -30);
|
||||
chassis.pid_wait();
|
||||
|
||||
claw.move(-127);
|
||||
|
||||
chassis.pid_drive_set(12_in, 100);
|
||||
chassis.pid_wait();
|
||||
|
||||
lift.move(80);
|
||||
pros::delay(350);
|
||||
lift.move(0);
|
||||
claw.move(0);
|
||||
pros::delay(150);
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -280_deg, SWING_SPEED, 0);
|
||||
}
|
||||
|
||||
void blue_right_3pin() {
|
||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::blue, 100, true);
|
||||
|
||||
lift.move(80);
|
||||
pros::delay(420);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -59.5_deg, SWING_SPEED, -7);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_drive_set(15.7_in, 100, true);
|
||||
chassis.pid_wait_until(9_in);
|
||||
chassis.pid_speed_max_set(30);
|
||||
chassis.pid_wait();
|
||||
|
||||
pros::delay(200);
|
||||
lift.move(-30);
|
||||
pros::delay(110);
|
||||
lift.move(0);
|
||||
claw.move(90);
|
||||
lift.move(-30);
|
||||
pros::delay(100);
|
||||
lift.move(0);
|
||||
pros::delay(500);
|
||||
|
||||
chassis.pid_drive_set(-3_in, 100);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -20_deg, SWING_SPEED, -0);
|
||||
chassis.pid_wait();
|
||||
|
||||
claw.move(-127);
|
||||
lift.move(-80);
|
||||
pros::delay(200);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_drive_set(18_in, 100);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -40_deg, 60, 9);
|
||||
chassis.pid_wait();
|
||||
|
||||
lift.move(100);
|
||||
pros::delay(200);
|
||||
lift.move(0);
|
||||
pros::delay(300);
|
||||
|
||||
chassis.pid_turn_set(112.4_deg, TURN_SPEED);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_drive_set(31_in, DRIVE_SPEED);
|
||||
chassis.pid_wait();
|
||||
|
||||
lift.move(100);
|
||||
pros::delay(900);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_drive_set(5_in, 70);
|
||||
chassis.pid_wait();
|
||||
|
||||
pros::delay(200);
|
||||
lift.move(-50);
|
||||
pros::delay(100);
|
||||
claw.move(127);
|
||||
pros::delay(500);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_drive_set(-3_in, 100);
|
||||
chassis.pid_wait();
|
||||
}
|
||||
|
||||
void red_left_3pin() {
|
||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::red, 100, true);
|
||||
|
||||
lift.move(80);
|
||||
pros::delay(420);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_swing_set(ez::LEFT_SWING, 60_deg, SWING_SPEED, -7);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_drive_set(15.7_in, 100, true);
|
||||
chassis.pid_wait_until(9_in);
|
||||
chassis.pid_speed_max_set(30);
|
||||
chassis.pid_wait();
|
||||
|
||||
pros::delay(200);
|
||||
lift.move(-30);
|
||||
pros::delay(110);
|
||||
lift.move(0);
|
||||
claw.move(90);
|
||||
lift.move(-30);
|
||||
pros::delay(100);
|
||||
lift.move(0);
|
||||
pros::delay(500);
|
||||
|
||||
chassis.pid_drive_set(-3_in, 100);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_swing_set(ez::LEFT_SWING, 20_deg, SWING_SPEED, -0);
|
||||
chassis.pid_wait();
|
||||
|
||||
claw.move(-127);
|
||||
lift.move(-80);
|
||||
pros::delay(200);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_drive_set(18_in, 100);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_swing_set(ez::LEFT_SWING, 40_deg, 60, 8);
|
||||
chassis.pid_wait();
|
||||
|
||||
lift.move(100);
|
||||
pros::delay(200);
|
||||
lift.move(0);
|
||||
pros::delay(300);
|
||||
|
||||
chassis.pid_turn_set(-112.4_deg, TURN_SPEED);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_drive_set(30_in, DRIVE_SPEED);
|
||||
chassis.pid_wait();
|
||||
|
||||
lift.move(100);
|
||||
pros::delay(900);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_drive_set(5_in, 70);
|
||||
chassis.pid_wait();
|
||||
|
||||
pros::delay(200);
|
||||
lift.move(-50);
|
||||
pros::delay(100);
|
||||
claw.move(127);
|
||||
pros::delay(500);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_drive_set(-3_in, 100);
|
||||
chassis.pid_wait();
|
||||
}
|
||||
|
||||
void red_right_3pin() {
|
||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::red, 100, true);
|
||||
|
||||
lift.move(80);
|
||||
pros::delay(420);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -59.3_deg, SWING_SPEED, -7);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_drive_set(15.7_in, 100, true);
|
||||
chassis.pid_wait_until(9_in);
|
||||
chassis.pid_speed_max_set(30);
|
||||
chassis.pid_wait();
|
||||
|
||||
pros::delay(200);
|
||||
lift.move(-30);
|
||||
pros::delay(110);
|
||||
lift.move(0);
|
||||
claw.move(90);
|
||||
lift.move(-30);
|
||||
pros::delay(100);
|
||||
lift.move(0);
|
||||
pros::delay(500);
|
||||
|
||||
chassis.pid_drive_set(-3_in, 100);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -20_deg, SWING_SPEED, -0);
|
||||
chassis.pid_wait();
|
||||
|
||||
claw.move(-127);
|
||||
lift.move(-80);
|
||||
pros::delay(200);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_drive_set(18_in, 100);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -40_deg, 60, 8);
|
||||
chassis.pid_wait();
|
||||
|
||||
lift.move(100);
|
||||
pros::delay(200);
|
||||
lift.move(0);
|
||||
pros::delay(300);
|
||||
|
||||
chassis.pid_turn_set(112.4_deg, TURN_SPEED);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_drive_set(30_in, DRIVE_SPEED);
|
||||
chassis.pid_wait();
|
||||
|
||||
lift.move(100);
|
||||
pros::delay(900);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_drive_set(5_in, 70);
|
||||
chassis.pid_wait();
|
||||
|
||||
pros::delay(200);
|
||||
lift.move(-50);
|
||||
pros::delay(100);
|
||||
claw.move(127);
|
||||
pros::delay(500);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_drive_set(-3_in, 100);
|
||||
chassis.pid_wait();
|
||||
}
|
||||
|
||||
void red_right_4pin() {
|
||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::red, 100, true);
|
||||
|
||||
lift.move(80);
|
||||
pros::delay(420);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -59.3_deg, SWING_SPEED, -7);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_drive_set(15.7_in, 100, true);
|
||||
chassis.pid_wait_until(9_in);
|
||||
chassis.pid_speed_max_set(30);
|
||||
chassis.pid_wait();
|
||||
|
||||
pros::delay(200);
|
||||
lift.move(-30);
|
||||
pros::delay(110);
|
||||
lift.move(0);
|
||||
claw.move(90);
|
||||
lift.move(-30);
|
||||
pros::delay(100);
|
||||
lift.move(0);
|
||||
pros::delay(500);
|
||||
|
||||
chassis.pid_drive_set(-3_in, 100);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -20_deg, SWING_SPEED, -0);
|
||||
chassis.pid_wait();
|
||||
|
||||
claw.move(-127);
|
||||
lift.move(-80);
|
||||
pros::delay(200);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_drive_set(18_in, 100);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -40_deg, 60, 7);
|
||||
chassis.pid_wait();
|
||||
|
||||
lift.move(100);
|
||||
pros::delay(1000);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -210_deg, SWING_SPEED, -20);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_turn_set(-215_deg, SWING_SPEED);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
chassis.pid_drive_set(10_in, 100);
|
||||
chassis.pid_wait();
|
||||
|
||||
pros::delay(200);
|
||||
lift.move(-50);
|
||||
pros::delay(100);
|
||||
claw.move(127);
|
||||
pros::delay(500);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_drive_set(-3_in, 80);
|
||||
chassis.pid_wait_quick_chain();
|
||||
|
||||
lift.move(-80);
|
||||
pros::delay(200);
|
||||
lift.move(0);
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -134_deg, SWING_SPEED, -30);
|
||||
chassis.pid_wait();
|
||||
|
||||
claw.move(-127);
|
||||
|
||||
chassis.pid_drive_set(12_in, 100);
|
||||
chassis.pid_wait();
|
||||
|
||||
lift.move(80);
|
||||
pros::delay(350);
|
||||
lift.move(0);
|
||||
claw.move(0);
|
||||
pros::delay(150);
|
||||
|
||||
chassis.pid_swing_set(ez::RIGHT_SWING, -280_deg, SWING_SPEED, 0);
|
||||
}
|
||||
void blue_wp() {
|
||||
|
||||
}
|
||||
|
||||
void red_wp() {
|
||||
|
||||
}
|
||||
|
||||
void skills() {
|
||||
|
||||
}
|
||||
|
||||
void Test() {
|
||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::blue, 100, true);
|
||||
}
|
||||
|
||||
///
|
||||
// Drive Example
|
||||
|
||||
+24
-2
@@ -9,7 +9,7 @@ ez::Drive chassis(
|
||||
|
||||
6, // IMU Port
|
||||
3.25, // Wheel Diameter (Remember, 4" wheels without screw holes are actually 4.125!)
|
||||
360.0); // Wheel RPM = cartridge * (motor gear / wheel gear)
|
||||
450.0); // Wheel RPM = cartridge * (motor gear / wheel gear)
|
||||
|
||||
// Uncomment the trackers you're using here!
|
||||
// - `8` and `9` are smart ports (making these negative will reverse the sensor)
|
||||
@@ -24,6 +24,20 @@ Pneumatics pistonControl;
|
||||
Mechanisms motorControl;
|
||||
//ArmMech armObj;
|
||||
|
||||
/**
|
||||
* This is creating and initializing and instance of the Optical sensors structure
|
||||
*
|
||||
* Finds the memory location of the two color sensors, which then the "mySensors" container
|
||||
* gives to the pointers. So now the pointers have somewhere to point to in memory.
|
||||
*/
|
||||
namespace ez {
|
||||
// Initializes the mySensors variable
|
||||
OpticalSensors mySensors = {
|
||||
// This is where color sensors go.
|
||||
&colorSensorOne,
|
||||
&colorSensorTwo
|
||||
};
|
||||
}
|
||||
// Lift constructor
|
||||
/*LiftMech liftObj(
|
||||
|
||||
@@ -96,7 +110,15 @@ void initialize() {
|
||||
// Autonomous Selector using LLEMU
|
||||
ez::as::auton_selector.autons_add({
|
||||
//Custom autonomouse routes go here.
|
||||
|
||||
{"Quick right blue\n\n1 pins on 1 goals", quick_right_blue},
|
||||
{"Quick right red\n\n1 pins on 1 goals", quick_right_red},
|
||||
{"Blue Left\n\n3 pins on 2 goals", blue_left_3pin},
|
||||
{"Blue Right\n\n4 pins on 2 goals", blue_right_4pin},
|
||||
{"Blue Right\n\n3 pins on 2 goals", blue_right_3pin},
|
||||
{"Red Left\n\n3 pins on 2 goals", red_left_3pin},
|
||||
{"Red Right\n\n3 pins on 2 goals", red_right_3pin},
|
||||
{"Red Right\n\n4 pins on 2 goals", red_right_4pin},
|
||||
{"Test\n\nTest testing", Test},
|
||||
|
||||
/*{"Drive\n\nDrive forward and come back", drive_example},
|
||||
{"Turn\n\nTurn 3 times.", turn_example},
|
||||
|
||||
Reference in new issue
Block a user