diff --git a/include/EZ-Template/rotation_mechanisms/rotation_calc.hpp b/include/EZ-Template/rotation_mechanisms/rotation_calc.hpp index 4f29ecf..8cdb4d4 100644 --- a/include/EZ-Template/rotation_mechanisms/rotation_calc.hpp +++ b/include/EZ-Template/rotation_mechanisms/rotation_calc.hpp @@ -82,7 +82,6 @@ namespace ez{ float liftKP; public: - int liftHeight; // Current height of the lift in centdegrees int currLiftState; int liftTarget; float liftError; @@ -92,7 +91,7 @@ namespace ez{ LiftMech(std::initializer_list _liftStates, int _numLiftStates); // Constructor to initialze array and amount of values in array. void lift_driver_control(enum ControllerR, enum ButtonsR); - void lift_auton_control(int pickState); + void lift_auton_control(long pickedHeight); void cycle_states(); void reset_state(); void lift_control(); // Computes the velocity for the lift to move at. diff --git a/src/EZ-Template/rotation_mechanisms/lift_rotation.cpp b/src/EZ-Template/rotation_mechanisms/lift_rotation.cpp index e6812c0..fc067b9 100644 --- a/src/EZ-Template/rotation_mechanisms/lift_rotation.cpp +++ b/src/EZ-Template/rotation_mechanisms/lift_rotation.cpp @@ -4,11 +4,10 @@ using namespace ez; LiftMech::LiftMech() { - liftHeight = 0; liftError = 0; liftVelocity = 0; - liftStates = {0, 0, 0, 0}; + liftStates = {0, 0}; } LiftMech::LiftMech(std::initializer_list _liftStates, int _numLiftStates) { liftStates = _liftStates; @@ -17,6 +16,11 @@ LiftMech::LiftMech(std::initializer_list _liftStates, int _numLiftStates) { liftTarget = 0; set_lift_kp(0.0173f); } +void LiftMech::lift_control() { + liftError = liftTarget - liftRotation.get_position(); + liftVelocity = get_lift_kp() * liftError; + lift.move(-liftVelocity); +} void LiftMech::lift_driver_control(ControllerR currController, ButtonsR buttonUsed) { switch (currController) @@ -66,25 +70,8 @@ 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::lift_auton_control(long pickedHeight) { + liftTarget = pickedHeight; } void LiftMech::cycle_states() { @@ -97,28 +84,11 @@ void LiftMech::cycle_states() { liftTarget = liftStates[currLiftState]; } } -void LiftMech::reset_state() { - currLiftState = 0; +void LiftMech::reset_state() {liftTarget = 0;} - if (!liftStates.empty()) { - liftTarget = liftStates[currLiftState]; - } -} +void LiftMech::set_lift_kp(float _liftKp) {liftKP = _liftKp;} -void LiftMech::lift_control() { - liftError = liftTarget - liftRotation.get_position(); - liftVelocity = get_lift_kp() * liftError; - lift.move(-liftVelocity); -} - -void LiftMech::set_lift_kp(float _liftKp) { - liftKP = _liftKp; -} -int LiftMech::get_lift_state() { - if (!liftStates.empty()) { - return liftStates[currLiftState]; - } -} +int LiftMech::get_lift_state() {return liftStates[currLiftState];} int LiftMech::get_num_lift_states() {return numLiftStates;} float LiftMech::get_lift_kp() {return liftKP;} diff --git a/src/main.cpp b/src/main.cpp index 81ad306..226e18d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,12 +40,7 @@ namespace ez { } // Lift constructor LiftMech liftObj( - -<<<<<<< HEAD - {0, 0, 0, 0}, 4); -======= {0, -19714, -13017, -27993, -17491, -48393, -37459, -69706, -58957, -89693, -79453, -106664, -99115}, 13); ->>>>>>> 4be5e2958fb4be3d35cbe58b8933bfde5ce90ed3 // Wrist constructor /*WristMech wristObj(