Skip to content

Commit 99001b0

Browse files
committed
Update navX libraries
* Fix I2C write method * Update for WPILib LiveWindow changes * Fix decoding of GyroFSRDPS and AccelFSRG This intentionally does not implement the enableLogging methods, as these can be filtered out by configuring the logging module. It appears the I2C read method was fixed for the flipped WPILib I2C write return values in 2017, but the write method wasn't fixed, as RegisterIO expects that a return value of True from write is success.
1 parent f9e95f1 commit 99001b0

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

.gittrack

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
validation_root = robotpy_ext/common_drivers/navx
33
exclude_commits_file = devtools/exclude_commits_navx
44
upstream_root = ../navxmxp
5-
upstream_commit = 09abe90221cb9d0ae104776af037d0b8a7f2d720
5+
upstream_commit = d8fa37624f03379ed0e2a8f6f458e3cecbb59247
66

devtools/exclude_commits_navx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
d34b079bfaeab387915436946233367d6bedb370 # enableLogging method

robotpy_ext/common_drivers/navx/ahrs.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# validated: 2017-02-19 DV a2358399f5a3 roborio/java/navx_frc/src/com/kauailabs/navx/frc/AHRS.java
1+
# validated: 2018-02-11 DV d8fa37624f03 roborio/java/navx_frc/src/com/kauailabs/navx/frc/AHRS.java
22
#----------------------------------------------------------------------------
33
# Copyright (c) Kauai Labs 2015. All Rights Reserved.
44
#
@@ -996,7 +996,13 @@ def getFirmwareVersion(self):
996996
:returns: The firmware version in the format [MajorVersion].[MinorVersion]
997997
"""
998998
return '%s.%s' % (self.fw_ver_major, self.fw_ver_minor)
999-
999+
1000+
def getGyroFullScaleRangeDPS(self) -> int:
1001+
return self.gyro_fsr_dps
1002+
1003+
def getAccelFullScaleRangeG(self) -> int:
1004+
return self.accel_fsr_g
1005+
10001006
#
10011007
# Internal API
10021008
#
@@ -1069,14 +1075,9 @@ def _yawResetComplete(self):
10691075
self.yaw_angle_tracker.reset()
10701076

10711077
#
1072-
# LiveWindow
1078+
# LiveWindow
10731079
#
1074-
1075-
def getSmartDashboardType(self):
1076-
return "Gyro"
1077-
1078-
def updateTable(self):
1079-
table = self.getTable()
1080-
if table is not None:
1081-
table.putNumber("Value", self.getYaw())
1082-
1080+
1081+
def initSendable(self, builder):
1082+
builder.setSmartDashboardType("Gyro")
1083+
builder.addDoubleProperty("Value", self.getAngle, None)

robotpy_ext/common_drivers/navx/registerio.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# validated: 2017-02-19 DS c5e3a8a9b642 roborio/java/navx_frc/src/com/kauailabs/navx/frc/RegisterIO.java
1+
# validated: 2018-02-11 DV d8fa37624f03 roborio/java/navx_frc/src/com/kauailabs/navx/frc/RegisterIO.java
22
#----------------------------------------------------------------------------
33
# Copyright (c) Kauai Labs 2015. All Rights Reserved.
44
#
@@ -219,8 +219,8 @@ def getCurrentData(self):
219219
board_state.selftest_status = curr_data[IMURegisters.NAVX_REG_SELFTEST_STATUS-first_address]
220220
board_state.sensor_status = AHRSProtocol.decodeBinaryUint16(curr_data,IMURegisters.NAVX_REG_SENSOR_STATUS_L-first_address)
221221
board_state.update_rate_hz = curr_data[IMURegisters.NAVX_REG_UPDATE_RATE_HZ-first_address]
222-
board_state.gyro_fsr_dps = AHRSProtocol.decodeBinaryUint16(curr_data,IMURegisters.NAVX_REG_GYRO_FSR_DPS_L)
223-
board_state.accel_fsr_g = curr_data[IMURegisters.NAVX_REG_ACCEL_FSR_G]
222+
board_state.gyro_fsr_dps = AHRSProtocol.decodeBinaryUint16(curr_data,IMURegisters.NAVX_REG_GYRO_FSR_DPS_L-first_address)
223+
board_state.accel_fsr_g = curr_data[IMURegisters.NAVX_REG_ACCEL_FSR_G-first_address]
224224
board_state.capability_flags= AHRSProtocol.decodeBinaryUint16(curr_data,IMURegisters.NAVX_REG_CAPABILITY_FLAGS_L-first_address)
225225
self.notify_sink._setBoardState(board_state)
226226

robotpy_ext/common_drivers/navx/registerio_i2c.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# validated: 2017-02-19 DS 3b0fc57cd0e0 roborio/java/navx_frc/src/com/kauailabs/navx/frc/RegisterIO_I2C.java
1+
# validated: 2018-02-11 DV 73aa4ea84010 roborio/java/navx_frc/src/com/kauailabs/navx/frc/RegisterIO_I2C.java
22
#----------------------------------------------------------------------------
33
# Copyright (c) Kauai Labs 2015. All Rights Reserved.
44
#
@@ -37,7 +37,10 @@ def init(self):
3737

3838
def write(self, address, value):
3939
with self.mutex:
40-
return self.port.write(address | 0x80, value)
40+
aborted = self.port.write(address | 0x80, value)
41+
if aborted:
42+
logger.warn("navX-MXP I2C write error")
43+
return not aborted
4144

4245
def read(self, first_address, count):
4346
buffer = []

0 commit comments

Comments
 (0)