Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Robotics & DIY

ROS (Robot Operating System): Getting Started on Raspberry Pi

ROS (Robot Operating System): Getting Started on Raspberry Pi

March 11, 2026 /Posted byJayesh Jain / 0

The ROS robot operating system Raspberry Pi combination has become one of the most popular platforms for robotics enthusiasts and researchers in India. Whether you are a student at IIT, a hobbyist building your first autonomous robot, or a startup prototyping a commercial product, ROS on Raspberry Pi offers a powerful yet affordable path into professional robotics development. This guide walks you through setting up ROS, understanding its core concepts, and building your first robot application.

Table of Contents

  • What is ROS and Why Use It?
  • Hardware Requirements for ROS on Raspberry Pi
  • Installing ROS on Raspberry Pi
  • ROS Core Concepts: Nodes, Topics & Messages
  • Building Your First ROS Robot
  • Integrating Sensors with ROS
  • Frequently Asked Questions

What is ROS and Why Use It?

ROS (Robot Operating System) is not actually an operating system — it is a flexible middleware framework for writing robot software. Originally developed at Stanford University and maintained by Open Robotics, ROS provides a collection of tools, libraries, and conventions that simplify the complex task of creating robust robot behaviour across a wide variety of robot platforms.

For Indian makers, ROS offers several compelling advantages. It is completely free and open source. The ROS ecosystem includes thousands of pre-built packages for navigation, perception, manipulation, and simulation. Companies like ISRO, Tata Motors, and numerous IIT robotics labs use ROS in production. Learning ROS opens doors to internships and careers at top robotics companies.

ROS provides a publish-subscribe messaging architecture that allows different parts of your robot software to communicate without tight coupling. A camera node can publish images, a perception node can subscribe to those images and publish detected objects, and a navigation node can use those objects to plan paths — all running on different processes or even different computers.

Recommended: Waveshare AlphaBot2 Robot Kit for Raspberry Pi — A complete robot platform with motors, sensors, and camera support, ideal for learning ROS on Raspberry Pi.

Hardware Requirements for ROS on Raspberry Pi

ROS has specific hardware requirements that you need to plan for carefully, especially when working with the resource-constrained Raspberry Pi.

Recommended Raspberry Pi Models:

  • Raspberry Pi 4B (4GB or 8GB RAM) — Strongly recommended for ROS2. Handles simultaneous navigation, perception, and communication without breaking a sweat.
  • Raspberry Pi 4B (2GB RAM) — Adequate for ROS1 Noetic with basic sensors. May struggle with simultaneous camera processing and navigation.
  • Raspberry Pi 3B+ — Can run ROS1 but performance will be limited. Consider offloading heavy computation to a laptop via rosbridge.

Additional Hardware Needed:

  • MicroSD card 32GB minimum (Class 10 / A2 rating) — ROS installation takes approximately 2-4GB
  • 5V 3A USB-C power supply (Pi 4) — Insufficient power causes random crashes during ROS operation
  • Active cooling (heatsink + fan) — ROS tasks can sustain 100% CPU for extended periods
  • Robot chassis with motors and wheels
  • Motor driver board (L298N or TB6612FNG)
  • Optional: LIDAR, camera, IMU, ultrasonic sensors
Recommended: Waveshare General Driver Board for Robots (ESP32) — Excellent companion board for Raspberry Pi ROS robots, handling low-level motor control via ESP32 while Pi runs ROS.

Installing ROS on Raspberry Pi

The recommended approach in 2026 is to install ROS2 Humble Hawksbill on Ubuntu 22.04 Server (64-bit) for Raspberry Pi 4. ROS1 Noetic reaches end-of-life in May 2025, making ROS2 the future-proof choice.

Step 1: Flash Ubuntu 22.04 to SD Card

# On your laptop, download Raspberry Pi Imager
# Select: Ubuntu Server 22.04.x LTS (64-bit)
# Flash to microSD card
# Boot and complete initial setup

Step 2: Install ROS2 Humble

# Set locale
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8

# Add ROS2 apt repository
sudo apt install -y software-properties-common curl
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key 
  -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] 
  http://packages.ros.org/ros2/ubuntu jammy main" | 
  sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

# Install ROS2 Humble (base install for Pi, saves space)
sudo apt update && sudo apt install -y ros-humble-ros-base python3-colcon-common-extensions

# Source ROS2 in every terminal
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
source ~/.bashrc

Step 3: Test Your Installation

# Terminal 1: Run a talker
ros2 run demo_nodes_cpp talker

# Terminal 2: Run a listener
ros2 run demo_nodes_cpp listener

# You should see: [INFO] [talker]: Publishing: 'Hello World: 1'

Step 4: Install Robot-Specific Packages

# Navigation stack
sudo apt install -y ros-humble-navigation2 ros-humble-nav2-bringup

# Robot state publisher
sudo apt install -y ros-humble-robot-state-publisher

# Teleop for keyboard control
sudo apt install -y ros-humble-teleop-twist-keyboard

ROS Core Concepts: Nodes, Topics & Messages

Understanding the ROS communication model is essential before building any robot. ROS uses a graph-based architecture where computation happens in nodes that communicate via topics, services, and actions.

Nodes: A node is a single process that performs computation. Your robot might have a motor_controller node, a sensor_reader node, and a navigation node — all running simultaneously. Nodes are the basic unit of ROS computation.

Topics: Topics are named buses over which nodes exchange messages. A node can publish data to a topic or subscribe to receive data. Topics are asynchronous — the publisher does not wait for subscribers.

Messages: ROS defines standard message types for common data: sensor_msgs/LaserScan for LIDAR, sensor_msgs/Image for cameras, geometry_msgs/Twist for velocity commands, and many more. You can also define custom message types.

# List all active topics
ros2 topic list

# See what a topic is publishing
ros2 topic echo /cmd_vel

# Manually publish a velocity command (move forward at 0.2 m/s)
ros2 topic pub /cmd_vel geometry_msgs/msg/Twist 
  "{linear: {x: 0.2, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.0}}"

Launch Files: In ROS2, launch files (Python-based) start multiple nodes simultaneously with configured parameters. A typical robot launch file starts the robot description, motor controller, sensor drivers, and navigation stack all at once.

# Example ROS2 launch file: my_robot_launch.py
from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    return LaunchDescription([
        Node(
            package='my_robot',
            executable='motor_controller',
            name='motor_controller'
        ),
        Node(
            package='my_robot',
            executable='sensor_publisher',
            name='sensor_publisher'
        ),
    ])

Building Your First ROS Robot

Let us build a simple differential drive robot that you can control with a keyboard. This project uses a Raspberry Pi 4, a motor driver, and two DC motors.

Create a ROS2 Package

# Create workspace
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src

# Create package
ros2 pkg create --build-type ament_python my_robot
cd ~/ros2_ws
colcon build
source install/setup.bash

Motor Controller Node (Python)

#!/usr/bin/env python3
# my_robot/motor_controller.py
import rclpy
from rclpy.node import Node
from geometry_msgs.msg import Twist
import RPi.GPIO as GPIO

class MotorController(Node):
    def __init__(self):
        super().__init__('motor_controller')
        # L298N motor driver pins (BCM numbering)
        self.LEFT_IN1, self.LEFT_IN2 = 17, 18
        self.RIGHT_IN1, self.RIGHT_IN2 = 22, 23
        self.LEFT_EN, self.RIGHT_EN = 12, 13
        
        GPIO.setmode(GPIO.BCM)
        for pin in [self.LEFT_IN1, self.LEFT_IN2, 
                    self.RIGHT_IN1, self.RIGHT_IN2]:
            GPIO.setup(pin, GPIO.OUT)
        
        self.subscription = self.create_subscription(
            Twist, '/cmd_vel', self.cmd_vel_callback, 10)
    
    def cmd_vel_callback(self, msg):
        linear = msg.linear.x
        angular = msg.angular.z
        
        left_speed = linear - angular
        right_speed = linear + angular
        
        self.set_motor(self.LEFT_IN1, self.LEFT_IN2, left_speed)
        self.set_motor(self.RIGHT_IN1, self.RIGHT_IN2, right_speed)
    
    def set_motor(self, in1, in2, speed):
        if speed > 0:
            GPIO.output(in1, GPIO.HIGH)
            GPIO.output(in2, GPIO.LOW)
        elif speed < 0:
            GPIO.output(in1, GPIO.LOW)
            GPIO.output(in2, GPIO.HIGH)
        else:
            GPIO.output(in1, GPIO.LOW)
            GPIO.output(in2, GPIO.LOW)

def main():
    rclpy.init()
    node = MotorController()
    rclpy.spin(node)
    GPIO.cleanup()
    rclpy.shutdown()

if __name__ == '__main__':
    main()
Recommended: Waveshare Servo Driver HAT for Raspberry Pi (16-Channel I2C) — Provides 16-channel PWM output for controlling servos and motor drivers from Raspberry Pi via I2C, perfect for ROS robot builds.

Integrating Sensors with ROS

Sensors are what make robots intelligent. ROS provides standard drivers for most common sensors used in hobby and research robotics.

Ultrasonic Sensor (HC-SR04):

# Custom ROS2 node for HC-SR04
import RPi.GPIO as GPIO
from sensor_msgs.msg import Range
import time

# Publish Range message on /ultrasonic topic
range_msg = Range()
range_msg.header.frame_id = 'ultrasonic_link'
range_msg.radiation_type = Range.ULTRASOUND
range_msg.min_range = 0.02
range_msg.max_range = 4.0
range_msg.range = measured_distance  # in metres

IMU (MPU6050): The MPU6050 provides 6-DOF motion data. Install the ros2-mpu6050-driver package or use the I2C interface directly. Publish to /imu/data using sensor_msgs/Imu message type.

LIDAR: The RPLidar A1 has excellent ROS2 support. Install with sudo apt install ros-humble-rplidar-ros and launch with the provided launch file. Data appears on the /scan topic as sensor_msgs/LaserScan.

Camera:

# Install camera driver
sudo apt install -y ros-humble-v4l2-camera

# Launch camera node
ros2 run v4l2_camera v4l2_camera_node --ros-args -p image_size:=[640,480]
Recommended: Waveshare ESP32 Servo Driver Expansion Board — Combine with Raspberry Pi for distributed robotics: ESP32 handles real-time motor/servo control while Pi runs ROS navigation stack.

Visualising with RViz2: Run RViz2 on your laptop and connect to the Raspberry Pi remotely to visualise sensor data, robot state, and navigation paths:

# Set ROS_DOMAIN_ID on both Pi and laptop (same network)
export ROS_DOMAIN_ID=42

# On laptop (Ubuntu), launch RViz2
ros2 run rviz2 rviz2
Recommended: ACEBOTT ESP8266 Quadruped Bionic Spider Robot Kit — A great learning platform for understanding robot kinematics before diving into ROS, complete with pre-written code.

Frequently Asked Questions

Can I run ROS on Raspberry Pi Zero?

Technically yes, but it is not practical. The Pi Zero has only 512MB RAM and a single-core processor. Even basic ROS nodes will struggle. Use at minimum a Raspberry Pi 3A+ for simple ROS applications, and a Pi 4 for navigation or vision tasks.

What is the difference between ROS1 and ROS2?

ROS1 (Noetic is the last LTS) uses a centralised roscore master. ROS2 uses DDS (Data Distribution Service) for decentralised, real-time communication — no single point of failure. ROS2 also has better security, real-time support, and is the future of the ROS ecosystem. New projects should use ROS2.

How do I control a ROS robot over WiFi from my laptop?

In ROS2, set the same ROS_DOMAIN_ID on both devices connected to the same WiFi network. ROS2 uses DDS multicast discovery, so nodes on different machines automatically discover each other. No additional configuration needed for basic setups.

Can I use ROS with Arduino?

Yes! Use micro-ROS to run ROS2 directly on Arduino (with sufficient RAM) or use rosserial with ROS1. A common architecture is to use Arduino for real-time low-level control (motors, encoders) connected to Raspberry Pi (running ROS) via USB serial.

How much does it cost to build a basic ROS robot in India?

A basic ROS robot in India typically costs between ₹8,000-₹20,000 depending on components. Raspberry Pi 4B (2GB): ~₹5,000-6,000, robot chassis with motors: ~₹800-2,000, motor driver: ~₹200-500, sensors: ~₹500-2,000, power bank or LiPo: ~₹500-1,500.

Shop Robotics & Automation at Zbotic →

Tags: Raspberry Pi, robot operating system, Robotics, ROS, ROS2
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
test
blog test 597930
blog mini hydro power system for rural india pelton wheel guide 597944
Mini Hydro Power System for Ru...

Related posts

Svg%3E
Read more

Caterpillar Track Robot: Tank-Drive Build for All Terrain

April 1, 2026 0
When wheels lose grip on sand, gravel, grass, or loose surfaces, caterpillar tracks keep moving. A tank-track robot distributes its... Continue reading
Svg%3E
Read more

RC Car to Robot: Convert a Toy Car into an Autonomous Robot

April 1, 2026 0
That old RC toy car gathering dust can be transformed into an Arduino-controlled autonomous robot with just a few electronic... Continue reading
Svg%3E
Read more

Robotic Arm Kit India: Best Options for Students and Hobbyists

April 1, 2026 0
If you are a student or hobbyist looking to get into robotics, a robotic arm kit is one of the... Continue reading
Svg%3E
Read more

Sumo Robot: Competition Build Guide India

April 1, 2026 0
Sumo robot competitions are among the most exciting events in Indian robotics, pitting small autonomous robots against each other in... Continue reading
Svg%3E
Read more

Robot Arm Build: 6-DOF Servo Arm with Arduino Control

April 1, 2026 0
Building a 6-DOF robot arm with servo motors and Arduino is one of the most rewarding robotics projects you can... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now