Skip to content

Commit

Permalink
Refine ros_gz_shims
Browse files Browse the repository at this point in the history
Co-authored-by: Louise Poubel <[email protected]>
  • Loading branch information
methylDragon and chapulina committed Aug 11, 2022
1 parent 554cf11 commit da80ba7
Show file tree
Hide file tree
Showing 39 changed files with 189 additions and 2,829 deletions.
2 changes: 1 addition & 1 deletion ros_gz_shims/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ ros2 run ros_gz parameter_bridge [...]
ros2 run ros_ign parameter_bridge [...] # Will emit deprecation warning
```

Additionally, installed files like launchfiles, message interfaces etc. are **duplicated** versions of the ones in `ros_gz` (but renamed as appropriate), and point to `ros_gz` dependencies as well (e.g. launchfiles pointing to `ros_gz` nodes.)
Additionally, installed files like launch files, message interfaces etc. are **duplicated** versions of the ones in `ros_gz` (but renamed as appropriate), and point to `ros_gz` dependencies as well (e.g. launch files pointing to `ros_gz` nodes.)
2 changes: 1 addition & 1 deletion ros_gz_shims/ros_ign/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# This is a shim meta-package
For [ros_gz](https://github.com/gazebosim/ros_gz)
For [ros_gz](https://github.com/gazebosim/ros_gz/tree/ros2/ros_gz)
6 changes: 1 addition & 5 deletions ros_gz_shims/ros_ign/package.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<!-- TODO: Make this a metapackage, see
https://github.com/ros2/ros2/issues/408 -->
<name>ros_ign</name>
<version>0.0.1</version>
<description>Shim meta-package to redirect to <a href="https://github.com/gazebosim/ros_gz">ros_gz</a>.</description>
<description>Shim meta-package to redirect to <a href="https://github.com/gazebosim/ros_gz/tree/ros2/ros_gz">ros_gz</a>.</description>
<maintainer email="[email protected]">Brandon Ong</maintainer>
<license>Apache 2.0</license>

Expand All @@ -16,8 +14,6 @@
<exec_depend>ros_ign_gazebo</exec_depend>
<exec_depend>ros_ign_gazebo_demos</exec_depend>
<exec_depend>ros_ign_image</exec_depend>
<!-- See https://github.com/gazebosim/ros_gz/issues/40 -->
<!--exec_depend>ros_gz_point_cloud</exec_depend-->

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
Expand Down
15 changes: 14 additions & 1 deletion ros_gz_shims/ros_ign_bridge/src/parameter_bridge_shim.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
// Copyright 2022 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.

// Shim to redirect "ros_ign_bridge parameter_bridge" call to "ros_gz_bridge parameter_bridge"

#include <string>
#include <sstream>
#include <iostream>
#include <stdlib.h>
Expand Down
15 changes: 14 additions & 1 deletion ros_gz_shims/ros_ign_bridge/src/static_bridge_shim.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
// Copyright 2022 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.

// Shim to redirect "ros_ign_bridge static_bridge" call to "ros_gz_bridge static_bridge"

#include <string>
#include <sstream>
#include <iostream>
#include <stdlib.h>
Expand Down
18 changes: 18 additions & 0 deletions ros_gz_shims/ros_ign_gazebo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ ament_export_dependencies(
ros_gz_bridge
)

# Edifice
if("$ENV{GZ_VERSION}" STREQUAL "edifice")
find_package(ignition-gazebo5 REQUIRED)
set(GZ_SIM_VER ${ignition-gazebo5_VERSION_MAJOR})
message(STATUS "Compiling against Gazebo Edifice")
# Garden
elseif("$ENV{GZ_VERSION}" STREQUAL "garden")
find_package(gz-sim7 REQUIRED)
set(GZ_SIM_VER ${gz-sim7_VERSION_MAJOR})
set(GZ_TARGET_PREFIX gz)
message(STATUS "Compiling against Gazebo Garden")
# Default to Fortress
else()
find_package(ignition-gazebo6 REQUIRED)
set(GZ_SIM_VER ${ignition-gazebo6_VERSION_MAJOR})
message(STATUS "Compiling against Gazebo Fortress")
endif()

configure_file(
launch/ign_gazebo.launch.py.in
launch/ign_gazebo.launch.py.configured
Expand Down
2 changes: 2 additions & 0 deletions ros_gz_shims/ros_ign_gazebo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This is a shim package
For [ros_gz_sim](https://github.com/gazebosim/ros_gz/tree/ros2/ros_gz_sim)
15 changes: 14 additions & 1 deletion ros_gz_shims/ros_ign_gazebo/src/create_shim.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
// Copyright 2022 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.

// Shim to redirect "ros_ign_bridge parameter_bridge" call to "ros_gz_sim parameter_bridge"

#include <string>
#include <sstream>
#include <iostream>
#include <stdlib.h>
Expand Down
12 changes: 0 additions & 12 deletions ros_gz_shims/ros_ign_gazebo_demos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,4 @@ install(
DESTINATION share/${PROJECT_NAME}/launch
)

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

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

ament_package()
43 changes: 7 additions & 36 deletions ros_gz_shims/ros_ign_gazebo_demos/launch/air_pressure.launch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 Open Source Robotics Foundation, Inc.
# Copyright 2022 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.
Expand All @@ -12,52 +12,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Launch Gazebo Sim with command line arguments."""

import os

from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration

from launch_ros.actions import Node


def generate_launch_description():
print("ros_ign_gazebo_demos is deprecated! Please use ros_gz_sim_demos instead!")

pkg_ros_gz_sim = get_package_share_directory('ros_gz_sim')

# Bridge
bridge = Node(
package='ros_gz_bridge',
executable='parameter_bridge',
arguments=['/air_pressure@sensor_msgs/msg/[email protected]'],
parameters=[{'qos_overrides./air_pressure.publisher.reliability': 'best_effort'}],
output='screen'
)

gz_sim = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(pkg_ros_gz_sim, 'launch', 'gz_sim.launch.py')),
launch_arguments={'gz_args': '-r sensors.sdf'}.items(),
)
pkg_ros_gz_sim_demos = get_package_share_directory('ros_gz_sim_demos')

# RQt
rqt = Node(
package='rqt_topic',
executable='rqt_topic',
arguments=['-t'],
condition=IfCondition(LaunchConfiguration('rqt'))
)
return LaunchDescription([
gz_sim,
DeclareLaunchArgument('rqt', default_value='true',
description='Open RQt.'),
bridge,
rqt
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(pkg_ros_gz_sim_demos, 'launch', 'air_pressure.launch.py')),
)
])
49 changes: 7 additions & 42 deletions ros_gz_shims/ros_ign_gazebo_demos/launch/battery.launch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 Open Source Robotics Foundation, Inc.
# Copyright 2022 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.
Expand All @@ -17,53 +17,18 @@
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration

from launch_ros.actions import Node


def generate_launch_description():
print("ros_ign_gazebo_demos is deprecated! Please use ros_gz_sim_demos instead!")

pkg_ros_gz_sim = get_package_share_directory('ros_gz_sim')

# RQt
rqt = Node(
package='rqt_plot',
executable='rqt_plot',
# FIXME: Why isn't the topic being populated on the UI? RQt issue?
arguments=['--force-discover',
'/model/vehicle_blue/battery/linear_battery/state/percentage'],
condition=IfCondition(LaunchConfiguration('rqt'))
)

gz_sim = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(pkg_ros_gz_sim, 'launch', 'gz_sim.launch.py')),
launch_arguments={
'gz_args': '-r -z 1000000 linear_battery_demo.sdf'
}.items(),
)

# Bridge
bridge = Node(
package='ros_gz_bridge',
executable='parameter_bridge',
arguments=[
'/model/vehicle_blue/cmd_vel@geometry_msgs/msg/[email protected]',
'/model/vehicle_blue/battery/linear_battery/state@sensor_msgs/msg/BatteryState@'
'ignition.msgs.BatteryState'
],
output='screen'
)
pkg_ros_gz_sim_demos = get_package_share_directory('ros_gz_sim_demos')

return LaunchDescription([
gz_sim,
DeclareLaunchArgument('rqt', default_value='true',
description='Open RQt.'),
bridge,
rqt
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(pkg_ros_gz_sim_demos, 'launch', 'battery.launch.py')),
)
])
41 changes: 6 additions & 35 deletions ros_gz_shims/ros_ign_gazebo_demos/launch/camera.launch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 Open Source Robotics Foundation, Inc.
# Copyright 2022 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.
Expand All @@ -17,47 +17,18 @@
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration

from launch_ros.actions import Node


def generate_launch_description():
print("ros_ign_gazebo_demos is deprecated! Please use ros_gz_sim_demos instead!")

pkg_ros_gz_sim_demos = get_package_share_directory('ros_gz_sim_demos')
pkg_ros_gz_sim = get_package_share_directory('ros_gz_sim')

gz_sim = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(pkg_ros_gz_sim, 'launch', 'gz_sim.launch.py')),
launch_arguments={'gz_args': '-r camera_sensor.sdf'}.items(),
)

# RViz
rviz = Node(
package='rviz2',
executable='rviz2',
arguments=['-d', os.path.join(pkg_ros_gz_sim_demos, 'rviz', 'camera.rviz')],
condition=IfCondition(LaunchConfiguration('rviz'))
)

# Bridge
bridge = Node(
package='ros_gz_bridge',
executable='parameter_bridge',
arguments=['/camera@sensor_msgs/msg/[email protected]',
'/camera_info@sensor_msgs/msg/[email protected]'],
output='screen'
)

return LaunchDescription([
DeclareLaunchArgument('rviz', default_value='true',
description='Open RViz.'),
gz_sim,
bridge,
rviz
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(pkg_ros_gz_sim_demos, 'launch', 'camera.launch.py')),
)
])
Loading

0 comments on commit da80ba7

Please sign in to comment.