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

Jazzy & gz8 support #14

Open
wants to merge 7 commits into
base: jazzy-devel
Choose a base branch
from
Open
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
18 changes: 9 additions & 9 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
name: main
name: jazzy-devel

on:
pull_request:
branches:
- humble-devel
- jazzy-devel
push:
branches:
- humble-devel
- jazyy-devel
jobs:
build-and-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
os: [ubuntu-24.04]
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: Setup ROS 2
uses: ros-tooling/[email protected].1
uses: ros-tooling/[email protected].9
with:
required-ros-distributions: humble
required-ros-distributions: jazzy
- name: build and test
uses: ros-tooling/[email protected].6
uses: ros-tooling/[email protected].15
with:
package-name: gazebo_mocap4r2_plugin mocap_interfaces mocap4r2_control mocap4r2_control_msgs rqt_mocap4r2_control
target-ros2-distro: humble
package-name: mocap4r2_gz_plugin mocap_interfaces mocap4r2_control mocap4r2_control_msgs rqt_mocap4r2_control
target-ros2-distro: jazzy
vcs-repo-file-url: ${GITHUB_WORKSPACE}/dependency_repos.repos
- name: Codecov
uses: codecov/[email protected]
Expand Down
1 change: 0 additions & 1 deletion CHANGELOG.rst

This file was deleted.

120 changes: 32 additions & 88 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,106 +1,50 @@
cmake_minimum_required(VERSION 3.5)
project(gazebo_mocap4r2_plugin)
cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)

# 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")
# we dont use add_compile_options with pedantic in message packages
# because the Python C extensions dont comply with it
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
endif()

if(WIN32)
add_compile_definitions(
# For math constants
_USE_MATH_DEFINES
# Minimize Windows namespace collision
NOMINMAX
WIN32_LEAN_AND_MEAN
)
endif()
project(mocap4r2_gz_plugin)

find_package(ament_cmake REQUIRED)
find_package(gazebo_dev REQUIRED)
find_package(gazebo_msgs REQUIRED)
find_package(gazebo_ros REQUIRED)
find_package(gz-cmake3 REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(mocap_interfaces REQUIRED)
find_package(mocap4r2_control REQUIRED)
find_package(rclcpp REQUIRED)

link_directories(${gazebo_dev_LIBRARY_DIRS})

option(ENABLE_PROFILER "Enable Ignition Profiler" FALSE)
if(ENABLE_PROFILER)
find_package(ignition-common3 QUIET COMPONENTS profiler)
if(ignition-common3_FOUND)
add_definitions("-DIGN_PROFILER_ENABLE=1" "-DIGN_PROFILER_REMOTERY=1")
message(STATUS "Profiler is active")
else()
message(WARNING "Can't find Ignition common3. Profiler will not be actived")
add_definitions("-DIGN_PROFILER_ENABLE=0" "-DIGN_PROFILER_REMOTERY=0")
endif()
endif()
gz_find_package(gz-plugin2 REQUIRED COMPONENTS register)
gz_find_package(gz-sim8 REQUIRED)
gz_find_package(gz-rendering8 REQUIRED)
gz_find_package(gz-sensors8 REQUIRED)

# gazebo_ros_mocap
add_library(gazebo_ros_mocap SHARED
src/gazebo_ros_mocap.cpp
)
target_include_directories(gazebo_ros_mocap PUBLIC include)
ament_target_dependencies(gazebo_ros_mocap
"gazebo_dev"
"gazebo_ros"
"rclcpp"
"mocap_interfaces"
"mocap4r2_control"
"geometry_msgs"
)
ament_export_libraries(gazebo_ros_mocap)
set(GZ_PLUGIN_VER ${gz-plugin2_VERSION_MAJOR})
set(GZ_SIM_VER ${gz-sim8_VERSION_MAJOR})
set(GZ_RENDERING_VER ${gz-rendering8_VERSION_MAJOR})
set(GZ_SENSORS_VER ${gz-sensors8_VERSION_MAJOR})

include_directories(include)

ament_export_include_directories(include)
ament_export_dependencies(rclcpp)
ament_export_dependencies(gazebo_dev)
ament_export_dependencies(gazebo_msgs)
ament_export_dependencies(gazebo_ros)
ament_export_dependencies(mocap_msgs)
ament_export_dependencies(mocap_control)
ament_export_dependencies(geometry_msgs)
add_library(mocap_gz_ros SHARED src/mocap_gz_ros.cpp)

if(BUILD_TESTING)
add_subdirectory(test)
find_package(ament_lint_auto REQUIRED)
set(ament_cmake_copyright_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

if(NOT WIN32)
if(NOT APPLE)
set(
AMENT_CMAKE_ENVIRONMENT_HOOKS_DESC_gazebo_plugins
"prepend-non-duplicate;LD_LIBRARY_PATH;${GAZEBO_PLUGIN_PATH}")
else()
set(
AMENT_CMAKE_ENVIRONMENT_HOOKS_DESC_gazebo_plugins
"prepend-non-duplicate;DYLD_LIBRARY_PATH;${GAZEBO_PLUGIN_PATH}")
endif()
endif()
ament_environment_hooks("${CMAKE_CURRENT_SOURCE_DIR}/env-hooks/gazebo_plugins.sh.in")

ament_package()
set_target_properties(mocap_gz_ros PROPERTIES OUTPUT_NAME mocap-gz-ros SUFFIX "" PREFIX "")

install(DIRECTORY include/
DESTINATION include)
ament_target_dependencies(mocap_gz_ros
rclcpp
geometry_msgs
mocap_interfaces
mocap4r2_control
)

install(TARGETS
gazebo_ros_mocap
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
target_link_libraries(mocap_gz_ros
gz-plugin${GZ_PLUGIN_VER}::gz-plugin${GZ_PLUGIN_VER}
gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
)

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

install(TARGETS mocap_gz_ros DESTINATION $ENV{HOME}/.gz/sim/plugins)

ament_export_libraries(mocap_gz_ros)
ament_export_dependencies(gz-cmake3 gz-plugin2 gz-sim8 geometry_msgs mocap_interfaces mocap4r2_control rclcpp)

ament_package()
8 changes: 0 additions & 8 deletions colcon.pkg

This file was deleted.

2 changes: 1 addition & 1 deletion dependency_repos.repos
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ repositories:
mocap4r2:
type: git
url: https://github.com/MOCAP4ROS2-Project/mocap4r2.git
version: rep-mocap-humble
version: rep-mocap-jazzy
17 changes: 0 additions & 17 deletions env-hooks/gazebo_plugins.sh.in

This file was deleted.

52 changes: 0 additions & 52 deletions include/gazebo_plugins/gazebo_ros_mocap.hpp

This file was deleted.

73 changes: 73 additions & 0 deletions include/mocap4r2_gz_plugin/mocap_gz_ros.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright 2024 Intelligent Robotics Lab
//
// 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.

#ifndef GZ_PLUGINS__MOCAP_GZ_ROS_HPP_
#define GZ_PLUGINS__MOCAP_GZ_ROS_HPP_

#include <gz/sim/System.hh>
#include <gz/transport/Node.hh>
#include <gz/plugin/Register.hh>
#include <gz/sim/Model.hh>
#include <gz/sim/Util.hh>
#include "gz/sim/components/ParentEntity.hh"
#include "gz/sim/components/World.hh"
#include "gz/sim/components/Model.hh"
#include "gz/sim/components/Link.hh"
#include "gz/sim/components/Name.hh"

#include "mocap_interfaces/msg/marker_array.hpp"
#include "mocap_interfaces/msg/rigid_body_array.hpp"
#include "mocap_interfaces/srv/create_rigid_body.hpp"
#include "lifecycle_msgs/msg/state.hpp"
#include "rclcpp/rclcpp.hpp"
#include "mocap4r2_control/ControlledLifecycleNode.hpp"

namespace gz
{
namespace sim
{
// Inline bracket to help doxygen filtering.
inline namespace GZ_SIM_VERSION_NAMESPACE
{
namespace systems
{
class MocapGzRosPrivate;

class MocapGzRos
: public gz::sim::System,
public gz::sim::ISystemConfigure,
public gz::sim::ISystemPostUpdate
{
public:
MocapGzRos();
~MocapGzRos() override = default;
void Configure(
const gz::sim::Entity & _entity,
const std::shared_ptr<const sdf::Element> & _sdf,
gz::sim::EntityComponentManager & _ecm,
gz::sim::EventManager & _eventMgr) override;

void PostUpdate(
const gz::sim::v8::UpdateInfo & _info,
const gz::sim::v8::EntityComponentManager & _ecm) override;

private:
std::unique_ptr<MocapGzRosPrivate> impl_;
};
} // namespace systems
} // inline namespace GZ_SIM_VERSION_NAMESPACE
} // namespace sim
} // namespace gz

#endif // GZ_PLUGINS__MOCAP_GZ_ROS_HPP_
Loading
Loading