@@ -37,45 +37,48 @@ void TurretSubsystem::refresh()
3737 // who needs hardware checks?
3838 // setAmputated(!hardwareOk());
3939
40+ #if defined(TARGET_HERO)
4041 Remote* remote = &drivers->remote ;
4142 float h = remote->getChannel (Remote::Channel::LEFT_HORIZONTAL);
4243 float v = remote->getChannel (Remote::Channel::LEFT_VERTICAL);
4344 yaw.setOutput (h);
4445 pitch.motor .setDesiredOutput (GM6020.maxOutput * v);
46+ return ;
47+ #endif
48+
49+ yaw.updateMotorAngle ();
50+ pitch.updateMotorAngle ();
51+
52+ #if defined(TARGET_STANDARD) || defined(TARGET_HERO)
53+ yawEncoder.update ();
54+
55+ if (!isCalibrated && yawEncoder.isOnline ())
56+ {
57+ baseYaw = yawEncoder.getAngle () - YAW_OFFSET - yaw.getAngle ();
58+ isCalibrated = true ;
59+
60+ setTargetWorldAngles (getCurrentLocalYaw () + getChassisYaw (), getCurrentLocalPitch ());
61+ }
62+ #else
63+ if (!isCalibrated && !isAmputated ())
64+ {
65+ baseYaw = -YAW_OFFSET;
66+ isCalibrated = true ;
67+
68+ setTargetWorldAngles (getCurrentLocalYaw () + getChassisYaw (), getCurrentLocalPitch ());
69+ }
70+ #endif
4571
46- // yaw.updateMotorAngle();
47- // pitch.updateMotorAngle();
48-
49- // #if defined(TARGET_STANDARD) || defined(TARGET_HERO)
50- // yawEncoder.update();
51-
52- // if (!isCalibrated && yawEncoder.isOnline())
53- // {
54- // baseYaw = yawEncoder.getAngle() - YAW_OFFSET - yaw.getAngle();
55- // isCalibrated = true;
56-
57- // setTargetWorldAngles(getCurrentLocalYaw() + getChassisYaw(), getCurrentLocalPitch());
58- // }
59- // #else
60- // if (!isCalibrated && !isAmputated())
61- // {
62- // baseYaw = -YAW_OFFSET;
63- // isCalibrated = true;
64-
65- // setTargetWorldAngles(getCurrentLocalYaw() + getChassisYaw(), getCurrentLocalPitch());
66- // }
67- // #endif
68-
69- // if (isCalibrated && !drivers->isKillSwitched())
70- // {
71- // yaw.setAngle(-baseYaw + getTargetLocalYaw(), DT);
72- // pitch.setAngle((PITCH_OFFSET + getTargetLocalPitch()) * PITCH_REDUCTION, DT);
73- // }
74- // else
75- // {
76- // yaw.reset();
77- // pitch.reset();
78- // }
72+ if (isCalibrated && !drivers->isKillSwitched ())
73+ {
74+ yaw.setAngle (-baseYaw + getTargetLocalYaw (), DT);
75+ pitch.setAngle ((PITCH_OFFSET + getTargetLocalPitch ()) * PITCH_REDUCTION, DT);
76+ }
77+ else
78+ {
79+ yaw.reset ();
80+ pitch.reset ();
81+ }
7982}
8083
8184void TurretSubsystem::inputTargetData (Vector3f position, Vector3f velocity, Vector3f acceleration)
0 commit comments