.. _tutorial_uav_leader_follower: Leader Follower Mission for UAV Swarm =========================================== .. figure:: ../img/swarmuav_leaderfollower/swarm_sitl_3uav_leader_follower.png :height: 450 px :width: 750 px :scale: 100 % :align: center The leader-follower formulation is a commonly accepted research paradigm in multi-agent systems, wherein an agent is specified as the leader while others act as followers and keep a relative distance from their neighbourhood to realize a formation. In this tutorial, we will show readers an example to perform a leader-follower mission for UAV swarm. 1. Mission Description --------------------------------- With the leader-follower formulation, it's feasible to request a UAV swarm to achieve a flight mission by requesting the leader to fly to a desired position. The leader can accept commands from autonomous service calls or simply from manual control. The demonstration is constructed on the basis of a state machine, and the S_FORMATION_LEADER_FOLLOWER subtask enumeration represents the state that the UAV swarm is under the leader-follower maneuver. 2. How to Run ------------------- .. hint:: 📌 The DASA code base is under rapid development, so users are suggested to refer to the latest user manual delivered with our product. 2.1 SITL Simulation ^^^^^^^^^^^^^^^^^^^^^^^^ The SITL simulation can be carried out in the Gazebo engine based on the virtual environment (see :ref:`tutorial_swarm_sim`). We provide scripts to launch swarm simulation with 3 uavs in the directory ~/DASA_space/catkinws_swarmdemo/scripts. The SITL nodes have to be launched first with the Gazebo engine: :: cd ~/DASA_space/catkinws_swarmdemo/scripts/sitl bash start_sitl_nodes_3uavs.sh Users can only start other swarm nodes after the Gazebo interface is shown up, :: cd ~/DASA_space/catkinws_swarmdemo/scripts/sitl bash start_leaderfollower_mission_swarm_nodes_3uavs.sh Then the UAV swarm will start the mission automatically. Users can send requests to the leader by utilizing the RequestLeaderVehicleCmd service. The following commands will request the leader (uav1) to move to position [5.0, 5.0, 5.0]. :: cd ~/DASA_space/catkinws_swarmdemo/ source devel/setup.bash rosservice call /uav1/swarm_mission/request_leader_cmd "leader_behavior_id: 1 params:[5.0, 5.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]" 2.2 Flight Test ^^^^^^^^^^^^^^^^^^^^^^^^ The localization setup shall be finished prior to flight tests (see :ref:`tutorial_indoor_loco`:). Users can start the leader-follower mission nodes for 3 uavs with the scripts below after remotely logging into these vehicles: :: cd ~/DASA_space/catkinws_swarmdemo/scripts/test bash start_indoor_leaderfollower_mission_3uavs.sh The mission can then be launched by setting these vehicles in offboard and armed modes. 3. Video Demonstration -------------------------- The video demonstration for the SITL and flight tests is shown in: .. raw:: html