Swarm Drone applications with ROS

asked 2023-07-01 08:29:22 -0500

dogan gravatar image

Hello,

I am using ROS for swarm drone application. For the navigation, I am using iq_gnc. For the tests, I am using two drones. Although my scripts which include the tasks of the drones run perfectly on the Gazebo simulation, I have a trouble in real-world application. The both drones don't arm and take off at the same time. There is a time synchronization problem. For the communication I am using telemetries (RFD900). You can see the launch files and basic task script below. Can the problem related with ROS?

Launch file for the communication:

<launch>
  <group ns="drone1">
    <node name="mavros" pkg="mavros" type="mavros_node" output="screen" respawn="true" required="false" clear_params="true">
      <param name="fcu_url" value="/dev/ttyUSB0:57600" />
      <param name="gcs_url" value="" />
      <param name="system_id" value="1" />
      <param name="comp_id" value="1" />
      <param name="fcu_protocol" value="v2.0" />
      <rosparam command="load" file="$(find mavros)/launch/apm_pluginlists.yaml" />
      <rosparam command="load" file="$(find mavros)/launch/apm_config.yaml" />
    </node>
  </group>

  <group ns="drone2">
    <node name="mavros" pkg="mavros" type="mavros_node" output="screen" respawn="true" required="false" clear_params="true">
      <param name="fcu_url" value="/dev/ttyUSB1:57600" />
      <param name="gcs_url" value="" />
      <param name="system_id" value="2" />
      <param name="comp_id" value="1" />
      <param name="fcu_protocol" value="v2.0" />
      <rosparam command="load" file="$(find mavros)/launch/apm_pluginlists.yaml" />
      <rosparam command="load" file="$(find mavros)/launch/apm_config.yaml" />
    </node>
  </group>
</launch>

Launch file for sending the task:

<launch>
    <group>
        <node pkg="iq_gnc" type="oda" name="drone1" output="screen" ns="/drone1">
            <param name="namespace" value="/drone1"/>
            <param name="use_sim_time"  value="true" />
        </node>
    </group>
    <group>

        <node pkg="iq_gnc" type="oda" name="drone2" output="screen" ns="/drone2">
            <param name="namespace" value="/drone2"/>
            <param name="use_sim_time"  value="true" />
        </node>
    </group>
</launch>

The task file (.cpp):

#include <gnc_functions.hpp>
//include API

int main(int argc, char** argv)
{
    //initialize ros
    ros::init(argc, argv, "gnc_node");
    ros::NodeHandle gnc_node("~");
    std::string skyart_id;

    //initialize control publisher/subscribers
    init_publisher_subscriber(gnc_node);

    // wait for FCU connection
    wait4connect();

    set_mode("STABILIZE");
    skyart_id = name_finder(gnc_node);
    //create local reference frame
    initialize_local_frame();
    sleep(25);

    arm();
    sleep(15);

    //ros::Rate rate(1.0);

    return 0;
}
edit retag flag offensive close merge delete