I have multiple drones work in swarm formation, i made the quadcopter model and the swarm one. Until now i have the swarm moving in a formation leader-follower and track a predefined trajectory based on PID Controller. What i need help is how to add GPS, IMU sensors model to my model?

  • $\begingroup$ Did you look at PX4 or Ardupilot frameworks ? $\endgroup$
    – McLovin
    Oct 17, 2022 at 16:41
  • $\begingroup$ Can you describe what you are doing / trying to do in more detail? This is a fairly broad ask... You want a simulated GPS and IMU? $\endgroup$
    – Ben
    Oct 17, 2022 at 18:38
  • $\begingroup$ I have multiple drones ,swarm of drones lets us say 5,one leader and 4 follower. i made the simulation in Matlab, for now the swarm follow a pre-defined path , what i want to do is how can add gps and imu to my simulation? how can put then into my design, i know it maybe be done by Kalman filter, but i need some ideas of the schematic or flow diagram? $\endgroup$ Oct 18, 2022 at 19:46
  • $\begingroup$ @jackabraham: On stack exchange, it is better to edit your question to add information requested in comments, rather than adding more comments. Comments are for helping to improve questions and answers, and are distracting, so we try to keep them to a minimum. If all of the information needed to answer the question is contained within it, the comments can be tidied up (deleted). $\endgroup$
    – Ben
    Oct 19, 2022 at 13:21

2 Answers 2


It depends on what you are trying to achieve.

If you want to see how your path following / formation tracking etc. works under non-ideal conditions, then you can simply give it a position that is slightly wrong. Perhaps some kind of Gaussian around the actual location. It is kind of pointless to be in a simulation environment with perfect localization, then simulate multiple noisy sensors, then use a complicated algorithm to fuse the sensors to try to get back out good localization. Why not just simulate the output of all that mess? i.e. "good" not "perfect" localization.

To reiterate, it is totally reasonable to not want to use perfect localization in your simulator. But there are easier ways to go about it.

If you want to make your simulation more closely match your real hardware, I would highly recommend looking at the noise, error, and other characteristics of your actual sensors, then adding those to the simulator. Every sensor, platform, and application is slightly different, so it will be difficult for anyone else to provide this data for you.

But in general, from what I've seen, GPS usually has some constant offset from the actual position, then in a little while, it will jump to some other offset. Acclerometers usually have a scale error, or axis misalignment. And gyros have drift.

If you want to test out your kalman filter or whatever sensor fusion algorithm you have, then that is probably better served in a different question.


I don't know Matlab, but if you are trying to simulate GPS data you might get some inspiration from Gazebo. It lets you simulate GPS data with varying degrees of accuracy. The plugin definition might look like this:

    <plugin name="rtk_gps_plugin" filename="libhector_gazebo_ros_gps.so">
        <updateRate>10.0</updateRate> <!-- Higher update rate for precision -->
        <noiseStdDev>0.05</noiseStdDev> <!-- About 2 inches of noise -->

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.