Using ROS_LOCALHOST_ONLY with micrortps_agent

Is it possible to use the environment variable ROS_LOCALHOST_ONLY with micrortps_agent? When I run it with this variable set to 1 it doesn’t show any of the RTPS topics.

I need to use this variable since I am working on a network with someone else also running ROS2 Foxy and micrortps_agent in SITL. We are having issues where our topics overlap and we cannot work at the same time since ROS2 automatically broadcasts.

If you say you tried and it’s not working then it means we need to figure out how to make it work. I have not tried it myself yet. But this will have to do with the DDS participants configuration for the agent. I will have a look at this when I have some time. In the mean time if you find a solution please post it here or bring it directly as a PR.

Did a quick search and this might be the solution to add to the Publishers and Subscribers templates: [foxy] Use interface whitelist for localhost only (#476) by fujitatomoya · Pull Request #514 · ros2/rmw_fastrtps · GitHub. So one needs to check for the env variable and if it is set, then use the interface whitelist. But again I am not entirely sure this will make it work, just suggesting a starting point.

I tried adding in the same code from the PR you mentioned on a fork and wasn’t able to get it working. I confirmed that it reads the environment variable properly and executes the code also.

I’ll take a look around and see if I can find anything else.