update nav2 launch

This commit is contained in:
locker98 2024-12-18 22:27:23 -05:00
parent a391de527d
commit 8b5f01d0ec
7 changed files with 77 additions and 16 deletions

View File

@ -7,20 +7,10 @@ endif()
# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
install(
DIRECTORY launch rviz worlds
DESTINATION share/${PROJECT_NAME}/
)
ament_package()

View File

@ -0,0 +1,50 @@
from launch import LaunchDescription
import os
from ament_index_python import get_package_share_directory
from launch_ros.parameter_descriptions import ParameterValue
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
def generate_launch_description():
# Declare the arguments
use_sim_time = LaunchConfiguration('use_sim_time', default='False')
map = LaunchConfiguration('map')
# Define RViz config path
rviz_config_path = os.path.join(
get_package_share_directory('locker98_tools_bringup'),
'rviz', 'nav2_config.rviz'
)
# Include the bringup launch file
bringup_launch_file = os.path.join(
get_package_share_directory('nav2_bringup'),
'launch', 'bringup_launch.py'
)
# Include the bringup launch file and pass arguments
include_bringup = IncludeLaunchDescription(
bringup_launch_file,
launch_arguments={
'use_sim_time': use_sim_time,
'map': map
}.items()
)
# RViz node
rviz2_node = Node(
package='rviz2',
executable='rviz2',
output='screen',
arguments=['-d', rviz_config_path]
)
# Return LaunchDescription
return LaunchDescription([
DeclareLaunchArgument('use_sim_time', default_value='False', description='Use simulation time'),
DeclareLaunchArgument('map', default_value='', description='Map input'),
include_bringup,
rviz2_node
])

View File

@ -1 +1,12 @@
<launch>
<arg name="use_sim_time" default="False" />
<arg name="map"/>
<include file="$(find-pkg-share nav2_bringup)/launch/bringup_launch.py">
<arg name="map" value="$(arg map)"/>
<arg name="use_sim_time" value="$(arg use_sim_time)"/>
</include>
<!--<node pkg="rviz2" executable="rviz2" output="screen" args="-d $(find-pkg-share locker98_tools_bringup)/rviz/nav2_config.rviz" />
-->
</launch>

View File

@ -9,6 +9,10 @@
<buildtool_depend>ament_cmake</buildtool_depend>
<exec_depend>my_robot1_description</exec_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

Binary file not shown.

View File

@ -0,0 +1,7 @@
image: my_map.pgm
mode: trinary
resolution: 0.05
origin: [-3.25, -3.99, 0]
negate: 0
occupied_thresh: 0.65
free_thresh: 0.25