Skip to content

Commit

Permalink
Implement shims
Browse files Browse the repository at this point in the history
Signed-off-by: methylDragon <[email protected]>
  • Loading branch information
methylDragon committed Jul 25, 2022
1 parent d94e7c7 commit 1ac6afe
Show file tree
Hide file tree
Showing 68 changed files with 3,925 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ros_gz_shims/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Description

These are shim packages for `ros_gz` that redirect executable calls to the related `ros_gz` executable.
These require `ros_gz` to be installed though, but are set up to depend on `ros_gz`.

This allows users to do either of these and get equivalent behavior:

```bash
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.)
10 changes: 10 additions & 0 deletions ros_gz_shims/ros_ign/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.5)
project(ros_ign)
find_package(ament_cmake REQUIRED)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
2 changes: 2 additions & 0 deletions ros_gz_shims/ros_ign/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This is a shim meta-package
For [ros_gz](https://github.com/gazebosim/ros_gz)
28 changes: 28 additions & 0 deletions ros_gz_shims/ros_ign/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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>
<maintainer email="[email protected]">Brandon Ong</maintainer>
<license>Apache 2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<exec_depend>ros_gz</exec_depend>

<exec_depend>ros_ign_bridge</exec_depend>
<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>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
29 changes: 29 additions & 0 deletions ros_gz_shims/ros_ign_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.5)
project(ros_ign_bridge)

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
endif()

find_package(ament_cmake REQUIRED)
find_package(ament_index_cpp REQUIRED)

add_executable(parameter_bridge src/parameter_bridge_shim.cpp)
ament_target_dependencies(parameter_bridge ament_index_cpp)

add_executable(static_bridge src/static_bridge_shim.cpp)
ament_target_dependencies(static_bridge ament_index_cpp)

ament_export_dependencies(ament_index_cpp ros_gz_bridge)

install(TARGETS
parameter_bridge
static_bridge
DESTINATION lib/${PROJECT_NAME}
)

ament_package()
2 changes: 2 additions & 0 deletions ros_gz_shims/ros_ign_bridge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This is a shim package
For [ros_gz_bridge](https://github.com/gazebosim/ros_gz/tree/ros2/ros_gz_bridge)
19 changes: 19 additions & 0 deletions ros_gz_shims/ros_ign_bridge/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>ros_ign_bridge</name>
<version>0.0.1</version>
<description>Shim package to redirect to ros_gz_bridge.</description>
<maintainer email="[email protected]">Brandon Ong</maintainer>

<license>Apache 2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_index_cpp</buildtool_depend>

<depend>ros_gz_bridge</depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
30 changes: 30 additions & 0 deletions ros_gz_shims/ros_ign_bridge/src/parameter_bridge_shim.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Shim to redirect "ros_ign_bridge parameter_bridge" call to "ros_gz_bridge parameter_bridge"

#include <string>
#include <sstream>
#include <iostream>
#include <stdlib.h>

#include <ament_index_cpp/get_package_prefix.hpp>


int main(int argc, char * argv[])
{
std::stringstream cli_call;

cli_call << ament_index_cpp::get_package_prefix("ros_gz_bridge")
<< "/lib/ros_gz_bridge/parameter_bridge";

if (argc > 1)
{
for (int i = 1; i < argc; i++)
cli_call << " " << argv[i];
}

std::cerr << "[ros_ign_bridge] is deprecated! "
<< "Redirecting to use [ros_gz_bridge] instead!"
<< std::endl << std::endl;
system(cli_call.str().c_str());

return 0;
}
30 changes: 30 additions & 0 deletions ros_gz_shims/ros_ign_bridge/src/static_bridge_shim.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Shim to redirect "ros_ign_bridge static_bridge" call to "ros_gz_bridge static_bridge"

#include <string>
#include <sstream>
#include <iostream>
#include <stdlib.h>

#include <ament_index_cpp/get_package_prefix.hpp>


int main(int argc, char * argv[])
{
std::stringstream cli_call;

cli_call << ament_index_cpp::get_package_prefix("ros_gz_bridge")
<< "/lib/ros_gz_bridge/static_bridge";

if (argc > 1)
{
for (int i = 1; i < argc; i++)
cli_call << " " << argv[i];
}

std::cerr << "[ros_ign_bridge] is deprecated! "
<< "Redirecting to use [ros_gz_bridge] instead!"
<< std::endl << std::endl;
system(cli_call.str().c_str());

return 0;
}
45 changes: 45 additions & 0 deletions ros_gz_shims/ros_ign_gazebo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
cmake_minimum_required(VERSION 3.5)
project(ros_ign_gazebo)

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
endif()

find_package(ament_cmake REQUIRED)
find_package(ament_index_cpp REQUIRED)

add_executable(create
src/create_shim.cpp
)
ament_target_dependencies(create ament_index_cpp)

ament_export_dependencies(
ament_index_cpp
ros_gz_bridge
)

configure_file(
launch/ign_gazebo.launch.py.in
launch/ign_gazebo.launch.py.configured
@ONLY
)
file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/launch/ign_gazebo.launch.py"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/launch/ign_gazebo.launch.py.configured"
)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/launch/ign_gazebo.launch.py"
DESTINATION share/${PROJECT_NAME}/launch
)

install(TARGETS
create
DESTINATION lib/${PROJECT_NAME}
)

ament_package()
63 changes: 63 additions & 0 deletions ros_gz_shims/ros_ign_gazebo/launch/ign_gazebo.launch.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2020 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 Gazebo Sim with command line arguments."""

from os import environ

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import ExecuteProcess
from launch.substitutions import LaunchConfiguration


def generate_launch_description():
env = {'GZ_SIM_SYSTEM_PLUGIN_PATH':
':'.join([environ.get('GZ_SIM_SYSTEM_PLUGIN_PATH', default=''),
environ.get('LD_LIBRARY_PATH', default='')]),
'IGN_GAZEBO_SYSTEM_PLUGIN_PATH': # TODO(CH3): To support pre-garden. Deprecated.
':'.join([environ.get('IGN_GAZEBO_SYSTEM_PLUGIN_PATH', default=''),
environ.get('LD_LIBRARY_PATH', default='')])}

return LaunchDescription([
DeclareLaunchArgument('gz_args', default_value='',
description='Arguments to be passed to Gazebo Sim'),
# Gazebo Sim's major version
DeclareLaunchArgument('gz_version', default_value='@GZ_SIM_VER@',
description='Gazebo Sim\'s major version'),

# TODO(CH3): Deprecated. Remove on tock.
DeclareLaunchArgument(
'ign_args', default_value='',
description='Deprecated: Arguments to be passed to Gazebo Sim'
),
# Gazebo Sim's major version
DeclareLaunchArgument(
'ign_version', default_value='@GZ_SIM_VER@',
description='Deprecated: Gazebo Sim\'s major version'
),

ExecuteProcess(
cmd=['gz sim',
LaunchConfiguration('gz_args'),
LaunchConfiguration('ign_args'),
'--force-version',
LaunchConfiguration('gz_version'),
LaunchConfiguration('ign_version'),
],
output='screen',
additional_env=env,
shell=True
)
])
19 changes: 19 additions & 0 deletions ros_gz_shims/ros_ign_gazebo/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>ros_ign_gazebo</name>
<version>0.0.1</version>
<description>Shim package to redirect to ros_gz_sim.</description>
<maintainer email="[email protected]">Brandon Ong</maintainer>

<license>Apache 2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_index_cpp</buildtool_depend>

<depend>ros_gz_sim</depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
30 changes: 30 additions & 0 deletions ros_gz_shims/ros_ign_gazebo/src/create_shim.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Shim to redirect "ros_ign_bridge parameter_bridge" call to "ros_gz_sim parameter_bridge"

#include <string>
#include <sstream>
#include <iostream>
#include <stdlib.h>

#include <ament_index_cpp/get_package_prefix.hpp>


int main(int argc, char * argv[])
{
std::stringstream cli_call;

cli_call << ament_index_cpp::get_package_prefix("ros_gz_sim")
<< "/lib/ros_gz_sim/create";

if (argc > 1)
{
for (int i = 1; i < argc; i++)
cli_call << " " << argv[i];
}

std::cerr << "[ros_ign_gazebo] is deprecated! "
<< "Redirecting to use [ros_gz_sim] instead!"
<< std::endl << std::endl;
system(cli_call.str().c_str());

return 0;
}
29 changes: 29 additions & 0 deletions ros_gz_shims/ros_ign_gazebo_demos/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.5)
project(ros_ign_gazebo_demos)

find_package(ament_cmake REQUIRED)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

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

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

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

ament_package()
2 changes: 2 additions & 0 deletions ros_gz_shims/ros_ign_gazebo_demos/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_demos](https://github.com/gazebosim/ros_gz/tree/ros2/ros_ign_gazebo_demos)
Loading

0 comments on commit 1ac6afe

Please sign in to comment.