Skip to content

Commit b02af76

Browse files
authored
Merge pull request #527 from JdeRobot/fix-monaco-launcher
Fix monaco and spa launcher
2 parents 2945534 + 446440a commit b02af76

10 files changed

+578
-156
lines changed

Launchers/monaco_circuit.launch .py

Lines changed: 0 additions & 76 deletions
This file was deleted.

Launchers/monaco_circuit.launch.py

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import os
2+
3+
from ament_index_python.packages import get_package_share_directory
4+
5+
from launch import LaunchDescription
6+
from launch.actions import (
7+
DeclareLaunchArgument,
8+
IncludeLaunchDescription,
9+
SetEnvironmentVariable,
10+
AppendEnvironmentVariable,
11+
)
12+
from launch.launch_description_sources import PythonLaunchDescriptionSource
13+
from launch.substitutions import LaunchConfiguration, Command
14+
from launch_ros.actions import Node
15+
from launch.substitutions import LaunchConfiguration
16+
from launch_ros.actions import Node
17+
18+
19+
def generate_launch_description():
20+
21+
x = LaunchConfiguration("x")
22+
y = LaunchConfiguration("y")
23+
z = LaunchConfiguration("z")
24+
roll = LaunchConfiguration("R")
25+
pitch = LaunchConfiguration("P")
26+
yaw = LaunchConfiguration("Y")
27+
28+
package_dir = get_package_share_directory("custom_robots")
29+
ros_gz_sim = get_package_share_directory("ros_gz_sim")
30+
31+
gazebo_models_path = os.path.join(package_dir, "models")
32+
33+
robot_launch_dir = "/opt/jderobot/Launchers/monaco_circuit"
34+
35+
use_sim_time = LaunchConfiguration("use_sim_time", default="true")
36+
x_pose = LaunchConfiguration("x_pose", default="1.0")
37+
y_pose = LaunchConfiguration("y_pose", default="-1.5")
38+
z_pose = LaunchConfiguration("z_pose", default="7.1")
39+
world_file_name = "monaco_circuit.world"
40+
worlds_dir = "/opt/jderobot/Worlds"
41+
world_path = os.path.join(worlds_dir, world_file_name)
42+
43+
gazebo_server = IncludeLaunchDescription(
44+
PythonLaunchDescriptionSource(
45+
os.path.join(ros_gz_sim, "launch", "gz_sim.launch.py")
46+
),
47+
launch_arguments={
48+
"gz_args": ["-r -s -v4 ", world_path],
49+
"on_exit_shutdown": "true",
50+
}.items(),
51+
)
52+
53+
declare_x_cmd = DeclareLaunchArgument("x", default_value="1.0")
54+
55+
declare_y_cmd = DeclareLaunchArgument("y", default_value="-1.5")
56+
57+
declare_z_cmd = DeclareLaunchArgument("z", default_value="7.1")
58+
59+
declare_roll_cmd = DeclareLaunchArgument("R", default_value="0.0")
60+
61+
declare_pitch_cmd = DeclareLaunchArgument("P", default_value="0.0")
62+
63+
declare_yaw_cmd = DeclareLaunchArgument("Y", default_value="1.57079")
64+
65+
robot_state_publisher_cmd = IncludeLaunchDescription(
66+
PythonLaunchDescriptionSource(
67+
os.path.join(robot_launch_dir, "robot_state_publisher.launch.py")
68+
),
69+
launch_arguments={"use_sim_time": use_sim_time}.items(),
70+
)
71+
72+
spawn_robot_cmd = IncludeLaunchDescription(
73+
PythonLaunchDescriptionSource(
74+
os.path.join(robot_launch_dir, "spawn_robot.launch.py")
75+
),
76+
launch_arguments={"x_pose": x_pose, "y_pose": y_pose, "z_pose": z_pose}.items(),
77+
)
78+
79+
world_entity_cmd = Node(
80+
package="ros_gz_sim",
81+
executable="create",
82+
arguments=["-name", "world", "-file", world_path],
83+
output="screen",
84+
)
85+
86+
ld = LaunchDescription()
87+
88+
ld.add_action(SetEnvironmentVariable("GZ_SIM_RESOURCE_PATH", gazebo_models_path))
89+
set_env_vars_resources = AppendEnvironmentVariable(
90+
"GZ_SIM_RESOURCE_PATH", os.path.join(package_dir, "models")
91+
)
92+
ld.add_action(set_env_vars_resources)
93+
ld.add_action(gazebo_server)
94+
# ld.add_action(gazebo_client)
95+
ld.add_action(declare_x_cmd)
96+
ld.add_action(declare_y_cmd)
97+
ld.add_action(declare_z_cmd)
98+
ld.add_action(declare_roll_cmd)
99+
ld.add_action(declare_pitch_cmd)
100+
ld.add_action(declare_yaw_cmd)
101+
ld.add_action(world_entity_cmd)
102+
ld.add_action(robot_state_publisher_cmd)
103+
ld.add_action(spawn_robot_cmd)
104+
105+
return ld
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Copyright 2019 ROBOTIS CO., LTD.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# Authors: Darby Lim
18+
19+
import os
20+
21+
from ament_index_python.packages import get_package_share_directory
22+
from launch import LaunchDescription
23+
from launch.actions import DeclareLaunchArgument
24+
from launch.substitutions import LaunchConfiguration
25+
from launch_ros.actions import Node
26+
27+
28+
def generate_launch_description():
29+
use_sim_time = LaunchConfiguration("use_sim_time", default="true")
30+
urdf_file_name = "turtlebot3_waffle.urdf"
31+
32+
print("urdf_file_name : {}".format(urdf_file_name))
33+
34+
urdf_path = os.path.join(
35+
get_package_share_directory("custom_robots"), "urdf", urdf_file_name
36+
)
37+
38+
with open(urdf_path, "r") as infp:
39+
robot_desc = infp.read()
40+
41+
return LaunchDescription(
42+
[
43+
DeclareLaunchArgument(
44+
"use_sim_time",
45+
default_value="true",
46+
description="Use simulation (Gazebo) clock if true",
47+
),
48+
Node(
49+
package="robot_state_publisher",
50+
executable="robot_state_publisher",
51+
name="robot_state_publisher",
52+
output="screen",
53+
parameters=[
54+
{"use_sim_time": use_sim_time, "robot_description": robot_desc}
55+
],
56+
),
57+
]
58+
)
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Copyright 2019 Open Source Robotics Foundation, Inc.
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+
from launch import LaunchDescription
19+
from launch.actions import DeclareLaunchArgument
20+
from launch.substitutions import LaunchConfiguration
21+
from launch_ros.actions import Node
22+
23+
24+
def generate_launch_description():
25+
# Get the urdf file
26+
model_folder = "turtlebot3_waffle"
27+
urdf_path = os.path.join(
28+
get_package_share_directory("custom_robots"),
29+
"models",
30+
model_folder,
31+
"model.sdf",
32+
)
33+
34+
# Launch configuration variables specific to simulation
35+
# x_pose = LaunchConfiguration('x_pose', default='1.0')
36+
# y_pose = LaunchConfiguration('y_pose', default='-1.5')
37+
# z_pose = LaunchConfiguration('z_pose', default='7.1')
38+
39+
# Declare the launch arguments
40+
# declare_x_position_cmd = DeclareLaunchArgument(
41+
# 'x_pose', default_value='1.0',
42+
# description='Specify namespace of the robot')
43+
44+
# declare_y_position_cmd = DeclareLaunchArgument(
45+
# 'y_pose', default_value='-1.5',
46+
# description='Specify namespace of the robot')
47+
48+
# declare_z_position_cmd = DeclareLaunchArgument(
49+
# 'z_pose', default_value='7.1',
50+
# description='Specify namespace of the robot')
51+
52+
# start_gazebo_ros_spawner_cmd = Node(
53+
# package='ros_gz_sim',
54+
# executable='create',
55+
# arguments=[
56+
# '-name', 'waffle',
57+
# '-file', urdf_path,
58+
# '-x', x_pose,
59+
# '-y', y_pose,
60+
# '-z', z_pose
61+
# ],
62+
# output='screen',
63+
# )
64+
65+
bridge_params = os.path.join(
66+
get_package_share_directory("custom_robots"), "params", "robot_params.yaml"
67+
)
68+
69+
start_gazebo_ros_bridge_cmd = Node(
70+
package="ros_gz_bridge",
71+
executable="parameter_bridge",
72+
arguments=[
73+
"--ros-args",
74+
"-p",
75+
f"config_file:={bridge_params}",
76+
],
77+
output="screen",
78+
)
79+
80+
start_gazebo_ros_image_bridge_cmd = Node(
81+
package="ros_gz_image",
82+
executable="image_bridge",
83+
arguments=["/turtlebot3/camera/image_raw"],
84+
output="screen",
85+
)
86+
87+
start_gazebo_ros_depth_bridge_cmd = Node(
88+
package="ros_gz_image",
89+
executable="image_bridge",
90+
arguments=["/turtlebot3/camera/depth"],
91+
output="screen",
92+
)
93+
94+
ld = LaunchDescription()
95+
96+
# Declare the launch options
97+
# ld.add_action(declare_x_position_cmd)
98+
# ld.add_action(declare_y_position_cmd)
99+
# ld.add_action(declare_z_position_cmd)
100+
101+
# Add any conditioned actions
102+
# ld.add_action(start_gazebo_ros_spawner_cmd)
103+
ld.add_action(start_gazebo_ros_bridge_cmd)
104+
ld.add_action(start_gazebo_ros_image_bridge_cmd)
105+
ld.add_action(start_gazebo_ros_depth_bridge_cmd)
106+
107+
return ld

0 commit comments

Comments
 (0)