Giter VIP home page Giter VIP 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 20.04 - ROS 2 Foxy)

Install ROS2 Foxy

Don't forget to install colcon:

sudo apt install python3-colcon-common-extensions

Install Gazebo:

curl -sSL http://get.gazebosim.org | sh

Install packages:

sudo apt install ros-foxy-gazebo-ros-pkgs ros-foxy-cartographer ros-foxy-cartographer-ros ros-foxy-navigation2 ros-foxy-nav2-bringup
sudo apt install ros-foxy-turtlebot3-msgs ros-foxy-dynamixel-sdk ros-foxy-hls-lfcd-lds-driver

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

Clone turtlebot original repository to have additional utilities:

git clone -b foxy-devel https://github.com/ROBOTIS-GIT/turtlebot3.git
git clone -b foxy-devel https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git

Include following lines in ~/.bashrc:

source /opt/ros/foxy/setup.bash
source /usr/share/colcon_cd/function/colcon_cd.sh
export _colcon_cd_root=~/turtlebot3_ws
source ~/turtlebot3_ws/install/setup.bash

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

Compile packages:

cd ~/turtlebot3_ws/
colcon build

How to run

Execute the launch file of the map you want to use (Opens Gazebo simulation, Rviz, Cartographer, Nav2 and exploration servers):

ros2 launch explorer_bringup map10.launch.py

Execute manager node and select 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>

Create a new launch file in /explorer_bringup/launch folder and modify the parameter map_name according to the map you just created.

Testing commands

Cartographer launch:

ros2 launch explorer_cartographer cartographer.launch.py use_sim_time:=True

Navigation launch:

ros2 launch explorer_navigation2 nav.launch.py use_sim_time:=True

Move the robot manually:

ros2 run turtlebot3_teleop teleop_keyboard

Save a map:

ros2 run nav2_map_server map_saver_cli

Publish a goal:

ros2 action send_goal /navigate_to_pose nav2_msgs/action/NavigateToPose "{pose: {header: {stamp: {sec: 0}, frame_id: 'map'}, pose: {position: {x: 0.0, y: 0.0, z: 0.0}, orientation: {w: 1.0}}}}"

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

Watchers

 avatar  avatar  avatar  avatar

ros2_explorer's Issues

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?

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?

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

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

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

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.

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']"

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.