Skip to content

Commit

Permalink
Add ability to plot both IMU and IMU3 at same time
Browse files Browse the repository at this point in the history
  • Loading branch information
waltjohnson committed Jan 9, 2025
1 parent 74b5688 commit 75b4bac
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 25 deletions.
27 changes: 17 additions & 10 deletions python/logInspector/logInspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def closeEvent(self, event):
super().closeEvent(event)

def popPlot(self):
print("Pop Plot")
print("New Plot")
mp = MPlotter(len(self.mplots), self, True, self.nameList[self.selectedIndex] + " - " + self.deviceInfo())
mp.dialogClosed.connect(self.on_mplotter_closed) # Connect the custom signal to a slot
mp.show()
Expand Down Expand Up @@ -427,14 +427,12 @@ def setupUi(self):
self.setAcceptDrops(True)

def createListSystem(self):
self.addListSection('SYSTEM')
self.addListItem('Flash Config', lambda: self.showFlashConfig())
self.addListItem('Device Info', lambda: self.showDeviceInfo())
self.addListItem('INS Status', 'insStatus')
self.addListItem('HDW Status', 'hdwStatus')

def createListIns(self):
self.addListSection('INS/AHRS')
self.addListItem('Pos NED Map', 'posNEDMap')
self.addListItem('Pos NED', 'posNED')
self.addListItem('Pos LLA', 'posLLA')
Expand All @@ -446,7 +444,6 @@ def createListIns(self):
self.addListItem('Climb Rate', 'climbRate')

def createListSensors(self):
self.addListSection('SENSORS')
self.addListItem('IMU PQR', 'imuPQR')
self.addListItem('IMU Accel', 'imuAcc')
self.addListItem('PSD PQR', 'gyroPSD')
Expand All @@ -456,7 +453,6 @@ def createListSensors(self):
self.addListItem('Temp', 'temp')

def createListGps(self):
self.addListSection('GPS')
self.addListItem('GPS LLA', 'gpsLLA')
self.addListItem('GPS 1 Stats', 'gpsStats')
self.addListItem('GPS 2 Stats', 'gps2Stats')
Expand All @@ -474,7 +470,7 @@ def createListGps(self):
self.addListItem('GPS Velocity NED', 'gpsVelNED')

def createListGeneral(self):
self.addListSection('GENERAL')
None

def setCurrentListRow(self, row):
if row < self.modelList.rowCount() and row < len(self.functionList):
Expand Down Expand Up @@ -509,10 +505,19 @@ def createPlotSelection(self):
groupBox.setLayout(LayoutList)
self.controlLayout.addWidget(groupBox)

self.addListSection('SYSTEM')
self.createListSystem()

self.addListSection('INS/AHRS')
self.createListIns()

self.addListSection('SENSORS')
self.createListSensors()

self.addListSection('GPS')
self.createListGps()

self.addListSection('GENERAL')
self.createListGeneral()

self.checkboxResidual = QCheckBox("Residual", self)
Expand Down Expand Up @@ -616,14 +621,16 @@ def createBottomToolbar(self):
self.toolLayout = QHBoxLayout()
self.toolLayout.addWidget(self.mplots[0].toolbar)

self.popPlotButton = QPushButton("Pop Plot")
self.popPlotButton.setToolTip("Open current plot in separate dialog window.")
self.popPlotButton.clicked.connect(self.popPlot)
self.toolLayout.addWidget(self.popPlotButton)
self.hideControlButton = QPushButton("Hide Panel")
self.hideControlButton.setToolTip("Hide/show left side control panel of the LogInspector.")
self.hideControlButton.clicked.connect(self.hideControl)
self.toolLayout.addWidget(self.hideControlButton)

self.popPlotButton = QPushButton("New Plot")
self.popPlotButton.setToolTip("Open current plot in separate dialog window.")
self.popPlotButton.clicked.connect(self.popPlot)
self.toolLayout.addWidget(self.popPlotButton)

self.newAppButton = QPushButton("New App")
self.newAppButton.setToolTip("Open a new instance of the LogInspector.")
self.newAppButton.clicked.connect(self.newWindow)
Expand Down
2 changes: 2 additions & 0 deletions python/logInspector/logInspectorInternal.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def createListIns(self):
self.addListItem('EKF Biases', 'ekfBiases')

def createListSensors(self):
self.addListItem('IMU 3 PQR', 'imu3PQR')
self.addListItem('IMU 3 Accel', 'imu3Acc')
super(logInspectorInternal, self).createListSensors()
self.addListItem('Allan Var. PQR', 'allanVariancePQR')
self.addListItem('Allan Var. Accel', 'allanVarianceAcc')
Expand Down
36 changes: 21 additions & 15 deletions python/logInspector/logPlotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2064,13 +2064,13 @@ def gnssEphemeris(self, fig=None, axs=None):
b.yaxis.set_major_locator(MaxNLocator(integer=True))


def loadGyros(self, device):
return self.loadIMU(device, 0)
def loadGyros(self, device, forceImu3=False):
return self.loadIMU(device, accelSensor=0, forceImu3=forceImu3)

def loadAccels(self, device):
return self.loadIMU(device, 1)
def loadAccels(self, device, forceImu3=False):
return self.loadIMU(device, accelSensor=1, forceImu3=forceImu3)

def loadIMU(self, device, accelSensor): # 0 = gyro, 1 = accelerometer
def loadIMU(self, device, accelSensor, forceImu3=False): # 0 = gyro, 1 = accelerometer
imu1 = None
imu2 = None
imu3 = None
Expand All @@ -2085,7 +2085,7 @@ def loadIMU(self, device, accelSensor): # 0 = gyro, 1 = accelerometer
else:
imu1 = np.copy(self.getData(device, DID_PIMU, 'vel'))

if np.shape(imu1)[0] != 0: # DID_PIMU
if np.shape(imu1)[0] != 0 and not forceImu3: # DID_PIMU
# time = self.getData(device, DID_IMU_RAW, 'time') # to plot raw gyro data
time = self.getData(device, DID_PIMU, 'time')
dt = self.getData(device, DID_PIMU, 'dt')
Expand Down Expand Up @@ -2118,7 +2118,7 @@ def loadIMU(self, device, accelSensor): # 0 = gyro, 1 = accelerometer
else:
time = self.getData(device, DID_IMU, 'time')

if len(time) != 0: # DID_IMU
if len(time) != 0 and not forceImu3: # DID_IMU
I = self.getData(device, DID_IMU, 'I')
dt = time[1:] - time[:-1]
dt = np.append(dt, dt[-1])
Expand Down Expand Up @@ -2166,7 +2166,13 @@ def loadIMU(self, device, accelSensor): # 0 = gyro, 1 = accelerometer

return (time, dt, imu1, imu2, imu3, imuCount)

def imuPQR(self, fig=None, axs=None):
def imu3PQR(self, fig=None, axs=None):
self.imuPQR(fig, axs, forceImu3=True)

def imu3Acc(self, fig=None, axs=None):
self.imuAcc(fig, axs, forceImu3=True)

def imuPQR(self, fig=None, axs=None, forceImu3=False):
if fig is None:
fig = plt.figure()

Expand All @@ -2182,21 +2188,21 @@ def imuPQR(self, fig=None, axs=None):
refTime.append(refTime_)

fig.suptitle('PQR - ' + os.path.basename(os.path.normpath(self.log.directory)))
(time, dt, pqr0, pqr1, pqr2, pqrCount) = self.loadGyros(0)
(time, dt, pqr0, pqr1, pqr2, pqrCount) = self.loadGyros(0, forceImu3)

plotResidual = pqrCount==1 and self.residual
if pqrCount:
ax = fig.subplots(3, (2 if plotResidual else pqrCount), sharex=True, squeeze=False)
if plotResidual:
for d in self.active_devs:
if self.log.serials[d] == 'Ref INS':
(time, dt, pqr0, pqr1, pqr2, pqrCount) = self.loadGyros(d)
(time, dt, pqr0, pqr1, pqr2, pqrCount) = self.loadGyros(d, forceImu3)
refTime = time
refPqr = pqr0
continue

for dev_idx, d in enumerate(self.active_devs):
(time, dt, pqr0, pqr1, pqr2, pqrCount) = self.loadGyros(d)
(time, dt, pqr0, pqr1, pqr2, pqrCount) = self.loadGyros(d, forceImu3)
if pqrCount:
for i in range(3):
axislable = 'P' if (i == 0) else 'Q' if (i==1) else 'R'
Expand Down Expand Up @@ -2243,7 +2249,7 @@ def imuPQR(self, fig=None, axs=None):
self.setup_and_wire_legend()
return self.saveFigJoinAxes(ax, axs, fig, 'pqrIMU')

def imuAcc(self, fig=None, axs=None):
def imuAcc(self, fig=None, axs=None, forceImu3=False):
if fig is None:
fig = plt.figure()

Expand All @@ -2258,21 +2264,21 @@ def imuAcc(self, fig=None, axs=None):
refTime.append(refTime_)

fig.suptitle('Accelerometer - ' + os.path.basename(os.path.normpath(self.log.directory)))
(time, dt, acc0, acc1, acc2, accCount) = self.loadAccels(0)
(time, dt, acc0, acc1, acc2, accCount) = self.loadAccels(0, forceImu3)

plotResidual = accCount==1 and self.residual
if accCount:
ax = fig.subplots(3, (2 if plotResidual else accCount), sharex=True, squeeze=False)
if plotResidual:
for d in self.active_devs:
if self.log.serials[d] == 'Ref INS':
(time, dt, acc0, acc1, acc2, accCount) = self.loadAccels(d)
(time, dt, acc0, acc1, acc2, accCount) = self.loadAccels(d, forceImu3)
refTime = time
refAcc = acc0
continue

for dev_idx, d in enumerate(self.active_devs):
(time, dt, acc0, acc1, acc2, accCount) = self.loadAccels(d)
(time, dt, acc0, acc1, acc2, accCount) = self.loadAccels(d, forceImu3)
if accCount:
for i in range(3):
axislable = 'X' if (i == 0) else 'Y' if (i==1) else 'Z'
Expand Down

0 comments on commit 75b4bac

Please sign in to comment.