Now it gets exciting: the rover builds a map of the flat with its camera, I click on a point in the map in the browser, and the rover plans its way there and drives off, around obstacles and even through a door with only 5 cm to spare on each side. This post describes how it is set up and which pitfalls there were. The topic isn’t finished yet, but the foundation is in place.
Division of labour: rover and server
The Jetson Nano can’t do everything at once: camera, drive, obstacle detection, path planning and building the map. So I split the work:
On the rover (Jetson Nano):
- ROS master, drive (Curio), camera, pose estimation (Kalman filter from wheel odometry and gyro)
- obstacle detection and path planning (
move_base). That belongs on the rover on purpose: if Wi-Fi drops briefly, it still stops at obstacles.
On a server in the house (for me a small machine in the basement that runs around the clock anyway, with Docker):
- RTAB-Map builds the map
- foxglove_bridge provides the ROS data via WebSocket
- Lichtblick (a free fork of Foxglove Studio) is the user interface in the browser, served via nginx
Only compressed data goes over Wi-Fi: the camera image as JPEG and, for the map, throttled image pairs (colour and depth) at 2 Hz. The ROS master runs on the rover, so it keeps working even if the server is off.
I built the server part as a Docker Compose project with four containers (ROS Melodic with RTAB-Map and bridge, Lichtblick, nginx). It starts with one command, and no packages mix with the rest of the system. Here too, ROS Melodic is EOL and the packages come from the snapshot archive (see post #5). The complete project: [link follows].
[Image: diagram rover – Wi-Fi – server – browser]
The map: RTAB-Map
RTAB-Map (“Real-Time Appearance-Based Mapping”) builds a 3D point cloud and a 2D occupancy map (free, occupied, unknown) from colour and depth images. It also recognises places the rover has visited before and uses them to correct the accumulated odometry drift.
Settings that mattered for me:
- Floor height:
Grid/MaxGroundHeightandGrid/MaxObstacleHeightdefine what counts as floor and what as obstacle, measured from the rover centre. For me floor up to 4 cm above the real floor, obstacles up to 55 cm. Anything higher (a table top) lets the rover pass underneath. These values are only right if the camera is well calibrated (post #6). Reg/Force3DoF true: the rover drives in the plane, the map should not tilt.RGBD/NeighborLinkRefining false: this feature corrects the odometry between two frames by image matching. At only 2 frames per second and with repeating patterns (shelves, tiles) it produced wrong matches for me and made the pose worse. Without it the map follows the (well calibrated) odometry; larger drift is still corrected by RTAB-Map via recognised places. Result: about 2 cm residual error after 1 m there and back instead of 8 cm.
The map is stored in a database file on the server and grows with every drive.
Control in the browser: Lichtblick
Lichtblick runs in any browser, even on a phone, without installation. My layout shows:
- the map as a top-down view that follows the rover (front is up)
- the live camera image
- a teleop control with arrow keys
- a red STOP button
Setting a goal: choose “Click to publish”, click the goal point, then move the mouse in the desired viewing direction and click again. The rover plans the path (green line) and drives off.
Pitfalls with the bridge under Melodic:
- Teleop with 5 seconds delay: by default the bridge regularly polls all ROS parameters and blocks while doing so. Fix: enable only the
clientPublishcapability in the bridge. - Allowed topics: for safety, browsers may only send on whitelisted topics (
client_topic_whitelist: drive command, goal, cancel). But beware: if the layout contains a topic that isn’t whitelisted, Lichtblick sends nothing at all. The goal arrow then simply disappears.
Obstacle detection on the rover
For path planning the rover needs current obstacles, not just the map. A small chain runs on the Jetson for that, all as nodelets in the camera process so that no images are copied:
- throttle the depth image to 5 frames per second
- turn it into a thinned point cloud up to 2 m distance. Further away the depth is so noisy that the floor shows up as an obstacle.
- remove the floor (
obstacles_detectionfrom RTAB-Map); what remains are the obstacles
This feeds the local costmap, a map around the rover in which every cell marks whether there is an obstacle.
Path planning: from goal to drive command
move_base from the ROS navigation stack plans in two stages:
- Global planner (NavFn): searches the map for the shortest path to the goal.
- Local planner: translates the stretch of path in front of the rover into drive commands and avoids current obstacles.
The local planner is where I experimented most:
DWA (the default) tries many combinations of speed and turn rate every cycle and picks the best. That suits robots with differential drive, but on the Sawppy it leads to wild steering: small turn rates at low speed mean tight arcs, and the corner servos swing back and forth. With DWA the rover did get through the narrow door, but only very slowly.
TEB (“Timed Elastic Band”) instead optimises a whole trajectory with acceleration limits and can model a vehicle with a minimum turning radius. My current state:
- TEB drives like a car, arcs with at least 0.5 m radius, and may back up in tight spots.
- Turning on the spot is handled by a small node of my own between Lichtblick and
move_base: if the rover points more than 30 degrees away from the planned path, it first turns on the spot (if the map shows enough room) and then drives off. At the goal it turns on the spot to the requested heading. - The reason for this split: the Sawppy needs a minimum turn rate to turn on the spot (about 0.3 rad/s on mine), otherwise the wheels can’t overcome friction and the motors just hum. TEB, however, likes to plan slow turns.
- Computing time: by default TEB treats every occupied cell of the costmap as a separate obstacle. In a cluttered corner that was almost 2000. One planning step then took 2.4 s instead of 0.2 s, and the rover stopped. Fix: the
costmap_converterplugin, which merges neighbouring cells into a few polygons.
Fine-tuning is still in progress. I’ll report once the rover reliably drives from room to room.
What I learned
- Calibration is everything: an error of 5 cm in the camera position or 4 % in the depth scale is enough for the rover to fail at a door.
- Time matters: if the Jetson’s clock jumps at boot, strange things break in ROS (see post #5).
- Measure, don’t guess: when there were problems I recorded drive commands, steering angles and odometry with
rosbagand analysed them. Only the numbers showed why the steering was twitching.
What’s next?
Next up: reliable drives through doors, the garden (Wi-Fi coverage, grass as floor) and a separate post on the electronics, which grew organically on my rover and can certainly be done more simply.
[Image/video: rover driving autonomously through the door]