Skip to content

wattanatum/unknown_robot2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

unknown_robot2

Unknown robot tf

unknown_robot2 is a ROS 2 mobile robot project for simulation, SLAM, localization, and autonomous navigation using Nav2.

This project contains the robot description, Gazebo simulation files, navigation configuration, maps, launch files, and RViz setup for a custom differential-drive mobile robot.

What Can You Do With It?

  • Simulate a custom mobile robot in Gazebo
  • Visualize robot model, TF, laser scan, odometry, and map in RViz2
  • Build a map using SLAM Toolbox
  • Navigate autonomously using Nav2
  • Test global planner and local planner behavior
  • Tune costmaps, inflation layer, controller, and planner parameters

Features

  • ROS 2 Jazzy / Ubuntu 24.04 support
  • Gazebo simulation
  • Differential-drive robot model
  • LiDAR sensor support
  • Camera sensor support
  • IMU support
  • SLAM Toolbox mapping
  • Nav2 autonomous navigation
  • AMCL localization
  • RViz2 visualization

Workspace Structure

unknown_robot2_ws/
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
└── src
    β”œβ”€β”€ unknown_robot2_bringup
    β”‚Β Β  β”œβ”€β”€ LICENSE
    β”‚Β Β  β”œβ”€β”€ package.xml
    β”‚Β Β  β”œβ”€β”€ resource
    β”‚Β Β  β”‚Β Β  └── unknown_robot2_bringup
    β”‚Β Β  β”œβ”€β”€ setup.cfg
    β”‚Β Β  β”œβ”€β”€ setup.py
    β”‚Β Β  β”œβ”€β”€ test
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test_copyright.py
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test_flake8.py
    β”‚Β Β  β”‚Β Β  └── test_pep257.py
    β”‚Β Β  └── unknown_robot2_bringup
    β”‚Β Β      └── __init__.py
    β”œβ”€β”€ unknown_robot2_description
    β”‚Β Β  β”œβ”€β”€ CMakeLists.txt
    β”‚Β Β  β”œβ”€β”€ include
    β”‚Β Β  β”‚Β Β  └── unknown_robot2_description
    β”‚Β Β  β”œβ”€β”€ launch
    β”‚Β Β  β”‚Β Β  └── display.launch.py
    β”‚Β Β  β”œβ”€β”€ LICENSE
    β”‚Β Β  β”œβ”€β”€ media
    β”‚Β Β  β”‚Β Β  └── materials
    β”‚Β Β  β”œβ”€β”€ meshes
    β”‚Β Β  β”œβ”€β”€ package.xml
    β”‚Β Β  β”œβ”€β”€ rviz
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ nav2_test.rviz
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ odom_test.rviz
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ slam_toolbox_test.rviz
    β”‚Β Β  β”‚Β Β  └── unknown_robot2.rviz
    β”‚Β Β  β”œβ”€β”€ src
    β”‚Β Β  └── urdf
    β”‚Β Β      └── unknown_robot2.urdf.xacro
    β”œβ”€β”€ unknown_robot2_gazebo
    β”‚Β Β  β”œβ”€β”€ config
    β”‚Β Β  β”‚Β Β  └── empty_world.config
    β”‚Β Β  β”œβ”€β”€ launch
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ empty_gazebo.launch.py
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ gazebo.launch.py
    β”‚Β Β  β”‚Β Β  └── gz_slam_world.launch.py
    β”‚Β Β  β”œβ”€β”€ LICENSE
    β”‚Β Β  β”œβ”€β”€ package.xml
    β”‚Β Β  β”œβ”€β”€ resource
    β”‚Β Β  β”‚Β Β  └── unknown_robot2_gazebo
    β”‚Β Β  β”œβ”€β”€ setup.cfg
    β”‚Β Β  β”œβ”€β”€ setup.py
    β”‚Β Β  β”œβ”€β”€ test
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test_copyright.py
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ test_flake8.py
    β”‚Β Β  β”‚Β Β  └── test_pep257.py
    β”‚Β Β  β”œβ”€β”€ unknown_robot2_gazebo
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ __init__.py
    β”‚Β Β  β”‚Β Β  └── odom_to_tf.py
    β”‚Β Β  └── worlds
    β”‚Β Β      β”œβ”€β”€ auto_test_world.sdf
    β”‚Β Β      └── empty.sdf
    └── unknown_robot2_navigation
        β”œβ”€β”€ behavior_trees
        β”‚Β Β  └── nav_to_pose_clear_costmap.xml
        β”œβ”€β”€ config
        β”‚Β Β  β”œβ”€β”€ nav2_map_params.yaml
        β”‚Β Β  └── nav2_slam_params.yaml
        β”œβ”€β”€ launch
        β”‚Β Β  β”œβ”€β”€ nav2_map.launch.py
        β”‚Β Β  └── nav2_slam.launch.py
        β”œβ”€β”€ LICENSE
        β”œβ”€β”€ maps
        β”‚Β Β  β”œβ”€β”€ auto_test_map.pgm
        β”‚Β Β  └── auto_test_map.yaml
        β”œβ”€β”€ package.xml
        β”œβ”€β”€ resource
        β”‚Β Β  └── unknown_robot2_navigation
        β”œβ”€β”€ setup.cfg
        β”œβ”€β”€ setup.py
        β”œβ”€β”€ test
        β”‚Β Β  β”œβ”€β”€ test_copyright.py
        β”‚Β Β  β”œβ”€β”€ test_flake8.py
        β”‚Β Β  └── test_pep257.py
        └── unknown_robot2_navigation
            └── __init__.py

Requirements

  • Ubuntu 24.04
  • ROS 2 Jazzy
  • Gazebo Harmonic
  • Nav2
  • SLAM Toolbox
  • RViz2
  • ros_gz bridge packages

Install common dependencies:

sudo apt update

sudo apt install -y \
  ros-jazzy-ros-gz-bridge \
  ros-jazzy-ros-gz-sim \
  ros-jazzy-slam-toolbox \
  ros-jazzy-navigation2 \
  ros-jazzy-nav2-bringup \
  ros-jazzy-tf2-ros \
  ros-jazzy-tf2-tools \
  ros-jazzy-rviz2 \
  ros-jazzy-nav-msgs \
  ros-jazzy-geometry-msgs \
  ros-jazzy-sensor-msgs \
  ros-jazzy-tf2-msgs \
  python3-colcon-common-extensions \
  python3-rosdep \
  python3-venv \
  python3-pip

Installation

Clone the repository:

cd ~
git clone git@github.com:wattanatum/unknown_robot2.git unknown_robot2_ws
cd unknown_robot2_ws

Install dependencies:

rosdep update
rosdep install --from-paths src -y --ignore-src

Build the workspace:

colcon build --symlink-install

Source the workspace:

source install/setup.bash

Optional: add to .bashrc:

echo "source ~/unknown_robot2_ws/install/setup.bash" >> ~/.bashrc
source ~/.bashrc

Quickstart

Check robot TF

ros2 launch unknown_robot2_description display.launch.py

SLAM Toolbox Mapping

Unknown robot tf

Terminal 1: Launch Gazebo Simulation

ros2 launch unknown_robot2_gazebo gazebo.launch.py 

Terminal 2: Launch SLAM Mapping

ros2 launch slam_toolbox online_async_launch.py use_sim_time:=true

Terminal 3: Launch nav2 for move and avoid obstacle whlie mapping

ros2 launch unknown_robot2_navigation nav2_slam.launch.py

Terminal 4: Run RViz2

rviz2

Open RViz2 config in this path:

~/unknown_robot2_ws/src/unknown_robot2_description/rviz2/slam_toolbox_test.rviz

5. Save Map

ros2 run nav2_map_server map_saver_cli \
  -f ~/unknown_robot2_ws/src/unknown_robot2_navigation/maps/auto_test_map

Navigation with Saved Map

Unknown robot nav2

Terminal 1: Launch Gazebo Simulation

ros2 launch unknown_robot2_gazebo gazebo.launch.py 

Terminal 2: Launch nav2 with saved map

ros2 launch unknown_robot2_navigation nav2_map.launch.py

Terminal 3: Run RViz2

rviz2

Open RViz2 config in this path:

~/unknown_robot2_ws/src/unknown_robot2_description/rviz2/nav2_test.rviz

Important ROS 2 Topics

Topic Description
/cmd_vel Robot velocity command
/odom Odometry data
/scan LiDAR scan
/imu IMU data
/tf Dynamic transforms
/tf_static Static transforms
/map Occupancy grid map
/goal_pose Navigation goal pose

Navigation Stack

This project uses Nav2 for autonomous navigation.

Main Nav2 components:

  • Planner Server
  • Controller Server
  • Behavior Tree Navigator
  • AMCL
  • Map Server
  • Global Costmap
  • Local Costmap
  • Recovery Behaviors
  • Velocity Smoother

Costmap Tuning

Inflation layer example:

inflation_layer:
  plugin: nav2_costmap_2d::InflationLayer
  inflation_radius: 0.25
  cost_scaling_factor: 3.0

Lower inflation_radius reduces the obstacle safety area.

Higher cost_scaling_factor makes obstacle cost drop faster.

Build Again After Editing Code

cd ~/unknown_robot2_ws
colcon build --symlink-install
source install/setup.bash

Troubleshooting

Robot does not move

Check:

ros2 topic echo /cmd_vel
ros2 topic echo /odom
ros2 run tf2_tools view_frames

No map in RViz2

Check:

ros2 topic list | grep map
ros2 topic echo /map --once

No LiDAR scan

Check:

ros2 topic echo /scan

TF problem

Check:

ros2 run tf2_ros tf2_echo odom base_link

Author

Kasiphat Uppaphak
GitHub: wattanatum

About

Unknown Robot 2 is a ROS 2 autonomous mobile robot platform designed for simulation, mapping, localization, and navigation using Gazebo, Nav2, SLAM Toolbox, and custom robot bringup packages.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors