This repository contains code for implementing a Kalman Filter for tracking an object traveling in 2D space.
The Kalman Filter is a recursive algorithm that estimates the state of a dynamic system with noisy measurements. In the context of this repository, the Kalman Filter is used to track the position and velocity of an object moving in a 2D plane.
The main components of this repository are as follows:
tracker.py
: This script contains the simulation code for generating measurements of the object's position and running the Kalman Filter to estimate its state.kf_tracker.py
: This module implements the Kalman Filter model with methods for initializing the filter, predicting the next state, and updating the state based on measurements.utils.py
: This module provides utility functions for generating noisy measurements and plotting the results.requirements.txt
: This file lists the required dependencies for running the code.
To run the object tracking simulation using the Kalman Filter, follow these steps:
- Install the required dependencies listed in
requirements.txt
by running the following command:
pip install -r requirements.txt
- Import the necessary modules and classes:
import numpy as np
from tracker import run_sim
from kf_tracker import KalmanFilterModel
- Set the simulation options and Kalman Filter options:
sim_options = {
'time_step': 0.01,
'end_time': 120,
'measurement_rate': 1.5,
'measurement_noise_std': 10,
'motion_type': 'circle',
'start_at_origin': False,
'start_at_random_speed': True,
'start_at_random_heading': True,
'draw_plots': True,
'draw_animation': True
}
kf_options = {
'accel_std': 0.5, # Q Matrix Param
'meas_std': 10, # R Matrix
'init_on_measurement': True
}
- Run the simulation using the
run_sim
function:
run_sim(KalmanFilterModel, sim_options, kf_options)
The simulation will generate plots and animations to visualize the object's true path, measured positions, and the estimated trajectory based on the Kalman Filter. These visualizations help in understanding the effectiveness of the Kalman Filter for object tracking in 2D space.
If you would like to contribute to this project, you can do so by following these steps:
- Fork the repository.
- Create a new branch for your changes.
- Make your changes and commit them with descriptive commit messages.
- Push your changes to your forked repository.
- Submit a pull request describing the changes you have made.