This commit is contained in:
Carter Essen committed 2026-11-22 20:07:03 -05:00
1 parent 7bf206c454
commit d9db3ee688
2 files changed
+41 -92

No files matched your search

@@ -21,79 +21,39 @@ LiftMech::LiftMech(std::initializer_list<int> _liftStates, int _numLiftStates) {
void LiftMech::lift_driver_control(ControllerR currController, ButtonsR buttonUsed) {
switch (currController)
{
case ControllerR::slave:
switch (buttonUsed)
{
case ButtonsR::arrow_buttons:
if (master.get_digital(DIGITAL_RIGHT)) {
lift.move(127);
}
else if (master.get_digital(DIGITAL_DOWN)) {
lift.move(-127);
}
break;
case ButtonsR::Y_B_buttons:
if (master.get_digital(DIGITAL_Y)) {
lift.move(127);
}
else if (master.get_digital(DIGITAL_B)) {
lift.move(-127);
}
break;
case ButtonsR::left_shoulder_buttons:
if (master.get_digital(DIGITAL_L1)) {
lift.move(127);
}
else if (master.get_digital(DIGITAL_L2)) {
lift.move(-127);
}
break;
case ButtonsR::right_shoulder_buttons:
if (master.get_digital(DIGITAL_R1)) {
lift.move(127);
}
else if (master.get_digital(DIGITAL_R2)) {
lift.move(-127);
}
break;
default:
break;
}
break;
case ControllerR::master:
switch (buttonUsed)
{
case ButtonsR::arrow_buttons:
if (slave.get_digital(DIGITAL_RIGHT)) {
if (master.get_digital(DIGITAL_RIGHT)) {
cycle_states();
}
else if (slave.get_digital(DIGITAL_DOWN)) {
else if (master.get_digital(DIGITAL_DOWN)) {
reset_state();
}
break;
case ButtonsR::Y_B_buttons:
if (slave.get_digital(DIGITAL_Y)) {
if (master.get_digital(DIGITAL_Y)) {
cycle_states();
}
else if (slave.get_digital(DIGITAL_B)) {
else if (master.get_digital(DIGITAL_B)) {
reset_state();
}
break;
case ButtonsR::left_shoulder_buttons:
if (slave.get_digital(DIGITAL_L1)) {
if (master.get_digital(DIGITAL_L1)) {
cycle_states();
}
else if (slave.get_digital(DIGITAL_L2)) {
else if (master.get_digital(DIGITAL_L2)) {
reset_state();
}
break;
case ButtonsR::right_shoulder_buttons:
if (slave.get_digital(DIGITAL_R1)) {
if (master.get_digital(DIGITAL_R1)) {
cycle_states();
}
else if (slave.get_digital(DIGITAL_R2)) {
else if (master.get_digital(DIGITAL_R2)) {
reset_state();
}
break;
@@ -106,6 +66,27 @@ void LiftMech::lift_driver_control(ControllerR currController, ButtonsR buttonUs
}
}
void LiftMech::lift_auton_control(int pickState) {
switch (pickState)
{
case 1:
liftTarget = liftStates[0];
break;
case 2:
liftTarget = liftStates[1];
break;
case 3:
liftTarget = liftStates[2];
break;
case 4:
liftTarget = liftStates[3];
break;
default:
liftTarget = liftStates[0];
break;
}
}
void LiftMech::cycle_states() {
currLiftState ++;
@@ -202,39 +183,39 @@ void LiftMech::lift_driver_control(ControllerR currController, ButtonsR buttonUs
break;
}
break;
case ControllerR::slave:
case ControllerR::master:
switch (buttonUsed)
{
case ButtonsR::arrow_buttons:
if (slave.get_digital(DIGITAL_RIGHT)) {
if (master.get_digital(DIGITAL_RIGHT)) {
cycle_states();
}
else if (slave.get_digital(DIGITAL_DOWN)) {
else if (master.get_digital(DIGITAL_DOWN)) {
reset_state();
}
break;
case ButtonsR::Y_B_buttons:
if (slave.get_digital(DIGITAL_Y)) {
if (master.get_digital(DIGITAL_Y)) {
cycle_states();
}
else if (slave.get_digital(DIGITAL_B)) {
else if (master.get_digital(DIGITAL_B)) {
reset_state();
}
break;
case ButtonsR::left_shoulder_buttons:
if (slave.get_digital(DIGITAL_L1)) {
if (master.get_digital(DIGITAL_L1)) {
cycle_states();
}
else if (slave.get_digital(DIGITAL_L2)) {
else if (master.get_digital(DIGITAL_L2)) {
reset_state();
}
break;
case ButtonsR::right_shoulder_buttons:
if (slave.get_digital(DIGITAL_R1)) {
if (master.get_digital(DIGITAL_R1)) {
cycle_states();
}
else if (slave.get_digital(DIGITAL_R2)) {
else if (master.get_digital(DIGITAL_R2)) {
reset_state();
}
break;
+3 -35
View File
@@ -25,7 +25,7 @@ Mechanisms motorControl;
//ArmMech armObj;
/**
* This is creating and initializing and instance of the Optical sensors structure
* Creates and initializes 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.
@@ -41,7 +41,7 @@ namespace ez {
// Lift constructor
LiftMech liftObj(
{0, }, 4);
{0, 0, 0, 0}, 4);
// Wrist constructor
/*WristMech wristObj(
@@ -321,38 +321,6 @@ void opcontrol() {
MotorGroups::roller_M, 127, 0);
// Basic control scheme
/*arm.set_brake_mode(MOTOR_BRAKE_HOLD);
if (master.get_digital(DIGITAL_L1)) {
arm.move(90);
}
else if (master.get_digital(DIGITAL_L2)) {
arm.move(-90);
}
else {
arm.brake();
}
lift.set_brake_mode(MOTOR_BRAKE_HOLD);
if (master.get_digital(DIGITAL_R1)) {
lift.move(127);
}
else if (master.get_digital(DIGITAL_R2)) {
lift.move(-127);
}
else {
lift.brake();
}
wrist.set_brake_mode(MOTOR_BRAKE_HOLD);
if (master.get_digital(DIGITAL_A)) {
wrist.move(20);
}
else if (master.get_digital(DIGITAL_B)) {
wrist.move(-20);
}
else {
wrist.brake();
}*/
//armObj.arm_driver_control(ControllerR::master, ButtonsR::left_shoulder_buttons);
//liftObj.lift_driver_control(ControllerR::master, ButtonsR::right_shoulder_buttons);
@@ -373,7 +341,7 @@ void opcontrol() {
//std::cout << "Wrist rotation sensor value: " << "\033[33m" << wristRotation.get_position() << " cdg" << "mm\033[0m" << std::endl;
//std::cout << "Arm limit switch value: " << "\033[34m" << armReset.get_value() << "mm\033[0m" << std::endl;*/
///pros::delay(250);
//pros::delay(250);
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}