The TurtleBot 4 Lite is a powerful ROS2-based mobile robot platform that's perfect for learning robotics, research, and development. By integrating Viam with your TurtleBot, you can unlock powerful remote control capabilities, cloud-based data management, and seamless integration with modern robotics workflows.
In this codelab, we'll transform your TurtleBot 4 Lite into a cloud-connected robot that you can control from anywhere and automatically capture sensor data for analysis and machine learning applications.
What You'll Build
A remotely controllable TurtleBot 4 Lite accessible from the Viam web interface, mobile app, and SDKs
Automated data capture and syncing from camera and status sensors
Real-time streaming of robot logs
Prerequisites
A TurtleBot 4 Lite with ROS2 pre-installed (Humble or Jazzy)
SSH access to the TurtleBot's onboard Raspberry Pi 4
Basic familiarity with ROS2 concepts (topics, nodes, messages)
A computer with network access to your TurtleBot
Sign up for a free Viam account, and then sign in to the Viam app
What You'll Learn
How to prepare a TurtleBot 4 Lite for Viam integration
Save and exit the file (Ctrl + X, then Y, then Enter).
Verify ROS2 functionality
Source the ROS2 environment:
source /opt/ros/humble/setup.bash # or /opt/ros/jazzy/setup.bash
source /etc/turtlebot4/setup.bash
Check that ROS2 topics are available:
ros2 topic list
You should see topics like /viamrostwo/cmd_vel, /viamrostwo/scan, etc.
Your TurtleBot is now ready for Viam integration!
Create your machine in Viam
In the Viam app under the LOCATIONS tab, create a machine by typing in a name like "ros-two" and clicking Add machine.
Click View setup instructions.
Select the Linux / Aarch64 platform for the Raspberry Pi, and leave your installation method as viam-agent.
Use the viam-agent to download and install viam-server on your TurtleBot. Follow the instructions to run the command provided in the setup instructions from the SSH prompt of your TurtleBot.
The setup page will indicate when the machine is successfully connected.
Now we'll configure the individual components that make up your TurtleBot system.
Configure the base component
The base component will allow you to control the TurtleBot's movement.
Click the + icon in the left-hand menu and select Component or service.
Select base, then search for "ros" and select the viam-soleng:ros2:base model.
When prompted for the viam-soleng:viam-ros2-integration module, click Add module.
Click on the JSON tab in the left sidebar above your machine name to display the full configuration JSON for your machine.
Configure the viam-soleng:viam-ros2-integration module environment variables by adding an env field with the relevant config, which should look like the following:
Notice adding this service adds the data manager service called datacapture. It will default to the "Capturing" and "Syncing" toggles as enabled.
In the "Additional paths" field of the Cloud sync section, type /opt/rosbags and hit the Enter key to also sync your rosbag files.
Click Save in the top right. This may take a moment to apply your configuration changes.
Configure camera data capture
Navigate to your roscamera component.
In the Data capture section, click Add method.
Configure the capture settings:
Method: GetImage
Frequency (hz): 0.1 (capture one image every 10 seconds)
MIME type: image/jpeg
Configure sensor data capture
Navigate to your battery_state component.
In the Data capture section, click Add method.
Configure:
Method: Readings
Frequency (hz): 0.5 (capture every 30 seconds)
Repeat the same process for dock_status and wheel_status sensors with the same frequency.
Verify data capture configuration
Click Save to apply all configurations.
Navigate to the CONTROL tab to verify all components are working.
Check that your camera shows a live feed and sensors display current readings.
Your TurtleBot will now automatically capture and sync data to the Viam cloud!
The ROS2 logger service will stream your robot's debug logs directly to Viam for real-time monitoring.
Add the ROS2 logger service
Click the + icon in the left-hand menu and select Component or Service.
Search for ros2_logger and select the viam-soleng:ros2:logger model.
Name it ros2_logger and click Create.
In the Attributes section, configure:
{
"ros_topic": "/rosout",
"log_level": "debug"
}
Test the logger service
Click Save to apply the configuration.
Navigate to the LOGS tab in the Viam app.
You should start seeing ROS2 log messages appearing in the Viam logs interface.
The logger service will now stream all ROS2 system messages with "debug" level and above directly to Viam for easy monitoring and debugging.
Now comes the exciting part - controlling your TurtleBot from anywhere using the Viam web interface!
Test basic movement
Navigate to the CONTROL tab in the Viam app.
Find your rosbase component card.
Use the Quick move buttons to test basic movements:
Click Forward to move the robot forward
Click Backward to move the robot backward
Click Left and Right to turn the robot
Enable keyboard control
In the base component control card, toggle Keyboard control to ON.
Now you can use your computer's keyboard to drive the TurtleBot:
W or ↑: Move forward
S or ↓: Move backward
A or ←: Turn left
D or →: Turn right
Test advanced movements
Try the Move straight function:
Set distance (in mm) and velocity
Click Execute to move a precise distance
Monitor live camera feed
Scroll to your roscamera component.
Set the refresh dropdown to "Live" to see the live camera feed from your TurtleBot.
You can now see what your robot sees while driving it remotely!
Your TurtleBot is now fully controllable from Viam.
Let's explore the data your TurtleBot has been automatically capturing and syncing to the cloud.
Access the data tab
In the Viam app, click on the document icon in the top-right of the machine configuration page to view captured data.
You'll see Images section by default to view photos captured by your TurtleBot's camera.
You can:
View individual images with timestamps
Filter by date range
Search by tags
Annotate for machine learning training
Review sensor data
Click on the Sensors section to view captured sensor readings.
You'll see data from:
Battery status (charge level, voltage, temperature)
Dock status (whether robot is docked)
Wheel status (motor health and performance)
Data is displayed in a JSON format and can be queried using SQL or MQL by clicking on the "Query" in the top-right of your machine card.
Your TurtleBot's data is now safely stored in the cloud and ready for analysis!
Congratulations! 🎉 You've successfully transformed your TurtleBot 4 Lite into a cloud-connected, remotely controllable robot with automated data capture capabilities.
The combination of TurtleBot's robust hardware platform, ROS2's flexible software ecosystem, and Viam's cloud-native robotics tools provides an incredibly powerful foundation for your robotics projects.
What You've Accomplished
Remote Control: Your TurtleBot can now be operated from anywhere via the Viam web interface
Data Collection: Automated capture of camera images and sensor readings with cloud sync
Real-time Monitoring: Live streaming of ROS2 logs and robot telemetry
Cloud Integration: Seamless data storage and access through Viam's platform
Expanding Your Robot's Capabilities
Now that you have the foundation in place, consider these exciting next steps:
Computer Vision & AI
Add object detection models to identify and track people or objects
Train custom machine learning models using your captured image data
Advanced Sensors
Integrate the TurtleBot's lidar for mapping and obstacle avoidance
Add the IMU sensor for better motion tracking and stability
Automation & Scheduling
Set up alerts based on sensor thresholds (low battery, obstacles, etc.)
Build custom workflows that respond to specific conditions
Fleet Management
Scale to multiple TurtleBots for coordinated tasks
Implement centralized monitoring and control
Share data and models across your robot fleet
Real-World Applications
Your enhanced TurtleBot setup opens doors to numerous practical applications:
Security & Surveillance: Automated security patrols with real-time alerts
Research & Education: Data collection for robotics research and classroom demos
Facility Monitoring: Regular inspections of warehouses, offices, or outdoor spaces
Environmental Sensing: Mobile data collection for IoT and environmental studies