Skip to content

Commit bea8aca

Browse files
authored
LL4 IMU Updates from Limelight OS 2025.1 (#13)
1 parent 82f2c96 commit bea8aca

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

yall/java/limelight/networktables/LimelightSettings.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public class LimelightSettings
6363
* Imu Mode for the Limelight 4.
6464
*/
6565
private NetworkTableEntry imuMode;
66+
/**
67+
* Imu Assist Alpha value for the Limelight 4.
68+
*/
69+
private NetworkTableEntry imuAssistAlpha;
6670
/**
6771
* Sets 3d offset point for easy 3d targeting Sets the 3D point-of-interest offset for the current fiducial pipeline.
6872
* <p>
@@ -109,6 +113,7 @@ public LimelightSettings(Limelight camera)
109113
streamMode = limelightTable.getEntry("stream");
110114
cropWindow = limelightTable.getDoubleArrayTopic("crop").getEntry(new double[0]);
111115
imuMode = limelightTable.getEntry("imumode_set");
116+
imuAssistAlpha = limelightTable.getEntry("imuassistalpha_set");
112117
robotOrientationSet = limelightTable.getDoubleArrayTopic("robot_orientation_set").getEntry(new double[0]);
113118
downscale = limelightTable.getEntry("fiducial_downscale_set");
114119
fiducial3DOffset = limelightTable.getDoubleArrayTopic("fiducial_offset_set").getEntry(new double[0]);
@@ -197,6 +202,20 @@ public LimelightSettings withImuMode(ImuMode mode)
197202
return this;
198203
}
199204

205+
/**
206+
* Set the IMU Assist filter alpha/strength value. Higher values will cause the internal imu to converge on
207+
* assist source more rapidly.
208+
* <p> This method changes the Limelight - normally immediately.
209+
*
210+
* @param alpha Assist alpha value (0.001 by default).
211+
* @return {@link LimelightSettings} for chaining.
212+
*/
213+
public LimelightSettings withImuAssistAlpha(double alpha)
214+
{
215+
imuAssistAlpha.setNumber(alpha);
216+
return this;
217+
}
218+
200219
/**
201220
* Set the current robot {@link Orientation3d} (normally given by the robot gyro) for LL to use in its MegaTag2
202221
* determination.
@@ -370,7 +389,15 @@ public enum ImuMode
370389
/**
371390
* Use internal IMU for MT2 localization. Ignores external IMU updates from {@link LimelightSettings#withRobotOrientation(Orientation3d)}.
372391
*/
373-
InternalImu
392+
InternalImu,
393+
/**
394+
* Use internal IMU for MT2 localization. The internal IMU will utilize filtered MT1 yaw estimates for continuous heading correction.
395+
*/
396+
InternalImuMT1Assist,
397+
/**
398+
* Use internal IMU for MT2 localization. The internal IMU will utilize the external IMU for continuous heading correction.
399+
*/
400+
InternalImuExternalAssist
374401
}
375402

376403
}

yall/python/yall/limelight.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,8 @@ class ImuMode(Enum):
709709
ExternalImu = 0 # Use external IMU yaw submitted via {@link withRobotOrientation} for MT2 localization. The internal IMU is ignored entirely.
710710
SyncInternalImu = 1 # Use external IMU yaw submitted via {@link withRobotOrientation} for MT2 localization. The internal IMU is synced with the external IMU.
711711
InternalImu = 2 # Use internal IMU for MT2 localization. Ignores external IMU updates from {@link withRobotOrientation}.
712+
InternalImuMT1Assist = 3 # Use internal IMU for MT2 localization. The internal IMU will utilize filtered MT1 yaw estimates for continuous heading correction.
713+
InternalImuExternalAssist = 4 # Use internal IMU for MT2 localization. The internal IMU will utilize the external IMU for continuous heading correction.
712714

713715
class DownscalingOverride(Enum):
714716
Pipeline = 0 # Pipeline downscaling, equivalent to 0
@@ -747,6 +749,9 @@ def __init__(self, camera: "Limelight"):
747749
self.imuMode: ntcore.NetworkTableEntry = self.limelightTable.getEntry(
748750
"imumode_set"
749751
)
752+
self.imuAssistAlpha: ntcore.NetworkTableEntry = self.limelightTable.getEntry(
753+
"imuassistalpha_set"
754+
)
750755
self.robotOrientationSet: ntcore.DoubleArrayEntry = (
751756
self.limelightTable.getDoubleArrayTopic("robot_orientation_set").getEntry(
752757
[]
@@ -803,6 +808,15 @@ def withImuMode(self, mode: ImuMode) -> "LimelightSettings":
803808
self.imuMode.setDouble(mode.value)
804809
return self
805810

811+
def withImuAssistAlpha(self, alpha: float) -> "LimelightSettings":
812+
"""
813+
Set the IMU Assist filter alpha/strength value.
814+
Higher values will cause the internal imu to converge on assist source more rapidly.
815+
Default value is 0.001.
816+
"""
817+
self.imuAssistAlpha.setDouble(alpha)
818+
return self
819+
806820
def withRobotOrientation(self, orientation: Orientation3d) -> "LimelightSettings":
807821
"""Set the robot orientation used for localization."""
808822
self.robotOrientationSet.set(LimelightUtils.orientation3dToArray(orientation))

0 commit comments

Comments
 (0)