Skip to content

Commit

Permalink
Port to humble
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniGarciaLopez committed May 31, 2024
1 parent aea1346 commit 1f5a3a2
Show file tree
Hide file tree
Showing 57 changed files with 186 additions and 2,099 deletions.
31 changes: 11 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,15 @@ The map is created using SLAM with the package [Google Cartographer](https://git

## Installation (tested on Ubuntu 20.04 - ROS 2 Foxy)

[Install ROS2 Foxy](https://docs.ros.org/en/foxy/Installation/Linux-Install-Debians.html)
[Install ROS2 Humble](https://docs.ros.org/en/humble/Installation/Linux-Install-Debians.html)

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
sudo apt install gazebo
```
Install Python libraries:
```
Expand All @@ -42,30 +37,26 @@ Clone the repository:
```
git clone https://github.com/DaniGarciaLopez/ros2_explorer.git
```
Clone turtlebot original repository to have additional utilities:
Compile packages and get dependencies:
```
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
cd ~/turtlebot3_ws/src
sudo apt update && rosdep install -r --from-paths . --ignore-src --rosdistro $ROS_DISTRO -y
cd ~/turtlebot3_ws/
colcon build
```
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
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
```
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
ros2 launch explorer_bringup explorer.launch.py map_name:=map10
```
Execute manager node and select exploring algorithm:
```
Expand Down
115 changes: 115 additions & 0 deletions explorer_bringup/launch/explorer.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import OpaqueFunction, IncludeLaunchDescription, DeclareLaunchArgument
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch_ros.substitutions import FindPackageShare
from launch_ros.actions import Node

TURTLEBOT3_MODEL = os.environ['TURTLEBOT3_MODEL']

def launch_setup(context, *args, **kwargs):

map_name = LaunchConfiguration('map_name', default='map10')
world_file_name = map_name.perform(context) + '.world.xml'
world = os.path.join(get_package_share_directory('explorer_gazebo'), 'worlds', world_file_name)

pkg_gazebo_ros = get_package_share_directory('gazebo_ros')
nav2_file_dir = get_package_share_directory('turtlebot3_navigation2')
gazebo_launch_file_dir = os.path.join(get_package_share_directory('turtlebot3_gazebo'), 'launch')
cartographer_launch_file_dir = os.path.join(get_package_share_directory('explorer_cartographer'), 'launch')

use_sim_time = LaunchConfiguration('use_sim_time', default='true')
x_pose = LaunchConfiguration('x_pose', default='2.0')
y_pose = LaunchConfiguration('y_pose', default='3.0')

param_file_name = TURTLEBOT3_MODEL + '.yaml'

gzserver_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(pkg_gazebo_ros, 'launch', 'gzserver.launch.py')
),
launch_arguments={'world': world}.items()
)

gzclient_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(pkg_gazebo_ros, 'launch', 'gzclient.launch.py')
)
)

robot_state_publisher_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(gazebo_launch_file_dir, 'robot_state_publisher.launch.py')
),
launch_arguments={'use_sim_time': use_sim_time}.items()
)

spawn_turtlebot_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(gazebo_launch_file_dir, 'spawn_turtlebot3.launch.py')
),
launch_arguments={
'x_pose': x_pose,
'y_pose': y_pose
}.items()
)

cartographer_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(cartographer_launch_file_dir, 'cartographer.launch.py')
),
launch_arguments={'use_sim_time': use_sim_time}.items(),
)

nav2_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(get_package_share_directory('nav2_bringup'), 'launch', 'bringup_launch.py')
),
launch_arguments={
'map': os.path.join(nav2_file_dir, 'map', 'map.yaml'),
'use_sim_time': use_sim_time,
'params_file': os.path.join(nav2_file_dir, 'param', param_file_name)}.items(),
)

wanderer_cmd = Node(
package='explorer_wanderer',
executable='wanderer_server',
name='wanderer_server',
output='screen',
)

discoverer_cmd = Node(
package='explorer_wanderer',
executable='discoverer_server',
name='discoverer_server',
output='screen',
)

watchtower_cmd = Node(
package='explorer_map_utils',
executable='watchtower',
name='watchtower',
output='screen',
parameters=[{'map_name': map_name}],
)

return [
gzserver_cmd,
gzclient_cmd,
robot_state_publisher_cmd,
spawn_turtlebot_cmd,
cartographer_cmd,
nav2_cmd,
wanderer_cmd,
discoverer_cmd,
watchtower_cmd,
]


def generate_launch_description():
return LaunchDescription([
OpaqueFunction(function=launch_setup)
])
97 changes: 0 additions & 97 deletions explorer_bringup/launch/map1.launch.py

This file was deleted.

97 changes: 0 additions & 97 deletions explorer_bringup/launch/map10.launch.py

This file was deleted.

Loading

0 comments on commit 1f5a3a2

Please sign in to comment.