Skip to content

It is a light-weight swarm algorithm implementation in C++.

License

Notifications You must be signed in to change notification settings

vaydingul/SwarmAlgorithm

Repository files navigation

Swarm Algorithm

This is a very basic approach to Swarm Algorithm. There are two main classes in this project, namely, Drone and Sim.

Drone

It is the main class that is responsible for the motion propagation of the Drone entity. It governs all the equations of motion in 2D space. There are several defined Force Models in the project, which can be exemplified as:

  • Drag force
  • Proximity Caution force
  • External force
  • Target Chase force

Drag Force

It is the 2D representation of the aerodynamic drag force, which can be formulated as the following:

Proximity Caution Force

It is a basic model to provide a collision prevention system to the drones. The basic mathematical model that hands out this ability can be observed below:

In this formulation, symbolizes a distance vector composed between two drones, and represents the unit vector in this direction. While represents a scalar coeffienct whose optimal value can be found via fine-tuning, represents the threshold distance in which the force model will work. If the current distance between two drone is greater than , then the , in opposite situation, will read as the above equation.

External Force

It is a user-specified external force model that one can add any force which is desired. It is not a derivation or result of any force model that is implemented here.

Target Chase Force

It is a force model that represents the situation where there is a target which the subject drone should be followed/aimed. It is contructed by consering a simple spring-mass-damper system. Therefore, it can be formulated as the following:

where k and d represent the spring and damping coefficient, respectively.

Sim

It is the main class which is responsible for the general management of the simulation. It can handle the initial drone orientation, and the propagation of the whole simulation.


To be able to visualize the simulation, there is attached MATLAB script, called plotDrones.m

Basic Execution

To be able to execute a simulation, the SimMain.cpp file can be used. After the execution of that file, the results can be visualized in MATLAB.

SimMain.cpp file contains a link for the deleteCsv.py file, which removes the previously created .csv files from the workspace. Ona can easily comment out the related line to prevent the usage of Python programming language.

Also, one can make use of the other visualization tools rather than MATLAB, by simply using the .csv files from the constructed drones folder.

TODO:

  • More generic Sim construction (Very simple)
  • 3D implementation (Might be challenging)
  • Addition of environment and mass-fuel models (Challenging)
  • Parameterization of the force models to prevent the addition of the model-specific parameters to the Drone class variables.

Final Words

It is a very incomplete project, therefore, all contributions and pull requests are welcome. Please do not hesitate to open an issue to clear out bugs and provide performance boosts.

About

It is a light-weight swarm algorithm implementation in C++.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published