Skip to content

Commit

Permalink
Fix Sentry issue due to no encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
calebchalmers committed Feb 1, 2025
1 parent 2f30dcd commit 0591e79
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions ut-robomaster/src/subsystems/turret/turret_subsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,30 @@ void TurretSubsystem::initialize()

void TurretSubsystem::refresh()
{
#if defined(TARGET_STANDARD) || defined(TARGET_HERO)
yawEncoder.update();
#endif

setAmputated(!hardwareOk());

yaw.updateMotorAngle();
pitch.updateMotorAngle();

#if defined(TARGET_STANDARD) || defined(TARGET_HERO)
yawEncoder.update();

if (!isCalibrated && !isAmputated() && yawEncoder.isOnline())
{
baseYaw = yawEncoder.getAngle() - YAW_OFFSET - yaw.getAngle();
isCalibrated = true;

setTargetWorldAngles(getCurrentLocalYaw() + getChassisYaw(), getCurrentLocalPitch());
}
#else
if (!isCalibrated && !isAmputated())
{
baseYaw = -YAW_OFFSET;
isCalibrated = true;

setTargetWorldAngles(getCurrentLocalYaw() + getChassisYaw(), getCurrentLocalPitch());
}
#endif

if (isCalibrated && !drivers->isKillSwitched() && !isAmputated())
{
Expand Down

0 comments on commit 0591e79

Please sign in to comment.