Skip to content

Commit 9708879

Browse files
authored
Merge pull request #4 from byeongkyu/humble-devel
Add package navigation2 for former robot
2 parents 6cba61f + e911b2e commit 9708879

16 files changed

+1788
-7
lines changed

former_description/urdf/former.urdf.xacro

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@
5454
</inertial>
5555
</link>
5656

57-
<joint name="${prefix}_wheel_suspension_joint" type="prismatic">
57+
<joint name="${prefix}_wheel_suspension_joint" type="fixed">
5858
<parent link="${parent}" />
5959
<child link="${prefix}_wheel_suspension" />
60-
<axis xyz="0 0 1"/>
60+
<!-- <axis xyz="0 0 1"/> -->
6161
<origin xyz="0 ${dir*0.0741} 0" rpy="0 0 0"/>
62-
<limit effort="10" velocity="0.1" lower="-0.01" upper="0.01"/>
62+
<!-- <limit effort="10" velocity="0.1" lower="-0.01" upper="0.01"/> -->
6363
</joint>
6464

6565
<link name="${prefix}_wheel_mount">

former_gazebo/launch/bringup.launch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def generate_launch_description():
3232
]),
3333
launch_arguments={
3434
"verbose": "true",
35-
"physics": "dart",
35+
"physics": "ode",
3636
"world": PathJoinSubstitution([
3737
get_package_share_directory('former_gazebo'),
3838
'worlds',

former_nav2/CMakeLists.txt former_navigation2/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.8)
2-
project(former_nav2)
2+
project(former_navigation2)
33

44
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
55
add_compile_options(-Wall -Wextra -Wpedantic)
@@ -14,6 +14,7 @@ install(
1414
config
1515
launch
1616
maps
17+
params
1718
rviz
1819
DESTINATION share/${PROJECT_NAME}
1920
)
File renamed without changes.
+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Copyright (c) 2018 Intel Corporation
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import os
16+
17+
from ament_index_python.packages import get_package_share_directory
18+
19+
from launch import LaunchDescription
20+
from launch.actions import (DeclareLaunchArgument, GroupAction,
21+
IncludeLaunchDescription, SetEnvironmentVariable)
22+
from launch.conditions import IfCondition
23+
from launch.launch_description_sources import PythonLaunchDescriptionSource
24+
from launch.substitutions import LaunchConfiguration, PythonExpression
25+
from launch_ros.actions import Node
26+
from launch_ros.actions import PushRosNamespace
27+
from nav2_common.launch import RewrittenYaml
28+
29+
30+
def generate_launch_description():
31+
# Get the launch directory
32+
bringup_dir = get_package_share_directory('former_navigation2')
33+
launch_dir = os.path.join(bringup_dir, 'launch')
34+
35+
# Create the launch configuration variables
36+
map_yaml_file = LaunchConfiguration('map')
37+
use_sim_time = LaunchConfiguration('use_sim_time')
38+
params_file = LaunchConfiguration('params_file')
39+
autostart = LaunchConfiguration('autostart')
40+
use_composition = LaunchConfiguration('use_composition')
41+
use_respawn = LaunchConfiguration('use_respawn')
42+
log_level = LaunchConfiguration('log_level')
43+
44+
remappings = [ ('/tf', 'tf'),
45+
('/tf_static', 'tf_static'),
46+
]
47+
48+
param_substitutions = {
49+
'use_sim_time': use_sim_time,
50+
'yaml_filename': map_yaml_file}
51+
52+
configured_params = RewrittenYaml(
53+
source_file=params_file,
54+
param_rewrites=param_substitutions,
55+
convert_types=True)
56+
57+
stdout_linebuf_envvar = SetEnvironmentVariable(
58+
'RCUTILS_LOGGING_BUFFERED_STREAM', '1')
59+
60+
declare_map_yaml_cmd = DeclareLaunchArgument(
61+
'map',
62+
default_value=os.path.join(bringup_dir, "maps", "map_office_building.yaml"),
63+
description='Full path to map yaml file to load')
64+
65+
declare_use_sim_time_cmd = DeclareLaunchArgument(
66+
'use_sim_time',
67+
default_value='True',
68+
description='Use simulation (Gazebo) clock if true')
69+
70+
declare_params_file_cmd = DeclareLaunchArgument(
71+
'params_file',
72+
default_value=os.path.join(bringup_dir, 'params', 'nav2_params.yaml'),
73+
description='Full path to the ROS2 parameters file to use for all launched nodes')
74+
75+
declare_autostart_cmd = DeclareLaunchArgument(
76+
'autostart', default_value='True',
77+
description='Automatically startup the nav2 stack')
78+
79+
declare_use_composition_cmd = DeclareLaunchArgument(
80+
'use_composition', default_value='False',
81+
description='Whether to use composed bringup')
82+
83+
declare_use_respawn_cmd = DeclareLaunchArgument(
84+
'use_respawn', default_value='False',
85+
description='Whether to respawn if a node crashes. Applied when composition is disabled.')
86+
87+
declare_log_level_cmd = DeclareLaunchArgument(
88+
'log_level', default_value='info',
89+
description='log level')
90+
91+
# Specify the actions
92+
bringup_cmd_group = GroupAction([
93+
Node(
94+
condition=IfCondition(use_composition),
95+
name='nav2_container',
96+
package='rclcpp_components',
97+
executable='component_container_isolated',
98+
parameters=[configured_params, {'autostart': autostart}],
99+
arguments=['--ros-args', '--log-level', log_level],
100+
remappings=remappings,
101+
output='screen'),
102+
103+
IncludeLaunchDescription(
104+
PythonLaunchDescriptionSource(os.path.join(launch_dir, 'localization_launch.py')),
105+
launch_arguments={ 'map': map_yaml_file,
106+
'use_sim_time': use_sim_time,
107+
'autostart': autostart,
108+
'params_file': params_file,
109+
'use_composition': use_composition,
110+
'use_respawn': use_respawn,
111+
'container_name': 'nav2_container'}.items()),
112+
113+
IncludeLaunchDescription(
114+
PythonLaunchDescriptionSource(os.path.join(launch_dir, 'navigation_launch.py')),
115+
launch_arguments={ 'use_sim_time': use_sim_time,
116+
'autostart': autostart,
117+
'params_file': params_file,
118+
'use_composition': use_composition,
119+
'use_respawn': use_respawn,
120+
'container_name': 'nav2_container'}.items()),
121+
])
122+
123+
# Create the launch description and populate
124+
ld = LaunchDescription()
125+
126+
# Set environment variables
127+
ld.add_action(stdout_linebuf_envvar)
128+
129+
# Declare the launch options
130+
ld.add_action(declare_map_yaml_cmd)
131+
ld.add_action(declare_use_sim_time_cmd)
132+
ld.add_action(declare_params_file_cmd)
133+
ld.add_action(declare_autostart_cmd)
134+
ld.add_action(declare_use_composition_cmd)
135+
ld.add_action(declare_use_respawn_cmd)
136+
ld.add_action(declare_log_level_cmd)
137+
138+
ld.add_action(bringup_cmd_group)
139+
return ld
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# Copyright (c) 2018 Intel Corporation
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import os
16+
17+
from ament_index_python.packages import get_package_share_directory
18+
19+
from launch import LaunchDescription
20+
from launch.actions import DeclareLaunchArgument, GroupAction, SetEnvironmentVariable
21+
from launch.conditions import IfCondition
22+
from launch.substitutions import LaunchConfiguration, PythonExpression
23+
from launch_ros.actions import LoadComposableNodes
24+
from launch_ros.actions import Node
25+
from launch_ros.descriptions import ComposableNode
26+
from nav2_common.launch import RewrittenYaml
27+
28+
29+
def generate_launch_description():
30+
# Get the launch directory
31+
bringup_dir = get_package_share_directory('nav2_bringup')
32+
33+
namespace = LaunchConfiguration('namespace')
34+
map_yaml_file = LaunchConfiguration('map')
35+
use_sim_time = LaunchConfiguration('use_sim_time')
36+
autostart = LaunchConfiguration('autostart')
37+
params_file = LaunchConfiguration('params_file')
38+
use_composition = LaunchConfiguration('use_composition')
39+
container_name = LaunchConfiguration('container_name')
40+
use_respawn = LaunchConfiguration('use_respawn')
41+
log_level = LaunchConfiguration('log_level')
42+
43+
lifecycle_nodes = ['map_server', 'amcl']
44+
45+
# Map fully qualified names to relative ones so the node's namespace can be prepended.
46+
# In case of the transforms (tf), currently, there doesn't seem to be a better alternative
47+
# https://github.com/ros/geometry2/issues/32
48+
# https://github.com/ros/robot_state_publisher/pull/30
49+
# TODO(orduno) Substitute with `PushNodeRemapping`
50+
# https://github.com/ros2/launch_ros/issues/56
51+
remappings = [('/tf', 'tf'),
52+
('/tf_static', 'tf_static')]
53+
54+
# Create our own temporary YAML files that include substitutions
55+
param_substitutions = {
56+
'use_sim_time': use_sim_time,
57+
'yaml_filename': map_yaml_file}
58+
59+
configured_params = RewrittenYaml(
60+
source_file=params_file,
61+
root_key=namespace,
62+
param_rewrites=param_substitutions,
63+
convert_types=True)
64+
65+
stdout_linebuf_envvar = SetEnvironmentVariable(
66+
'RCUTILS_LOGGING_BUFFERED_STREAM', '1')
67+
68+
declare_namespace_cmd = DeclareLaunchArgument(
69+
'namespace',
70+
default_value='',
71+
description='Top-level namespace')
72+
73+
declare_map_yaml_cmd = DeclareLaunchArgument(
74+
'map',
75+
description='Full path to map yaml file to load')
76+
77+
declare_use_sim_time_cmd = DeclareLaunchArgument(
78+
'use_sim_time',
79+
default_value='false',
80+
description='Use simulation (Gazebo) clock if true')
81+
82+
declare_params_file_cmd = DeclareLaunchArgument(
83+
'params_file',
84+
default_value=os.path.join(bringup_dir, 'params', 'nav2_params.yaml'),
85+
description='Full path to the ROS2 parameters file to use for all launched nodes')
86+
87+
declare_autostart_cmd = DeclareLaunchArgument(
88+
'autostart', default_value='true',
89+
description='Automatically startup the nav2 stack')
90+
91+
declare_use_composition_cmd = DeclareLaunchArgument(
92+
'use_composition', default_value='False',
93+
description='Use composed bringup if True')
94+
95+
declare_container_name_cmd = DeclareLaunchArgument(
96+
'container_name', default_value='nav2_container',
97+
description='the name of conatiner that nodes will load in if use composition')
98+
99+
declare_use_respawn_cmd = DeclareLaunchArgument(
100+
'use_respawn', default_value='False',
101+
description='Whether to respawn if a node crashes. Applied when composition is disabled.')
102+
103+
declare_log_level_cmd = DeclareLaunchArgument(
104+
'log_level', default_value='info',
105+
description='log level')
106+
107+
load_nodes = GroupAction(
108+
condition=IfCondition(PythonExpression(['not ', use_composition])),
109+
actions=[
110+
Node(
111+
package='nav2_map_server',
112+
executable='map_server',
113+
name='map_server',
114+
output='screen',
115+
respawn=use_respawn,
116+
respawn_delay=2.0,
117+
parameters=[configured_params],
118+
arguments=['--ros-args', '--log-level', log_level],
119+
remappings=remappings),
120+
Node(
121+
package='nav2_amcl',
122+
executable='amcl',
123+
name='amcl',
124+
output='screen',
125+
respawn=use_respawn,
126+
respawn_delay=2.0,
127+
parameters=[configured_params],
128+
arguments=['--ros-args', '--log-level', log_level],
129+
remappings=remappings),
130+
Node(
131+
package='nav2_lifecycle_manager',
132+
executable='lifecycle_manager',
133+
name='lifecycle_manager_localization',
134+
output='screen',
135+
arguments=['--ros-args', '--log-level', log_level],
136+
parameters=[{'use_sim_time': use_sim_time},
137+
{'autostart': autostart},
138+
{'node_names': lifecycle_nodes}])
139+
]
140+
)
141+
142+
load_composable_nodes = LoadComposableNodes(
143+
condition=IfCondition(use_composition),
144+
target_container=container_name,
145+
composable_node_descriptions=[
146+
ComposableNode(
147+
package='nav2_map_server',
148+
plugin='nav2_map_server::MapServer',
149+
name='map_server',
150+
parameters=[configured_params],
151+
remappings=remappings),
152+
ComposableNode(
153+
package='nav2_amcl',
154+
plugin='nav2_amcl::AmclNode',
155+
name='amcl',
156+
parameters=[configured_params],
157+
remappings=remappings),
158+
ComposableNode(
159+
package='nav2_lifecycle_manager',
160+
plugin='nav2_lifecycle_manager::LifecycleManager',
161+
name='lifecycle_manager_localization',
162+
parameters=[{'use_sim_time': use_sim_time,
163+
'autostart': autostart,
164+
'node_names': lifecycle_nodes}]),
165+
],
166+
)
167+
168+
# Create the launch description and populate
169+
ld = LaunchDescription()
170+
171+
# Set environment variables
172+
ld.add_action(stdout_linebuf_envvar)
173+
174+
# Declare the launch options
175+
ld.add_action(declare_namespace_cmd)
176+
ld.add_action(declare_map_yaml_cmd)
177+
ld.add_action(declare_use_sim_time_cmd)
178+
ld.add_action(declare_params_file_cmd)
179+
ld.add_action(declare_autostart_cmd)
180+
ld.add_action(declare_use_composition_cmd)
181+
ld.add_action(declare_container_name_cmd)
182+
ld.add_action(declare_use_respawn_cmd)
183+
ld.add_action(declare_log_level_cmd)
184+
185+
# Add the actions to launch all of the localiztion nodes
186+
ld.add_action(load_nodes)
187+
ld.add_action(load_composable_nodes)
188+
189+
return ld

0 commit comments

Comments
 (0)