Usage of multiple PX4s in offboard mode

Hello, I am using PX4 to control my drone with ROS2, and it is working. I am planning to build two drones, and I anticipate facing an issue in this part because having two PX4s means having the same topic names. When I researched this problem, I came across works done in simulation environments, and I tried them in simulation, and they worked. However, I am wondering how to achieve this in a real system. Can you help me with this?
I have reviewed the PX4-Autopilot software and attempted to modify the ‘dds_topics.yaml’ file located at ‘PX4-Autopilot/src/modules/uxrce_dds_client/’. However, the changes I made to the ‘topic’ sections in the file did not take effect when I attempted to upload it.

see [Bug] Two PX4 boards cannot be used simultaneously in offboard mode · Issue #22587 · PX4/PX4-Autopilot · GitHub

I downloaded the PX4-Autopilot software and solved the problem by adding different names to the uxrce_dds_client section in the “PX4-Autopilot/src/modules/uxrce_dds_client/module.yaml” file while installing.

resources: uxrce-dds-client

The parameter specified in uxrce-dds-client must be added and the namespace we want to add must be added.

Hi serkan, I am have the same problem as you. I also try to control multiple drones but cannot switch to offboard mode. Could you please tell me how you changed the module.yaml?

Hi @px4ke
At the top of the file located at src/modules/uxrce_dds_client/module.yaml, in the following section

serial_config:
    - command: |
        if [ $SERIAL_DEV != ethernet ]; then
            set UXRCE_DDS_ARGS "-t serial -d ${SERIAL_DEV} -b p:${BAUD_PARAM}"
        else
            set UXRCE_DDS_ARGS "-t udp"
        fi
        uxrce_dds_client start ${UXRCE_DDS_ARGS} -n drone_1

      port_config_param:
        name: UXRCE_DDS_CFG
        group: UXRCE-DDS Client
      supports_networking: true

uxrce_dds_client start ${UXRCE_DDS_ARGS} -n drone_1

the value provided after the -n parameter will be used as the active name of the drone.

Hi @serkan , thanks for the reply. I solved my problem without chaging the module.yaml. I followd the instruction from Multi-Vehicle Simulation with Gazebo | PX4 Guide (main) but I realized if I use

PX4_SYS_AUTOSTART=4001 PX4_SIM_MODEL=gz_x500 ./build/px4_sitl_default/bin/px4 -i 1

the copter target system is set to 2 instead of 1.

1 Like

Yes, if you are working in simulation, it’s more appropriate to do it that way. My answer mainly applies to real systems that communicate over serial. Since the simulation runs over UDP, any changes you make in serial_config won’t affect the system in that case.