<s> import logging <EOL> import gpxpy <EOL> import gpxpy . gpx <EOL> class PerceptionUnit : <EOL> def __init__ ( self , vehicle_constants , data ) : <EOL> self . _vehicle_constants = vehicle_constants <EOL> self . _observed_speed = <NUM_LIT:0.0> <EOL> self . _observed_heading = <NUM_LIT:0.0> <EOL> self . update ( data ) <EOL> @ property <EOL> def observed_speed ( self ) : <EOL> return self . _observed_speed <EOL> @ property <EOL> def observed_heading ( self ) : <EOL> return self . _observed_heading <EOL> def update ( self , data ) : <EOL> """<STR_LIT>""" <EOL> if data . has_time : <EOL> pass <EOL> if data . has_compass : <EOL> compass_heading = data . compass_heading <EOL> compass_pitch = data . compass_pitch <EOL> compass_roll = data . compass_roll <EOL> if data . has_GPS and data . fix : <EOL> lat = data . lat <EOL> lon = data . lon <EOL> gps_heading = data . gps_heading <EOL> gps_speed = data . speed <EOL> altitude = data . altitude <EOL> num_sat = data . num_sat <EOL> if data . has_GPS and data . fix : <EOL> self . _observed_speed = <NUM_LIT:0.0> <EOL> if data . has_compass and data . has_GPS and data . fix : <EOL> self . _observed_heading = ( compass_heading + gps_heading ) / <NUM_LIT> <EOL> elif data . has_compass : <EOL> self . _observed_heading = compass_heading <EOL> elif data . has_GPS and data . fix : <EOL> self . _observed_heading = gps_heading <EOL> def load_gpx ( self , filename ) : <EOL> gpx_file = open ( filename ) <EOL> gpx = gpxpy . parse ( gpx_file ) <EOL> return gpx </s>
