Vehicle’s State Space

In this notebook, we will demonstrate how to retrieve a single dataframe representing vehicle’s state information as comprehsive as possible for a particular driver. Generally, it is not trivial since not all state information come at same data rate and not all state information is retreived at the same time.

[1]:
import strym
from strym import strymread
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
/home/ivory/anaconda3/envs/dbn/lib/python3.7/site-packages/statsmodels/tools/_testing.py:19: FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.
  import pandas.util.testing as tm
Loading BokehJS ...
[2]:
%%time
folder = "../../PandaData/2020_04_30/"
file= "2020-04-30-15-54-48_2T3Y1RFV8KC014025_CAN_Messages.csv"
r =strymread(csvfile=folder + file)
CPU times: user 8.98 s, sys: 154 ms, total: 9.13 s
Wall time: 7.8 s

Lets retrieve the state information of the vehicle using state_space

[3]:
%%time
state_var = r.state_space(rate = 1, cont_method='nearest')
CPU times: user 3min 1s, sys: 27.5 s, total: 3min 28s
Wall time: 1min 31s
[4]:
state_var
[4]:
Time speed distance_covered accelx accely accelz steer_torque yaw_rate steer_rate steer_angle steer_fraction wheel_speed_fl wheel_speed_fr wheel_speed_rl wheel_speed_rr lead_distance acc_status relative_vel
Clock
2020-04-30 22:54:49.316447973 1.588287e+09 0.00 0.000000 0.000 15.0 46.0 -9.0 0.00 0.0 -27.0 -0.6 0.00 0.00 0.00 0.00 252.0 0.0 0.0
2020-04-30 22:54:50.318795919 1.588287e+09 0.00 0.000000 0.000 14.0 46.0 -8.0 0.00 0.0 -27.0 -0.6 0.00 0.00 0.00 0.00 252.0 0.0 0.0
2020-04-30 22:54:51.321143866 1.588287e+09 0.00 0.000000 0.000 14.0 46.0 -9.0 0.00 0.0 -27.0 -0.6 0.00 0.00 0.00 0.00 252.0 0.0 0.0
2020-04-30 22:54:52.323491812 1.588287e+09 0.00 0.000000 0.000 14.0 46.0 -8.0 0.00 0.0 -27.0 -0.6 0.00 0.00 0.00 0.00 252.0 0.0 0.0
2020-04-30 22:54:53.325839758 1.588287e+09 0.00 0.000000 0.000 14.0 46.0 -9.0 0.00 0.0 -27.0 -0.6 0.00 0.00 0.00 0.00 252.0 0.0 0.0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2020-04-30 23:04:34.687644243 1.588288e+09 14.51 21718.269588 0.067 -79.0 113.0 -41.0 -25.25 -200.0 -262.5 -0.1 15.83 13.42 15.18 12.98 252.0 2.0 0.0
2020-04-30 23:04:35.689992189 1.588288e+09 14.51 21732.808192 0.000 -75.0 46.0 -34.0 -31.50 -1.0 -310.5 0.1 16.18 13.24 15.22 12.47 252.0 2.0 0.0
2020-04-30 23:04:36.692340136 1.588288e+09 14.06 21747.141382 -0.008 -60.0 165.0 -23.0 -27.50 122.0 -273.0 -0.4 15.50 12.98 14.72 12.16 252.0 2.0 0.0
2020-04-30 23:04:37.694688082 1.588288e+09 14.46 21761.208512 0.381 -31.0 172.0 8.0 -13.00 100.0 -118.5 -0.3 15.30 14.00 14.91 13.85 252.0 2.0 0.0
2020-04-30 23:04:38.697036028 1.588288e+09 16.43 21776.642314 0.462 -23.0 253.0 12.0 -4.75 19.0 -43.5 0.2 16.91 16.35 16.55 16.39 252.0 2.0 0.0

589 rows × 18 columns

The state_space function call further creates a sqlite3 database with State Space table in a local folder ~/.strym folder that can be used for database query.