Okay I managed to solve the problem. The reason why my external pc is unable to see the /fmu topics is probably due to the voxl-microdds-agent service starting before the network is fully "set up". From this stack overflow topic, I edited my /etc/systemd/system/voxl-microdds-agent.service
file to include the line ExecStartPre=/bin/sh -c 'until ping -c1 google.com; do sleep 1; done;
(this is the only "hacky" method that somehow worked). My entire service file is:
[Unit]
Description=voxl-microdds-agent
SourcePath=/usr/bin/MicroXRCEAgent
After=network.target
After=multi-user.target
# After=network-online.target
# Wants=network-online.target
[Service]
User=root
Type=simple
ExecStartPre=/bin/sh -c 'until ping -c1 google.com; do sleep 1; done;'
ExecStart=/usr/bin/MicroXRCEAgent udp4 -p 8888
[Install]
WantedBy=multi-user.target
After modifying the service file and rebooting the voxl2, the external computer can now see and echo topics from the /fmu. This will obviously not work if the voxl2 is not connected to the internet.. However you can still manually fix this by ssh or adb shell into the voxl2 and restart the service using the commands:
systemctl stop voxl-microdds-agent
systemctl start voxl-microdds-agent
and the external computer should be able to see /fmu topics.
On a side note, to customize & add a prefix to the /fmu topic such that it is /drone1/fmu/ in ROS2, edit the px4 start up script /usr/bin/voxl-px4-start
. There is a line that starts the microdds_client for px4 where:
# Start microdds_client for ros2 offboard messages from agent over localhost
microdds_client start -t udp -h 127.0.0.1 -p 8888
Simply add -n <desired _name> such that it becomes:
# Start microdds_client for ros2 offboard messages from agent over localhost
microdds_client start -t udp -h 127.0.0.1 -p 8888 -n drone2