I started work working on the color display function to show the color the sensor is seeing on the brain.
This commit is contained in:
1 parent
83ac6ad184
commit
62670f8c80
4 files changed
+86
-45
No files matched your search
@@ -55,10 +55,11 @@ namespace ez {
|
|||||||
* \param looped
|
* \param looped
|
||||||
* do we want to continusly check for that color
|
* do we want to continusly check for that color
|
||||||
*/
|
*/
|
||||||
void color_sorter(pros::Optical* c_sensor, control_period period, wanted_color selected_color, int led_brightness, bool looped);
|
void color_sorter(pros::Optical* c_sensor, wanted_color selected_color, int led_brightness, bool looped);
|
||||||
|
|
||||||
void DisplayColor();
|
void DisplayColor(pros::Optical* cSensor, int portNum, int sensorCount);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declares a variable that can be used anywhere to access information
|
* Declares a variable that can be used anywhere to access information
|
||||||
* from inside the structure.
|
* from inside the structure.
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "pros/screen.h"
|
||||||
|
|
||||||
using namespace ez;
|
using namespace ez;
|
||||||
|
|
||||||
@@ -8,7 +9,7 @@ ColorSensors::ColorSensors() {}
|
|||||||
* Coler sorter function, allows you to take the value of a sensor
|
* Coler sorter function, allows you to take the value of a sensor
|
||||||
* and complete a task based on the selected color.
|
* 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) {
|
void ColorSensors::color_sorter(pros::Optical* c_sensor, wanted_color selected_color, int led_brightness, bool looped) {
|
||||||
// Sets the sensors leds to a certain brightness
|
// Sets the sensors leds to a certain brightness
|
||||||
c_sensor->set_led_pwm(led_brightness);
|
c_sensor->set_led_pwm(led_brightness);
|
||||||
colorSensorTwo.set_led_pwm(led_brightness);
|
colorSensorTwo.set_led_pwm(led_brightness);
|
||||||
@@ -41,7 +42,6 @@ void ColorSensors::color_sorter(pros::Optical* c_sensor, control_period period,
|
|||||||
roller.move(60);
|
roller.move(60);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wanted_color::red:
|
case wanted_color::red:
|
||||||
// If both sensors see the same color exit the loop and stop doing the code
|
// If both sensors see the same color exit the loop and stop doing the code
|
||||||
if (main_is_red == true && backup_is_red == true) {
|
if (main_is_red == true && backup_is_red == true) {
|
||||||
@@ -53,7 +53,6 @@ void ColorSensors::color_sorter(pros::Optical* c_sensor, control_period period,
|
|||||||
roller.move(65);
|
roller.move(65);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -62,6 +61,73 @@ void ColorSensors::color_sorter(pros::Optical* c_sensor, control_period period,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ColorSensors::DisplayColor(pros::Optical* cSensor, int portNum, int sensorCount) {
|
||||||
|
double mainHue = cSensor->get_hue();
|
||||||
|
|
||||||
|
bool isRed = (mainHue <= 20 || mainHue >= 340);
|
||||||
|
bool isBlue = (mainHue >= 160 && mainHue <= 280);
|
||||||
|
|
||||||
|
switch (sensorCount)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
if (isRed == true) {
|
||||||
|
pros::screen::print(TEXT_SMALL, 20, 30, "Sensor on port " + sensorCount);
|
||||||
|
}
|
||||||
|
else if (isBlue == true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (isRed == true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (isBlue == true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (isRed == true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (isBlue == true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if (isRed == true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (isBlue == true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
if (isRed == true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (isBlue == true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
if (isRed == true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (isBlue == true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*while (looped == true) {
|
/*while (looped == true) {
|
||||||
if (sensorNum == 1 && period == auton) {
|
if (sensorNum == 1 && period == auton) {
|
||||||
pros::delay(100);
|
pros::delay(100);
|
||||||
|
|||||||
+9
-9
@@ -56,7 +56,7 @@ void default_constants() {
|
|||||||
// Custom auton routes
|
// Custom auton routes
|
||||||
//
|
//
|
||||||
void quick_right_blue() {
|
void quick_right_blue() {
|
||||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::blue, 100, true);
|
sorter.color_sorter(mySensors.leftColorSensor, wanted_color::blue, 100, true);
|
||||||
|
|
||||||
lift.move(80);
|
lift.move(80);
|
||||||
pros::delay(420);
|
pros::delay(420);
|
||||||
@@ -85,7 +85,7 @@ void quick_right_blue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void quick_right_red() {
|
void quick_right_red() {
|
||||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::red, 100, true);
|
sorter.color_sorter(mySensors.leftColorSensor, wanted_color::red, 100, true);
|
||||||
|
|
||||||
lift.move(80);
|
lift.move(80);
|
||||||
pros::delay(420);
|
pros::delay(420);
|
||||||
@@ -114,7 +114,7 @@ void quick_right_red() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void blue_left_3pin() {
|
void blue_left_3pin() {
|
||||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::blue, 100, true);
|
sorter.color_sorter(mySensors.leftColorSensor, wanted_color::blue, 100, true);
|
||||||
|
|
||||||
lift.move(80);
|
lift.move(80);
|
||||||
pros::delay(420);
|
pros::delay(420);
|
||||||
@@ -185,7 +185,7 @@ void blue_left_3pin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void blue_right_4pin() {
|
void blue_right_4pin() {
|
||||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::blue, 100, true);
|
sorter.color_sorter(mySensors.leftColorSensor, wanted_color::blue, 100, true);
|
||||||
|
|
||||||
lift.move(80);
|
lift.move(80);
|
||||||
pros::delay(420);
|
pros::delay(420);
|
||||||
@@ -271,7 +271,7 @@ void blue_right_4pin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void blue_right_3pin() {
|
void blue_right_3pin() {
|
||||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::blue, 100, true);
|
sorter.color_sorter(mySensors.leftColorSensor, wanted_color::blue, 100, true);
|
||||||
|
|
||||||
lift.move(80);
|
lift.move(80);
|
||||||
pros::delay(420);
|
pros::delay(420);
|
||||||
@@ -342,7 +342,7 @@ void blue_right_3pin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void red_left_3pin() {
|
void red_left_3pin() {
|
||||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::red, 100, true);
|
sorter.color_sorter(mySensors.leftColorSensor, wanted_color::red, 100, true);
|
||||||
|
|
||||||
lift.move(80);
|
lift.move(80);
|
||||||
pros::delay(420);
|
pros::delay(420);
|
||||||
@@ -413,7 +413,7 @@ void red_left_3pin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void red_right_3pin() {
|
void red_right_3pin() {
|
||||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::red, 100, true);
|
sorter.color_sorter(mySensors.leftColorSensor, wanted_color::red, 100, true);
|
||||||
|
|
||||||
lift.move(80);
|
lift.move(80);
|
||||||
pros::delay(420);
|
pros::delay(420);
|
||||||
@@ -484,7 +484,7 @@ void red_right_3pin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void red_right_4pin() {
|
void red_right_4pin() {
|
||||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::red, 100, true);
|
sorter.color_sorter(mySensors.leftColorSensor, wanted_color::red, 100, true);
|
||||||
|
|
||||||
lift.move(80);
|
lift.move(80);
|
||||||
pros::delay(420);
|
pros::delay(420);
|
||||||
@@ -581,7 +581,7 @@ void skills() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Test() {
|
void Test() {
|
||||||
sorter.color_sorter(mySensors.leftColorSensor, control_period::auton, wanted_color::blue, 100, true);
|
sorter.color_sorter(mySensors.leftColorSensor, wanted_color::blue, 100, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|||||||
+5
-31
@@ -22,7 +22,7 @@ ez::tracking_wheel vert_tracker(17, 3.25, 2.0); // This tracking wheel is para
|
|||||||
// Default Objects
|
// Default Objects
|
||||||
Pneumatics pistonControl;
|
Pneumatics pistonControl;
|
||||||
Mechanisms motorControl;
|
Mechanisms motorControl;
|
||||||
//ArmMech armObj;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and initializes and instance of the Optical sensors structure
|
* Creates and initializes and instance of the Optical sensors structure
|
||||||
@@ -42,11 +42,6 @@ namespace ez {
|
|||||||
LiftMech liftObj(
|
LiftMech liftObj(
|
||||||
{0, -19714, -13017, -27993, -17491, -48393, -37459, -69706, -58957, -89693, -79453, -106664, -99115}, 13);
|
{0, -19714, -13017, -27993, -17491, -48393, -37459, -69706, -58957, -89693, -79453, -106664, -99115}, 13);
|
||||||
|
|
||||||
// Wrist constructor
|
|
||||||
/*WristMech wristObj(
|
|
||||||
|
|
||||||
{0, -14529}, 2);*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs initialization code. This occurs as soon as the program is started.
|
* Runs initialization code. This occurs as soon as the program is started.
|
||||||
*
|
*
|
||||||
@@ -59,22 +54,7 @@ void initialize() {
|
|||||||
|
|
||||||
pros::delay(500); // Stop the user from doing anything while legacy ports configure
|
pros::delay(500); // Stop the user from doing anything while legacy ports configure
|
||||||
|
|
||||||
/*armObj.set_state_values(
|
|
||||||
{0, -5642},
|
|
||||||
{0, -22702},
|
|
||||||
{0, -19740},
|
|
||||||
{0, -17121}
|
|
||||||
);
|
|
||||||
liftObj.set_ranges(
|
|
||||||
{0, 63194},
|
|
||||||
{63194, 94246},
|
|
||||||
{94246, 139878},
|
|
||||||
{139878, 150000}
|
|
||||||
);
|
|
||||||
|
|
||||||
armRotation.reset_position();*/
|
|
||||||
liftRotation.reset_position();
|
liftRotation.reset_position();
|
||||||
//wristRotation.reset_position();
|
|
||||||
|
|
||||||
pros::Task liftControlTasck([&]{
|
pros::Task liftControlTasck([&]{
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -312,22 +292,16 @@ void opcontrol() {
|
|||||||
// Call custom drive functions here
|
// Call custom drive functions here
|
||||||
pistonControl.control_piston(PistonsP::PlaceHolderP, ControlPeriodP::driver,
|
pistonControl.control_piston(PistonsP::PlaceHolderP, ControlPeriodP::driver,
|
||||||
ControllerP::master, ButtonsP::arrow_buttons);
|
ControllerP::master, ButtonsP::arrow_buttons);
|
||||||
/*motorControl.motor_control(ControlPeriodM::driver, ControllerM::master, ButtonsM::right_shoulder_buttons,
|
motorControl.motor_control(ControlPeriodM::driver, ControllerM::master, ButtonsM::right_shoulder_buttons,
|
||||||
MotorGroups::lift_MG, 127, -127);*/
|
MotorGroups::lift_MG, 127, -127);
|
||||||
motorControl.motor_control(ControlPeriodM::driver, ControllerM::master, ButtonsM::left_shoulder_buttons,
|
motorControl.motor_control(ControlPeriodM::driver, ControllerM::master, ButtonsM::left_shoulder_buttons,
|
||||||
MotorGroups::claw_M, -127, 127);
|
MotorGroups::claw_M, -127, 127);
|
||||||
motorControl.motor_control(ControlPeriodM::driver, ControllerM::master, ButtonsM::Y_B_buttons,
|
motorControl.motor_control(ControlPeriodM::driver, ControllerM::master, ButtonsM::Y_B_buttons,
|
||||||
MotorGroups::roller_M, 127, 0);
|
MotorGroups::roller_M, 127, 0);
|
||||||
|
|
||||||
// Basic control scheme
|
//liftObj.lift_driver_control(ControllerR::master, ButtonsR::right_shoulder_buttons);
|
||||||
//armObj.arm_driver_control(ControllerR::master, ButtonsR::left_shoulder_buttons);
|
|
||||||
liftObj.lift_driver_control(ControllerR::master, ButtonsR::right_shoulder_buttons);
|
|
||||||
|
|
||||||
//armObj.arm_driver_control(ControllerR::slave, ButtonsR::left_shoulder_buttons);
|
|
||||||
//liftObj.lift_driver_control(ControllerR::slave, ButtonsR::right_shoulder_buttons);
|
|
||||||
//wristObj.wrist_driver_control(ControllerR::slave, ButtonsR::Y_B_buttons);
|
|
||||||
//wristObj.rotate_wrist(90);
|
|
||||||
|
|
||||||
|
//Basic drive presets
|
||||||
chassis.opcontrol_arcade_standard(ez::SPLIT); // Standard split arcade
|
chassis.opcontrol_arcade_standard(ez::SPLIT); // Standard split arcade
|
||||||
// chassis.opcontrol_tank(); // Tank control
|
// chassis.opcontrol_tank(); // Tank control
|
||||||
// chassis.opcontrol_arcade_standard(ez::SINGLE); // Standard single arcade
|
// chassis.opcontrol_arcade_standard(ez::SINGLE); // Standard single arcade
|
||||||
|
|||||||
Reference in new issue
Block a user