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

Enable use of ign gazebo -s on Windows #1574

Closed
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
#============================================================================
# Initialize the project
#============================================================================
project(ignition-gazebo6 VERSION 6.11.0)
project(ignition-gazebo6 VERSION 6.12.0)
set (GZ_DISTRIBUTION "Fortress")

#============================================================================
Expand Down
14 changes: 14 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
## Ignition Gazebo 6.x

### Gazebo Sim 6.12.0 (2022-08-30)

1. Add topic parameter to thrust plugin
* [Pull request #1681](https://github.com/gazebosim/gz-sim/pull/1681)

1. Add information about `<topic>` system parameter
* [Pull request #1671](https://github.com/gazebosim/gz-sim/pull/1671)

1. Adding tests for hydrodynamics
* [Pull request #1617](https://github.com/gazebosim/gz-sim/pull/1617)

1. Fix Windows and Doxygen
* [Pull request #1643](https://github.com/gazebosim/gz-sim/pull/1643)

### Gazebo Sim 6.11.0 (2022-08-17)

1. Add support for specifying log record period
Expand Down
6 changes: 6 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Deprecated code produces compile-time warnings. These warning serve as
notification to users that their code should be upgraded. The next major
release will remove the deprecated code.

## Ignition Gazebo 6.11.X to 6.12.X

* **Modified**:
+ In the Hydrodynamics plugin, inverted the added mass contribution to make it
act in the correct direction.

## Ignition Gazebo 6.1 to 6.2

* If no `<namespace>` is given to the `Thruster` plugin, the namespace now
Expand Down
35 changes: 30 additions & 5 deletions examples/worlds/triggered_publisher.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,17 @@ start falling.
<time>0.001</time>
<enabled>true</enabled>
</plugin>
<plugin filename="ignition-gazebo-detachable-joint-system" name="ignition::gazebo::systems::DetachableJoint">
<plugin
filename="ignition-gazebo-detachable-joint-system"
name="ignition::gazebo::systems::DetachableJoint">
<parent_link>body</parent_link>
<child_model>box1</child_model>
<child_link>box_body</child_link>
<topic>/box1/detach</topic>
</plugin>
<plugin filename="ignition-gazebo-detachable-joint-system" name="ignition::gazebo::systems::DetachableJoint">
<plugin
filename="ignition-gazebo-detachable-joint-system"
name="ignition::gazebo::systems::DetachableJoint">
<parent_link>body</parent_link>
<child_model>box2</child_model>
<child_link>box_body</child_link>
Expand Down Expand Up @@ -448,19 +452,40 @@ start falling.
</link>
</model>

<plugin filename="ignition-gazebo-triggered-publisher-system" name="ignition::gazebo::systems::TriggeredPublisher">
<plugin
filename="ignition-gazebo-triggered-publisher-system"
name="ignition::gazebo::systems::TriggeredPublisher">
<input type="ignition.msgs.Empty" topic="/start"/>
<output type="ignition.msgs.Twist" topic="/cmd_vel">
linear: {x: 3}
</output>
</plugin>
<plugin filename="ignition-gazebo-triggered-publisher-system" name="ignition::gazebo::systems::TriggeredPublisher">
<plugin
filename="ignition-gazebo-triggered-publisher-system"
name="ignition::gazebo::systems::TriggeredPublisher">
<input type="ignition.msgs.Empty" topic="/reset_robot"/>
<output type="ignition.msgs.Twist" topic="/cmd_vel">
linear: {x: 0}
</output>
<service
name="/world/triggered_publisher/set_pose"
reqType="ignition.msgs.Pose"
repType="ignition.msgs.Boolean"
timeout="3000"
reqMsg="name: 'blue_vehicle', position: {x: -3, z: 0.325}">
</service>
</plugin>
<plugin
filename="ignition-gazebo-triggered-publisher-system"
name="ignition::gazebo::systems::TriggeredPublisher">
<input type="ignition.msgs.Boolean" topic="/trigger/touched">
<match>data: true</match>
</input>
<output type="ignition.msgs.Empty" topic="/box1/detach"/>
</plugin>
<plugin filename="ignition-gazebo-triggered-publisher-system" name="ignition::gazebo::systems::TriggeredPublisher">
<plugin
filename="ignition-gazebo-triggered-publisher-system"
name="ignition::gazebo::systems::TriggeredPublisher">
<input type="ignition.msgs.Altimeter" topic="/altimeter">
<match field="vertical_position" tol="0.2">-7.5</match>
</input>
Expand Down
4 changes: 4 additions & 0 deletions include/ignition/gazebo/rendering/RenderUtil.hh
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
/// \brief Clears the set of selected entities and lowlights all of them.
public: void DeselectAllEntities();

/// \brief Init render engine plugins paths. This lets gz-rendering know
/// paths to find render engine plugins
public: void InitRenderEnginePluginPaths();

/// \brief Helper function to get all child links of a model entity.
/// \param[in] _entity Entity to find child links
/// \return Vector of child links found for the parent entity
Expand Down
32 changes: 26 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,29 @@ set (gtest_sources
TestFixture_TEST.cc
Util_TEST.cc
World_TEST.cc
ign_TEST.cc
comms/Broker_TEST.cc
comms/MsgManager_TEST.cc
network/NetworkConfig_TEST.cc
network/PeerTracker_TEST.cc
network/NetworkManager_TEST.cc
)

# ign_TEST and ModelCommandAPI_TEST are not supported with multi config
# CMake generators, see also cmd/CMakeLists.txt
get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT GENERATOR_IS_MULTI_CONFIG)
list(APPEND gtest_sources ign_TEST.cc)
endif()


# Tests that require a valid display
set(tests_needing_display
ModelCommandAPI_TEST.cc
)

if(NOT GENERATOR_IS_MULTI_CONFIG)
list(APPEND tests_needing_display ModelCommandAPI_TEST.cc)
endif()

# Add systems that need a valid display here.
# \todo(anyone) Find a way to run these tests with a virtual display such Xvfb
# or Xdummy instead of skipping them
Expand Down Expand Up @@ -222,9 +232,19 @@ foreach(CMD_TEST
set_tests_properties(${CMD_TEST} PROPERTIES
ENVIRONMENT "${_env_vars}")

endforeach()
# On Windows there is no RPATH, so an alternative way for tests for finding .dll libraries
# in build directory in necessary. For regular tests, the trick is to place all libraries
# and executables in a common CMAKE_RUNTIME_OUTPUT_DIRECTORY, so that the .dll are found
# as they are in the same directory where the executable is loaded. For tests that are
# launched via Ruby, this does not work, so we need to manually add CMAKE_RUNTIME_OUTPUT_DIRECTORY
# to the PATH. This is done via the ENVIRONMENT_MODIFICATION that is only available
# since CMake 3.22. However, if an older CMake is used another trick to install the libraries
# beforehand
if (WIN32 AND CMAKE_VERSION STRGREATER "3.22")
set_tests_properties(${CMD_TEST} PROPERTIES
ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
endif()

if(NOT WIN32)
add_subdirectory(cmd)
endif()
endforeach()

add_subdirectory(cmd)
121 changes: 69 additions & 52 deletions src/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
# Generate the ruby script.
# Note that the major version of the library is included in the name.
# Ex: cmdgazebo0.rb
set(cmd_script_generated "${CMAKE_CURRENT_BINARY_DIR}/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_configured "${cmd_script_generated}.configured")
set(cmd_script_name "cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_generated "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>_${cmd_script_name}")
set(cmd_script_configured "${CMAKE_CURRENT_BINARY_DIR}/${cmd_script_name}.configured")

# Set the library_location variable to the relative path to the library file
# within the install directory structure.
set(library_location "../../../${CMAKE_INSTALL_LIBDIR}/$<TARGET_FILE_NAME:${ign_lib_target}>")
if(WIN32)
set(plugin_location ${CMAKE_INSTALL_BINDIR})
else()
set(plugin_location ${CMAKE_INSTALL_LIBDIR})
endif()

set(library_location "../../../${plugin_location}/$<TARGET_FILE_NAME:${ign_lib_target}>")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows CI is failing on this file:

[12.204s] CMake Error in src/cmd/CMakeLists.txt:
[12.204s]   Evaluation file to be written multiple times with different content.  This
[12.204s]   is generally caused by the content evaluating the configuration type,
[12.204s]   language, or location of object files:
[12.204s] 
[12.204s]    C:/Jenkins/workspace/ign_gazebo-pr-win/ws/build/ignition-gazebo6/test/lib/ruby/ignition/cmdgazebo6.rb

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. For reference, I was developing using Ninja cmake generator, while this error appears with Visual Studio 16 2019.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This turned out to be quite a can of worms. Basically, all the logic that is generating .yaml files and ruby scripts for testing was written strictly assuming the use of a single-config CMake generator. So everything was working fine when using make, single-config Ninja or NMake Makefiles, but it was going to fail as soon as Visual Studio, XCode or multiple config Ninja was used.

Initially, I tried to make the CMake code support also multiple config generator, but that was going to make that code quite difficult to mantain. For this reason, I switched the PR to explicitly disable the UNIT_ign_TEST and UNIT_ModelCommandAPI_TEST test when a multiple-config CMake generator is used. Note that this test can be run on Windows using any of the available single-config CMake generators, such as Ninja or NMake Makefiles.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, while working on this I also got UNIT_ign_TEST to work on Windows.

configure_file(
"cmd${IGN_DESIGNATION}.rb.in"
Expand All @@ -19,7 +26,7 @@ file(GENERATE
INPUT "${cmd_script_configured}")

# Install the ruby command line library in an unversioned location.
install(FILES ${cmd_script_generated} DESTINATION lib/ruby/ignition)
install(FILES ${cmd_script_generated} DESTINATION lib/ruby/ignition RENAME ${cmd_script_name})

set(ign_library_path "${CMAKE_INSTALL_PREFIX}/lib/ruby/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}")

Expand All @@ -40,8 +47,9 @@ install( FILES
# Used for the installed model command version.
# Generate the ruby script that gets installed.
# Note that the major version of the library is included in the name.
set(cmd_model_script_generated "${CMAKE_CURRENT_BINARY_DIR}/cmdmodel${PROJECT_VERSION_MAJOR}.rb")
set(cmd_model_script_configured "${cmd_model_script_generated}.configured")
set(cmd_model_script_name "cmdmodel${PROJECT_VERSION_MAJOR}.rb")
set(cmd_model_script_generated "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>_${cmd_model_script_name}")
set(cmd_model_script_configured "${CMAKE_CURRENT_BINARY_DIR}/${cmd_model_script_name}.configured")

configure_file(
"cmdmodel.rb.in"
Expand All @@ -51,7 +59,7 @@ file(GENERATE
OUTPUT "${cmd_model_script_generated}"
INPUT "${cmd_model_script_configured}")

install(FILES ${cmd_model_script_generated} DESTINATION lib/ruby/ignition)
install(FILES ${cmd_model_script_generated} DESTINATION lib/ruby/ignition RENAME ${cmd_model_script_name})

# Used for the installed version.
set(ign_model_ruby_path "${CMAKE_INSTALL_PREFIX}/lib/ruby/ignition/cmdmodel${PROJECT_VERSION_MAJOR}")
Expand All @@ -68,55 +76,64 @@ install(FILES ${model_configured} DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_IN
# Generate the ruby script for internal testing.
# Note that the major version of the library is included in the name.
# Ex: cmdgazebo0.rb
set(cmd_script_generated_test "${CMAKE_BINARY_DIR}/test/lib/ruby/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_configured_test "${cmd_script_generated_test}.configured")

# Set the library_location variable to the relative path to the library file
# within the install directory structure.
set(library_location "$<TARGET_FILE:${ign_lib_target}>")

configure_file(
"cmd${IGN_DESIGNATION}.rb.in"
"${cmd_script_configured_test}"
@ONLY)

file(GENERATE
OUTPUT "${cmd_script_generated_test}"
INPUT "${cmd_script_configured_test}")

# Used only for internal testing.
set(ign_library_path
"${CMAKE_BINARY_DIR}/test/lib/ruby/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}")

# Generate a configuration file for internal testing.
# Note that the major version of the library is included in the name.
# Ex: gazebo0.yaml
configure_file(
"${IGN_DESIGNATION}.yaml.in"
"${CMAKE_BINARY_DIR}/test/conf/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml" @ONLY)
# The logic is valid only for single-config CMake generators, so no script is
# generated if a multiple-config CMake geneator is used
get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT GENERATOR_IS_MULTI_CONFIG)
set(cmd_script_generated_test "${CMAKE_BINARY_DIR}/test/lib/ruby/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_configured_test "${cmd_script_generated_test}.configured")

# Set the library_location variable to the relative path to the library file
# within the install directory structure.
set(library_location "$<TARGET_FILE:${ign_lib_target}>")

configure_file(
"cmd${IGN_DESIGNATION}.rb.in"
"${cmd_script_configured_test}"
@ONLY)

file(GENERATE
OUTPUT "${cmd_script_generated_test}"
INPUT "${cmd_script_configured_test}")

# Used only for internal testing.
set(ign_library_path
"${CMAKE_BINARY_DIR}/test/lib/ruby/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}")

# Generate a configuration file for internal testing.
# Note that the major version of the library is included in the name.
# Ex: gazebo0.yaml
configure_file(
"${IGN_DESIGNATION}.yaml.in"
"${CMAKE_BINARY_DIR}/test/conf/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml" @ONLY)
endif()

#===============================================================================
# Generate the ruby script for internal testing.
# Note that the major version of the library is included in the name.
set(cmd_model_ruby_test_dir "${CMAKE_BINARY_DIR}/test/lib/ruby/ignition")
set(cmd_model_script_generated_test "${cmd_model_ruby_test_dir}/cmdmodel${PROJECT_VERSION_MAJOR}.rb")
set(cmd_model_script_configured_test "${cmd_model_script_generated_test}.configured")

configure_file(
"cmdmodel.rb.in"
"${cmd_model_script_configured_test}"
@ONLY)

file(GENERATE
OUTPUT "${cmd_model_script_generated_test}"
INPUT "${cmd_model_script_configured_test}")

# Used for internal testing.
set(ign_model_ruby_path "${cmd_model_script_generated_test}")

configure_file(
"model.yaml.in"
"${CMAKE_BINARY_DIR}/test/conf/model${PROJECT_VERSION_MAJOR}.yaml" @ONLY)
# The logic is valid only for single-config CMake generators, so no script is
# generated if a multiple-config CMake geneator is used
if(NOT GENERATOR_IS_MULTI_CONFIG)
set(cmd_model_ruby_test_dir "${CMAKE_BINARY_DIR}/test/lib/ruby/ignition")
set(cmd_model_script_generated_test "${cmd_model_ruby_test_dir}/cmdmodel${PROJECT_VERSION_MAJOR}.rb")
set(cmd_model_script_configured_test "${cmd_model_script_generated_test}.configured")

configure_file(
"cmdmodel.rb.in"
"${cmd_model_script_configured_test}"
@ONLY)

file(GENERATE
OUTPUT "${cmd_model_script_generated_test}"
INPUT "${cmd_model_script_configured_test}")

# Used for internal testing.
set(ign_model_ruby_path "${cmd_model_script_generated_test}")

configure_file(
"model.yaml.in"
"${CMAKE_BINARY_DIR}/test/conf/model${PROJECT_VERSION_MAJOR}.yaml" @ONLY)
endif()

#===============================================================================
# Bash completion
Expand Down
6 changes: 4 additions & 2 deletions src/cmd/ModelCommandAPI.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@
*
*/

#include "ignition/gazebo/Export.hh"

/// \brief External hook to get a list of available models.
extern "C" void cmdModelList();
extern "C" IGNITION_GAZEBO_VISIBLE void cmdModelList();

/// \brief External hook to dump model information.
/// \param[in] _modelName Model name.
/// \param[in] _pose --pose option.
/// \param[in] _linkName Link name.
/// \param[in] _jointName Joint name.
/// \param[in] _sensorName Sensor name.
extern "C" void cmdModelInfo(
extern "C" IGNITION_GAZEBO_VISIBLE void cmdModelInfo(
const char *_modelName, int _pose, const char *_linkName,
const char *_jointName,
const char *_sensorName);
Expand Down
Loading