Giter Club home page Giter Club logo

ros2_explorer's Introduction

ROS 2 Turtlebot 3 Map Explorer

Description

In this repo we use Turtlebot 3 along with ROS 2 and Gazebo to explore an unknown csv environment, navigate through it and create a map.

The map is created using SLAM with the package Google Cartographer and navigation is achieved with Nav2 package. We have developed two exploring algorithyms:

Wanderer Exploration explores the map doing random turns when it detects an obstacle. It's a convenient way to explore small maps but time consuming for bigger ones.

Discoverer Exploration prioritizes specific unknown hotspots of the map convoluting the occupancy grid. It's a better way to explore bigger maps in exchange of a higher computational cost.

IMAGE ALT TEXT HERE

Installation (tested on Ubuntu 22.04 - ROS 2 Humble)

Install ROS2 Humble

Don't forget to install colcon:

sudo apt install python3-colcon-common-extensions

Install Gazebo:

sudo apt install gazebo

Install Python libraries:

sudo apt install python3-pip
pip3 install pandas

Create a ROS2 workspace:

mkdir -p ~/turtlebot3_ws/src
cd ~/turtlebot3_ws/src

Clone the repository:

git clone https://github.com/DaniGarciaLopez/ros2_explorer.git

Compile packages and get dependencies:

cd ~/turtlebot3_ws/src
sudo apt update && rosdep install -r --from-paths . --ignore-src --rosdistro $ROS_DISTRO -y

cd ~/turtlebot3_ws/
colcon build

Include the following lines in ~/.bashrc:

source /opt/ros/humble/local_setup.bash
source ~/turtlebot3_ws/install/local_setup.bash

export TURTLEBOT3_MODEL=burger
export GAZEBO_MODEL_PATH=~/turtlebot3_ws/src/ros2_explorer/explorer_gazebo/models

How to run

Execute the launch file and pass the map name (Opens Gazebo simulation, Rviz, Cartographer, Nav2 and exploration servers):

ros2 launch explorer_bringup explorer.launch.py map_name:=map10

Execute manager node and select the desired exploring algorithm:

ros2 run explorer_bringup manager

Add your own CSV Map

Add your own csv maps in this folder:

cd ~/turtlebot3_ws/src/ros2_explorer/explorer_gazebo/maps/

Run Python script:

cd ~/turtlebot3_ws/src/ros2_explorer/explorer_gazebo/
python3 gazebo-map-from-csv.py

Maps will be converted to Gazebo format in /explorer_gazebo/models folder. Create a new .world.xml file in /explorer_gazebo/worlds and modify the name of the map you want to use:

<include>
  <uri>model://map1</uri>
</include>

Package structure

image image

ros2_explorer's People

Contributors

browmy avatar danigarcialopez avatar kikefdezl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ros2_explorer's Issues

Invalid frame ID "map" passed to canTransform argument target_frame - frame does not exist

I have a problem when I launch the map.
I get this error:

[rviz2-7] Warning: Invalid frame ID "map" passed to canTransform argument target_frame - frame does not exist

[rviz2-7] at line 156 in /tmp/binarydeb/ros-galactic-tf2-0.17.4/src/buffer_core.cpp

What happens is that the robot goes straight and then it crashes on the wall as it was not "sensing it"

I've downloaded the package as said. I'm using ROS2 Galactic

Error after building. Amy idea how to resolve this? Thanks.

ros2 launch explorer_bringup map10.launch.py
[INFO] [launch]: All log files can be found below /home/chi/.ros/log/2021-07-05-21-25-01-637335-chi-49624
[INFO] [launch]: Default logging verbosity is set to INFO
Task exception was never retrieved
future: <Task finished name='Task-2' coro=<LaunchService._process_one_event() done, defined at /opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py:274> exception=InvalidLaunchFileError('py')>
Traceback (most recent call last):
File "/opt/ros/foxy/lib/python3.8/site-packages/ament_index_python/packages.py", line 49, in get_package_prefix
content, package_prefix = get_resource('packages', package_name)
File "/opt/ros/foxy/lib/python3.8/site-packages/ament_index_python/resources.py", line 48, in get_resource
raise LookupError(
LookupError: Could not find the resource 'turtlebot3_gazebo' of type 'packages'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/any_launch_file_utilities.py", line 53, in get_launch_description_from_any_launch_file
return loader(launch_file_path)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/python_launch_file_utilities.py", line 68, in get_launch_description_from_python_launch_file
return getattr(launch_file_module, 'generate_launch_description')()
File "/home/chi/turtlebot3_ws/install/explorer_bringup/share/explorer_bringup/map10.launch.py", line 38, in generate_launch_description
gazebo_launch_file_dir = os.path.join(get_package_share_directory('turtlebot3_gazebo'), 'launch')
File "/opt/ros/foxy/lib/python3.8/site-packages/ament_index_python/packages.py", line 69, in get_package_share_directory
return os.path.join(get_package_prefix(package_name), 'share', package_name)
File "/opt/ros/foxy/lib/python3.8/site-packages/ament_index_python/packages.py", line 51, in get_package_prefix
raise PackageNotFoundError(
ament_index_python.packages.PackageNotFoundError: "package 'turtlebot3_gazebo' not found, searching: ['/home/chi/turtlebot3_ws/install/turtlebot3', '/home/chi/turtlebot3_ws/install/turtlebot3_teleop', '/home/chi/turtlebot3_ws/install/turtlebot3_bringup', '/home/chi/turtlebot3_ws/install/turtlebot3_node', '/home/chi/turtlebot3_ws/install/turtlebot3_navigation2', '/home/chi/turtlebot3_ws/install/turtlebot3_example', '/home/chi/turtlebot3_ws/install/turtlebot3_description', '/home/chi/turtlebot3_ws/install/turtlebot3_cartographer', '/home/chi/turtlebot3_ws/install/explorer_wanderer', '/home/chi/turtlebot3_ws/install/explorer_navigation2', '/home/chi/turtlebot3_ws/install/explorer_map_utils', '/home/chi/turtlebot3_ws/install/explorer_interfaces', '/home/chi/turtlebot3_ws/install/explorer_gazebo', '/home/chi/turtlebot3_ws/install/explorer_cartographer', '/home/chi/turtlebot3_ws/install/explorer_bringup', '/opt/ros/foxy']"

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 276, in _process_one_event
await self.__process_event(next_event)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 296, in __process_event
visit_all_entities_and_collect_futures(entity, self.__context))
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 38, in visit_all_entities_and_collect_futures
sub_entities = entity.visit(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/action.py", line 108, in visit
return self.execute(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/actions/include_launch_description.py", line 125, in execute
launch_description = self.__launch_description_source.get_launch_description(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_source.py", line 84, in get_launch_description
self._get_launch_description(self.__expanded_location)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/any_launch_description_source.py", line 53, in _get_launch_description
return get_launch_description_from_any_launch_file(location)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/any_launch_file_utilities.py", line 56, in get_launch_description_from_any_launch_file
raise InvalidLaunchFileError(extension, likely_errors=exceptions)
launch.invalid_launch_file_error.InvalidLaunchFileError: Caught exception when trying to load file of format [py]: "package 'turtlebot3_gazebo' not found, searching: ['/home/chi/turtlebot3_ws/install/turtlebot3', '/home/chi/turtlebot3_ws/install/turtlebot3_teleop', '/home/chi/turtlebot3_ws/install/turtlebot3_bringup', '/home/chi/turtlebot3_ws/install/turtlebot3_node', '/home/chi/turtlebot3_ws/install/turtlebot3_navigation2', '/home/chi/turtlebot3_ws/install/turtlebot3_example', '/home/chi/turtlebot3_ws/install/turtlebot3_description', '/home/chi/turtlebot3_ws/install/turtlebot3_cartographer', '/home/chi/turtlebot3_ws/install/explorer_wanderer', '/home/chi/turtlebot3_ws/install/explorer_navigation2', '/home/chi/turtlebot3_ws/install/explorer_map_utils', '/home/chi/turtlebot3_ws/install/explorer_interfaces', '/home/chi/turtlebot3_ws/install/explorer_gazebo', '/home/chi/turtlebot3_ws/install/explorer_cartographer', '/home/chi/turtlebot3_ws/install/explorer_bringup', '/opt/ros/foxy']"

use with NAV2 SLAM

I am using NAV2 SLAM and Navigation on a real robot.
Is there a way to hook in the explorer into the nav2 map/slam stack?

Thanks for wanderer.py - take a look at how I changed it for my "GoPiGo3 ROSbot Humble Dave"

Thank you for putting together your ROS2 wanderer node. I was sure someone had coded this, and I used your wanderer as a base for my GoPiGo3 ROSbot Humble Dave.

My version at https://github.com/slowrunner/HumbleDave/blob/main/ros2ws/src/explorer_wanderer/explorer_wanderer/wanderer.py

Slam_Toolbox Map and localization using wanderer:

https://forum.dexterindustries.com/t/reality-strikes-gopigo3-dave-again/9536/5?u=cyclicalobsessive

Early run video - (now tuned for my YDLIDAR X4 and GoPiGo3 robot with tolerance for "black holes" - black stuff that causes 0.0 ranges):

https://youtu.be/bcxohp6gSgY

Discoverer Exploration algorithm doesn't work

After launching gazebo (ros2 launch explorer_bringup map10.launch.py) I've tried to use Discoverer Exploration algorithm, but it's stuck:
image

However Wanderer Exploration works well.

running (not) on iron

Hello,

I am trying explorer on iron. It seems to fail when looking for occupancy grid:

ros2 launch -d explorer_bringup map10.launch.py
[DEBUG] [launch.launch_context]: emitting event synchronously: 'launch.events.IncludeLaunchDescription'
[INFO] [launch]: All log files can be found below /home/karlo/.ros/log/2024-05-27-21-53-42-623028-karlo-ros2-2050
[INFO] [launch]: Default logging verbosity is set to DEBUG
[DEBUG] [launch]: processing event: '<launch.events.include_launch_description.IncludeLaunchDescription object at 0x7ba1dc083b20>'
[DEBUG] [launch]: processing event: '<launch.events.include_launch_description.IncludeLaunchDescription object at 0x7ba1dc083b20>' \u2713 '<launch.event_handlers.on_include_launch_description.OnIncludeLaunchDescription object at 0x7ba1dbeceb90>'
urdf_file_name : turtlebot3_burger.urdf
[DEBUG] [launch.launch_description_source]: Traceback (most recent call last):
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/launch_description_source.py", line 68, in try_get_launch_description_without_context
    perform_substitutions(context, self.__location)
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in perform_substitutions
    return ''.join([context.perform_substitution(sub) for sub in subs])
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in <listcomp>
    return ''.join([context.perform_substitution(sub) for sub in subs])
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/launch_context.py", line 241, in perform_substitution
    return substitution.perform(self)
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/substitutions/this_launch_file_dir.py", line 57, in perform
    raise SubstitutionFailure(
launch.substitutions.substitution_failure.SubstitutionFailure: ThisLaunchFileDir used outside of a launch file (in a script)

[DEBUG] [launch.launch_description_source]: Failed to load the launch file without a context: ThisLaunchFileDir used outside of a launch file (in a script)
urdf_file_name : turtlebot3_burger.urdf
[DEBUG] [launch.launch_description_source]: Traceback (most recent call last):
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/launch_description_source.py", line 68, in try_get_launch_description_without_context
    perform_substitutions(context, self.__location)
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in perform_substitutions
    return ''.join([context.perform_substitution(sub) for sub in subs])
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in <listcomp>
    return ''.join([context.perform_substitution(sub) for sub in subs])
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/launch_context.py", line 241, in perform_substitution
    return substitution.perform(self)
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/substitutions/this_launch_file_dir.py", line 57, in perform
    raise SubstitutionFailure(
launch.substitutions.substitution_failure.SubstitutionFailure: ThisLaunchFileDir used outside of a launch file (in a script)

[DEBUG] [launch.launch_description_source]: Failed to load the launch file without a context: ThisLaunchFileDir used outside of a launch file (in a script)
Executing <Task finished name='Task-2' coro=<LaunchService._process_one_event() done, defined at /opt/ros/iron/lib/python3.10/site-packages/launch/launch_service.py:228> exception=SubstitutionFailure("executable 'occupancy_grid_node' not found on the libexec directory '/opt/ros/iron/lib/cartographer_ros' ") created at /opt/ros/iron/lib/python3.10/site-packages/launch/launch_service.py:319> took 1.746 seconds
[DEBUG] [launch]: An exception was raised in an async action/event
[DEBUG] [launch]: Traceback (most recent call last):
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/launch_service.py", line 337, in run_async
    raise completed_tasks_exceptions[0]
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/launch_service.py", line 230, in _process_one_event
    await self.__process_event(next_event)
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/launch_service.py", line 250, in __process_event
    visit_all_entities_and_collect_futures(entity, self.__context))
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
    futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
    futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
    futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
  [Previous line repeated 5 more times]
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 38, in visit_all_entities_and_collect_futures
    sub_entities = entity.visit(context)
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/action.py", line 109, in visit
    return self.execute(context)
  File "/opt/ros/iron/lib/python3.10/site-packages/launch_ros/actions/node.py", line 509, in execute
    ret = super().execute(context)
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/actions/execute_local.py", line 642, in execute
    self.prepare(context)
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/actions/execute_local.py", line 617, in prepare
    self.__process_description.prepare(context, self)
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/descriptions/executable.py", line 174, in prepare
    cmd = [perform_substitutions(context, x) for x in self.__cmd]
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/descriptions/executable.py", line 174, in <listcomp>
    cmd = [perform_substitutions(context, x) for x in self.__cmd]
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in perform_substitutions
    return ''.join([context.perform_substitution(sub) for sub in subs])
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in <listcomp>
    return ''.join([context.perform_substitution(sub) for sub in subs])
  File "/opt/ros/iron/lib/python3.10/site-packages/launch/launch_context.py", line 241, in perform_substitution
    return substitution.perform(self)
  File "/opt/ros/iron/lib/python3.10/site-packages/launch_ros/substitutions/executable_in_package.py", line 84, in perform
    raise SubstitutionFailure(
launch.substitutions.substitution_failure.SubstitutionFailure: executable 'occupancy_grid_node' not found on the libexec directory '/opt/ros/iron/lib/cartographer_ros' 

[ERROR] [launch]: Caught exception in launch (see debug for traceback): executable 'occupancy_grid_node' not found on the libexec directory '/opt/ros/iron/lib/cartographer_ros' 
[DEBUG] [launch.launch_context]: emitting event: 'launch.events.Shutdown'
[DEBUG] [launch]: processing event: '<launch.events.shutdown.Shutdown object at 0x7ba1dbeced70>'
[DEBUG] [launch]: processing event: '<launch.events.shutdown.Shutdown object at 0x7ba1dbeced70>' \u2713 '<launch.event_handlers.on_shutdown.OnShutdown object at 0x7ba1d92e2a70>'
[DEBUG] [launch]: processing event: '<launch.events.shutdown.Shutdown object at 0x7ba1dbeced70>' \u2713 '<launch.event_handlers.on_shutdown.OnShutdown object at 0x7ba1d9244d60>'
[DEBUG] [launch]: processing event: '<launch.events.shutdown.Shutdown object at 0x7ba1dbeced70>' \u2713 '<launch.event_handlers.on_shutdown.OnShutdown object at 0x7ba1d93f25c0>'
[DEBUG] [launch]: processing event: '<launch.events.shutdown.Shutdown object at 0x7ba1dbeced70>' \u2713 '<launch.event_handlers.on_shutdown.OnShutdown object at 0x7ba1d93f3700>'
[DEBUG] [launch]: processing event: '<launch.events.shutdown.Shutdown object at 0x7ba1dbeced70>' \u2713 '<launch.event_handlers.on_shutdown.OnShutdown object at 0x7ba1d92478e0>'
[DEBUG] [launch]: processing event: '<launch.events.shutdown.Shutdown object at 0x7ba1dbeced70>' \u2713 '<launch.event_handlers.on_shutdown.OnShutdown object at 0x7ba1dbecfa60>'

Changing map for single exploration

Hi, I wanted to change the environment to be mapped with a single robot. I do not find the lines where this issue can be addressed. Can someone help?

Map gets lost after some time on KITTI Run 007 at turns

Hi, I am trying to run cartographer using KITTI run 007. I preprocesed the dataset using a preprocessing step that turns the data into a range image of size [3,60,512]. The cartograher works well in straight lines but blunders at turns. I am clueless as to what coud be the issue here and tried different tricks with respect to the lua configuration, but didnt work. Could someone help here. I am posting the rosbag and the lua file here for refernece. KITTI bag used: kitti-run-007-bag Lua file used Lua This is the result using the bag with the given configuration. The map seems to get lost at the turns. Screenshot from 2022-09-09 12-56-51 Requesting your help here. Thanks. Prashant

Can't run the explorer with my own map

Hi!

I'm trying to run the explorer on this map:
turtlebot3_big_house.zip

I haven't been able to modify the launch file to launch my own map and what happens now is that i launch the map in gazebo with:
ros2 launch turtlebot3_gazebo turtlebot3_big_house.launch.py

then i launch nav2 in slam mode
ros2 launch turtlebot3_navigation2 navigation2.launch.py use_sim_time:=True slam:=True

and then your explorer:
ros2 run explorer_bringup manager

choosing Wanderer and what I get is

[INFO] [1693477736.178197689] [manager]: Waiting for action server...

What can I do? I can't manage to modify properly files, could you help me please? I'm a noob ;(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.