88import json
99import matplotlib .pyplot as plt
1010import numpy as np
11+ from GEMstack .mathutils .transforms import lat_lon_to_xy
1112
1213def parse_behavior_log (filename ):
1314 """
@@ -23,9 +24,11 @@ def parse_behavior_log(filename):
2324 speeds = []
2425 xs = []
2526 ys = []
27+ ref_lat = 0.0
28+ ref_long = 0.0
2629
2730 with open (filename , 'r' ) as f :
28- for line in f :
31+ for idx , line in enumerate ( f ) :
2932 try :
3033 entry = json .loads (line )
3134 except json .JSONDecodeError :
@@ -43,6 +46,10 @@ def parse_behavior_log(filename):
4346 frame = vehicle_data ["pose" ].get ("frame" )
4447 x = vehicle_data ["pose" ].get ("x" )
4548 y = vehicle_data ["pose" ].get ("y" )
49+ if idx == 0 :
50+ ref_lat = x
51+ ref_long = y
52+ x , y = lat_lon_to_xy (x ,y ,ref_lat ,ref_long )
4653 # Only add if all fields are available
4754 if None not in (t , acceleration , heading_rate , speed ) and frame != 3 :
4855 times .append (t )
@@ -143,7 +150,7 @@ def plot_accelerations(axis, accelerations, time):
143150def plot_gg_diagram (axis , longitudinal_gs , lateral_gs ):
144151 """Plots gg diagram"""
145152 # Plot G-G diagram
146- axis .scatter (longitudinal_gs , lateral_gs , alpha = 0.5 , label = "Data Points" )
153+ axis .scatter (lateral_gs , longitudinal_gs , alpha = 0.5 , label = "Data Points" )
147154
148155 # Draw friction ellipse (assuming µ = 1.0)
149156 mu = 1.0
0 commit comments