Skip to content

Commit

Permalink
Fix turret cooldown and heat monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
calebchalmers committed May 26, 2024
1 parent f7b7adf commit e8aab44
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 25 deletions.
3 changes: 2 additions & 1 deletion ut-robomaster/src/robots/hero/hero_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ 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 FLYWHEEL_SPEED = 190.0f; // 16 m/s
const float TARGET_PROJECTILE_VELOCITY = 16; // m/s
const float FLYWHEEL_SPEED = 190.0f;

const float BALLS_PER_SEC = 4.0f;
const float BALLS_PER_REV = 6.0f;
Expand Down
3 changes: 2 additions & 1 deletion ut-robomaster/src/robots/sentry/sentry_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ 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 float FLYWHEEL_SPEED = 122.0f; // 30 m/s
const float TARGET_PROJECTILE_VELOCITY = 30; // m/s
const float FLYWHEEL_SPEED = 122.0f;

const float BALLS_PER_SEC = 10.0f;
const float BALLS_PER_REV = 8.0f;
Expand Down
3 changes: 2 additions & 1 deletion ut-robomaster/src/robots/standard/standard_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ 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 float FLYWHEEL_SPEED = 122.0f; // 30 m/s
const float TARGET_PROJECTILE_VELOCITY = 30; // m/s
const float FLYWHEEL_SPEED = 122.0f;

const float BALLS_PER_SEC = 10.0f;
const float BALLS_PER_REV = 8.0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bool CommandAgitatorBurst::isFinished() const
}

if (drivers->refSerial.getRefSerialReceivingData() &&
power_limiter::getRemainingCooldown(drivers, barrelId) <= BARREL_HEAT_BUFFER)
power_limiter::getRemainingHeat(drivers, barrelId) <= BARREL_HEAT_BUFFER)
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void CommandAgitatorContinuous::execute()
}
else if ( // barrel overheat
drivers->refSerial.getRefSerialReceivingData() &&
power_limiter::getRemainingCooldown(drivers, barrelId) <= BARREL_HEAT_BUFFER)
power_limiter::getRemainingHeat(drivers, barrelId) <= BARREL_HEAT_BUFFER)
{
agitator->setBallsPerSecond(0.0f);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void CommandMoveTurretAimbot::execute()

bool validBallistcs = findTargetProjectileIntersection(
kinState,
getBulletSpeed(),
TARGET_PROJECTILE_VELOCITY,
BALLISTIC_ITERATIONS,
&turretPitch,
&turretYaw,
Expand Down Expand Up @@ -77,14 +77,4 @@ void CommandMoveTurretAimbot::execute()
void CommandMoveTurretAimbot::end(bool) {}

bool CommandMoveTurretAimbot::isFinished(void) const { return false; }

float CommandMoveTurretAimbot::getBulletSpeed()
{
auto turretInfo = &drivers->refSerial.getRobotData().turret;
#if defined(TARGET_STANDARD) || defined(TARGET_SENTRY)
return turretInfo->barrelSpeedLimit17ID1;
#elif defined(TARGET_HERO)
return turretInfo->barrelSpeedLimit42;
#endif
}
} // namespace commands
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class CommandMoveTurretAimbot : public tap::control::Command
const char* getName() const override { return "move turret aimbot command"; }

private:
float getBulletSpeed();

src::Drivers* drivers;
TurretSubsystem* turret;

Expand Down
8 changes: 2 additions & 6 deletions ut-robomaster/src/utils/power_limiter/barrel_cooldown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,25 @@

namespace power_limiter
{
float getRemainingCooldown(src::Drivers *drivers, BarrelId id)
float getRemainingHeat(src::Drivers *drivers, BarrelId id)
{
auto turret = drivers->refSerial.getRobotData().turret;

float heat = 0.0f;
float limit = 0.0f;

switch (id)
{
case STANDARD1:
heat = turret.heat17ID1;
limit = turret.heatLimit17ID1;
break;
case STANDARD2:
heat = turret.heat17ID2;
limit = turret.heatLimit17ID2;
break;
case HERO:
heat = turret.heat42;
limit = turret.heatLimit42;
break;
}

return limit - heat;
return turret.heatLimit - heat;
}
} // namespace power_limiter
2 changes: 1 addition & 1 deletion ut-robomaster/src/utils/power_limiter/barrel_cooldown.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ enum BarrelId
HERO // 42
};

float getRemainingCooldown(src::Drivers *drivers, BarrelId id);
float getRemainingHeat(src::Drivers *drivers, BarrelId id);
} // namespace power_limiter

0 comments on commit e8aab44

Please sign in to comment.