Dev Environment Up: ROS2 + Gazebo in WSL2, and the Middleware Bug That Ate an Afternoon

The plan said environment setup would run July 7–18. It’s done on July 3 — ROS2 Humble, Gazebo, Nav2 and the TurtleBot3 stack all running on my Windows PC under WSL2, and the LLM planner returning its first valid waypoint plan end-to-end. This post documents the setup and the one genuinely nasty problem, because “ROS2 on WSL2” guides all skip the part where nothing talks to anything.

The stack

Layer Choice
Host Windows 11, i9-14900KS, RTX 4060 Ti 8 GB, 32 GB RAM
VM WSL2 Ubuntu 22.04 — 20 GB RAM / 12 cores, mirrored networking
Robotics ROS2 Humble desktop, Gazebo Classic 11, Nav2, TurtleBot3 (waffle), SLAM Toolbox
Planner Python 3.12 venv, OpenAI API (gpt-4o-mini as the working model)

Two WSL2 lessons carried over from setting up my laptop: default NAT networking gave no raw-IP connectivity inside the VM (mirrored mode fixes it), and install scripts should health-check DNS before touching apt, because WSL’s generated resolv.conf fails silently.

The GPU passthrough works out of the box — glxinfo inside Ubuntu reports the renderer as D3D12 (NVIDIA GeForce RTX 4060 Ti), so Gazebo’s rendering is hardware-accelerated through WSLg rather than software Mesa.

The bug: ROS2 nodes that discover each other but never speak

First launch of turtlebot3_world and the robot never appeared:

[spawn_entity.py-4] [ERROR] [spawn_entity]: Service /spawn_entity unavailable.
Was Gazebo started with GazeboRosFactory?

Gazebo was running. The factory plugin was loaded. ros2 node list from a fresh shell: empty. ros2 multicast receive/send: works. A demo talker/listener pair: talker publishing happily, listener hearing nothing — on the same machine, over loopback.

That combination is the fingerprint of a transport problem, not a discovery problem: under WSL2’s mirrored networking mode, Fast DDS (Humble’s default middleware) completes multicast discovery but its data path silently delivers nothing. I tried the standard fixes in order — ROS_LOCALHOST_ONLY=1, an XML profile disabling shared memory, a profile pinning everything to 127.0.0.1 unicast. All three failed the same way: publisher fine, subscriber silent, no error anywhere.

The fix was swapping the middleware entirely for Cyclone DDS, pinned to loopback with unicast peer discovery:

<CycloneDDS xmlns="https://cdds.io/config">
    <Domain Id="any">
        <General>
            <Interfaces><NetworkInterface name="lo"/></Interfaces>
            <AllowMulticast>false</AllowMulticast>
        </General>
        <Discovery>
            <ParticipantIndex>auto</ParticipantIndex>
            <MaxAutoParticipantIndex>100</MaxAutoParticipantIndex>
            <Peers><Peer address="127.0.0.1"/></Peers>
        </Discovery>
    </Domain>
</CycloneDDS>

with RMW_IMPLEMENTATION=rmw_cyclonedds_cpp and CYCLONEDDS_URI pointing at that file in .bashrc. Immediately: listener hears talker, spawn service appears, robot spawns.

One trap worth recording: the ros2 CLI runs a background daemon that caches discovery. Mine had started under the broken Fast DDS config, so even after the fix, ros2 topic list returned nothing while the simulation was visibly running. ros2 daemon stop (or --no-daemon) before trusting any “there are no topics” result.

TurtleBot3 waffle in the turtlebot3_world Gazebo simulation, running under WSLg

Proof of life: TurtleBot3 waffle spawned, sim at 1.00 real-time factor, ~62 FPS, /scan, /odom, /imu and both camera topics publishing.

First end-to-end planner run

With the sim verified I pointed the planner at a Level 3–4 style command:

$ python src/planner.py "Patrol aisle 2, then come home; if the aisle is blocked, skip it"
[openai/gpt-4o-mini] 6.026s
{
  "understood": true,
  "clarification_question": null,
  "plan": [
    { "action": "navigate", "target": "aisle_2_south", "on_blocked": "skip",
      "reason": "Enter aisle 2 from the south to begin the patrol." },
    { "action": "navigate", "target": "aisle_2_north", "on_blocked": "skip",
      "reason": "Traverse to the north end to complete the aisle." },
    { "action": "navigate", "target": "charging_dock", "on_blocked": null,
      "reason": "Return home as instructed." }
  ],
  "notes": null
}

Exactly right: the patrol decomposed into a south→north traversal with the blocked-contingency attached to both aisle waypoints, and an unconditional return home. One good run proves nothing statistically — that’s what the 100-command evaluation is for — but the pipe from English to schema-valid plan is now real.

Next up

Building the actual warehouse world (the stock turtlebot3_world is just the smoke test), SLAM-mapping it, and labelling the semantic locations the planner’s map file promises.