diff --git a/ut-robomaster/src/robots/hero/hero_constants.hpp b/ut-robomaster/src/robots/hero/hero_constants.hpp index 66968067..f416edfa 100644 --- a/ut-robomaster/src/robots/hero/hero_constants.hpp +++ b/ut-robomaster/src/robots/hero/hero_constants.hpp @@ -136,9 +136,7 @@ static constexpr float WHEEL_MAX_VEL = 120.0f; // rad/s static constexpr float MAX_LINEAR_VEL = WHEEL_MAX_VEL * WHEEL_RADIUS; // m/s static constexpr float MAX_ANGULAR_VEL = WHEEL_MAX_VEL * WHEEL_RADIUS / WHEEL_LXY; // rad/s -static constexpr float DEFAULT_SPEED = 60.0f; // default speed for the flywheels - -static constexpr modm::Pair FLYWHEEL_RPS_MAPPING[] = {{10, 105.0f}, {16, 190.0f}}; +static constexpr float FLYWHEEL_SPEED = 190.0f; // 16 m/s const float BALLS_PER_SEC = 4.0f; const float BALLS_PER_REV = 6.0f; diff --git a/ut-robomaster/src/robots/sentry/sentry_constants.hpp b/ut-robomaster/src/robots/sentry/sentry_constants.hpp index f2a6ab40..3b78fb4a 100644 --- a/ut-robomaster/src/robots/sentry/sentry_constants.hpp +++ b/ut-robomaster/src/robots/sentry/sentry_constants.hpp @@ -135,11 +135,7 @@ static constexpr float WHEEL_MAX_VEL = 50.0f; // rad/s static constexpr float MAX_LINEAR_VEL = WHEEL_MAX_VEL * WHEEL_RADIUS; // m/s static constexpr float MAX_ANGULAR_VEL = WHEEL_MAX_VEL * WHEEL_RADIUS / WHEEL_LXY; // rad/s -static constexpr modm::Pair FLYWHEEL_RPS_MAPPING[] = { - {15, 67.0f}, - {18, 75.0f}, - {30, 122.0f}}; -static constexpr float DEFAULT_SPEED = 70.0f; +static constexpr float FLYWHEEL_SPEED = 122.0f; // 30 m/s const float BALLS_PER_SEC = 10.0f; const float BALLS_PER_REV = 8.0f; diff --git a/ut-robomaster/src/robots/standard/standard_constants.hpp b/ut-robomaster/src/robots/standard/standard_constants.hpp index 78b53123..ed2849a7 100644 --- a/ut-robomaster/src/robots/standard/standard_constants.hpp +++ b/ut-robomaster/src/robots/standard/standard_constants.hpp @@ -131,11 +131,7 @@ static constexpr float WHEEL_MAX_VEL = 50.0f; // rad/s static constexpr float MAX_LINEAR_VEL = WHEEL_MAX_VEL * WHEEL_RADIUS; // m/s static constexpr float MAX_ANGULAR_VEL = WHEEL_MAX_VEL * WHEEL_RADIUS / WHEEL_LXY; // rad/s -static constexpr modm::Pair FLYWHEEL_RPS_MAPPING[] = { - {15, 67.0f}, - {18, 75.0f}, - {30, 122.0f}}; -static constexpr float DEFAULT_SPEED = 70.0f; +static constexpr float FLYWHEEL_SPEED = 122.0f; // 30 m/s const float BALLS_PER_SEC = 10.0f; const float BALLS_PER_REV = 8.0f; diff --git a/ut-robomaster/src/subsystems/flywheel/command_rotate_flywheel.cpp b/ut-robomaster/src/subsystems/flywheel/command_rotate_flywheel.cpp index b497f37b..ffe64e06 100644 --- a/ut-robomaster/src/subsystems/flywheel/command_rotate_flywheel.cpp +++ b/ut-robomaster/src/subsystems/flywheel/command_rotate_flywheel.cpp @@ -3,39 +3,9 @@ namespace commands { -void CommandRotateFlywheel::initialize() {} +void CommandRotateFlywheel::initialize() { flywheel->setLaunchSpeed(FLYWHEEL_SPEED); } -void CommandRotateFlywheel::execute() -{ - if (drivers->refSerial.getRefSerialReceivingData()) - { - auto turretData = drivers->refSerial.getRobotData().turret; - -#if defined(TARGET_STANDARD) || defined(TARGET_SENTRY) - uint16_t speedLimit = turretData.barrelSpeedLimit17ID1; -#elif defined(TARGET_HERO) - uint16_t speedLimit = turretData.barrelSpeedLimit42; -#endif - - float launchSpeed = 0.0f; - - for (int i = 0; i < 3; i++) - { - if (FLYWHEEL_RPS_MAPPING[i].getFirst() == speedLimit) - { - launchSpeed = FLYWHEEL_RPS_MAPPING[i].getSecond(); - break; - } - } - - flywheel->setLaunchSpeed(launchSpeed); - } - else - { - // NO REF SYSTEM DATA - flywheel->setLaunchSpeed(DEFAULT_SPEED); - } -} +void CommandRotateFlywheel::execute() {} void CommandRotateFlywheel::end(bool) { flywheel->setLaunchSpeed(0.0f); } diff --git a/ut-robomaster/src/subsystems/flywheel/flywheel_subsystem.cpp b/ut-robomaster/src/subsystems/flywheel/flywheel_subsystem.cpp index b38c6085..fd444e5f 100644 --- a/ut-robomaster/src/subsystems/flywheel/flywheel_subsystem.cpp +++ b/ut-robomaster/src/subsystems/flywheel/flywheel_subsystem.cpp @@ -37,9 +37,9 @@ void FlywheelSubsystem::refresh() for (int i = 0; i < FLYWHEELS; i++) { motors[i].setActive(!killSwitch); - motors[i].update(launchSpeed); + motors[i].update(velocity); } } -void FlywheelSubsystem::setLaunchSpeed(float speed) { launchSpeed = speed; } +void FlywheelSubsystem::setVelocity(float newVelocity) { velocity = newVelocity; } } // namespace subsystems::flywheel diff --git a/ut-robomaster/src/subsystems/flywheel/flywheel_subsystem.hpp b/ut-robomaster/src/subsystems/flywheel/flywheel_subsystem.hpp index 6e87a515..a53457b8 100644 --- a/ut-robomaster/src/subsystems/flywheel/flywheel_subsystem.hpp +++ b/ut-robomaster/src/subsystems/flywheel/flywheel_subsystem.hpp @@ -26,12 +26,14 @@ class FlywheelSubsystem : public tap::control::Subsystem void refresh() override; - void setLaunchSpeed(float speed); + /// @brief Change flywheel velocity. + /// @param velocity Velocity in rev/s. + void setVelocity(float velocity); private: src::Drivers* drivers; MotorVelocityController motors[FLYWHEELS]; - float launchSpeed = 0.0f; + float velocity = 0.0f; }; } // namespace flywheel