navigation workspace cleanup
This commit is contained in:
parent
97acfda70c
commit
9852be991f
|
@ -1,107 +0,0 @@
|
|||
# Copyright (c) 2018 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os
|
||||
|
||||
from ament_index_python.packages import get_package_share_directory
|
||||
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument, SetEnvironmentVariable
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
from launch_ros.actions import Node
|
||||
from nav2_common.launch import RewrittenYaml
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
# Get the launch directory
|
||||
bringup_dir = get_package_share_directory('nav2_bringup')
|
||||
|
||||
namespace = LaunchConfiguration('namespace')
|
||||
map_yaml_file = LaunchConfiguration('map')
|
||||
use_sim_time = LaunchConfiguration('use_sim_time')
|
||||
autostart = LaunchConfiguration('autostart')
|
||||
params_file = LaunchConfiguration('params_file')
|
||||
lifecycle_nodes = ['map_server', 'amcl']
|
||||
|
||||
# Map fully qualified names to relative ones so the node's namespace can be prepended.
|
||||
# In case of the transforms (tf), currently, there doesn't seem to be a better alternative
|
||||
# https://github.com/ros/geometry2/issues/32
|
||||
# https://github.com/ros/robot_state_publisher/pull/30
|
||||
# TODO(orduno) Substitute with `PushNodeRemapping`
|
||||
# https://github.com/ros2/launch_ros/issues/56
|
||||
remappings = [('/tf', 'tf'),
|
||||
('/tf_static', 'tf_static')]
|
||||
|
||||
# Create our own temporary YAML files that include substitutions
|
||||
param_substitutions = {
|
||||
'use_sim_time': use_sim_time,
|
||||
'yaml_filename': map_yaml_file}
|
||||
|
||||
configured_params = RewrittenYaml(
|
||||
source_file=params_file,
|
||||
root_key=namespace,
|
||||
param_rewrites=param_substitutions,
|
||||
convert_types=True)
|
||||
|
||||
return LaunchDescription([
|
||||
# Set env var to print messages to stdout immediately
|
||||
SetEnvironmentVariable('RCUTILS_LOGGING_BUFFERED_STREAM', '1'),
|
||||
|
||||
DeclareLaunchArgument(
|
||||
'namespace', default_value='',
|
||||
description='Top-level namespace'),
|
||||
|
||||
DeclareLaunchArgument(
|
||||
'map',
|
||||
default_value=os.path.join(bringup_dir, 'maps', 'turtlebot3_world.yaml'),
|
||||
description='Full path to map yaml file to load'),
|
||||
|
||||
DeclareLaunchArgument(
|
||||
'use_sim_time', default_value='false',
|
||||
description='Use simulation (Gazebo) clock if true'),
|
||||
|
||||
DeclareLaunchArgument(
|
||||
'autostart', default_value='true',
|
||||
description='Automatically startup the nav2 stack'),
|
||||
|
||||
DeclareLaunchArgument(
|
||||
'params_file',
|
||||
default_value=os.path.join(bringup_dir, 'params', 'nav2_params.yaml'),
|
||||
description='Full path to the ROS2 parameters file to use'),
|
||||
|
||||
Node(
|
||||
package='nav2_map_server',
|
||||
executable='map_server',
|
||||
name='map_server',
|
||||
output='screen',
|
||||
parameters=[configured_params],
|
||||
remappings=remappings),
|
||||
|
||||
Node(
|
||||
package='nav2_amcl',
|
||||
executable='amcl',
|
||||
name='amcl',
|
||||
output='screen',
|
||||
parameters=[configured_params],
|
||||
remappings=remappings),
|
||||
|
||||
Node(
|
||||
package='nav2_lifecycle_manager',
|
||||
executable='lifecycle_manager',
|
||||
name='lifecycle_manager_localization',
|
||||
output='screen',
|
||||
parameters=[{'use_sim_time': use_sim_time},
|
||||
{'autostart': autostart},
|
||||
{'node_names': lifecycle_nodes}])
|
||||
])
|
|
@ -1,141 +0,0 @@
|
|||
# Copyright (c) 2018 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os
|
||||
|
||||
from ament_index_python.packages import get_package_share_directory
|
||||
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import (DeclareLaunchArgument, GroupAction,
|
||||
IncludeLaunchDescription, SetEnvironmentVariable)
|
||||
from launch.conditions import IfCondition
|
||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||
from launch.substitutions import LaunchConfiguration, PythonExpression
|
||||
from launch_ros.actions import PushRosNamespace
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
# Get the launch directory
|
||||
bringup_dir = get_package_share_directory('sportmode_nav2')
|
||||
launch_dir = os.path.join(bringup_dir, 'launch')
|
||||
|
||||
# Create the launch configuration variables
|
||||
namespace = LaunchConfiguration('namespace')
|
||||
use_namespace = LaunchConfiguration('use_namespace')
|
||||
slam = LaunchConfiguration('slam')
|
||||
map_yaml_file = LaunchConfiguration('map')
|
||||
use_sim_time = LaunchConfiguration('use_sim_time')
|
||||
params_file = LaunchConfiguration('params_file')
|
||||
default_bt_xml_filename = LaunchConfiguration('default_bt_xml_filename')
|
||||
autostart = LaunchConfiguration('autostart')
|
||||
|
||||
stdout_linebuf_envvar = SetEnvironmentVariable(
|
||||
'RCUTILS_LOGGING_BUFFERED_STREAM', '1')
|
||||
|
||||
declare_namespace_cmd = DeclareLaunchArgument(
|
||||
'namespace',
|
||||
default_value='',
|
||||
description='Top-level namespace')
|
||||
|
||||
declare_use_namespace_cmd = DeclareLaunchArgument(
|
||||
'use_namespace',
|
||||
default_value='false',
|
||||
description='Whether to apply a namespace to the navigation stack')
|
||||
|
||||
declare_slam_cmd = DeclareLaunchArgument(
|
||||
'slam',
|
||||
default_value='False',
|
||||
description='Whether run a SLAM')
|
||||
|
||||
declare_map_yaml_cmd = DeclareLaunchArgument(
|
||||
'map',
|
||||
description='Full path to map yaml file to load')
|
||||
|
||||
declare_use_sim_time_cmd = DeclareLaunchArgument(
|
||||
'use_sim_time',
|
||||
default_value='false',
|
||||
description='Use simulation (Gazebo) clock if true')
|
||||
|
||||
declare_params_file_cmd = DeclareLaunchArgument(
|
||||
'params_file',
|
||||
default_value=os.path.join(bringup_dir, 'params', 'nav2_params.yaml'),
|
||||
description='Full path to the ROS2 parameters file to use for all launched nodes')
|
||||
|
||||
declare_bt_xml_cmd = DeclareLaunchArgument(
|
||||
'default_bt_xml_filename',
|
||||
default_value=os.path.join(
|
||||
get_package_share_directory('nav2_bt_navigator'),
|
||||
'behavior_trees', 'navigate_w_replanning_and_recovery.xml'),
|
||||
description='Full path to the behavior tree xml file to use')
|
||||
|
||||
declare_autostart_cmd = DeclareLaunchArgument(
|
||||
'autostart', default_value='true',
|
||||
description='Automatically startup the nav2 stack')
|
||||
|
||||
# Specify the actions
|
||||
bringup_cmd_group = GroupAction([
|
||||
PushRosNamespace(
|
||||
condition=IfCondition(use_namespace),
|
||||
namespace=namespace),
|
||||
|
||||
IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(os.path.join(launch_dir, 'slam_launch.py')),
|
||||
condition=IfCondition(slam),
|
||||
launch_arguments={'namespace': namespace,
|
||||
'use_sim_time': use_sim_time,
|
||||
'autostart': autostart,
|
||||
'params_file': params_file}.items()),
|
||||
|
||||
IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(os.path.join(launch_dir,
|
||||
'localization_launch.py')),
|
||||
condition=IfCondition(PythonExpression(['not ', slam])),
|
||||
launch_arguments={'namespace': namespace,
|
||||
'map': map_yaml_file,
|
||||
'use_sim_time': use_sim_time,
|
||||
'autostart': autostart,
|
||||
'params_file': params_file,
|
||||
'use_lifecycle_mgr': 'false'}.items()),
|
||||
|
||||
IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(os.path.join(launch_dir, 'navigation_launch.py')),
|
||||
launch_arguments={'namespace': namespace,
|
||||
'use_sim_time': use_sim_time,
|
||||
'autostart': autostart,
|
||||
'params_file': params_file,
|
||||
'default_bt_xml_filename': default_bt_xml_filename,
|
||||
'use_lifecycle_mgr': 'false',
|
||||
'map_subscribe_transient_local': 'true'}.items()),
|
||||
])
|
||||
|
||||
# Create the launch description and populate
|
||||
ld = LaunchDescription()
|
||||
|
||||
# Set environment variables
|
||||
ld.add_action(stdout_linebuf_envvar)
|
||||
|
||||
# Declare the launch options
|
||||
ld.add_action(declare_namespace_cmd)
|
||||
ld.add_action(declare_use_namespace_cmd)
|
||||
ld.add_action(declare_slam_cmd)
|
||||
ld.add_action(declare_map_yaml_cmd)
|
||||
ld.add_action(declare_use_sim_time_cmd)
|
||||
ld.add_action(declare_params_file_cmd)
|
||||
ld.add_action(declare_autostart_cmd)
|
||||
ld.add_action(declare_bt_xml_cmd)
|
||||
|
||||
# Add the actions to launch all of the navigation nodes
|
||||
ld.add_action(bringup_cmd_group)
|
||||
|
||||
return ld
|
|
@ -1,107 +0,0 @@
|
|||
# Copyright (c) 2020 Samsung Research Russia
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os
|
||||
|
||||
from ament_index_python.packages import get_package_share_directory
|
||||
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
|
||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
from launch_ros.actions import Node
|
||||
from nav2_common.launch import RewrittenYaml
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
# Input parameters declaration
|
||||
namespace = LaunchConfiguration('namespace')
|
||||
params_file = LaunchConfiguration('params_file')
|
||||
use_sim_time = LaunchConfiguration('use_sim_time')
|
||||
autostart = LaunchConfiguration('autostart')
|
||||
|
||||
# Variables
|
||||
lifecycle_nodes = ['map_saver']
|
||||
|
||||
# Getting directories and launch-files
|
||||
bringup_dir = get_package_share_directory('sportmode_nav2')
|
||||
slam_toolbox_dir = get_package_share_directory('sportmode_nav2')
|
||||
slam_launch_file = os.path.join(slam_toolbox_dir, 'launch', 'mapping.launch.py')
|
||||
|
||||
# Create our own temporary YAML files that include substitutions
|
||||
param_substitutions = {
|
||||
'use_sim_time': use_sim_time}
|
||||
|
||||
configured_params = RewrittenYaml(
|
||||
source_file=params_file,
|
||||
root_key=namespace,
|
||||
param_rewrites=param_substitutions,
|
||||
convert_types=True)
|
||||
|
||||
# Declare the launch arguments
|
||||
declare_namespace_cmd = DeclareLaunchArgument(
|
||||
'namespace',
|
||||
default_value='',
|
||||
description='Top-level namespace')
|
||||
|
||||
declare_params_file_cmd = DeclareLaunchArgument(
|
||||
'params_file',
|
||||
default_value=os.path.join(bringup_dir, 'params', 'nav2_params.yaml'),
|
||||
description='Full path to the ROS2 parameters file to use for all launched nodes')
|
||||
|
||||
declare_use_sim_time_cmd = DeclareLaunchArgument(
|
||||
'use_sim_time',
|
||||
default_value='true',
|
||||
description='Use simulation (Gazebo) clock if true')
|
||||
|
||||
declare_autostart_cmd = DeclareLaunchArgument(
|
||||
'autostart', default_value='true',
|
||||
description='Automatically startup the nav2 stack')
|
||||
|
||||
# Nodes launching commands
|
||||
start_slam_toolbox_cmd = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(slam_launch_file),
|
||||
launch_arguments={'use_sim_time': use_sim_time}.items())
|
||||
|
||||
start_map_saver_server_cmd = Node(
|
||||
package='nav2_map_server',
|
||||
node_executable='map_saver_server',
|
||||
output='screen',
|
||||
parameters=[configured_params])
|
||||
|
||||
start_lifecycle_manager_cmd = Node(
|
||||
package='nav2_lifecycle_manager',
|
||||
node_executable='lifecycle_manager',
|
||||
node_name='lifecycle_manager_slam',
|
||||
output='screen',
|
||||
parameters=[{'use_sim_time': use_sim_time},
|
||||
{'autostart': autostart},
|
||||
{'node_names': lifecycle_nodes}])
|
||||
|
||||
ld = LaunchDescription()
|
||||
|
||||
# Declare the launch options
|
||||
ld.add_action(declare_namespace_cmd)
|
||||
ld.add_action(declare_params_file_cmd)
|
||||
ld.add_action(declare_use_sim_time_cmd)
|
||||
ld.add_action(declare_autostart_cmd)
|
||||
|
||||
# Running SLAM Toolbox
|
||||
ld.add_action(start_slam_toolbox_cmd)
|
||||
|
||||
# Running Map Saver Server
|
||||
ld.add_action(start_map_saver_server_cmd)
|
||||
ld.add_action(start_lifecycle_manager_cmd)
|
||||
|
||||
return ld
|
|
@ -1,59 +0,0 @@
|
|||
import os
|
||||
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument, LogInfo
|
||||
from launch.conditions import UnlessCondition
|
||||
from launch.substitutions import LaunchConfiguration, PythonExpression
|
||||
from launch_ros.actions import Node
|
||||
from ament_index_python.packages import get_package_share_directory
|
||||
from nav2_common.launch import HasNodeParams
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
use_sim_time = LaunchConfiguration('use_sim_time', default=False)
|
||||
params_file = LaunchConfiguration('params_file')
|
||||
default_params_file = os.path.join(get_package_share_directory("sportmode_nav2"),
|
||||
'params', 'mapping_async.yaml')
|
||||
|
||||
declare_use_sim_time_argument = DeclareLaunchArgument(
|
||||
'use_sim_time',
|
||||
default_value='false',
|
||||
description='Use simulation/Gazebo clock')
|
||||
declare_params_file_cmd = DeclareLaunchArgument(
|
||||
'params_file',
|
||||
default_value=default_params_file,
|
||||
description='Full path to the ROS2 parameters file to use for the slam_toolbox node')
|
||||
|
||||
# If the provided param file doesn't have slam_toolbox params, we must pass the
|
||||
# default_params_file instead. This could happen due to automatic propagation of
|
||||
# LaunchArguments. See:
|
||||
# https://github.com/ros-planning/navigation2/pull/2243#issuecomment-800479866
|
||||
has_node_params = HasNodeParams(source_file=params_file,
|
||||
node_name='slam_toolbox')
|
||||
|
||||
actual_params_file = PythonExpression(['"', params_file, '" if ', has_node_params,
|
||||
' else "', default_params_file, '"'])
|
||||
|
||||
log_param_change = LogInfo(msg=['provided params_file ', params_file,
|
||||
' does not contain slam_toolbox parameters. Using default: ',
|
||||
default_params_file],
|
||||
condition=UnlessCondition(has_node_params))
|
||||
|
||||
start_async_slam_toolbox_node = Node(
|
||||
parameters=[
|
||||
actual_params_file,
|
||||
{'use_sim_time': use_sim_time}
|
||||
],
|
||||
package='slam_toolbox',
|
||||
executable='async_slam_toolbox_node',
|
||||
name='slam_toolbox',
|
||||
output='screen')
|
||||
|
||||
ld = LaunchDescription()
|
||||
|
||||
ld.add_action(declare_use_sim_time_argument)
|
||||
ld.add_action(declare_params_file_cmd)
|
||||
ld.add_action(log_param_change)
|
||||
ld.add_action(start_async_slam_toolbox_node)
|
||||
|
||||
return ld
|
|
@ -19,7 +19,7 @@ slam_toolbox:
|
|||
# if you'd like to immediately start continuing a map at a given pose
|
||||
# or at the dock, but they are mutually exclusive, if pose is given
|
||||
# will use pose
|
||||
map_file_name: /home/unitree/locomotion/Go2Py/deploy/nav2_ws/Feb21_hallway
|
||||
map_file_name: /home/unitree/locomotion/Go2Py/deploy/nav2_ws/maps/Feb21_hallway
|
||||
#map_start_pose: [0.33, 1.49, 0.0]
|
||||
map_start_at_dock: true
|
||||
|
||||
|
|
Loading…
Reference in New Issue