From f3c68f143b9001c3fccc2a6481755def4fb9e703 Mon Sep 17 00:00:00 2001 From: Jeroen Veen Date: Wed, 23 Apr 2025 09:10:15 +0200 Subject: [PATCH] To allow ROS2 communication over Tailscale, explicitly disable multicast and use unicast for DDS communications --- cyclonedds.xml | 18 ++++++++++++++++++ pixi.toml | 8 +++++++- setup_ros_tailscale.sh | 16 ++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 cyclonedds.xml create mode 100755 setup_ros_tailscale.sh diff --git a/cyclonedds.xml b/cyclonedds.xml new file mode 100644 index 0000000..d22795c --- /dev/null +++ b/cyclonedds.xml @@ -0,0 +1,18 @@ + + + + + + + + false + + + + + + + auto + + + diff --git a/pixi.toml b/pixi.toml index 1aeca5c..e7def26 100644 --- a/pixi.toml +++ b/pixi.toml @@ -8,6 +8,11 @@ preview = ["pixi-build"] [tasks] build = "colcon build --packages-select audio_tools --cmake-args -DCMAKE_BUILD_TYPE=Release" +# Run the audio capture node and publish via tailscale +run_audio_capture_tailscale = { cmd = [ + "./setup_ros_tailscale.sh", "ros2", "run", "audio_tools", "audio_capture_node", "--ros-args", "-p", "sample_rate:=16000", "-p", "channels:=1", "-p", "sample_format:=S16LE" +], depends-on = ["build"] } + [target.win-64.tasks] vscode = "code ." @@ -36,4 +41,5 @@ numpy = "*" [target.win-64.dependencies] python-devtools = "*" -python = "*" \ No newline at end of file +python = "*" + diff --git a/setup_ros_tailscale.sh b/setup_ros_tailscale.sh new file mode 100755 index 0000000..12ce77c --- /dev/null +++ b/setup_ros_tailscale.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Set up the network and DDS environment variables for Tailscale +export CYCLONEDDS_URI=file://$PIXI_PROJECT_ROOT/cyclonedds.xml +export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp +export ROS_NETWORK_INTERFACE=tailscale0 +export ROS_IP=$(tailscale ip -4) +export ROS_DOMAIN_ID=0 + +# Source the ROS workspace +source install/setup.bash + +# Execute the command passed as arguments +exec "$@" + +echo "ROS2 environment configured for Tailscale communication"