This repository contains a ROS2 package that allows you to control a simulated TurtleBot3 using a web interface. The system uses FastAPI to handle communication between the web application and ROS2, with a ROS2 Bridge script interfacing with Nav2 to set goals and start navigation.
The system consists of four main components:
- Web Application (Frontend)
- FastAPI Backend
- ROS2 Bridge
- TurtleBot3 Simulation
- A simple HTML/JavaScript application
- Allows users to input X, Y, theta values for the 2D Pose Goal
- Provides buttons to set navigation goal and start navigation
- Communicates with the FastAPI backend
- Handles HTTP requests from the web application
- Processes the navigation goals
- Communicates with the ROS2 Bridge
- A Python script that interfaces between FastAPI and ROS2
- Uses rclpy to create ROS2 nodes and interact with Nav2
- Uses the default turtlebot3_world
- Controlled by Nav2
ros2_ws/
└── src/
└── turtlebot3_web_nav/
├── turtlebot3_web_nav/
│ ├── __init__.py
│ └── ros2_bridge.py
├── web_app/
│ ├── index.html
│ ├── style.css
│ └── script.js
├── backend/
│ ├── main.py
│ └── requirements.txt
├── launch/
│ └── web_nav_launch.py
├── resource/
│ └── turtlebot3_web_nav
├── test/
│ └── test_copyright.py
├── setup.py
├── setup.cfg
└── package.xml
This script creates a ROS2 node that interfaces with Nav2. It provides functionality to:
- Set navigation goals
- Start navigation
- Handle goal responses and results
The FastAPI application handles HTTP requests from the web interface. It provides two main endpoints:
/set_goal
: Sets a new navigation goal/start_navigation
: Initiates the navigation process
The web interface allows users to:
- Input X, Y, and theta values for the navigation goal
- Set the navigation goal
- Start the navigation process
This file configures the ROS2 package, including:
- Package name and version
- Dependencies
- Entry points for ROS2 nodes
- Clone this repository into your ROS2 workspace.
- Build the package using
colcon build
. - Source your ROS2 workspace.
- Launch the TurtleBot3 simulation (not included in this package).
- Run the ROS2 bridge node.
- Start the FastAPI backend.
- Open the web application in a browser.
- ROS2 (tested with Humble)
- Nav2
- FastAPI
- Uvicorn
- TurtleBot3 packages
Contributions to improve the functionality or documentation of this package are welcome. Please feel free to submit issues or pull requests.
[Insert your chosen license here]
This project was inspired by the need for an easy-to-use web interface for controlling TurtleBot3 in ROS2 simulations.