Skip to content

Simulates ball trajectory with gravity and bounce effects, applying a Kalman Filter for position estimation from noisy observations. Visualizes true trajectory, noisy data, and filter estimates with performance metrics.

License

Notifications You must be signed in to change notification settings

suraj5424/Ball-Trajectory-Kalman-Filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Ball Trajectory Simulation with Kalman Filter and Bounce Effect

This project simulates the trajectory of a ball launched with a given speed and angle while incorporating the effects of gravity and bounce. The simulation also applies a Kalman Filter to estimate the ball's position from noisy observations, providing a comparison between the true trajectory and the estimated trajectory.

Features

  • Trajectory Simulation: Models the motion of a ball under the influence of gravity and includes bounce effects when the ball hits the ground.
  • Kalman Filter: Implements a Kalman Filter to estimate the ball's position based on noisy measurements.
  • Noise Handling: Adds Gaussian noise to the observations to simulate measurement inaccuracies.
  • Performance Metrics: Calculates the Mean Squared Error (MSE) and Root Mean Squared Error (RMSE) to evaluate the Kalman Filter's performance.
  • Visualization: Plots the true trajectory, noisy observations, and Kalman Filter estimates for visual comparison.

Parameters

  • dt: Time interval for the simulation (default: 0.1 seconds).
  • total_time: Total duration of the simulation (default: 10 seconds).
  • observation_noise_cov: Covariance matrix for observation noise.
  • launch_params: Dictionary containing launch position, speed, and angle.
  • init_state_mean: Initial state mean for the Kalman Filter, including position and velocity.
  • init_state_cov: Covariance matrix for the initial state estimate.
  • transition_cov: Process noise covariance matrix.

How It Works

  1. Initialization: The simulation starts by setting the initial position and velocity of the ball and initializing the Kalman Filter with the given parameters.
  2. Simulation Loop:
    • The ball's position and velocity are updated at each time step.
    • If the ball hits the ground, its position is reflected, and its vertical velocity is reversed and reduced to simulate energy loss on impact.
    • Noisy observations are generated based on the current position.
    • The Kalman Filter uses these observations to estimate the ball's position.
  3. Performance Evaluation: The difference between the true and estimated positions is used to calculate MSE and RMSE, providing a quantitative measure of the filter's accuracy.
  4. Visualization: The results are plotted, showing the true trajectory, noisy observations, and Kalman Filter estimates.

Visualization Example

The plot generated by this simulation illustrates:

  • True Ball Trajectory: The actual path of the ball under the influence of gravity and bounce.
  • Noisy Observations: The measurements with added noise, simulating real-world sensor inaccuracies.
  • Kalman Filter Estimate: The estimated trajectory using the Kalman Filter, showing how well the filter tracks the true path.

Execution Time

The script also measures and prints the total execution time, providing insights into the computational efficiency of the simulation.

About

Simulates ball trajectory with gravity and bounce effects, applying a Kalman Filter for position estimation from noisy observations. Visualizes true trajectory, noisy data, and filter estimates with performance metrics.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published