Finish Tasks 1b-d,

This commit is contained in:
Cal Wing 2023-11-02 19:08:19 +10:00
parent a2ee6af610
commit 69b7cbc6a3
2 changed files with 97 additions and 5 deletions

97
main.py
View File

@ -182,7 +182,7 @@ INIT_FLIGHT_PRAMS = {
}
def generateGraphs(missionData, mission):
pBar = tqdm(total=6)
pBar = tqdm(total=7)
graphData = {
"figTitle": f"Mission {mission} Flight Characteristics",
"figTitleFontSize": 16,
@ -227,6 +227,7 @@ def generateGraphs(missionData, mission):
"yLabel": "Time [s]",
"plotDim": (3,1),
"grid": True,
"tightLayout": True,
"subPlots":[
{
"title": "North Position",
@ -489,6 +490,91 @@ def generateGraphs(missionData, mission):
makeGraph(graphData, False, False, figSavePath=f"./images/m{mission}_flight_chars.png")
pBar.update(1)
graphData = {
"figTitle": f"Mission {mission} Flight Characteristics",
"figTitleFontSize": 16,
"figSize": (20, 12), #Yay America, this is in inches :/ # Note: cm = 1/2.54
"yLabel": "Time [s]",
"plotDim": (3,3),
"grid": True,
"subPlots":[
{
"title": "Roll Rate",
"yLabel": "Roll Rate [rad/s]",
"plots": [
{"x":missionData[0][IMU_TIME_HEADER[0]], "y":missionData[0][IMU_WBE_HEADERS[0]], "label":"Low Grade Data", "colour":"uq:purple"},
{"x":missionData[1][IMU_TIME_HEADER[0]], "y":missionData[1][IMU_WBE_HEADERS[0]], "label":"High Grade Data", "colour":"uq:blue"},
]
},
{
"title": "North Velocity",
"yLabel": "Velocity [m/s]",
"plots": [
{"x":missionData[1][IMU_TIME_HEADER[0]], "y":missionData[1][NED_VELOCITY_HEADER[0]], "label":"High Grade Data", "colour":"uq:blue"},
{"x":missionData[0][IMU_TIME_HEADER[0]], "y":missionData[0][NED_VELOCITY_HEADER[0]], "label":"Low Grade Data", "colour":"uq:purple"},
]
},
{
"title": "North Acceleration",
"yLabel": "Acceleration [m/s$^2$]",
"plots": [
{"x":missionData[0][IMU_TIME_HEADER[0]], "y":missionData[0][NED_ACCELERATION_HEADER[0]], "label":"Low Grade Data", "colour":"uq:purple"},
{"x":missionData[1][IMU_TIME_HEADER[0]], "y":missionData[1][NED_ACCELERATION_HEADER[0]], "label":"High Grade Data", "colour":"uq:blue"},
]
},
{
"title": "Pitch Rate",
"yLabel": "Pitch Rate [rad/s]",
"plots": [
{"x":missionData[0][IMU_TIME_HEADER[0]], "y":missionData[0][IMU_WBE_HEADERS[1]], "label":"Low Grade Data", "colour":"uq:purple"},
{"x":missionData[1][IMU_TIME_HEADER[0]], "y":missionData[1][IMU_WBE_HEADERS[1]], "label":"High Grade Data", "colour":"uq:blue"},
]
},
{
"title": "East Velocity",
"yLabel": "Velocity [m/s]",
"plots": [
{"x":missionData[1][IMU_TIME_HEADER[0]], "y":missionData[1][NED_VELOCITY_HEADER[1]], "label":"High Grade Data", "colour":"uq:blue"},
{"x":missionData[0][IMU_TIME_HEADER[0]], "y":missionData[0][NED_VELOCITY_HEADER[1]], "label":"Low Grade Data", "colour":"uq:purple"},
]
},
{
"title": "East Acceleration",
"yLabel": "Acceleration [m/s$^2$]",
"plots": [
{"x":missionData[0][IMU_TIME_HEADER[0]], "y":missionData[0][NED_ACCELERATION_HEADER[1]], "label":"Low Grade Data", "colour":"uq:purple"},
{"x":missionData[1][IMU_TIME_HEADER[0]], "y":missionData[1][NED_ACCELERATION_HEADER[1]], "label":"High Grade Data", "colour":"uq:blue"},
]
},
{
"title": "Yaw Rate",
"yLabel": "Yaw Rate [rad/s]",
"plots": [
{"x":missionData[0][IMU_TIME_HEADER[0]], "y":missionData[0][IMU_WBE_HEADERS[2]], "label":"Low Grade Data", "colour":"uq:purple"},
{"x":missionData[1][IMU_TIME_HEADER[0]], "y":missionData[1][IMU_WBE_HEADERS[2]], "label":"High Grade Data", "colour":"uq:blue"},\
]
},
{
"title": "Down Velocity",
"yLabel": "Velocity [m/s]",
"plots": [
{"x":missionData[1][IMU_TIME_HEADER[0]], "y":missionData[1][NED_VELOCITY_HEADER[2]], "label":"High Grade Data", "colour":"uq:blue"},
{"x":missionData[0][IMU_TIME_HEADER[0]], "y":missionData[0][NED_VELOCITY_HEADER[2]], "label":"Low Grade Data", "colour":"uq:purple"},
]
},
{
"title": "Down Acceleration",
"yLabel": "Acceleration [m/s$^2$]",
"plots": [
{"x":missionData[0][IMU_TIME_HEADER[0]], "y":missionData[0][NED_ACCELERATION_HEADER[2]], "label":"Low Grade Data", "colour":"uq:purple"},
{"x":missionData[1][IMU_TIME_HEADER[0]], "y":missionData[1][NED_ACCELERATION_HEADER[2]], "label":"High Grade Data", "colour":"uq:blue"},
]
},
]
}
makeGraph(graphData, False, False, figSavePath=f"./images/m{mission}_flight_chars_rpy.png")
pBar.update(1)
TRUTH_NPOS_DELTA_HEADER = ["Calculated vs True Position Delta [m]", "Calculated vs True Position Error [%]"]
def doTruthComparison(missionData, truthData):
@ -546,18 +632,21 @@ def generateTruthErrorGraphs(missionData):
if __name__ == '__main__':
#Load, Process & Graph Mission Data for Mission 1
print("Loading / Calculating to Mission 1 Data")
missionData = cacheData("./tmp/m1_L_transData.dfz", calculateVelocityPosition, (m1_IMUData[0], INIT_FLIGHT_PRAMS), forceCalc=False), \
cacheData("./tmp/m1_H_transData.dfz", calculateVelocityPosition, (m1_IMUData[1], INIT_FLIGHT_PRAMS), forceCalc=False)
missionData = doTruthComparison(missionData, m1TruthData)
print("Starting to Graph Mission 1")
generateTruthErrorGraphs(missionData)
generateGraphs(missionData, 1)
exit()
#exit()
#Load, Process & Graph Mission Data for Mission 1
#Load, Process & Graph Mission Data for Mission 2
print("Loading / Calculating to Mission 2 Data")
missionData = cacheData("./tmp/m2_L_transData.dfz", calculateVelocityPosition, (m2_IMUData[0], INIT_FLIGHT_PRAMS), forceCalc=False), \
cacheData("./tmp/m2_H_transData.dfz", calculateVelocityPosition, (m2_IMUData[1], INIT_FLIGHT_PRAMS), forceCalc=False)
print("Starting to Graph Mission 2")
generateGraphs(missionData, 2)
print("Complete")

View File

@ -242,6 +242,7 @@ def makeGraph(graphData, showPlot=True, doProgramBlock=True, figSavePath=None, h
doKeyCopy = False
figSize = graphData["figSize"] if "figSize" in graphData else None
tightLayout = graphData["tightLayout"] if "tightLayout" in graphData else True
fig, axes = plt.subplots(*plotDim, figsize=figSize) # Create a figure and an axes.
@ -285,6 +286,7 @@ def makeGraph(graphData, showPlot=True, doProgramBlock=True, figSavePath=None, h
orig_ax = ax1
ax1 = fig.add_subplot(orig_ax.get_position(), projection='3d')
orig_ax.remove()
if "tightLayout" not in graphData: tightLayout = False
# Duct Tape
ax = ax1
@ -528,7 +530,8 @@ def makeGraph(graphData, showPlot=True, doProgramBlock=True, figSavePath=None, h
fig.suptitle(graphData["figTitle"], fontsize=getSafeValue("figTitleFontSize"))
if "title" not in graphData: fig.canvas.manager.set_window_title(graphData["figTitle"].replace("\n", " "))
fig.tight_layout() #Fix labels being cut off sometimes
if tightLayout:
fig.tight_layout() #Fix labels being cut off sometimes
#Very big hack
if hideEmptyAxis: