Ubuntu Linux for Robotics · Lesson 85 of 96
DDS tuning
Cyclone and Fast DDS configuration files, network buffers and large messages.
Estimated time · 60–90 min
Learning goals
What you will understand
- Explain dds tuning in your own words
- Use it in a small workstation example
- Verify the result instead of assuming it worked
Understand the idea first
The mental model
Default DDS settings often fail on real networks. Symptoms: slow or missing discovery, dropped image or point cloud messages, high CPU. Configure the middleware with an XML file: Cyclone DDS through CYCLONEDDS_URI, Fast DDS through FASTRTPS_DEFAULT_PROFILES_FILE. Bind to one network interface, limit discovery, and enlarge buffers.
Large messages need bigger kernel socket buffers: sudo sysctl -w net.core.rmem_max=... and net.core.rmem_default. Test one change at a time and measure with ros2 topic hz and bw. Keep the configuration file in your repository and set the variable in the robot's service file.
Guided lesson
Work through these steps
- 1.
Open a terminal and record the current state before changing anything.
- 2.
Read the dds tuning commands and predict what each one does.
- 3.
Run the commands one at a time and compare each output with your prediction.
- 4.
Write the commands that worked in a setup note you can repeat later.
Worked example
Read it before you run it
sudo sysctl -w net.core.rmem_max=26214400
# Allow a 25 MB receive buffer (needed for large messages).
sudo sysctl -w net.core.rmem_default=26214400
# Make it the default for new sockets.
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
# Use Cyclone DDS.
export CYCLONEDDS_URI=file://$HOME/cyclonedds.xml
# Load the tuned configuration.
ros2 topic hz /points
# Measure the effect on a large topic.What the example is doing
- 1.Lines without sudo only inspect or change files you own; sudo authorizes a system-wide change.
- 2.Read command output before moving to the next line. Stop if names, versions, disks, or paths differ from the lesson.
- 3.Comments beginning with # explain safety checks and are not executed by the shell.
Watch it run · Messages between nodes
See what this code does
The terminal types this lesson's practice solution and runs it. The scene shows the kind of robot behaviour that code drives. It plays by itself and loops.
Demo for DDS tuning. Expected result: 26214400
Practice code
Now type it yourself
Open a terminal, run the starter line by line (or save it as practice.sh and run bash practice.sh), and replace every TODO with your own command.
# TODO: set net.core.rmem_max to 26214400 with sysctl -w
sysctl -n net.core.rmem_maxExpected output
26214400Stuck? Show the full solution (try it yourself first)
sudo sysctl -w net.core.rmem_max=26214400
sysctl -n net.core.rmem_maxExpected result
How you know it worked
- Each command completes without an unexplained error.
- Your notes contain the command, the important output, and what it proves.
Practical exercise
Apply the lesson
Stream a point cloud between two computers, measure the rate and drops, raise the receive buffer, bind DDS to one interface, and record the improvement after each change.
Before you continue
- You recorded the starting state
- Every command and output is understood
- The change can be repeated from your notes
If something goes wrong
Check ownership and permissions first. Do not add sudo unless the command changes a documented system location.
Check spelling, Ubuntu version, enabled repositories, and whether the previous installation command succeeded.