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,
agent
is created that handles data collection from carla. Code - Creating the class creates the carla
client
,blueprint library
andworld
objects. See the carla documentation for details. spawn_vehicle
spawns 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_gnss
spawns 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_callback
registers 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_imu
spawns 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_callback
registers 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_xyz
converts 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
state
object stores state in same format asinitial_state
arguement in the constructor. Updated in both updation and measurement stages.states
list stores tuples of state vector ,timestamp, and0
if state was added during updation and1
if state was added during measurementcovar
object stores the covariance matrix (5x5)covars
list stores covariance matrices after each udation or measurement, like thestates
list