Skip to content

A ROS2 Humble–based autonomous robot navigation system demonstrating node-based architecture, topic communication, and reactive obstacle avoidance using Python.

Notifications You must be signed in to change notification settings

aruleshrobotics-amhy/robot-navigation-ros2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ROS2 Autonomous Robot Navigation (Humble)

This project implements a ROS2 Humble–based autonomous robot navigation system using Python (rclpy). It demonstrates a real-world robotics software architecture where sensing, decision-making, and execution are separated into independent ROS2 nodes that communicate via topics.

The project focuses on ROS2 fundamentals, node-based design, and middleware communication, without using Gazebo or RViz.

🎯 Project Objective

Understand ROS2 architecture deeply

Implement publisher–subscriber communication

Separate robot software into logical nodes

Simulate an autonomous navigation pipeline

Build interview-ready, industry-aligned robotics software

🧠 System Architecture

sensor_node → /obstacle_distance → controller_node → /cmd_move → robot_node

Node Responsibilities

1️⃣ sensor_node (Perception Layer)

Simulates an ultrasonic sensor

Publishes distance values periodically

Outputs fake distance data in meters

2️⃣ controller_node (Decision Layer)

Subscribes to distance data

Applies safety threshold logic

Decides whether the robot should MOVE or TURN

Publishes movement commands

3️⃣ robot_node (Execution Layer)

Subscribes to movement commands

Updates robot position and direction

Logs robot state continuously

This architecture mirrors real robotics middleware design used in autonomous systems.

🛠️ Technologies Used

ROS2 Humble

Python (rclpy)

Publisher–Subscriber communication

Standard ROS2 messages (std_msgs)

Linux / WSL environment

🗂️ Project Structure

robot_nav/

sensor_node.py — sensor data handling

controller_node.py — control logic

robot_node.py — main robot node

init.py

setup.py

package.xml

README.md

🚀 Project Creation Steps

1️⃣ Create ROS2 workspace (if not already created)

mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src

2️⃣ Create the ROS2 Python package

ros2 pkg create robot_nav --build-type ament_python

This creates the base ROS2 package structure.

3️⃣ Navigate to the source folder

cd robot_nav/robot_nav

4️⃣ Create node files

touch sensor_node.py
touch controller_node.py
touch robot_node.py

🧩 Node Implementation Summary

sensor_node.py

Publishes Float32 messages on /obstacle_distance

Uses a timer to publish data periodically

Simulates ultrasonic distance readings

controller_node.py

Subscribes to /obstacle_distance

Applies threshold logic

Publishes String commands (MOVE / TURN) on /cmd_move

robot_node.py

Subscribes to /cmd_move

Updates robot position (x, y)

Updates direction (N, E, S, W)

Logs robot state

⚙️ setup.py Configuration

The nodes are registered as executable scripts:

entry_points={
    'console_scripts': [
        'sensor_node = robot_nav.sensor_node:main',
        'controller_node = robot_nav.controller_node:main',
        'robot_node = robot_nav.robot_node:main',
    ],
},

This allows running nodes using ros2 run.

▶️ Build and Run Instructions

1️⃣ Build the workspace

cd ~/ros2_ws
colcon build

2️⃣ Source the workspace

source install/setup.bash

3️⃣ Run the nodes (use separate terminals)

Terminal 1 – Sensor Node

            ros2 run robot_nav sensor_node

Terminal 2 – Controller Node

            ros2 run robot_nav controller_node

Terminal 3 – Robot Node

            ros2 run robot_nav robot_node

📡 ROS2 Topics

List active topics:

ros2 topic list

Expected topics:

/obstacle_distance
/cmd_move

View live data:

ros2 topic echo /obstacle_distance
ros2 topic echo /cmd_move

📸 Sample Output

ROS2 Nodes Running

The system runs with:

Sensor node publishing distance values

Controller node deciding MOVE / TURN

Robot node updating position and direction

🔌 Mapping to Real Robotics Systems

Robotics Concept ROS2 Implementation
Ultrasonic sensor sensor_node
Control logic controller_node
Motor execution robot_node
Middleware ROS2 topics
Control loop ROS2 callbacks

⚠️ Limitations

Sensor data is simulated

Reactive navigation only

No global path planning

No visualization tools (Gazebo / RViz)

These limitations are intentional to focus on core ROS2 architecture.

🔮 Future Enhancements

ROS2 launch files

Integration with real sensors

Path planning algorithms (A*, BFS)

Visualization using RViz

Hardware integration (Arduino / micro-ROS)

👤 Author

Arulesh P P

Robotics Software Engineer

About

A ROS2 Humble–based autonomous robot navigation system demonstrating node-based architecture, topic communication, and reactive obstacle avoidance using Python.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages