This project is a trajectory estimation system. It includes program for estimation trajectory from IMU for real and simulated UAV.
config.yaml: Configuration file for the project settings.README.md: This file containing the project description.requirements.txt: Lists the dependencies required to run the project.save_to_file_mavsdk.py: Script to extract inercial data from UAV using MAVSDK (MAVLink SDK).my_functions.py: Contains various utility functions used throughout the project.trajectory_estimator_hardware.py: Script for trajectory estimation for real UAV.trajectory_estimator_sim.py: Script for trajectory estimation using simulated UAV.
src/trajectory_estimator/: Contains the ROS2 package for trajectory estimation.package.xml: Package configuration file.setup.py: Setup script for the ROS2 package.setup.cfg: Configuration file for the package.trajectory_estimator/: Contains the core implementation.__init__.py: Initialization file.imu_pub.py: Publishes IMU data to the ROS2 topic.gps_pub.py: Publishes GPS data to the ROS2 topic.
resource/: Contains additional resources for the package.test/: Contains test scripts for the package.
imu_trajectory.csv: IMU trajectory data estimated either for a simulated UAV or a real UAV.gps_trajectory.csv: GPS trajectory data converted either for a simulated UAV or a real UAV.hardware/: Contains hardware data files.sensor_combined.csvmag.csvgps.csvodo.csv
sim/: Contains simulation data files and directories for different trajectories.sensor_combined.csvgps.csvodo.csvtrajectory1/: Data for trajectory 1.sensor_combined.txtodo.txtgps.txt
trajectory2/: Data for trajectory 2.sensor_combined.txtodo.txtgps.txt
trajectory3/: Data for trajectory 3.sensor_combined.txtodo.txtgps.txt
-
Clone the repository:
git clone https://github.com/BUT-DRONE-CENTRE/inertial_data_analysis.git
-
Set up the virtual environment:
python3 -m venv .venv source .venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
-
Build the ROS2 workspace:
cd ros2_ws colcon build -
Run the trajectory estimator:
- For hardware data:
python trajectory_estimator_hardware.py
- For simulation data:
python trajectory_estimator_sim.py
- For hardware data:
The config.yaml file is used to set various paths and parameters for the project. Below is a detailed guide on how to set up the configuration file according to your needs.
root: The root directory of your project.ros2_path_imu: Path to the IMU trajectory data for ROS2.ros2_path_gps: Path to the GPS trajectory data for ROS2.path_imu_sim: Path to the simulated IMU data.path_odo_sim: Path to the simulated odometry data.path_gps_sim: Path to the simulated GPS data.path_imu_hardware: Path to the hardware IMU data.path_magnetometer_hardware: Path to the hardware magnetometer data.path_odo_hardware: Path to the hardware odometry data.path_gps_hardware: Path to the hardware GPS data.ahrs_alg: The estimator algorithm to use. Available options are:"fourati"(works the best for simulated UAV)"ekf"(works the best for real UAV)"madgwick"(kinda work for simulated UAV)"uav"(UAV board estimator is using GPS and IMU for best performance but isn't relevant due thesis criteria)"test"(placeholder for any custom algorithm)
plot_data: List of data types to plot (e.g., "gyro", "acc", "mag", etc.).
Below is an example configuration that you can modify according to your setup:
# Set the root directory of your project
root: "/home/vitek/test/pythonProject"
# ROS2 paths
ros2_paths:
imu: "/imu/imu_trajectory.csv"
gps: "/imu/gps_trajectory.csv"
# Simulation data paths
simulation_data_paths:
imu_sim: "/imu/sim/trajectory1/sensor_combined.csv"
odo_sim: "/imu/sim/trajectory1/odo.csv"
gps_sim: "/imu/sim/trajectory1/gps.csv"
# Hardware data paths
hardware_data_paths:
imu_hardware: "/imu/hardware/sensor_combined.csv"
magnetometer_hardware: "/imu/hardware/mag.csv"
odo_hardware: "/imu/hardware/odo.csv"
gps_hardware: "/imu/hardware/gps.csv"
# Estimator algorithm (options: "fourati", "ekf", "madgwick", "uav", "test")
#ahrs_alg: "ekf" # recommended for real UAV
ahrs_alg: "fourati" #recommended for simulated UAV
# Data to plot
plot_data:
# - "gyro"
# - "gyro_filter"
# - "acc"
# - "acc_filter"
# - "mag"
# - "mag_filter"
# - "local_acc"
# - "local_velocity"
# - "local_position"
- "trajectory"
- "trajectory_precision"
- "euler_angles"
-
IMU Data Publishing:
- Use
imu_pub.pyto publish IMU data to a ROS2 topic. - Use
gps_pub.pyto publish GPS data to a ROS2 topic.
- Use
-
Trajectory Estimation:
trajectory_estimator_hardware.pyuses real hardware data for estimation.trajectory_estimator_sim.pyuses simulated data for estimation.
This section provides instructions on how to visualize ROS2 nodes that publish messages of type nav_msgs/Path using RViz. The project includes two nodes: imu_pub.py and gps_pub.py.
-
Launch Your ROS2 Nodes
First, ensure your ROS2 nodes that publish
nav_msgs/Pathmessages are running. You can run them using the following commands:cd ros2_ws source ./install/setup.bash ros2 run trajectory_estimator imu_pub
cd ros2_ws source ./install/setup.bash ros2 run trajectory_estimator gps_pub
In the following image, we can see the accuracy of the estimation algorithms over time. The GPS offset is calculated as the Euclidean distance.

