Kalman filter for self driving cars using gnss and imu data. Data was collected from the CARLA open source simulator.
- Ubuntu 18.04
- Carla 0.9.11
- Python 3.7 API
- Python 3.6 interpreter
- VS Code for editing
- IPython 5.5.0
- A class,
agentis created that handles data collection from carla. Code - Creating the class creates the carla
client,blueprint libraryandworldobjects. See the carla documentation for details. spawn_vehiclespawns a vehicle at a location, based on the arguments. The vehicle is namedvehicle- argument : index : The index of pre-defined location in the world at which to spawn the vehicle. If not mentioned, a random location is choosen.
spawn_gnssspawns a gnss sensor, namedgnss_sensor- argument :
per: Period for refreshing gnss data - argument :
std_dev: Standard deviation of gnss data (in degrees for latitude and longitude)
- argument :
reg_gnss_callbackregisters the passed function as a callback that will be executed when the gnss data is available.- argument :
callback: The function that will be called with the gnss data as the argument, when data is ready.
- argument :
spawn_imuspawns an IMU sensor, namedimu_sensor- arguemnt :
per: Period for refreshing imu data - argument :
accel_std_dev: Standard deviation for accelerometer - argument :
gyro_std_dev: Standard deviation for gyroscope data.
- arguemnt :
reg_imu_callbackregisters the passed function as a callback that will be executed when the imu data is available.- argument :
callback: The function that will be called with the imu data as the argument, when data is ready.
- argument :
gnss_to_xyzconverts gnss data passed into xyz coordinates in the current map, by comparing to the geographic coordinates(latitude, longitude) of the map centre to geographic coordinates in the passed gnss data.- argument :
data: The gnss data to be converted - returns :
[x, y, z]: Standard cartesian coordinates
- argument :
For controlling and giving inputs
-
At initialization, we give the following details to the constructor:
initial_state- A 5x1 column vector, with the format
[x_pos, y_pos, yaw_angle, x_vel, y_vel] - This is considered to be perfect data, i.e with 0 variance.
- A 5x1 column vector, with the format
accel_var- Variance of accelerometer data
yaw_var- Variance of gyroscope yaw angular velocity estimate
meas_var- Variance of measurements (gnss data)
-
For the prediction stage, to feed with inputs (x and y acceleration from acceleromter and yaw angular veloicty from gyroscope), pass the following
inp- A 3x1 column vector with the format
[x_accel, y_accel, yaw_vel]
- A 3x1 column vector with the format
time- Current time in seconds
-
For the updation stage, to feed with measurements (x, y data from GNSS sensor), pass the following
measurement- A 2x1 column vector with the format
[x_pos, y_pos]
- A 2x1 column vector with the format
time- Current time in seconds
For getting outputs and viewing previous estimations, use the following data members
stateobject stores state in same format asinitial_statearguement in the constructor. Updated in both updation and measurement stages.stateslist stores tuples of state vector ,timestamp, and0if state was added during updation and1if state was added during measurementcovarobject stores the covariance matrix (5x5)covarslist stores covariance matrices after each udation or measurement, like thestateslist