A ROS 2 autonomous drone mission package built with YASMIN state machines and Nectar SDK for drone control.
The drone initializes, takes off, navigates to a starting position, flies a square path, returns to launch, and lands — all orchestrated through a finite state machine.
INITIALIZE ──succeed──▶ TAKEOFF ──succeed──▶ GOTOFST ──succeed──▶ DOSQUARE
│ │ │ │
abort abort abort abort
│ │ │ │
▼ ▼ ▼ ▼
END RETURN_TO_LAUNCH ◀──────────┴────────────────────┘
│
succeed
│
▼
END ──succeed──▶ (done)
| State | Description |
|---|---|
| INITIALIZE | Creates the drone instance via DroneFactory using MAVROS |
| TAKEOFF | Arms, sets home, and takes off to the configured altitude |
| GOTOFST | Navigates to the initial position (INITPOSX, INITPOSY) |
| DOSQUARE | Flies a square path with side length LINESIZE using relative moves |
| RETURN_TO_LAUNCH | Returns to the launch position at RTL_ALTITUDE |
| END | Lands the drone and finishes the mission |
- ROS 2 (Humble / Jazzy)
- YASMIN — state machine framework
- Nectar SDK — drone control abstraction over MAVROS
Clone into your ROS 2 workspace:
cd ~/ros2_ws/src
git clone https://github.com/your-user/nectarefa.git
git clone https://github.com/uleroboticsgroup/yasmin.git
# Also clone nectar-sdk if not already presentBuild:
cd ~/ros2_ws
colcon build --packages-select nectarefa --symlink-install
source install/setup.bashros2 run nectarefa mangalargaros2 run nectarefa mangalarga --initposx 1.0 --initposy -1.0 --linesize 3.0Set the NECTAREFA_SIM environment variable before launching:
NECTAREFA_SIM=1 ros2 run nectarefa mangalarga| Argument | Type | Default | Description |
|---|---|---|---|
--initposx |
float |
0.5 |
Initial X position for the square path |
--initposy |
float |
-0.5 |
Initial Y position for the square path |
--linesize |
float |
1.5 |
Side length of the square (meters) |
nectarefa/
├── package.xml
├── setup.py
├── setup.cfg
└── nectarefa/
├── __init__.py
├── mangalarga.py # Main entry point & state machine definition
├── constants.py # Mission parameters & CLI argument parsing
└── states/
├── __init__.py
├── basicstates.py # Initialize, Takeoff, ReturnToLaunch, End
└── navigation.py # GoToFst, DoSquare
Licensed under the Apache License 2.0.
Arthur Xavier — arthuraxribeiro@gmail.com