Skip to content

Commit

Permalink
Fix build for Gazebo Harmonic
Browse files Browse the repository at this point in the history
  • Loading branch information
bjsowa committed Apr 27, 2024
1 parent 7e4bd9b commit e97468e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
13 changes: 13 additions & 0 deletions leo_gz_plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ if(DEFINED ENV{GZ_VERSION} AND "$ENV{GZ_VERSION}" STREQUAL "garden")
gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
gz-plugin${GZ_PLUGIN_VER}::gz-plugin${GZ_PLUGIN_VER}
)
elseif(DEFINED ENV{GZ_VERSION} AND "$ENV{GZ_VERSION}" STREQUAL "harmonic")
find_package(gz-plugin2 REQUIRED COMPONENTS register)
set(GZ_PLUGIN_VER ${gz-plugin2_VERSION_MAJOR})

find_package(gz-sim8 REQUIRED)
set(GZ_SIM_VER ${gz-sim8_VERSION_MAJOR})

target_link_libraries(leo_gz_differential_plugin
gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
gz-plugin${GZ_PLUGIN_VER}::gz-plugin${GZ_PLUGIN_VER}
)

message(STATUS "Compiling against Gazebo Harmonic")
else()
#If GZ_VERSION is not set default to Fortress
find_package(ignition-plugin1 REQUIRED COMPONENTS register)
Expand Down
6 changes: 6 additions & 0 deletions leo_gz_plugins/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@
<author email="janek@fictionlab.pl">Jan Hernas</author>

<buildtool_depend>ament_cmake</buildtool_depend>

<!-- Harmonic -->
<depend condition="$GZ_VERSION == garden or $IGNITION_VERSION == garden">gz-plugin2</depend>
<depend condition="$GZ_VERSION == garden or $IGNITION_VERSION == garden">gz-sim8</depend>

<!-- Garden -->
<depend condition="$GZ_VERSION == garden or $IGNITION_VERSION == garden">gz-plugin2</depend>
<depend condition="$GZ_VERSION == garden or $IGNITION_VERSION == garden">gz-sim7</depend>

<!-- Fortress (default) -->
<depend condition="$GZ_VERSION == fortress or $IGNITION_VERSION == fortress">gz-plugin</depend>
<depend condition="$GZ_VERSION == fortress or $IGNITION_VERSION == fortress">gz-sim6</depend>
Expand Down
17 changes: 14 additions & 3 deletions leo_gz_plugins/src/differential_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,27 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#ifdef USE_IGNITION

#define SUPPRESS_IGNITION_HEADER_DEPRECATION
#include <ignition/gazebo/System.hh>
#include <ignition/gazebo/Model.hh>
#include <ignition/gazebo/components.hh>
#include <ignition/plugin/Register.hh>
#ifdef USE_IGNITION

namespace gazebo = ignition::gazebo;

#define GZ_ADD_PLUGIN IGNITION_ADD_PLUGIN

#else

#define SUPPRESS_IGNITION_HEADER_DEPRECATION
#include <gz/sim/System.hh>
#include <gz/sim/Model.hh>
#include <gz/sim/components.hh>
#include <gz/plugin/Register.hh>

namespace gazebo = gz::sim;

#endif

namespace leo_gz
Expand Down Expand Up @@ -147,7 +158,7 @@ class DifferentialSystem

} // namespace leo_gz

IGNITION_ADD_PLUGIN(
GZ_ADD_PLUGIN(
leo_gz::DifferentialSystem,
gazebo::System,
leo_gz::DifferentialSystem::ISystemConfigure,
Expand Down

0 comments on commit e97468e

Please sign in to comment.