Changed a few variable nemes in the lift rotation file.
I also changed the lift reset function and the auton lift control to instead of looking at the array they will just set the lift target to the specified value.
This commit is contained in:
1 parent
ecebf87643
commit
83ac6ad184
3 files changed
+12
-48
No files matched your search
@@ -82,7 +82,6 @@ namespace ez{
|
|||||||
float liftKP;
|
float liftKP;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int liftHeight; // Current height of the lift in centdegrees
|
|
||||||
int currLiftState;
|
int currLiftState;
|
||||||
int liftTarget;
|
int liftTarget;
|
||||||
float liftError;
|
float liftError;
|
||||||
@@ -92,7 +91,7 @@ namespace ez{
|
|||||||
LiftMech(std::initializer_list<int> _liftStates, int _numLiftStates); // Constructor to initialze array and amount of values in array.
|
LiftMech(std::initializer_list<int> _liftStates, int _numLiftStates); // Constructor to initialze array and amount of values in array.
|
||||||
|
|
||||||
void lift_driver_control(enum ControllerR, enum ButtonsR);
|
void lift_driver_control(enum ControllerR, enum ButtonsR);
|
||||||
void lift_auton_control(int pickState);
|
void lift_auton_control(long pickedHeight);
|
||||||
void cycle_states();
|
void cycle_states();
|
||||||
void reset_state();
|
void reset_state();
|
||||||
void lift_control(); // Computes the velocity for the lift to move at.
|
void lift_control(); // Computes the velocity for the lift to move at.
|
||||||
|
|||||||
@@ -4,11 +4,10 @@
|
|||||||
using namespace ez;
|
using namespace ez;
|
||||||
|
|
||||||
LiftMech::LiftMech() {
|
LiftMech::LiftMech() {
|
||||||
liftHeight = 0;
|
|
||||||
liftError = 0;
|
liftError = 0;
|
||||||
liftVelocity = 0;
|
liftVelocity = 0;
|
||||||
|
|
||||||
liftStates = {0, 0, 0, 0};
|
liftStates = {0, 0};
|
||||||
}
|
}
|
||||||
LiftMech::LiftMech(std::initializer_list<int> _liftStates, int _numLiftStates) {
|
LiftMech::LiftMech(std::initializer_list<int> _liftStates, int _numLiftStates) {
|
||||||
liftStates = _liftStates;
|
liftStates = _liftStates;
|
||||||
@@ -17,6 +16,11 @@ LiftMech::LiftMech(std::initializer_list<int> _liftStates, int _numLiftStates) {
|
|||||||
liftTarget = 0;
|
liftTarget = 0;
|
||||||
set_lift_kp(0.0173f);
|
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) {
|
void LiftMech::lift_driver_control(ControllerR currController, ButtonsR buttonUsed) {
|
||||||
switch (currController)
|
switch (currController)
|
||||||
@@ -66,25 +70,8 @@ void LiftMech::lift_driver_control(ControllerR currController, ButtonsR buttonUs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LiftMech::lift_auton_control(int pickState) {
|
void LiftMech::lift_auton_control(long pickedHeight) {
|
||||||
switch (pickState)
|
liftTarget = pickedHeight;
|
||||||
{
|
|
||||||
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() {
|
void LiftMech::cycle_states() {
|
||||||
@@ -97,28 +84,11 @@ void LiftMech::cycle_states() {
|
|||||||
liftTarget = liftStates[currLiftState];
|
liftTarget = liftStates[currLiftState];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void LiftMech::reset_state() {
|
void LiftMech::reset_state() {liftTarget = 0;}
|
||||||
currLiftState = 0;
|
|
||||||
|
|
||||||
if (!liftStates.empty()) {
|
void LiftMech::set_lift_kp(float _liftKp) {liftKP = _liftKp;}
|
||||||
liftTarget = liftStates[currLiftState];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LiftMech::lift_control() {
|
int LiftMech::get_lift_state() {return liftStates[currLiftState];}
|
||||||
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_num_lift_states() {return numLiftStates;}
|
int LiftMech::get_num_lift_states() {return numLiftStates;}
|
||||||
float LiftMech::get_lift_kp() {return liftKP;}
|
float LiftMech::get_lift_kp() {return liftKP;}
|
||||||
|
|
||||||
|
|||||||
@@ -40,12 +40,7 @@ namespace ez {
|
|||||||
}
|
}
|
||||||
// Lift constructor
|
// Lift constructor
|
||||||
LiftMech liftObj(
|
LiftMech liftObj(
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
{0, 0, 0, 0}, 4);
|
|
||||||
=======
|
|
||||||
{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);
|
||||||
>>>>>>> 4be5e2958fb4be3d35cbe58b8933bfde5ce90ed3
|
|
||||||
|
|
||||||
// Wrist constructor
|
// Wrist constructor
|
||||||
/*WristMech wristObj(
|
/*WristMech wristObj(
|
||||||
|
|||||||
Reference in new issue
Block a user