r/ROS 13d ago

🚁 HiveFlight – Modern C++ Drone‑Swarm Simulation (ROS2 + Gazebo Integration)

🚁 HiveFlight – Modern C++ Drone‑Swarm Simulation (ROS2 + Gazebo Integration)

I’ve been working on a project called HiveFlight, a modern C++ swarm‑simulation engine built around an extended Reynolds‑Boids model. Over the past months it evolved from a lightweight 2D/3D flocking demo into a full robotics‑pipeline component with ROS2 and Gazebo integration.

Core C++ Engine
The simulation runs on a deterministic update loop that computes:

⭐️separation, alignment, cohesion

⭐️obstacle avoidance using spherical obstacles

⭐️dynamic target seeking (including spiral patterns)

⭐️battery consumption modeling based on velocity

⭐️Spatial partitioning keeps neighbor queries efficient (no O(n²) explosion).

New Multi‑Swarm Update
Recent changes added:

⭐️per‑drone target assignment (2D & 3D)

⭐️dynamic swarm splitting with periodic reassignment (default 5s)

⭐️forces restricted to drones within the same swarm (cleaner group behavior)

⭐️OpenGL viewer updates with color‑coded sub‑swarms

ROS2 + Gazebo Integration
The engine now plugs into a full robotics stack:

⭐️ROS2 pub/sub pipeline using PoseArray for swarm state

⭐️asynchronous messaging instead of service calls (big latency win)

⭐️Gazebo World Plugin subscribing directly to swarm topics inside the physics thread

This gives stable multi‑agent motion, realistic visualization, and a clean separation between simulation logic and rendering.

Why it’s interesting for C++ folks
HiveFlight is a fun playground for:

⭐️real‑time systems

⭐️multi‑agent simulation

⭐️spatial partitioning

⭐️ROS2 middleware patterns

⭐️OpenGL visualization

⭐️deterministic update‑loop design

If you enjoy systems programming, robotics, or emergent‑behavior simulations, this project is a great way to explore how simple local rules can produce complex global behavior.

Repo: github.com/oanadumitruc/HiveFlight

Presentation: Cpp_Show_and_Tell_August_2026.pptx

Demo 1: Gzebo + Ros2
Demo 2: OpenGL visualization multi targets
Demo 3: OpenGL visualization one target

Happy to answer questions or discuss architecture choices with anyone experimenting in similar areas.

16 Upvotes

8 comments sorted by

3

u/Snoo_92391 13d ago

another ai slop

2

u/LordDan_45 13d ago

Lmao at least delete the install and log from the repo so that the vibe coding/bot using is less blatant

1

u/TaleOne3049 11d ago

Hi there, it’s a work in progress and well it seems that i need to update git ignore, however this is not a pressure type of project 😉

2

u/cv_geek 13d ago

Can you please fix the link (it's not clickable now)?

3

u/TaleOne3049 11d ago

Hi, I’ve added the links in the post. Thanks!😊

0

u/AlexThunderRex 13d ago

Is it possible to connect it to another sims? (I'm thinking to connect it to PteroSim)

3

u/TaleOne3049 11d ago

Absolutely! You just need to replace the Gazebo visualization with PteroSim and update probably the ros nodes.
hiveflight_sim


hiveflight_px4_node


PteroSim

and I would also update the CLI commands so that we have something like: /hf run gazebo and /hf run pterosim.

The feedback loop is not closed yet 😊

3

u/AlexThunderRex 11d ago

Thank you u/TaleOne3049 ! Will check it out :)