-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Launch files to launch ros2 nodes
- Loading branch information
1 parent
7c48194
commit 9debdd4
Showing
4 changed files
with
220 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Copyright 2019 ROBOTIS CO., LTD. | ||
# | ||
# 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. | ||
# | ||
# Authors: Darby Lim | ||
|
||
import os | ||
|
||
from ament_index_python.packages import get_package_share_directory | ||
from launch import LaunchDescription | ||
from launch.actions import DeclareLaunchArgument | ||
from launch.substitutions import LaunchConfiguration | ||
from launch_ros.actions import Node | ||
|
||
|
||
def generate_launch_description(): | ||
TURTLEBOT3_MODEL = os.environ['TURTLEBOT3_MODEL'] | ||
|
||
use_sim_time = LaunchConfiguration('use_sim_time', default='false') | ||
urdf_file_name = 'turtlebot3_' + TURTLEBOT3_MODEL + '.urdf' | ||
|
||
print('urdf_file_name : {}'.format(urdf_file_name)) | ||
|
||
urdf_path = "src/walker/urdf/turtlebot3_burger.urdf" | ||
|
||
with open(urdf_path, 'r') as infp: | ||
robot_desc = infp.read() | ||
|
||
return LaunchDescription([ | ||
DeclareLaunchArgument( | ||
'use_sim_time', | ||
default_value='false', | ||
description='Use simulation (Gazebo) clock if true'), | ||
|
||
Node( | ||
package='robot_state_publisher', | ||
executable='robot_state_publisher', | ||
name='robot_state_publisher', | ||
output='screen', | ||
parameters=[{ | ||
'use_sim_time': use_sim_time, | ||
'robot_description': robot_desc | ||
}], | ||
), | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<launch> | ||
<arg name="record" default="false"/> // record rosbag | ||
<arg name="bag_name" default="walker_bagfile"/> // default name of bagfile | ||
|
||
<include file= "src/walker/launch/turtlebot3_world.launch.py"/> // launch turtlebot3 world | ||
|
||
<set_env name="TURTLEBOT3_MODEL" value="burger"/> // set turtlebot3 model | ||
|
||
<node pkg="walker" exec="WALKER" name="walker" output="screen"/> // launch walker node | ||
|
||
<executable cmd="ros2 bag record -a --output src/walker/bagfiles/$(var bag_name)" if="$(var record)"/> // record rosbag | ||
|
||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Copyright 2019 Open Source Robotics Foundation, Inc. | ||
# | ||
# 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 | ||
from launch.substitutions import LaunchConfiguration | ||
from launch_ros.actions import Node | ||
|
||
|
||
def generate_launch_description(): | ||
# Get the urdf file | ||
TURTLEBOT3_MODEL = os.environ['TURTLEBOT3_MODEL'] | ||
model_folder = 'turtlebot3_' + TURTLEBOT3_MODEL | ||
urdf_path = os.path.join( | ||
get_package_share_directory('walker'), | ||
'models', | ||
model_folder, | ||
'model.sdf' | ||
) | ||
|
||
# Launch configuration variables specific to simulation | ||
x_pose = LaunchConfiguration('x_pose', default='0.0') | ||
y_pose = LaunchConfiguration('y_pose', default='0.0') | ||
|
||
# Declare the launch arguments | ||
declare_x_position_cmd = DeclareLaunchArgument( | ||
'x_pose', default_value='0.0', | ||
description='Specify namespace of the robot') | ||
|
||
declare_y_position_cmd = DeclareLaunchArgument( | ||
'y_pose', default_value='0.0', | ||
description='Specify namespace of the robot') | ||
|
||
start_gazebo_ros_spawner_cmd = Node( | ||
package='gazebo_ros', | ||
executable='spawn_entity.py', | ||
arguments=[ | ||
'-entity', TURTLEBOT3_MODEL, | ||
'-file', urdf_path, | ||
'-x', x_pose, | ||
'-y', y_pose, | ||
'-z', '0.01' | ||
], | ||
output='screen', | ||
) | ||
|
||
ld = LaunchDescription() | ||
|
||
# Declare the launch options | ||
ld.add_action(declare_x_position_cmd) | ||
ld.add_action(declare_y_position_cmd) | ||
|
||
# Add any conditioned actions | ||
ld.add_action(start_gazebo_ros_spawner_cmd) | ||
|
||
return ld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Copyright 2019 ROBOTIS CO., LTD. | ||
# | ||
# 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. | ||
# | ||
# Authors: Joep Tool | ||
|
||
import os | ||
|
||
from ament_index_python.packages import get_package_share_directory | ||
from launch import LaunchDescription | ||
from launch.actions import IncludeLaunchDescription | ||
from launch.launch_description_sources import PythonLaunchDescriptionSource | ||
from launch.substitutions import LaunchConfiguration | ||
|
||
|
||
def generate_launch_description(): | ||
launch_file_dir = os.path.join(get_package_share_directory('walker'), 'launch') | ||
pkg_gazebo_ros = get_package_share_directory('gazebo_ros') | ||
|
||
use_sim_time = LaunchConfiguration('use_sim_time', default='true') | ||
x_pose = LaunchConfiguration('x_pose', default='-2.0') | ||
y_pose = LaunchConfiguration('y_pose', default='-0.5') | ||
|
||
world = os.path.join( | ||
get_package_share_directory('walker'), | ||
'worlds', | ||
'turtlebot3_world.world' | ||
) | ||
|
||
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(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(launch_file_dir, 'spawn_turtlebot3.launch.py') | ||
), | ||
launch_arguments={ | ||
'x_pose': x_pose, | ||
'y_pose': y_pose | ||
}.items() | ||
) | ||
|
||
ld = LaunchDescription() | ||
|
||
# Add the commands to the launch description | ||
ld.add_action(gzserver_cmd) | ||
ld.add_action(gzclient_cmd) | ||
ld.add_action(robot_state_publisher_cmd) | ||
ld.add_action(spawn_turtlebot_cmd) | ||
|
||
return ld |