diff --git a/src/main/cpp/Gripper.cpp b/src/main/cpp/Gripper.cpp index 329f3a9..74834b5 100644 --- a/src/main/cpp/Gripper.cpp +++ b/src/main/cpp/Gripper.cpp @@ -7,7 +7,7 @@ void Gripper::OnUpdate(units::second_t dt) { switch (_state) { case GripperState::kIdle: - voltage = 0_V; + voltage = 1_V; break; case GripperState::kIntaking: diff --git a/src/main/cpp/behaviour/ArmavatorBehaviour.cpp b/src/main/cpp/behaviour/ArmavatorBehaviour.cpp index 0704eb5..37464d2 100644 --- a/src/main/cpp/behaviour/ArmavatorBehaviour.cpp +++ b/src/main/cpp/behaviour/ArmavatorBehaviour.cpp @@ -106,14 +106,26 @@ void ArmavatorManualBehaviour::OnTick(units::second_t dt) { av.angleSpeed = -wom::spow2(wom::deadzone(_codriver.GetLeftY(), 0.1)) * (180_deg / 1_s); av.elevatorSpeed = -wom::spow2(wom::deadzone(_codriver.GetRightY(), 0.1)) * (2_m / 1_s); - + units::meter_t height = _armavator->GetCurrentPosition().height; + units::degree_t angle = _armavator->GetCurrentPosition().angle; + //bool above_height = true; + //sets hard limits in place, necessary to make the system not break itself (you will burn the neos out if they try to go past what they can) +// if (av.elevatorSpeed > _max_height) { +// _manualSetpoint.height = _max_height; +// } else if (_manualSetpoint.height < _min_height) { +// _manualSetpoint.height = _min_height; +// } +// else { +// av.elevatorSpeed = -wom::spow2(wom::deadzone(_codriver.GetRightY(), 0.1)) * (2_m / 1_s); +// } + units::meter_t max_height = (1.7_m - 0.51_m) - _armavator->arm->GetConfig().armLength * units::math::sin(_manualSetpoint.angle); units::degree_t max_angle_front = units::math::acos(_armavator->GetCurrentPosition().height/_armavator->arm->GetConfig().armLength) + 10_deg - 120_deg; units::degree_t max_angle_back = 360_deg - units::math::acos(_armavator->GetCurrentPosition().height/_armavator->arm->GetConfig().armLength) - 5_deg - 50_deg; - units::meter_t height = _armavator->GetCurrentPosition().height; - units::degree_t angle = _armavator->GetCurrentPosition().angle; + //units::meter_t height = _armavator->GetCurrentPosition().height; + //units::degree_t angle = _armavator->GetCurrentPosition().angle; frc::SmartDashboard::PutNumber("Max Angle Front: ", max_angle_front.value()); frc::SmartDashboard::PutNumber("Max Angle Back: ", max_angle_back.value()); @@ -203,36 +215,95 @@ void ArmavatorManualBehaviour::OnTick(units::second_t dt) { units::meter_t height = _armavator->GetCurrentPosition().height; units::degree_t angle = _armavator->GetCurrentPosition().angle; _armavator->SetSpeedValues(0.5, 0.3); - + //bool above_height = true; //sets hard limits in place, necessary to make the system not break itself (you will burn the neos out if they try to go past what they can) if (_manualSetpoint.height > _max_height) { _manualSetpoint.height = _max_height; } else if (_manualSetpoint.height < _min_height) { _manualSetpoint.height = _min_height; - } else { - _manualSetpoint.height -= (wom::deadzone(_codriver.GetRightY(), 0.2) * 1_m * 0.05); //slows the system down, otherwise it's wayyy too fast + } + else { + _manualSetpoint.height -= (wom::deadzone(_codriver.GetRightY(), 0.2) * 1_m * 0.1); //slows the system down, otherwise it's wayyy too fast } if (_manualSetpoint.angle > _max_angle) { _manualSetpoint.angle = _max_angle; } else if (_manualSetpoint.angle < _min_angle) { _manualSetpoint.angle = _min_angle; - } else { - _manualSetpoint.angle -= (wom::deadzone(_codriver.GetLeftY(), 0.2) * 1_deg * 1); + } + else { + _manualSetpoint.angle -= (wom::deadzone(_codriver.GetLeftY(), 0.2) * 1_deg * 1.5); } // +// _manualSetpoint.height -= (wom::deadzone(_codriver.GetRightY(), 0.2) * 1_m * 0.05); //slows the system down, otherwise it's wayyy too fast +// _manualSetpoint.angle -= (wom::deadzone(_codriver.GetLeftY(), 0.2) * 1_deg * 1); - //some funky math which makes the armavator stay within extension limits - units::meter_t max_height = (1.9_m - 0.51_m) - _armavator->arm->GetConfig().armLength * units::math::sin(_manualSetpoint.angle); + //some funky math which makes the armavator stay within extension limits + units::meter_t max_height = (1.6_m - 0.51_m) - _armavator->arm->GetConfig().armLength * units::math::sin(_manualSetpoint.angle); ArmavatorPosition sp{ units::math::min(_manualSetpoint.height, max_height), _manualSetpoint.angle }; + //units::meter_t max_height = (1.7_m - 0.51_m) - _armavator->arm->GetConfig().armLength * units::math::sin(_manualSetpoint.angle); + units::degree_t max_angle_front = units::math::acos(_armavator->GetCurrentPosition().height/_armavator->arm->GetConfig().armLength) + 10_deg - 120_deg; + units::degree_t max_angle_back = 360_deg - units::math::acos(_armavator->GetCurrentPosition().height/_armavator->arm->GetConfig().armLength) - 5_deg - 50_deg; + + + //units::meter_t height = _armavator->GetCurrentPosition().height; + //units::degree_t angle = _armavator->GetCurrentPosition().angle; + + frc::SmartDashboard::PutNumber("Max Angle Front: ", max_angle_front.value()); + frc::SmartDashboard::PutNumber("Max Angle Back: ", max_angle_back.value()); + frc::SmartDashboard::PutNumber("Current Angle", angle.value()); + + frc::SmartDashboard::PutNumber("Height", height.value()); + frc::SmartDashboard::PutNumber("Max Height", max_height.value()); + + + + if (height > 0.675_m) { + _armavator->SetPosition(sp); + } + else if (angle < max_angle_front) { + //_armavator->SetArmPosition(max_angle_front * (std::numbers::pi / 180)); + if (sp.angle > max_angle_front) { + _armavator->SetPosition(sp); + } + else { + //sp.angle = max_angle_front / 60; + _manualSetpoint.angle = max_angle_front; + _armavator->SetPosition(sp); + } + } + else if (angle > max_angle_back) { + if (sp.angle < max_angle_back) { + _armavator->SetPosition(sp); + } + else { + _manualSetpoint.angle = max_angle_back; + _armavator->SetPosition(sp); + } + + } + + else { + //if (wom::deadzone(_codriver.GetLeftY(), 0.2)) { + //_manualSetpoint.angle -= (wom::deadzone(_codriver.GetLeftY(), 0.2) * 1_deg * 1); + //} + //if (wom::deadzone(_codriver.GetRightY(), 0.2)) { + //_manualSetpoint.height -= (wom::deadzone(_codriver.GetRightY(), 0.2) * 1_m * 0.05); //slows the system down, otherwise it's wayyy too fast + //} + _armavator->SetPosition(sp); + + frc::SmartDashboard::PutNumber("Current Angle", _manualSetpoint.angle.value()); + frc::SmartDashboard::PutNumber("Current Height", _manualSetpoint.height.value()); + + + } - _armavator->SetPosition(sp); //print the values, REMOVE THESE BEFORE WARP, too many print out clog the system and can make the robot loose connection to the field std::cout << "set position height: " << _manualSetpoint.height.value() << std::endl; diff --git a/src/main/cpp/behaviour/GripperBehaviour.cpp b/src/main/cpp/behaviour/GripperBehaviour.cpp index e1b1839..77af29f 100644 --- a/src/main/cpp/behaviour/GripperBehaviour.cpp +++ b/src/main/cpp/behaviour/GripperBehaviour.cpp @@ -24,9 +24,9 @@ GripperBehaviour::GripperBehaviour(Gripper *gripper, frc::XboxController &codriv void GripperBehaviour::OnTick(units::second_t dt) { //setting the gripper mode - if (_codriver.GetRightTriggerAxis() > 0.2) { - gripper->SetOutaking(_codriver.GetRightTriggerAxis()); - } else if (_codriver.GetLeftTriggerAxis() > 0.2) { + if (_codriver.GetLeftTriggerAxis() > 0.2) { + gripper->SetOutaking(_codriver.GetLeftTriggerAxis()); + } else if (_codriver.GetRightTriggerAxis() > 0.2) { gripper->SetIntaking(); } else { gripper->SetIdle();