Multiple Arducopter waypoints overwriting

I’m currently running two instances of arducopter via ardupilot and the sim_vehicle.py script connecting to a gazebo simulation running two iris models. I can navigate the models independently using the set position commands - I run these via mavros, but I’ve also run these via the console. A problem arises when I try to use two different waypoint tables. I command one iris model to follow a set of waypoints in auto mode and let it start following the points, then after setting a second iris model to follow a different set of waypoints (different alt. to be obvious) the first iris model then proceeds to follow the second set of waypoints.
This seems like a bug to me - is there anything I can check to make sure things are configured correctly on my end?

My guess is that both sim vehicles have the same SYSID so you’re sending the updates to both. You need to uniquely identify each vehicle (set SYSID_THISMAV to 1 and 2 for your 2 vehicles for instance)

I am setting the instance to different numbers:

sim_vehicle.py -v ArduCopter -f gazebo-iris -I0 --console
sim_vehicle.py -v ArduCopter -f gazebo-iris -I1 --console

Should I also set up a param file that includes SYSID_THISMAV for each instance?

I’ll defer to @khancyr who maintains the ROS stuff :slight_smile:
Sorry

So, setting the SYSID_THISMAV seem to helped the direct simulation, but now my ROS node isn’t connecting… weird. @khancyr, would really appreciate your input here.

Further evidence: Looking over this post the response suggests running 2 different arducopter instances in different folders. I tried this, but the faulty waypoint behavior didn’t change.

hello,

On ArduPilot side :

sim_vehicle.py -v ArduCopter -f gazebo-iris -I0 --console  --use-dir quad0
sim_vehicle.py -v ArduCopter -f gazebo-iris -I1 --console  --use-dir quad1

You need to set SYSID_THISMAV to 1 on the first one and 2 on the second one (we don’t have a simple way to do it for now, it should come soon)

On ROS side, you launch file should be something like this :

<?xml version="1.0"?>
<launch>
    <group ns="drone0">
        <arg name="fcu_url" default="tcp://127.0.0.1:5760/?ids=1,240"/>
        <!--<arg name="gcs_url" default="udp-pb://127.0.0.1:4243@4242"/>-->
        <arg name="tgt_system" default="1"/>
        <arg name="tgt_component" default="1"/>
        <arg name="log_output" default="screen"/>

        <include file="$(find mavros)/launch/node.launch">
            <arg name="pluginlists_yaml" value="$(find mavros)/launch/apm_pluginlists.yaml"/>
            <arg name="config_yaml" value="$(find mavros)/launch/apm_config.yaml"/>

            <arg name="fcu_url" value="$(arg fcu_url)"/>
            <arg name="gcs_url" value="$(arg gcs_url)"/>
            <arg name="tgt_system" value="$(arg tgt_system)"/>
            <arg name="tgt_component" value="$(arg tgt_component)"/>
            <arg name="log_output" value="$(arg log_output)"/>
        </include>
    </group>
    <group ns="drone1">
        <arg name="fcu_url" default="tcp://127.0.0.1:5770/?ids=2,240"/>
        <!--<arg name="gcs_url" default="udp-pb://127.0.0.1:4244@4242"/>-->
        <arg name="tgt_system" default="2"/>
        <arg name="tgt_component" default="1"/>
        <arg name="log_output" default="screen"/>

        <include file="$(find mavros)/launch/node.launch">
            <arg name="pluginlists_yaml" value="$(find mavros)/launch/apm_pluginlists.yaml"/>
            <arg name="config_yaml" value="$(find mavros)/launch/apm_config.yaml"/>

            <arg name="fcu_url" value="$(arg fcu_url)"/>
            <arg name="gcs_url" value="$(arg gcs_url)"/>
            <arg name="tgt_system" value="$(arg tgt_system)"/>
            <arg name="tgt_component" value="$(arg tgt_component)"/>
            <arg name="log_output" value="$(arg log_output)"/>
        </include>
    </group>

</launch> 

that will launch two instance of mavros on different name space : drone0 and drone1 . Now you drone aren’t link in any way. So issuing command to one won’t interfer the others

Thanks for your reply @khancyr. Had some issues to sort out unrelated to this, but after those were squared away adding a namespace, --use-dir option, and SYSID_THISMAV parameter worked perfectly. Thanks again for your help.

Now I’m curious. Why does ardupilot / arducopter share the waypoint table state?

There don’t share anything…
But if you launch two sitl instance from the same directory, they use the same file as eeprom, so that can mess up thing

Is there possibly a way to specify the file used to store the eeprom?

To follow up on this, because I solved it long ago, is to specify the --use-dir parameter in a unique directory. This allows arducopter to write and use its own eeprom file.