Nav2 and Autonomous NavigationSeptember 05, 20257 min read

ROS 2 Dataset Guide: Foxglove, RViz, and TurtleBot3 SLAM

Step by step guide to ROS 2 datasets. Learn recording, replay, and visualization with Foxglove, RViz, and TurtleBot3 SLAM.

ROS 2 Dataset Guide: Foxglove, RViz, and TurtleBot3 SLAM

Share :

Quick answer

Step by step guide to ROS 2 datasets. Learn recording, replay, and visualization with Foxglove, RViz, and TurtleBot3 SLAM.

Quick Answer

Step by step guide to ROS 2 datasets. Learn recording, replay, and visualization with Foxglove, RViz, and TurtleBot3 SLAM.

Who This Is For

  • ROS 2 Learner
  • Mobile Robotics Student
  • Robotics Career Shifter

What You Will Learn

  • What Nav2 means in practical robotics.
  • How this topic connects to real robot projects.
  • What to learn or build next after this article.

When you start working with ROS 2 datasets, you quickly realize that handling real-world robotics data requires both structure and the right set of tools. Whether you're running a SLAM experiment, visualizing data in RViz, or testing algorithms with a TurtleBot3, datasets serve as the backbone of your robotics development workflow. In this blog, we'll walk through what ROS 2 datasets are, how they're used, and demonstrate with examples using Foxglove Studio, RViz, and TurtleBot3 SLAM. This guide will help you understand not just the "what" but also the "how" of working with robotics datasets in ROS 2.

What is a ROS 2 Dataset?

A ROS 2 dataset is a collection of recorded robotic data (e.g., lidar scans, odometry, IMU readings, images) that is stored in ROS bag files. These bag files allow developers to replay sensor data as if it were being produced by a real robot. Instead of relying solely on hardware, you can use datasets to test algorithms, validate mapping pipelines, or even train AI perception models. For example, a ROS 2 dataset might contain:

  • Laser scans (/scan)
  • Odometry (/odom)
  • IMU data (/imu)
  • Camera images (/camera/color/image_raw) This makes datasets a powerful tool for debugging, testing, and simulation.

Why Datasets are Critical in Robotics

Robotics involves uncertainty. Sensors are noisy, environments are dynamic, and algorithms often fail in ways you cannot predict in simulation. Datasets give you a repeatable way to test under identical conditions. Here's why they matter:

  1. Debugging algorithms- Replaying the same dataset helps find reproducible bugs.
  2. Benchmarking- Compare algorithm performance across different datasets.
  3. Training AI models- Labeled datasets can be used to train perception pipelines.
  4. Simulation to reality transfer- Test algorithms on real-world data without needing constant robot access. One of the most well-known public robotics datasets is KITTI, which provides raw sensor data from autonomous driving.

Setting Up a ROS 2 Dataset with Foxglove

Foxglove Studio is a modern visualization tool designed for robotics data. Unlike RViz, which is bundled with ROS, Foxglove can handle large datasets efficiently, making it ideal for replaying long SLAM or navigation runs.

Steps to Load a ROS 2 Dataset in Foxglove

  1. Install Foxglove Studio (official site).
  2. Open a recorded ROS bag file: ros2 bag play dataset_folder
  3. Connect Foxglove Studio to your ROS 2 session:
  • Open Foxglove Studio
  • Add a ROS connection (ROS 2 WebSocket Bridge)
  • Visualize topics such as /scan, /odom, or /camera. This workflow helps you inspect dataset contents visually, ensuring your data is consistent before plugging it into an algorithm.

Visualizing Datasets in RViz

RViz remains the go-to visualization tool for most ROS developers. It lets you view live or replayed sensor data in 3D.

Example: Visualizing Lidar and Odometry

Launch RViz: rviz2 Add a LaserScan display and select /scan. Add an Odometry display and select /odom. Replay the dataset: ros2 bag play dataset_folder You should now see lidar points and odometry traces updating in RViz as if the robot were moving in real-time.

Using Datasets with TurtleBot3 SLAM

The TurtleBot3 is one of the most popular educational robots in ROS 2. When paired with a dataset, it becomes a repeatable testbed for SLAM.

Example Workflow

Install TurtleBot3 packages: sudo apt install ros-humble-turtlebot3* Launch SLAM with TurtleBot3: ros2 launch turtlebot3_slam turtlebot3_slam.launch.py Replay dataset with lidar scans: ros2 bag play tb3_dataset Save generated map: ros2 run nav2_map_server map_saver_cli -f ~/map This process allows you to test mapping algorithms without physically driving the robot.

Example Code for Dataset Analysis

Sometimes you don't just want to visualize but also process datasets programmatically. ROS 2's Python API allows you to read topics from bag files.

Python Example: Reading Odometry and Lidar

import rclpy
from rclpy.node import Node
from sensor_msgs.msg import LaserScan
from nav_msgs.msg import Odometry
class DatasetReader(Node):
def __init__(self):
super().__init__('dataset_reader')
self.create_subscription(LaserScan, '/scan', self.lidar_callback, 10)
self.create_subscription(Odometry, '/odom', self.odom_callback, 10)
def lidar_callback(self, msg):
self.get_logger().info(f"Received {len(msg.ranges)} lidar points")
def odom_callback(self, msg):
x, y = msg.pose.pose.position.x, msg.pose.pose.position.y
self.get_logger().info(f"Odom position: ({x}, {y})")
rclpy.init()
node = DatasetReader()
rclpy.spin(node)

This simple script subscribes to /scan and /odom during dataset playback and logs key values.

Launch File Example for Automating Dataset Runs

Instead of manually launching multiple components, you can automate dataset playback with a launch file.

from launch import LaunchDescription
from launch_ros.actions import Node
def generate_launch_description():
return LaunchDescription([
Node(
package='rosbag2_transport',
executable='play',
arguments=['tb3_dataset'],
output='screen'
),
Node(
package='rviz2',
executable='rviz2',
output='screen'
)
])

This ensures that RViz starts automatically alongside dataset playback.

Common Mistakes When Using ROS 2 Datasets

  • Mismatched ROS versions - A dataset recorded in ROS 2 Humble may not replay smoothly in Galactic.
  • Missing TF transforms - Many datasets lack transformations, causing RViz visualizations to break.
  • Incorrect topic remapping - If your algorithm expects /scan, but dataset has /lidar_scan, you must remap topics. Example remap:
ros2 bag play dataset_folder --remap /lidar_scan:=/scan

Building Your Own Dataset

If you're working with TurtleBot3 or any ROS 2-enabled robot, recording your own dataset is straightforward:

ros2 bag record /scan /odom /imu /camera/color/image_raw

This records lidar, odometry, IMU, and camera topics into a dataset for later replay.

Future of ROS 2 Datasets

With the rise of AI and cloud robotics, datasets are moving beyond simple bag files. Developers now store datasets in cloud platforms, enabling distributed replay, multi-robot testing, and integration with ML pipelines. Tools like Foxglove Data Platform are making large-scale dataset management seamless.

Conclusion

ROS 2 datasets give developers the ability to test, validate, and train robotics systems without needing constant access to hardware. Whether using Foxglove Studio for visualization, RViz for debugging, or TurtleBot3 for SLAM experiments, datasets create a reproducible and efficient development pipeline. At Robotisim, we provide learning resources to help you bridge the gap from theory to practice in robotics using ROS 2 datasets. Explore more on our site to see how you can get hands-on with robotics today.

FAQs

**Q1: Which ROS 2 version should I start with?******A: ROS 2 Humble (Ubuntu 22.04) is currently the most stable release with long-term support, making it the best starting point.**Q2: Can I use ROS 2 datasets without owning a robot?******A: Yes. Public datasets like KITTI and EuRoC MAV let you replay lidar, camera, and IMU data directly in ROS 2, no hardware required.**Q3: What's the difference between RViz and Foxglove?******A: RViz is bundled with ROS and best for quick visualization. Foxglove provides a modern interface, handles large datasets, and supports multi-robot debugging.**Q4: Is TurtleBot3 good for beginners?******A: Absolutely. TurtleBot3 is affordable, well-supported in ROS 2, and widely used in SLAM, navigation, and dataset recording experiments.**Q5: How do I create my own ROS 2 dataset?******A: Use the ros2 bag record command to capture topics like /scan, /odom, and /camera while running your robot. This creates a bag file for future replay.

Practical Example

A practical way to use this article is to connect the concept to a small robot workflow: identify the input, the processing step, and the output you expect from the robot. If the article involves ROS 2, test the idea in a small workspace or simulation before applying it to a larger robot project.

Common Mistakes

  • Trying to memorize the term without connecting it to a robot behavior.
  • Skipping the prerequisite concepts that make the workflow easier to debug.
  • Copying commands or code without checking what each node, topic, file, or parameter is responsible for.
  • Treating one tutorial as a complete roadmap instead of linking it to the next concept.

How This Connects to Other Topics

  • How to Add Custom Libraries to a ROS 2 C++ Package
  • Robot Localization Guide: Indoor Pose Estimation with Encoder Odometry
  • Robot Starter Kit Guide: Choose the Right Beginner Robot Parts
  • ROS 2 SLAM Beginner Guide: Help Your Robot Draw Its First Floorplan
  • From STL to Autonomy: Building an Indoor Self-Driving Robot

Learn Next

  • How to Add Custom Libraries to a ROS 2 C++ Package
  • Robot Localization Guide: Indoor Pose Estimation with Encoder Odometry
  • Robot Starter Kit Guide: Choose the Right Beginner Robot Parts
  • ROS 2 SLAM Beginner Guide: Help Your Robot Draw Its First Floorplan
  • From STL to Autonomy: Building an Indoor Self-Driving Robot
  • Mobile Robotics Engineer Path

FAQ

Is ROS 2 Dataset Guide: Foxglove, RViz, and TurtleBot3 SLAM suitable for beginners?

Yes. The article is written to make the concept easier to understand, while still connecting it to practical robotics work.

What should I learn before this topic?

Start with the prerequisite ideas listed in the article, then connect them to a small project or simulation so the concept becomes concrete.

How does this topic connect to real robots?

It helps you understand how software, sensors, control, simulation, or career decisions show up in practical robot development.

What should I do after reading this article?

Pick one related concept from the Learn Next section and build a small example that uses it.

Can I learn this through Robotisim?

Yes. Robotisim connects these concepts to structured learning paths and project-based robotics practice.

Final Summary

ROS 2 Dataset Guide: Foxglove, RViz, and TurtleBot3 SLAM is part of the broader Nav2 and Autonomous Navigation learning path. The key is to understand the concept, connect it to a real robot workflow, and then practice it through a focused project instead of learning it in isolation.

Connected learning path

This article supports Mobile Robotics Engineer Path, especially Nav2.

Learn with Robotisim

Build a complete Nav2 robot inside Robotisim.

Explore the academy

Learn next

How to Add Custom Libraries to a ROS 2 C++ Package
Jun 02, 2024|8 min read

How to Add Custom Libraries to a ROS 2 C++ Package

Learn to add custom libraries to your ROS 2 C++ packages. Enhance your robotics projects with reusable code and streamline your development process!

Read more
Robot Localization Guide: Indoor Pose Estimation with Encoder Odometry
Oct 07, 2025|6 min read

Robot Localization Guide: Indoor Pose Estimation with Encoder Odometry

Understand robot localization using encoder odometry in C++. Learn how robots estimate pose indoors with equations, examples, and real world insights.

Read more
Robot Starter Kit Guide: Choose the Right Beginner Robot Parts
Jul 29, 2025|9 min read

Robot Starter Kit Guide: Choose the Right Beginner Robot Parts

Avoid overspending on the wrong parts. This guide walks you through building your first robot with a smart, affordable robot starter kit and key upgrade paths.

Read more
ROS 2 SLAM Beginner Guide: Help Your Robot Draw Its First Floorplan
Jun 07, 2025|8 min read

ROS 2 SLAM Beginner Guide: Help Your Robot Draw Its First Floorplan

Learn how to set up ROS 2 SLAM and map your robot's environment. A beginner friendly guide to launching SLAM with LiDAR, odometry, and ROS 2 navigation stack.

Read more