Skip to content

Fix monaco and spa launcher #527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 0 additions & 76 deletions Launchers/monaco_circuit.launch .py

This file was deleted.

105 changes: 105 additions & 0 deletions Launchers/monaco_circuit.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import os

from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import (
DeclareLaunchArgument,
IncludeLaunchDescription,
SetEnvironmentVariable,
AppendEnvironmentVariable,
)
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, Command
from launch_ros.actions import Node
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node


def generate_launch_description():

x = LaunchConfiguration("x")
y = LaunchConfiguration("y")
z = LaunchConfiguration("z")
roll = LaunchConfiguration("R")
pitch = LaunchConfiguration("P")
yaw = LaunchConfiguration("Y")

package_dir = get_package_share_directory("custom_robots")
ros_gz_sim = get_package_share_directory("ros_gz_sim")

gazebo_models_path = os.path.join(package_dir, "models")

robot_launch_dir = "/opt/jderobot/Launchers/monaco_circuit"

use_sim_time = LaunchConfiguration("use_sim_time", default="true")
x_pose = LaunchConfiguration("x_pose", default="1.0")
y_pose = LaunchConfiguration("y_pose", default="-1.5")
z_pose = LaunchConfiguration("z_pose", default="7.1")
world_file_name = "monaco_circuit.world"
worlds_dir = "/opt/jderobot/Worlds"
world_path = os.path.join(worlds_dir, world_file_name)

gazebo_server = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(ros_gz_sim, "launch", "gz_sim.launch.py")
),
launch_arguments={
"gz_args": ["-r -s -v4 ", world_path],
"on_exit_shutdown": "true",
}.items(),
)

declare_x_cmd = DeclareLaunchArgument("x", default_value="1.0")

declare_y_cmd = DeclareLaunchArgument("y", default_value="-1.5")

declare_z_cmd = DeclareLaunchArgument("z", default_value="7.1")

declare_roll_cmd = DeclareLaunchArgument("R", default_value="0.0")

declare_pitch_cmd = DeclareLaunchArgument("P", default_value="0.0")

declare_yaw_cmd = DeclareLaunchArgument("Y", default_value="1.57079")

robot_state_publisher_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(robot_launch_dir, "robot_state_publisher.launch.py")
),
launch_arguments={"use_sim_time": use_sim_time}.items(),
)

spawn_robot_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(robot_launch_dir, "spawn_robot.launch.py")
),
launch_arguments={"x_pose": x_pose, "y_pose": y_pose, "z_pose": z_pose}.items(),
)

world_entity_cmd = Node(
package="ros_gz_sim",
executable="create",
arguments=["-name", "world", "-file", world_path],
output="screen",
)

ld = LaunchDescription()

ld.add_action(SetEnvironmentVariable("GZ_SIM_RESOURCE_PATH", gazebo_models_path))
set_env_vars_resources = AppendEnvironmentVariable(
"GZ_SIM_RESOURCE_PATH", os.path.join(package_dir, "models")
)
ld.add_action(set_env_vars_resources)
ld.add_action(gazebo_server)
# ld.add_action(gazebo_client)
ld.add_action(declare_x_cmd)
ld.add_action(declare_y_cmd)
ld.add_action(declare_z_cmd)
ld.add_action(declare_roll_cmd)
ld.add_action(declare_pitch_cmd)
ld.add_action(declare_yaw_cmd)
ld.add_action(world_entity_cmd)
ld.add_action(robot_state_publisher_cmd)
ld.add_action(spawn_robot_cmd)

return ld
58 changes: 58 additions & 0 deletions Launchers/monaco_circuit/robot_state_publisher.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/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():
use_sim_time = LaunchConfiguration("use_sim_time", default="true")
urdf_file_name = "turtlebot3_waffle.urdf"

print("urdf_file_name : {}".format(urdf_file_name))

urdf_path = os.path.join(
get_package_share_directory("custom_robots"), "urdf", urdf_file_name
)

with open(urdf_path, "r") as infp:
robot_desc = infp.read()

return LaunchDescription(
[
DeclareLaunchArgument(
"use_sim_time",
default_value="true",
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}
],
),
]
)
107 changes: 107 additions & 0 deletions Launchers/monaco_circuit/spawn_robot.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# 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
model_folder = "turtlebot3_waffle"
urdf_path = os.path.join(
get_package_share_directory("custom_robots"),
"models",
model_folder,
"model.sdf",
)

# Launch configuration variables specific to simulation
# x_pose = LaunchConfiguration('x_pose', default='1.0')
# y_pose = LaunchConfiguration('y_pose', default='-1.5')
# z_pose = LaunchConfiguration('z_pose', default='7.1')

# Declare the launch arguments
# declare_x_position_cmd = DeclareLaunchArgument(
# 'x_pose', default_value='1.0',
# description='Specify namespace of the robot')

# declare_y_position_cmd = DeclareLaunchArgument(
# 'y_pose', default_value='-1.5',
# description='Specify namespace of the robot')

# declare_z_position_cmd = DeclareLaunchArgument(
# 'z_pose', default_value='7.1',
# description='Specify namespace of the robot')

# start_gazebo_ros_spawner_cmd = Node(
# package='ros_gz_sim',
# executable='create',
# arguments=[
# '-name', 'waffle',
# '-file', urdf_path,
# '-x', x_pose,
# '-y', y_pose,
# '-z', z_pose
# ],
# output='screen',
# )

bridge_params = os.path.join(
get_package_share_directory("custom_robots"), "params", "robot_params.yaml"
)

start_gazebo_ros_bridge_cmd = Node(
package="ros_gz_bridge",
executable="parameter_bridge",
arguments=[
"--ros-args",
"-p",
f"config_file:={bridge_params}",
],
output="screen",
)

start_gazebo_ros_image_bridge_cmd = Node(
package="ros_gz_image",
executable="image_bridge",
arguments=["/turtlebot3/camera/image_raw"],
output="screen",
)

start_gazebo_ros_depth_bridge_cmd = Node(
package="ros_gz_image",
executable="image_bridge",
arguments=["/turtlebot3/camera/depth"],
output="screen",
)

ld = LaunchDescription()

# Declare the launch options
# ld.add_action(declare_x_position_cmd)
# ld.add_action(declare_y_position_cmd)
# ld.add_action(declare_z_position_cmd)

# Add any conditioned actions
# ld.add_action(start_gazebo_ros_spawner_cmd)
ld.add_action(start_gazebo_ros_bridge_cmd)
ld.add_action(start_gazebo_ros_image_bridge_cmd)
ld.add_action(start_gazebo_ros_depth_bridge_cmd)

return ld
Loading