Skip to content

Commit

Permalink
Remove flywheel ref system speed adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
calebchalmers committed May 23, 2024
1 parent b2ad5ea commit 96044ce
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 49 deletions.
4 changes: 1 addition & 3 deletions ut-robomaster/src/robots/hero/hero_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint16_t, float> 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;
Expand Down
6 changes: 1 addition & 5 deletions ut-robomaster/src/robots/sentry/sentry_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint16_t, float> 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;
Expand Down
6 changes: 1 addition & 5 deletions ut-robomaster/src/robots/standard/standard_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint16_t, float> 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;
Expand Down
34 changes: 2 additions & 32 deletions ut-robomaster/src/subsystems/flywheel/command_rotate_flywheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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); }

Expand Down
4 changes: 2 additions & 2 deletions ut-robomaster/src/subsystems/flywheel/flywheel_subsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions ut-robomaster/src/subsystems/flywheel/flywheel_subsystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 96044ce

Please sign in to comment.