Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi drones flight #27

Closed
golden-memory opened this issue Aug 4, 2020 · 10 comments
Closed

Multi drones flight #27

golden-memory opened this issue Aug 4, 2020 · 10 comments
Assignees
Labels
type: question Further information is requested

Comments

@golden-memory
Copy link

golden-memory commented Aug 4, 2020

I want to make multiple drones fly, but i don't know how to do it!
I run the command in a terminal as following
roslaunch bebop_simulator fly1.launch
13

fly1.launch

<?xml version="1.0"?>

<launch>
    <arg name="name" default="bebop"/>
    <arg name="plotName" default="bebopPlots"/>
    <arg name="use_sim_time" default="true"/>
    <arg name="world_name" default="test_city"/>
    <arg name="wind_force" default="0.25"/>
    <arg name="wind_start" default="5.0"/>
    <arg name="wind_duration" default="40.0"/>
    <arg name="wind_direction_x" default="1.0"/>
    <arg name="wind_direction_y" default="0.0"/>
    <arg name="wind_direction_z" default="0.0"/>
    <arg name="csvFilesStoring" default="false"/>
    <arg name="csvFilesStoringTime" default="60.0"/>
    <arg name="user_account" default="giuseppe"/> 
    <arg name="waypoint_filter" default="true"/>
    <arg name="EKFActive" default="false"/>
    <arg name="enable_odometry_sensor_with_noise" default="false"/>
    <arg name="disable_odometry_sensor_with_noise" default="true"/>
    <arg name="enable_ground_truth_sensor" default="false"/>
    <arg name="enable_wind_plugin" default="false"/>
    <arg name="enable_laser1D" default="false"/>
    <arg name="enable_plots" default="false"/>
    <arg name="enable_imu" default="true"/>

    
  <env name="GAZEBO_MODEL_PATH" value="${GAZEBO_MODEL_PATH}:$(find bebop_simulator)/models"/>
  <env name="GAZEBO_RESOURCE_PATH" value="${GAZEBO_RESOURCE_PATH}:$(find bebop_simulator)/models"/>
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find bebop_simulator)/worlds/$(arg world_name).world" />
  </include>

    <group ns="firefly">
        <include file="$(find bebop_simulator)/launch/spawn_bebop.launch">
           <arg name="name" value="$(arg name)" />
           <arg name="x" value="0.0"/>
           <arg name="y" value="0.0"/>
           <arg name="z" value="0.5"/>
           <arg name="wind_force" value="$(arg wind_force)"/>
           <arg name="wind_start" value="$(arg wind_start)"/>
           <arg name="wind_duration" value="$(arg wind_duration)"/>
           <arg name="wind_direction_x" value="$(arg wind_direction_x)"/>
           <arg name="wind_direction_y" value="$(arg wind_direction_y)"/>
           <arg name="wind_direction_z" value="$(arg wind_direction_z)"/>
           <arg name="enable_odometry_sensor_with_noise" value="$(arg enable_odometry_sensor_with_noise)"/>
           <param name="disable_odometry_sensor_with_noise" value="false" unless="$(arg enable_odometry_sensor_with_noise)" />
           <arg name="disable_odometry_sensor_with_noise" value="$(arg disable_odometry_sensor_with_noise)"/>
           <arg name="enable_ground_truth_sensor" value="$(arg enable_ground_truth_sensor)"/>
           <arg name="enable_wind_plugin" value="$(arg enable_wind_plugin)"/>
           <arg name="enable_imu" value="$(arg enable_imu)"/>
           <arg name="enable_laser1D" value="$(arg enable_laser1D)"/>
        </include>

        <node name="position_controller_node" pkg="bebop_simulator" type="position_controller_node" output="screen"> 
          <rosparam command="load" file="$(find bebop_simulator)/resource/controller_bebop.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/bebop.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/EKF_matrix.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/waypoint_filter.yaml" />
      	  <param name="use_sim_time" value="$(arg use_sim_time)" />
          <param name="csvFilesStoring" value="$(arg csvFilesStoring)"/>
          <param name="csvFilesStoringTime" value="$(arg csvFilesStoringTime)"/>
          <param name="user_account" value="$(arg user_account)"/>
          <param name="waypoint_filter" value="$(arg waypoint_filter)"/>
          <param name="EKFActive" value="$(arg EKFActive)"/>
          <remap from="/command/motor_speed" to="/gazebo/command/motor_speed" />
          <remap from="/odometry" to="/bebop/odometry" />
          <remap from="/odometry_gt" to="/bebop/odometry_gt" />
          <remap from="/filteredOutput" to="/bebop/filteredOutput" />
          <remap from="/referenceAngles" to="/bebop/referenceAngles" />
          <remap from="/stateErrors" to="/bebop/stateErrors" />
          <remap from="/smoothedTrajectory" to="/bebop/smoothedTrajectory" />
          <remap from="/command/trajectory" to="/bebop/command/trajectory" />
          <remap from="/uTerrComponents" to="/bebop/uTerrComponents" />
          <remap from="/zVelocityComponents" to="/bebop/zVelocityComponents" />
          <remap from="/positionAndVelocityErrors" to="/bebop/positionAndVelocityErrors" />
          <remap from="/angularAndAngularVelocityErrors" to="/bebop/angularAndAngularVelocityErrors" />
        </node>  

    </group>

    <group ns="hummingbird">
        <include file="$(find bebop_simulator)/launch/spawn_bebop.launch">
           <arg name="name" value="$(arg name)" />
           <arg name="x" value="0.0"/>
           <arg name="y" value="1.0"/>
           <arg name="z" value="0.5"/>
           <arg name="wind_force" value="$(arg wind_force)"/>
           <arg name="wind_start" value="$(arg wind_start)"/>
           <arg name="wind_duration" value="$(arg wind_duration)"/>
           <arg name="wind_direction_x" value="$(arg wind_direction_x)"/>
           <arg name="wind_direction_y" value="$(arg wind_direction_y)"/>
           <arg name="wind_direction_z" value="$(arg wind_direction_z)"/>
           <arg name="enable_odometry_sensor_with_noise" value="$(arg enable_odometry_sensor_with_noise)"/>
           <param name="disable_odometry_sensor_with_noise" value="false" unless="$(arg enable_odometry_sensor_with_noise)" />
           <arg name="disable_odometry_sensor_with_noise" value="$(arg disable_odometry_sensor_with_noise)"/>
           <arg name="enable_ground_truth_sensor" value="$(arg enable_ground_truth_sensor)"/>
           <arg name="enable_wind_plugin" value="$(arg enable_wind_plugin)"/>
           <arg name="enable_imu" value="$(arg enable_imu)"/>
           <arg name="enable_laser1D" value="$(arg enable_laser1D)"/>
        </include>

        <node name="position_controller_node" pkg="bebop_simulator" type="position_controller_node" output="screen"> 
          <rosparam command="load" file="$(find bebop_simulator)/resource/controller_bebop.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/bebop.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/EKF_matrix.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/waypoint_filter.yaml" />
      	  <param name="use_sim_time" value="$(arg use_sim_time)" />
          <param name="csvFilesStoring" value="$(arg csvFilesStoring)"/>
          <param name="csvFilesStoringTime" value="$(arg csvFilesStoringTime)"/>
          <param name="user_account" value="$(arg user_account)"/>
          <param name="waypoint_filter" value="$(arg waypoint_filter)"/>
          <param name="EKFActive" value="$(arg EKFActive)"/>
          <remap from="/command/motor_speed" to="/gazebo/command/motor_speed" />
          <remap from="/odometry" to="/bebop/odometry" />
          <remap from="/odometry_gt" to="/bebop/odometry_gt" />
          <remap from="/filteredOutput" to="/bebop/filteredOutput" />
          <remap from="/referenceAngles" to="/bebop/referenceAngles" />
          <remap from="/stateErrors" to="/bebop/stateErrors" />
          <remap from="/smoothedTrajectory" to="/bebop/smoothedTrajectory" />
          <remap from="/command/trajectory" to="/bebop/command/trajectory" />
          <remap from="/uTerrComponents" to="/bebop/uTerrComponents" />
          <remap from="/zVelocityComponents" to="/bebop/zVelocityComponents" />
          <remap from="/positionAndVelocityErrors" to="/bebop/positionAndVelocityErrors" />
          <remap from="/angularAndAngularVelocityErrors" to="/bebop/angularAndAngularVelocityErrors" />
        </node>
    </group>

    <!-- Launch the trajectory generator -->
   <group ns="$(arg name)">
       <node name="waypoint_example" pkg="bebop_simulator" type="waypoint_example" output="screen" args="$(find bebop_simulator)/resource/waypoints.txt"/>   
    </group>

</launch>
@gsilano gsilano self-assigned this Aug 4, 2020
@gsilano gsilano added the type: question Further information is requested label Aug 4, 2020
@gsilano
Copy link
Owner

gsilano commented Aug 4, 2020

Please, follow this issue: gsilano/CrazyS#44 Although it refers to CrazyS (another work of mine), the procedure should be exactly the same.

@golden-memory golden-memory changed the title Multi drone flight Multi drones flight Aug 5, 2020
@golden-memory
Copy link
Author

golden-memory commented Aug 5, 2020

Please, this issue: gsilano/CrazyS#44 Although it refers to CrazyS (another work of mine), the procedure should be exactly the same.

Thanks for your response. Now, I know that the problem may be related to the namespace. But I don't know how to modify it, I would be very appreciate it if you can give me some guidance?
The original launch file and rqt_graph are here:

<?xml version="1.0"?>

<launch>
    <arg name="name" default="bebop"/>
    <arg name="plotName" default="bebopPlots"/>
    <arg name="world_name" default="test_city"/>
  <env name="GAZEBO_MODEL_PATH" value="${GAZEBO_MODEL_PATH}:$(find bebop_simulator)/models"/>
  <env name="GAZEBO_RESOURCE_PATH" value="${GAZEBO_RESOURCE_PATH}:$(find bebop_simulator)/models"/>
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find bebop_simulator)/worlds/$(arg world_name).world" />
  </include>

    <include file="$(find bebop_simulator)/launch/spawn_bebop.launch">
       <arg name="name" value="$(arg name)" />
       <arg name="x" value="0.0"/>
       <arg name="y" value="0.0"/>
       <arg name="z" value="0.3"/>
       <arg name="wind_force" value="0.0"/>
       <arg name="wind_start" value="0.0"/>
       <arg name="wind_duration" value="40.0"/>
       <arg name="wind_direction_x" value="0.0"/>
       <arg name="wind_direction_y" value="0.0"/>
       <arg name="wind_direction_z" value="0.0"/>
       <arg name="enable_odometry_sensor_with_noise" value="false"/>
       <arg name="disable_odometry_sensor_with_noise" value="true"/>
       <arg name="enable_ground_truth_sensor" value="false"/>
       <arg name="enable_wind_plugin" value="false"/>
       <arg name="enable_imu" value="true"/>
       <arg name="enable_laser1D" value="false"/>
    </include>

    <node name="position_controller_node" pkg="bebop_simulator" type="position_controller_node" output="screen"> 
      <rosparam command="load" file="$(find bebop_simulator)/resource/controller_bebop.yaml" />
      <rosparam command="load" file="$(find bebop_simulator)/resource/bebop.yaml" />
      <rosparam command="load" file="$(find bebop_simulator)/resource/EKF_matrix.yaml" />
      <rosparam command="load" file="$(find bebop_simulator)/resource/waypoint_filter.yaml" />
      <param name="use_sim_time" value="true" />
      <param name="csvFilesStoring" value="false"/>
      <param name="csvFilesStoringTime" value="60.0"/>
      <param name="user_account" value="giuseppe"/>
      <param name="waypoint_filter" value="true"/>
      <param name="EKFActive" value="false"/>
      <remap from="/command/motor_speed" to="/gazebo/command/motor_speed" />
      <remap from="/odometry" to="/bebop/odometry" />
      <remap from="/odometry_gt" to="/bebop/odometry_gt" />
      <remap from="/filteredOutput" to="/bebop/filteredOutput" />
      <remap from="/referenceAngles" to="/bebop/referenceAngles" />
      <remap from="/stateErrors" to="/bebop/stateErrors" />
      <remap from="/smoothedTrajectory" to="/bebop/smoothedTrajectory" />
      <remap from="/command/trajectory" to="/bebop/command/trajectory" />
      <remap from="/uTerrComponents" to="/bebop/uTerrComponents" />
      <remap from="/zVelocityComponents" to="/bebop/zVelocityComponents" />
      <remap from="/positionAndVelocityErrors" to="/bebop/positionAndVelocityErrors" />
      <remap from="/angularAndAngularVelocityErrors" to="/bebop/angularAndAngularVelocityErrors" />
    </node>

    <!-- Launch the trajectory generator -->
   <group ns="$(arg name)">
       <node name="waypoint_example" pkg="bebop_simulator" type="waypoint_example" output="screen" args="$(find bebop_simulator)/resource/waypoints.txt"/>   
    </group>

</launch>

rosgraph2

I made the first improvement by adding several namespaces:

<?xml version="1.0"?>

<launch>
    <arg name="name" default="bebop"/>
    <arg name="plotName" default="bebopPlots"/>
    <arg name="world_name" default="test_city"/>
  <env name="GAZEBO_MODEL_PATH" value="${GAZEBO_MODEL_PATH}:$(find bebop_simulator)/models"/>
  <env name="GAZEBO_RESOURCE_PATH" value="${GAZEBO_RESOURCE_PATH}:$(find bebop_simulator)/models"/>
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find bebop_simulator)/worlds/$(arg world_name).world" />
  </include>

    <!-- add the namespace -->
    <group ns="$(arg name)1">
        <include file="$(find bebop_simulator)/launch/spawn_bebop.launch">
           <arg name="name" value="$(arg name)" />
           <arg name="x" value="0.0"/>
           <arg name="y" value="0.0"/>
           <arg name="z" value="0.3"/>
           <arg name="wind_force" value="0.0"/>
           <arg name="wind_start" value="0.0"/>
           <arg name="wind_duration" value="40.0"/>
           <arg name="wind_direction_x" value="0.0"/>
           <arg name="wind_direction_y" value="0.0"/>
           <arg name="wind_direction_z" value="0.0"/>
           <arg name="enable_odometry_sensor_with_noise" value="false"/>
           <arg name="disable_odometry_sensor_with_noise" value="true"/>
           <arg name="enable_ground_truth_sensor" value="false"/>
           <arg name="enable_wind_plugin" value="false"/>
           <arg name="enable_imu" value="true"/>
           <arg name="enable_laser1D" value="false"/>
        </include>
     </group>

    <!-- add the namespace -->
    <group ns="$(arg name)">
        <node name="position_controller_node" pkg="bebop_simulator" type="position_controller_node" output="screen"> 
          <rosparam command="load" file="$(find bebop_simulator)/resource/controller_bebop.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/bebop.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/EKF_matrix.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/waypoint_filter.yaml" />
          <param name="use_sim_time" value="true" />
          <param name="csvFilesStoring" value="false"/>
          <param name="csvFilesStoringTime" value="60.0"/>
          <param name="user_account" value="giuseppe"/>
          <param name="waypoint_filter" value="true"/>
          <param name="EKFActive" value="false"/>
          <remap from="/command/motor_speed" to="/gazebo/command/motor_speed"/>
          <remap from="/odometry" to="/bebop/odometry" />
          <remap from="/odometry_gt" to="/bebop/odometry_gt" />
          <remap from="/filteredOutput" to="/bebop/filteredOutput" />
          <remap from="/referenceAngles" to="/bebop/referenceAngles" />
          <remap from="/stateErrors" to="/bebop/stateErrors" />
          <remap from="/smoothedTrajectory" to="/bebop/smoothedTrajectory" />
          <remap from="/command/trajectory" to="/bebop/command/trajectory" />
          <remap from="/uTerrComponents" to="/bebop/uTerrComponents" />
          <remap from="/zVelocityComponents" to="/bebop/zVelocityComponents"/>
          <remap from="/positionAndVelocityErrors" to="/bebop/positionAndVelocityErrors" />
          <remap from="/angularAndAngularVelocityErrors" to="/bebop/angularAndAngularVelocityErrors" />
        </node>
     </group>

    <!-- Launch the trajectory generator -->
   <group ns="$(arg name)">
       <node name="waypoint_example" pkg="bebop_simulator" type="waypoint_example" output="screen" args="$(find bebop_simulator)/resource/waypoints.txt"/>   
     </group>

</launch>

rosgraph3

I made the second improvement:

<?xml version="1.0"?>

<launch>
    <arg name="name" default="bebop"/>
    <arg name="plotName" default="bebopPlots"/>
    <arg name="world_name" default="test_city"/>
  <env name="GAZEBO_MODEL_PATH" value="${GAZEBO_MODEL_PATH}:$(find bebop_simulator)/models"/>
  <env name="GAZEBO_RESOURCE_PATH" value="${GAZEBO_RESOURCE_PATH}:$(find bebop_simulator)/models"/>
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find bebop_simulator)/worlds/$(arg world_name).world" />
  </include>

    <!-- add the namespace -->
    <group ns="$(arg name)1">
        <include file="$(find bebop_simulator)/launch/spawn_bebop.launch">
           <arg name="name" value="$(arg name)" />
           <arg name="x" value="0.0"/>
           <arg name="y" value="0.0"/>
           <arg name="z" value="0.3"/>
           <arg name="wind_force" value="0.0"/>
           <arg name="wind_start" value="0.0"/>
           <arg name="wind_duration" value="40.0"/>
           <arg name="wind_direction_x" value="0.0"/>
           <arg name="wind_direction_y" value="0.0"/>
           <arg name="wind_direction_z" value="0.0"/>
           <arg name="enable_odometry_sensor_with_noise" value="false"/>
           <arg name="disable_odometry_sensor_with_noise" value="true"/>
           <arg name="enable_ground_truth_sensor" value="false"/>
           <arg name="enable_wind_plugin" value="false"/>
           <arg name="enable_imu" value="true"/>
           <arg name="enable_laser1D" value="false"/>
        </include>

        <node name="position_controller_node" pkg="bebop_simulator" type="position_controller_node" output="screen"> 
          <rosparam command="load" file="$(find bebop_simulator)/resource/controller_bebop.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/bebop.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/EKF_matrix.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/waypoint_filter.yaml" />
          <param name="use_sim_time" value="true" />
          <param name="csvFilesStoring" value="false"/>
          <param name="csvFilesStoringTime" value="60.0"/>
          <param name="user_account" value="giuseppe"/>
          <param name="waypoint_filter" value="true"/>
          <param name="EKFActive" value="false"/>
          <remap from="/command/motor_speed" to="/gazebo/command/motor_speed"/>
          <remap from="/odometry" to="/bebop/odometry" />
          <remap from="/odometry_gt" to="/bebop/odometry_gt" />
          <remap from="/filteredOutput" to="/bebop/filteredOutput" />
          <remap from="/referenceAngles" to="/bebop/referenceAngles" />
          <remap from="/stateErrors" to="/bebop/stateErrors" />
          <remap from="/smoothedTrajectory" to="/bebop/smoothedTrajectory" />
          <remap from="/command/trajectory" to="/bebop/command/trajectory" />
          <remap from="/uTerrComponents" to="/bebop/uTerrComponents" />
          <remap from="/zVelocityComponents" to="/bebop/zVelocityComponents"/>
          <remap from="/positionAndVelocityErrors" to="/bebop/positionAndVelocityErrors" />
          <remap from="/angularAndAngularVelocityErrors" to="/bebop/angularAndAngularVelocityErrors" />
        </node>
     </group>

    <!-- Launch the trajectory generator -->
   <group ns="$(arg name)1">
       <node name="waypoint_example" pkg="bebop_simulator" type="waypoint_example" output="screen" args="$(find bebop_simulator)/resource/waypoints.txt"/>   
     </group>

</launch>

rosgraph4

The third improvement are here:

<?xml version="1.0"?>

<launch>
    <arg name="name" default="bebop"/>
    <arg name="plotName" default="bebopPlots"/>
    <arg name="world_name" default="test_city"/>
  <env name="GAZEBO_MODEL_PATH" value="${GAZEBO_MODEL_PATH}:$(find bebop_simulator)/models"/>
  <env name="GAZEBO_RESOURCE_PATH" value="${GAZEBO_RESOURCE_PATH}:$(find bebop_simulator)/models"/>
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find bebop_simulator)/worlds/$(arg world_name).world" />
  </include>

    <!-- add the namespace -->
    <group ns="$(arg name)1">
        <include file="$(find bebop_simulator)/launch/spawn_bebop.launch">
           <arg name="name" value="$(arg name)" />
           <arg name="x" value="0.0"/>
           <arg name="y" value="0.0"/>
           <arg name="z" value="0.3"/>
           <arg name="wind_force" value="0.0"/>
           <arg name="wind_start" value="0.0"/>
           <arg name="wind_duration" value="40.0"/>
           <arg name="wind_direction_x" value="0.0"/>
           <arg name="wind_direction_y" value="0.0"/>
           <arg name="wind_direction_z" value="0.0"/>
           <arg name="enable_odometry_sensor_with_noise" value="false"/>
           <arg name="disable_odometry_sensor_with_noise" value="true"/>
           <arg name="enable_ground_truth_sensor" value="false"/>
           <arg name="enable_wind_plugin" value="false"/>
           <arg name="enable_imu" value="true"/>
           <arg name="enable_laser1D" value="false"/>
        </include>
     </group>

    <!-- add the namespace -->
    <group ns="$(arg name)">
        <node name="position_controller_node" pkg="bebop_simulator" type="position_controller_node" output="screen"> 
          <rosparam command="load" file="$(find bebop_simulator)/resource/controller_bebop.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/bebop.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/EKF_matrix.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/waypoint_filter.yaml" />
          <param name="use_sim_time" value="true" />
          <param name="csvFilesStoring" value="false"/>
          <param name="csvFilesStoringTime" value="60.0"/>
          <param name="user_account" value="giuseppe"/>
          <param name="waypoint_filter" value="true"/>
          <param name="EKFActive" value="false"/>
          <remap from="/command/motor_speed" to="/gazebo/command/motor_speed"/>
          <remap from="/odometry" to="/bebop/odometry" />
          <remap from="/odometry_gt" to="/bebop/odometry_gt" />
          <remap from="/filteredOutput" to="/bebop/filteredOutput" />
          <remap from="/referenceAngles" to="/bebop/referenceAngles" />
          <remap from="/stateErrors" to="/bebop/stateErrors" />
          <remap from="/smoothedTrajectory" to="/bebop/smoothedTrajectory" />
          <remap from="/command/trajectory" to="/bebop/command/trajectory" />
          <remap from="/uTerrComponents" to="/bebop/uTerrComponents" />
          <remap from="/zVelocityComponents" to="/bebop/zVelocityComponents"/>
          <remap from="/positionAndVelocityErrors" to="/bebop/positionAndVelocityErrors" />
          <remap from="/angularAndAngularVelocityErrors" to="/bebop/angularAndAngularVelocityErrors" />
        </node>
     </group>

    <!-- change the namespace -->
   <group ns="$(arg name)1">
       <node name="waypoint_example" pkg="bebop_simulator" type="waypoint_example" output="screen" args="$(find bebop_simulator)/resource/waypoints.txt"/>   
     </group>

</launch>

rosgraph5

@gsilano
Copy link
Owner

gsilano commented Aug 5, 2020

I suggest you start from this file, and then take a look at all the related file (e.g., the spawn_mav_crazyfle). I hope this helps.

@golden-memory
Copy link
Author

golden-memory commented Aug 10, 2020

I suggest you start from this file, and then take a look at all the related file (e.g., the spawn_mav_crazyfle). I hope this helps.

I'm so sorry to disturb you again. But now, I have no idea about the problem. My recent study status is as follows:

Firstly, The biggest problem I have encountered is that gazebo node and position_controller_node node cannot communicate.
The correct graph should be:
rosgraph2
But my graph is:
rosgraph1

Secondly, I tried to make some modifications, but it still doesn't work.
The file I modified is spawn_bebop.launch. On line 34, I change namespace:=$(arg name) to amespace:='$(arg name)_1' where the first drone is located. Unfortunately it reported an error:
a1

At last, Related launch files are as follows:
fly6.launch

<?xml version="1.0"?>

<launch>
    <arg name="name" default="bebop"/>
    <arg name="plotName" default="bebopPlots"/>
    <arg name="world_name" default="test_city"/>
  <env name="GAZEBO_MODEL_PATH" value="${GAZEBO_MODEL_PATH}:$(find bebop_simulator)/models"/>
  <env name="GAZEBO_RESOURCE_PATH" value="${GAZEBO_RESOURCE_PATH}:$(find bebop_simulator)/models"/>
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find bebop_simulator)/worlds/$(arg world_name).world" />
  </include>

    <!-- add the namespace -->
    <group ns="$(arg name)_1">
        <include file="$(find bebop_simulator)/launch/spawn_bebop.launch">
           <arg name="name" value="$(arg name)"/>
           <arg name="x" value="0.0"/>
           <arg name="y" value="0.0"/>
           <arg name="z" value="0.3"/>
           <arg name="wind_force" value="0.0"/>
           <arg name="wind_start" value="0.0"/>
           <arg name="wind_duration" value="40.0"/>
           <arg name="wind_direction_x" value="0.0"/>
           <arg name="wind_direction_y" value="0.0"/>
           <arg name="wind_direction_z" value="0.0"/>
           <arg name="enable_odometry_sensor_with_noise" value="false"/>
           <arg name="disable_odometry_sensor_with_noise" value="true"/>
           <arg name="enable_ground_truth_sensor" value="false"/>
           <arg name="enable_wind_plugin" value="false"/>
           <arg name="enable_imu" value="true"/>
           <arg name="enable_laser1D" value="false"/>
        </include>

        <node name="position_controller_node" pkg="bebop_simulator" type="position_controller_node" output="screen"> 
          <rosparam command="load" file="$(find bebop_simulator)/resource/controller_bebop.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/bebop.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/EKF_matrix.yaml" />
          <rosparam command="load" file="$(find bebop_simulator)/resource/waypoint_filter.yaml" />
          <param name="use_sim_time" value="true" />
          <param name="csvFilesStoring" value="false"/>
          <param name="csvFilesStoringTime" value="60.0"/>
          <param name="user_account" value="giuseppe"/>
          <param name="waypoint_filter" value="true"/>
          <param name="EKFActive" value="false"/>
          <remap from="/command/motor_speed" to="/gazebo/command/motor_speed"/>
          <remap from="/odometry" to="/bebop/odometry" />
          <remap from="/odometry_gt" to="/bebop/odometry_gt" />
          <remap from="/filteredOutput" to="/bebop/filteredOutput" />
          <remap from="/referenceAngles" to="/bebop/referenceAngles" />
          <remap from="/stateErrors" to="/bebop/stateErrors" />
          <remap from="/smoothedTrajectory" to="/bebop/smoothedTrajectory" />
          <remap from="/command/trajectory" to="/bebop/command/trajectory" />
          <remap from="/uTerrComponents" to="/bebop/uTerrComponents" />
          <remap from="/zVelocityComponents" to="/bebop/zVelocityComponents"/>
          <remap from="/positionAndVelocityErrors" to="/bebop/positionAndVelocityErrors" />
          <remap from="/angularAndAngularVelocityErrors" to="/bebop/angularAndAngularVelocityErrors" />
        </node>

       <node name="waypoint_example" pkg="bebop_simulator" type="waypoint_example" output="screen" args="$(find bebop_simulator)/resource/waypoints.txt"/> 
     </group>

</launch>

spawn_bebop.launch

<?xml version="1.0"?>

<launch>
  <arg name="name" default="bebop"/>
  <arg name="tf_prefix" default="$(arg name)"/>
  <arg name="x" default="0.0"/>
  <arg name="y" default="0.0"/>
  <arg name="z" default="0.031"/>
  <arg name="wind_force" default="0.0"/>
  <arg name="wind_start" default="0.0"/>
  <arg name="wind_duration" default="0.0"/>
  <arg name="wind_direction_x" default="0.0"/>
  <arg name="wind_direction_y" default="0.0"/>
  <arg name="wind_direction_z" default="0.0"/>
  <arg name="enable_ground_truth" default="true"/>
  <arg name="enable_odometry_sensor_with_noise" default="false"/>
  <arg name="disable_odometry_sensor_with_noise" default="true"/>
  <arg name="enable_ground_truth_sensor" default="false"/>
  <arg name="enable_wind_plugin" default="false"/>
  <arg name="enable_laser1D" default="false"/>
  <arg name="enable_imu" default="false"/>
  <arg name="model" value="$(find bebop_simulator)/urdf/bebop.urdf.xacro" />

  <!-- send the robot XML to param server -->
  <param name="robot_description" command="
    $(find xacro)/xacro --inorder '$(arg model)'
    enable_ground_truth:='$(arg enable_ground_truth)'
    enable_odometry_sensor_with_noise:='$(arg enable_odometry_sensor_with_noise)'
    disable_odometry_sensor_with_noise:='$(arg disable_odometry_sensor_with_noise)'
    enable_ground_truth_sensor:='$(arg enable_ground_truth_sensor)'
    enable_wind_plugin:='$(arg enable_wind_plugin)'
    enable_laser1D:='$(arg enable_laser1D)'
    enable_imu:='$(arg enable_imu)'
    namespace:='$(arg name)_1'
    wind_force:=$(arg wind_force)
    wind_start:=$(arg wind_start)
    wind_duration:=$(arg wind_duration)
    wind_direction_x:=$(arg wind_direction_x)
    wind_direction_y:=$(arg wind_direction_y)
    wind_direction_z:=$(arg wind_direction_z)
    "
  />
  <param name="tf_prefix" type="string" value="$(arg tf_prefix)" />

  <!-- push robot_description to factory and spawn robot in gazebo -->
  <node name="spawn_robot" pkg="gazebo_ros" type="spawn_model"
   args="-param robot_description
         -urdf
         -x $(arg x)
         -y $(arg y)
         -z $(arg z)
         -model $(arg name)"
   respawn="false" output="screen" >
  </node>

</launch>

The command entered is
roslaunch bebop_simulator fly6.launch

My question is a bit stupid, I am sorry to disturb you. But I really want to know what to do next

@gsilano
Copy link
Owner

gsilano commented Aug 10, 2020

Okay, I get it. Let's do it this way. To save time, I'll create this file for you and then upload it to the repository. I should give back to you in a few days.

@golden-memory
Copy link
Author

Okay, I get it. Let's do it this way. To save time, I'll create this file for you and then upload it to the repository. I should give back to you in a few days.

Thank you so much!

@gsilano
Copy link
Owner

gsilano commented Aug 22, 2020

Hi @golden-memory! Sorry for the delay, but this a very stressful period for me. Therefore, I did not have time to work on a ready-to-use example. However, I would like to help you understand the issue and to fix it.
As far as I remember, the issue is related to the namespace. Unlike CrazyS, is not possible to separate drones by using the namespace here (e.g., bebop1, bebop2, etc.). My mistake, when I designed BebopS I did not think that a day this could be of help to someone.
So, a possible workaround could be changing the namespace. First, check if the task1_world.launch file works for you. Then, copy and paste these changes and let me know if the drones start hovering.

I think a few problems should come up, but let's see what it happens.

<?xml version="1.0"?>
<launch>
    <arg name="name_1" default="bebop_1"/>
    <arg name="name_1" default="bebop_2"/>
    <arg name="x_1" default="0.0" />
    <arg name="y_1" default="0.0" />
    <arg name="z_1" default="0.02" />
    <arg name="x_2" default="-5.0" />
    <arg name="y_2" default="-5.0" />
    <arg name="z_2" default="0.02" />
    <arg name="use_sim_time" default="true"/>
    <arg name="world_name" default="basic"/>
    <arg name="wind_force" default="0.5"/>
    <arg name="wind_start" default="15.0"/>
    <arg name="wind_duration" default="10.0"/>
    <arg name="wind_direction_x" default="0.0"/>
    <arg name="wind_direction_y" default="0.0"/>
    <arg name="wind_direction_z" default="1.0"/>
    <arg name="csvFilesStoring" default="false"/>
    <arg name="csvFilesStoringTime" default="15.0"/> <!-- seconds -->
    <arg name="user_account" default="giuseppe"/>
    <arg name="waypoint_filter" default="true"/>
    <arg name="EKFActive" default="false"/>
    <arg name="enable_imu" default="true"/>
    <arg name="enable_odometry_sensor_with_noise" default="false"/>
    <!-- The "disable_odometry_sensor_with_noise" variable values is equal to true if "enable_odometry_sensor_with_noise"
    is false, and viceversa -->
    <arg name="disable_odometry_sensor_with_noise" value="true" unless="$(arg enable_odometry_sensor_with_noise)"/>
    <arg name="disable_odometry_sensor_with_noise" value="false" if="$(arg enable_odometry_sensor_with_noise)"/>
    <arg name="enable_ground_truth_sensor" default="false"/>
    <arg name="enable_wind_plugin" default="false"/>
    <arg name="enable_laser1D" default="false"/>
    <arg name="enable_imu" default="true"/>
    
  <env name="GAZEBO_MODEL_PATH" value="${GAZEBO_MODEL_PATH}:$(find bebop_simulator)/models"/>
  <env name="GAZEBO_RESOURCE_PATH" value="${GAZEBO_RESOURCE_PATH}:$(find bebop_simulator)/models"/>
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find bebop_simulator)/worlds/$(arg world_name).world" />
  </include>

    <!-- Launch UAV1 -->
    <include file="$(find bebop_simulator)/launch/spawn_bebop.launch">
       <arg name="name" value="$(arg name_1)" />
       <arg name="x" value="$(arg x_1)"/>
       <arg name="y" value="$(arg y_1)"/>
       <arg name="z" value="$(arg z_1)"/>
       <arg name="wind_force" value="$(arg wind_force)"/>
       <arg name="wind_start" value="$(arg wind_start)"/>
       <arg name="wind_duration" value="$(arg wind_duration)"/>
       <arg name="wind_direction_x" value="$(arg wind_direction_x)"/>
       <arg name="wind_direction_y" value="$(arg wind_direction_y)"/>
       <arg name="wind_direction_z" value="$(arg wind_direction_z)"/>
      <!-- The disable_odometry_sensor_with_noise will only become true if enable_odometry_sensor_with_noise will is false.
       In this way, only one odometry sensor will be simulated: with or without noise. -->
       <arg name="enable_odometry_sensor_with_noise" value="$(arg enable_odometry_sensor_with_noise)"/>
       <arg name="disable_odometry_sensor_with_noise" value="$(arg disable_odometry_sensor_with_noise)" /> 
       <arg name="enable_ground_truth_sensor" value="$(arg enable_ground_truth_sensor)"/>
       <arg name="enable_wind_plugin" value="$(arg enable_wind_plugin)"/>
       <arg name="enable_laser1D" value="$(arg enable_laser1D)"/>
       <arg name="enable_imu" value="$(arg enable_imu)"/>
    </include>

    <!-- Launch UAV2 -->
    <include file="$(find bebop_simulator)/launch/spawn_bebop.launch">
       <arg name="name" value="$(arg name_2)" />
       <arg name="x" value="$(arg x_2)"/>
       <arg name="y" value="$(arg y_2)"/>
       <arg name="z" value="$(arg z_2)"/>
       <arg name="wind_force" value="$(arg wind_force)"/>
       <arg name="wind_start" value="$(arg wind_start)"/>
       <arg name="wind_duration" value="$(arg wind_duration)"/>
       <arg name="wind_direction_x" value="$(arg wind_direction_x)"/>
       <arg name="wind_direction_y" value="$(arg wind_direction_y)"/>
       <arg name="wind_direction_z" value="$(arg wind_direction_z)"/>
      <!-- The disable_odometry_sensor_with_noise will only become true if enable_odometry_sensor_with_noise will is false.
       In this way, only one odometry sensor will be simulated: with or without noise. -->
       <arg name="enable_odometry_sensor_with_noise" value="$(arg enable_odometry_sensor_with_noise)"/>
       <arg name="disable_odometry_sensor_with_noise" value="$(arg disable_odometry_sensor_with_noise)" /> 
       <arg name="enable_ground_truth_sensor" value="$(arg enable_ground_truth_sensor)"/>
       <arg name="enable_wind_plugin" value="$(arg enable_wind_plugin)"/>
       <arg name="enable_laser1D" value="$(arg enable_laser1D)"/>
       <arg name="enable_imu" value="$(arg enable_imu)"/>
    </include>

    <!-- Launch the controller  for UAV 1-->
    <node name="position_controller_node" pkg="bebop_simulator" type="position_controller_node" output="screen"> 
      <rosparam command="load" file="$(find bebop_simulator)/resource/controller_bebop.yaml" />
      <rosparam command="load" file="$(find bebop_simulator)/resource/bebop.yaml" />
      <rosparam command="load" file="$(find bebop_simulator)/resource/EKF_matrix.yaml" />
      <rosparam command="load" file="$(find bebop_simulator)/resource/waypoint_filter.yaml" />
      <param name="use_sim_time" value="$(arg use_sim_time)" />
      <param name="csvFilesStoring" value="$(arg csvFilesStoring)"/>
      <param name="csvFilesStoringTime" value="$(arg csvFilesStoringTime)"/>
      <param name="user_account" value="$(arg user_account)"/>
      <param name="waypoint_filter" value="$(arg waypoint_filter)"/>
      <param name="EKFActive" value="$(arg EKFActive)"/>
      <remap from="/command/motor_speed" to="/gazebo/command/motor_speed" />
      <remap from="/odometry" to="/$(arg name_1)/odometry" />
      <remap from="/odometry_gt" to="/$(arg name_1)/odometry_gt" />
      <remap from="/referenceAngles" to="/$(arg name_1)/referenceAngles" />
      <remap from="/filteredOutput" to="/$(arg name_1)/filteredOutput" />
      <remap from="/stateErrors" to="/$(arg name_1)/stateErrors" />
      <remap from="/smoothedTrajectory" to="/$(arg name_1)/smoothedTrajectory" />
      <remap from="/command/trajectory" to="/$(arg name_1)/command/trajectory" />
    </node>

    <!-- Launch the controller  for UAV 2-->
    <node name="position_controller_node" pkg="bebop_simulator" type="position_controller_node" output="screen"> 
      <rosparam command="load" file="$(find bebop_simulator)/resource/controller_bebop.yaml" />
      <rosparam command="load" file="$(find bebop_simulator)/resource/bebop.yaml" />
      <rosparam command="load" file="$(find bebop_simulator)/resource/EKF_matrix.yaml" />
      <rosparam command="load" file="$(find bebop_simulator)/resource/waypoint_filter.yaml" />
      <param name="use_sim_time" value="$(arg use_sim_time)" />
      <param name="csvFilesStoring" value="$(arg csvFilesStoring)"/>
      <param name="csvFilesStoringTime" value="$(arg csvFilesStoringTime)"/>
      <param name="user_account" value="$(arg user_account)"/>
      <param name="waypoint_filter" value="$(arg waypoint_filter)"/>
      <param name="EKFActive" value="$(arg EKFActive)"/>
      <remap from="/command/motor_speed" to="/gazebo/command/motor_speed" />
      <remap from="/odometry" to="/$(arg name_2)/odometry" />
      <remap from="/odometry_gt" to="/$(arg name_2)/odometry_gt" />
      <remap from="/referenceAngles" to="/$(arg name_2)/referenceAngles" />
      <remap from="/filteredOutput" to="/$(arg name_2)/filteredOutput" />
      <remap from="/stateErrors" to="/$(arg name_2)/stateErrors" />
      <remap from="/smoothedTrajectory" to="/$(arg name_2)/smoothedTrajectory" />
      <remap from="/command/trajectory" to="/$(arg name_2)/command/trajectory" />
    </node>

    <!-- Launch the trajectory generator -->
   <group ns="$(arg name)">
       <node name="hovering_example" pkg="bebop_simulator" type="hovering_example" output="screen"/>   
    </group>

</launch>

@golden-memory
Copy link
Author

golden-memory commented Aug 24, 2020

@gsilano Thank you for your reply!
Firstly, I need to fix some minor errors. In task1_world.launch, I deleted the 29 line which is the same as the 20 line. In the file you gave above, I changed name_1 to name_2 in 4 line.
Secondly, I have run the task1_world.launch, Although there is an error, the drone is indeed flying. Then I ran the file you gave above, The following error occurred
roslaunch file contains multiple nodes named [/spawn_robot]. Please check all <node> 'name' attributes to make sure they are unique. Also check that $(anon id) use different ids. The traceback for the exception was written to the log file

@gsilano
Copy link
Owner

gsilano commented Aug 25, 2020

Mhmm. As I can understand, add a second Bebop is not so easy as I supposed to be. This requires a lot of effort and a redesign of the simulation framework. The easiest way could be to start from the multi-robot example provided in the CrazyS repository, replacing the .xacro files used for the Crazyflie with those of the Bebop. This also means that you should manage the moving of the control algorithm.

collinthornton added a commit to collinthornton/BebopS that referenced this issue Aug 25, 2020
Modifications made to urdf/multirotor_base.urdf.xacro such that multiple bebops may be spawned
in the same simulation. Lines 109 and 113 were changed so that parameter titles matched with those
found in RotorS/rotors_gazebo_plugins/src/gazebo_motor_model.cpp. This resolves the rostopic
advertising conflict on bebop/motor_speed experienced by other developers.

Launch file examples have been added. See

    - launch/multiple_bebop_without_controller.launch

    - launch/multiple_task2_world.launch

for examples without and with a controller, respectively.

Resolves: gsilano#20, gsilano#27
@golden-memory
Copy link
Author

@gsilano
I thank you from the bottom of my heart!Now drones can fly well, the problem is basically solved. As a beginner, I am very satisfied! And it all comes from your help to me, thanks ever so!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants