Skip to content
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

Launch ros_gz_bridge from xml #550

Merged
merged 67 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
21d4c23
Add gzserver with ability to load an SDF file or string
azeey Feb 21, 2024
3a5e099
Testing components.
caguero Apr 3, 2024
1b3ba4e
Tweak
caguero Apr 4, 2024
04255e3
Tweak
caguero Apr 4, 2024
d28021a
Tweak
caguero Apr 4, 2024
82633e7
Style
caguero Apr 4, 2024
0a34d24
Merge remote-tracking branch 'origin/ros2' into gz_sim_ros_node
azeey Apr 4, 2024
2506cb9
Merge branch 'gz_sim_ros_node' into gz_sim_ros_node_composition
caguero Apr 4, 2024
2f19e16
Remove comments
caguero Apr 5, 2024
82f4ffb
Launch file for the bridge
caguero Apr 10, 2024
968a9dc
Tweak
caguero Apr 10, 2024
ff3149b
Tweak
caguero Apr 11, 2024
1124d28
Launch file for running gz_bridge (#530)
caguero Apr 11, 2024
1ff1ae7
gzserver launch file
caguero Apr 12, 2024
7ebdffd
Rename
caguero Apr 12, 2024
d220277
Merge branch 'gz_sim_ros_node_composition' into gzserver_launch
caguero Apr 12, 2024
09da4ed
Create a combined bridge+gzserver launch file.
caguero Apr 12, 2024
7718888
Spawn models with bridge
caguero Apr 12, 2024
de3908a
Initial launch_gz
caguero Apr 18, 2024
78127ca
Launch file for running gzserver (#532)
caguero Apr 18, 2024
3860b74
Update ros_gz_sim/launch/ros_gz_sim.launch.py
caguero Apr 18, 2024
54c68d7
Tweaks
caguero Apr 18, 2024
774334f
Merge from gz_sim_ros_node_composition
caguero Apr 18, 2024
1990402
Merge branch 'gzserver_and_bridge_launch' into spawn_model_and_bridge…
caguero Apr 18, 2024
4b16d7a
Style
caguero Apr 18, 2024
73dc37d
Tweaks
caguero Apr 26, 2024
c7aa5a5
Working gzserver.launch example
caguero May 10, 2024
9709a9f
Tweak
caguero May 13, 2024
43f2a88
Merge branch 'spawn_model_and_bridge_launch' into launch_gz
caguero May 13, 2024
2e28e0d
Merge branch 'ros2' into gz_sim_ros_node_composition
caguero May 13, 2024
16e5779
Merge branch 'gz_sim_ros_node_composition' into gzserver_and_bridge_l…
caguero May 13, 2024
c7fd874
Merge branch 'gzserver_and_bridge_launch' into spawn_model_and_bridge…
caguero May 13, 2024
ca47316
Merge branch 'spawn_model_and_bridge_launch' into launch_gz
caguero May 13, 2024
e6201ca
Update launch_gz/launch_gz/actions/__init__.py
caguero May 13, 2024
4e502c2
Update launch_gz/launch_gz/actions/gzserver.py
caguero May 13, 2024
95e9c78
Update launch_gz/launch_gz/actions/gzserver.py
caguero May 13, 2024
f4a6d1a
Update launch_gz/setup.py
caguero May 13, 2024
53c024a
Tweak
caguero May 13, 2024
c2a26ef
Launch file for combined gzserver + bridge (#533)
caguero May 15, 2024
6a73faa
Launch file for combined spawn_model + bridge (#534)
caguero May 15, 2024
7bcbd32
Merge branch 'gz_sim_ros_node_composition' into launch_gz
caguero May 15, 2024
7b80582
Adding launch_ros dependency
caguero May 17, 2024
bed3609
ros_gz_bridge launch action.
caguero May 20, 2024
c9c0b69
Tweak
caguero May 20, 2024
401586e
Tweak
caguero May 20, 2024
9694246
Missing file
caguero May 20, 2024
13e3716
Restore
caguero May 20, 2024
c4a3163
Spaces
caguero May 20, 2024
68919b6
Spacing
caguero May 20, 2024
1ba6ebf
Launch gzserver from xml (#548)
caguero May 21, 2024
7c380c3
Merge remote-tracking branch 'origin/ros2' into gz_sim_ros_node
azeey May 22, 2024
2b07936
Fix build, remove experimental code
azeey May 22, 2024
35be061
Add comment, fix linter
azeey May 22, 2024
85904db
Merge remote-tracking branch 'origin/gz_sim_ros_node' into gz_sim_ros…
azeey May 22, 2024
8d01ae8
Fix end of file newline
azeey May 22, 2024
2188858
Merge from gz_sim_ros_node_composition
caguero May 22, 2024
08e0389
Merge remote-tracking branch 'origin/ros2' into gz_sim_ros_node_compo…
azeey May 22, 2024
f7eaa49
Update ros_gz_sim/src/gzserver.cpp
caguero May 23, 2024
efb5f92
Update ros_gz_sim/src/gzserver.cpp
caguero May 23, 2024
01345e2
Remove launch_gz and use ros_gz_sim instead
caguero May 23, 2024
122ac28
Merge branch 'gz_sim_ros_node_composition' of github.com:gazebosim/ro…
caguero May 23, 2024
305097b
Tweaks
caguero May 23, 2024
2416aaf
Mostly styule.
caguero May 23, 2024
fc73dfb
Style
caguero May 23, 2024
9e8dd63
Tweaks
caguero May 23, 2024
5f73da5
Merge branch 'ros2' into launch_gz_bridge
caguero May 23, 2024
0bfc81d
Tweak
caguero May 23, 2024
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
5 changes: 5 additions & 0 deletions ros_gz_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ install(
DESTINATION include/${PROJECT_NAME}
)

install(
DIRECTORY launch/
DESTINATION share/${PROJECT_NAME}/launch
)

set(bridge_executables
parameter_bridge
static_bridge
Expand Down
16 changes: 16 additions & 0 deletions ros_gz_bridge/launch/ros_gz_bridge.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<launch>
<arg name="config_file" default="" />
<arg name="container_name" default="ros_gz_container" />
<arg name="namespace" default="" />
<arg name="use_composition" default="False" />
<arg name="use_respawn" default="False" />
<arg name="log_level" default="info" />
<ros_gz_bridge
config_file="$(var config_file)"
container_name="$(var container_name)"
namespace="$(var namespace)"
use_composition="$(var use_composition)"
use_respawn="$(var use_respawn)"
log_level="$(var log_level)">
</ros_gz_bridge>
</launch>
109 changes: 109 additions & 0 deletions ros_gz_bridge/launch/ros_gz_bridge.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Copyright 2024 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.

"""Launch ros_gz bridge in a component container."""

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, GroupAction
from launch.conditions import IfCondition
from launch.substitutions import LaunchConfiguration, PythonExpression
from launch_ros.actions import ComposableNodeContainer, Node
from launch_ros.descriptions import ComposableNode


def generate_launch_description():

config_file = LaunchConfiguration('config_file')
container_name = LaunchConfiguration('container_name')
namespace = LaunchConfiguration('namespace')
use_composition = LaunchConfiguration('use_composition')
use_respawn = LaunchConfiguration('use_respawn')
log_level = LaunchConfiguration('log_level')

declare_config_file_cmd = DeclareLaunchArgument(
'config_file', default_value='', description='YAML config file'
)

declare_container_name_cmd = DeclareLaunchArgument(
'container_name',
default_value='ros_gz_container',
description='Name of container that nodes will load in if use composition',
)

declare_namespace_cmd = DeclareLaunchArgument(
'namespace', default_value='', description='Top-level namespace'
)

declare_use_composition_cmd = DeclareLaunchArgument(
'use_composition', default_value='False', description='Use composed bringup if True'
)

declare_use_respawn_cmd = DeclareLaunchArgument(
'use_respawn',
default_value='False',
description='Whether to respawn if a node crashes. Applied when composition is disabled.',
)

declare_log_level_cmd = DeclareLaunchArgument(
'log_level', default_value='info', description='log level'
)

load_nodes = GroupAction(
condition=IfCondition(PythonExpression(['not ', use_composition])),
actions=[
Node(
package='ros_gz_bridge',
executable='bridge_node',
output='screen',
respawn=use_respawn,
respawn_delay=2.0,
parameters=[{'config_file': config_file}],
arguments=['--ros-args', '--log-level', log_level],
),
],
)

load_composable_nodes = ComposableNodeContainer(
condition=IfCondition(use_composition),
name=container_name,
namespace=namespace,
package='rclcpp_components',
executable='component_container',
composable_node_descriptions=[
ComposableNode(
package='ros_gz_bridge',
plugin='ros_gz_bridge::RosGzBridge',
name='ros_gz_bridge',
parameters=[{'config_file': config_file}],
extra_arguments=[{'use_intra_process_comms': True}],
),
],
output='screen',
)

# Create the launch description and populate
ld = LaunchDescription()

# Declare the launch options
ld.add_action(declare_config_file_cmd)
ld.add_action(declare_container_name_cmd)
ld.add_action(declare_namespace_cmd)
ld.add_action(declare_use_composition_cmd)
ld.add_action(declare_use_respawn_cmd)
ld.add_action(declare_log_level_cmd)
# Add the actions to launch all of the bridge nodes
ld.add_action(load_nodes)
ld.add_action(load_composable_nodes)

return ld
37 changes: 33 additions & 4 deletions ros_gz_sim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(std_msgs REQUIRED)

find_package(gz_math_vendor REQUIRED)
Expand All @@ -33,6 +34,9 @@ gz_find_package(gflags
PKGCONFIG gflags)
find_package(std_msgs REQUIRED)

# Install the python module for this package
ament_python_install_package(${PROJECT_NAME})

add_executable(create src/create.cpp)
ament_target_dependencies(create
rclcpp
Expand Down Expand Up @@ -60,15 +64,22 @@ install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION include/${PROJECT_NAME}
)

add_executable(gzserver src/gzserver.cpp)
ament_target_dependencies(gzserver
add_library(gzserver_component SHARED src/gzserver.cpp)
rclcpp_components_register_nodes(gzserver_component "ros_gz_sim::GzServer")
ament_target_dependencies(gzserver_component
rclcpp
rclcpp_components
std_msgs
)
target_link_libraries(gzserver
target_link_libraries(gzserver_component
gz-sim::core
)
ament_target_dependencies(gzserver std_msgs)
ament_target_dependencies(gzserver_component std_msgs)
rclcpp_components_register_node(
gzserver_component
PLUGIN "ros_gz_sim::GzServer"
EXECUTABLE gzserver
)

configure_file(
launch/gz_sim.launch.py.in
Expand All @@ -85,6 +96,16 @@ install(FILES
DESTINATION share/${PROJECT_NAME}/launch
)

install(FILES
"launch/gz_server.launch"
"launch/gz_server.launch.py"
"launch/gz_spawn_model.launch.py"
"launch/ros_gz_sim.launch.py"
"launch/ros_gz_sim.launch.py"
"launch/ros_gz_spawn_model.launch.py"
DESTINATION share/${PROJECT_NAME}/launch
)

install(TARGETS
create
DESTINATION lib/${PROJECT_NAME}
Expand All @@ -94,6 +115,14 @@ install(TARGETS
DESTINATION lib/${PROJECT_NAME}
)

ament_export_targets(export_gzserver_component)
install(TARGETS gzserver_component
EXPORT export_gzserver_component
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

install(
TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION lib
Expand Down
12 changes: 12 additions & 0 deletions ros_gz_sim/launch/gz_server.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<launch>
<arg name="world_sdf_file" default="empty.sdf" />
<arg name="world_sdf_string" default="" />
<arg name="container_name" default="ros_gz_container" />
<arg name="use_composition" default="False" />
<gz_server
world_sdf_file="$(var world_sdf_file)"
world_sdf_string="$(var world_sdf_string)"
container_name="$(var container_name)"
use_composition="$(var use_composition)">
</gz_server>
</launch>
80 changes: 80 additions & 0 deletions ros_gz_sim/launch/gz_server.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright 2024 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.

"""Launch gz_server in a component container."""

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.conditions import IfCondition
from launch.substitutions import LaunchConfiguration, PythonExpression, TextSubstitution
from launch_ros.actions import ComposableNodeContainer, Node
from launch_ros.descriptions import ComposableNode


def generate_launch_description():

declare_world_sdf_file_cmd = DeclareLaunchArgument(
'world_sdf_file', default_value=TextSubstitution(text=''),
description='Path to the SDF world file')
declare_world_sdf_string_cmd = DeclareLaunchArgument(
'world_sdf_string', default_value=TextSubstitution(text=''),
description='SDF world string')
declare_container_name_cmd = DeclareLaunchArgument(
'container_name', default_value='ros_gz_container',
description='Name of container that nodes will load in if use composition',)
declare_use_composition_cmd = DeclareLaunchArgument(
'use_composition', default_value='False',
description='Use composed bringup if True')

load_nodes = Node(
condition=IfCondition(PythonExpression(['not ', LaunchConfiguration('use_composition')])),
package='ros_gz_sim',
executable='gzserver',
output='screen',
parameters=[{'world_sdf_file': LaunchConfiguration('world_sdf_file'),
'world_sdf_string': LaunchConfiguration('world_sdf_string')}],
)

load_composable_nodes = ComposableNodeContainer(
condition=IfCondition(LaunchConfiguration('use_composition')),
name=LaunchConfiguration('container_name'),
namespace='',
package='rclcpp_components',
executable='component_container',
composable_node_descriptions=[
ComposableNode(
package='ros_gz_sim',
plugin='ros_gz_sim::GzServer',
name='gz_server',
parameters=[{'world_sdf_file': LaunchConfiguration('world_sdf_file'),
'world_sdf_string': LaunchConfiguration('world_sdf_string')}],
extra_arguments=[{'use_intra_process_comms': True}],
),
],
output='screen',
)

# Create the launch description and populate
ld = LaunchDescription()

# Declare the launch options
ld.add_action(declare_world_sdf_file_cmd)
ld.add_action(declare_world_sdf_string_cmd)
ld.add_action(declare_container_name_cmd)
ld.add_action(declare_use_composition_cmd)
# Add the actions to launch all of the gz_server nodes
ld.add_action(load_nodes)
ld.add_action(load_composable_nodes)

return ld
Loading