Skip to content

Commit

Permalink
Adding ign-tool interface
Browse files Browse the repository at this point in the history
  • Loading branch information
nkoenig committed Apr 26, 2019
1 parent d7c9481 commit 7dbc19e
Show file tree
Hide file tree
Showing 10 changed files with 813 additions and 100 deletions.
56 changes: 11 additions & 45 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_subdirectory(gui)
add_subdirectory(cmd)
add_subdirectory(systems)
add_subdirectory(msgs)

Expand Down Expand Up @@ -28,6 +29,16 @@ set(gui_sources
PARENT_SCOPE
)

ign_add_component(ign SOURCES cmd/ign.cc GET_TARGET_NAME ign_lib_target)
target_link_libraries(${ign_lib_target}
PRIVATE
${PROJECT_LIBRARY_TARGET_NAME}
ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
ignition-gazebo${PROJECT_VERSION_MAJOR}
ignition-gazebo${PROJECT_VERSION_MAJOR}-gui
)


set (sources
Conversions.cc
EntityComponentManager.cc
Expand Down Expand Up @@ -109,48 +120,3 @@ ign_build_tests(TYPE UNIT
${PROJECT_LIBRARY_TARGET_NAME}
ignition-gazebo${PROJECT_VERSION_MAJOR}
)

# Create the gazebo executable
ign_add_executable(ign-gazebo-exec main.cc)
set_property(TARGET ign-gazebo-exec PROPERTY OUTPUT_NAME ign-gazebo)
target_link_libraries(ign-gazebo-exec PUBLIC ${PROJECT_LIBRARY_TARGET_NAME}
gflags
ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
)

# Create the server executable
ign_add_executable(ign-gazebo-server server_main.cc)
set_property(TARGET ign-gazebo-server PROPERTY OUTPUT_NAME ign-gazebo-server)
target_link_libraries(ign-gazebo-server PUBLIC ${PROJECT_LIBRARY_TARGET_NAME}
gflags
ignition-plugin${IGN_PLUGIN_VER}::ignition-plugin${IGN_PLUGIN_VER}
ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
ignition-transport${IGN_TRANSPORT_VER}::ignition-transport${IGN_TRANSPORT_VER}
)

# Create the gui executable
ign_add_executable(ign-gazebo-gui gui_main.cc)
set_property(TARGET ign-gazebo-gui PROPERTY OUTPUT_NAME ign-gazebo-gui)
target_link_libraries(ign-gazebo-gui PUBLIC ${PROJECT_LIBRARY_TARGET_NAME}
gflags
ignition-gazebo${PROJECT_VERSION_MAJOR}-gui
ignition-plugin${IGN_PLUGIN_VER}::ignition-plugin${IGN_PLUGIN_VER}
ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
ignition-gui${IGN_GUI_VER}::ignition-gui${IGN_GUI_VER}
ignition-transport${IGN_TRANSPORT_VER}::ignition-transport${IGN_TRANSPORT_VER}
${Qt5Core_LIBRARIES}
${Qt5Widgets_LIBRARIES}
)

# Switch to ign_install_executable when it is fixed (https://bitbucket.org/ignitionrobotics/ign-cmake/issues/29)
set_target_properties(ign-gazebo-exec
PROPERTIES VERSION ${PROJECT_VERSION_FULL})
install (TARGETS ign-gazebo-exec DESTINATION ${IGN_BIN_INSTALL_DIR})

set_target_properties(ign-gazebo-server
PROPERTIES VERSION ${PROJECT_VERSION_FULL})
install (TARGETS ign-gazebo-server DESTINATION ${IGN_BIN_INSTALL_DIR})

set_target_properties(ign-gazebo-gui
PROPERTIES VERSION ${PROJECT_VERSION_FULL})
install (TARGETS ign-gazebo-gui DESTINATION ${IGN_BIN_INSTALL_DIR})
21 changes: 12 additions & 9 deletions src/SimulationRunner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,19 @@ SimulationRunner::SimulationRunner(const sdf::World *_world,
_config.NetworkRole(), _config.NetworkSecondaries()));
}

if (this->networkMgr->IsPrimary())
{
ignmsg << "Network Primary, expects ["
<< this->networkMgr->Config().numSecondariesExpected
<< "] secondaries." << std::endl;
}
else if (this->networkMgr->IsSecondary())
if (this->networkMgr)
{
ignmsg << "Network Secondary, with namespace ["
<< this->networkMgr->Namespace() << "]." << std::endl;
if (this->networkMgr->IsPrimary())
{
ignmsg << "Network Primary, expects ["
<< this->networkMgr->Config().numSecondariesExpected
<< "] secondaries." << std::endl;
}
else if (this->networkMgr->IsSecondary())
{
ignmsg << "Network Secondary, with namespace ["
<< this->networkMgr->Namespace() << "]." << std::endl;
}
}
}

Expand Down
58 changes: 58 additions & 0 deletions src/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Generate a the ruby script.
# Note that the major version of the library is included in the name.
# Ex: cmdgazebo0.rb
if (APPLE)
set(IGN_LIBRARY_NAME lib${PROJECT_LIBRARY_TARGET_NAME}.dylib)
else()
set(IGN_LIBRARY_NAME lib${PROJECT_LIBRARY_TARGET_NAME}.so)
endif()

configure_file(
"cmdgazebo.rb.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmdgazebo${PROJECT_VERSION_MAJOR}.rb" @ONLY)

# Install the ruby command line library in an unversioned location.
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmdgazebo${PROJECT_VERSION_MAJOR}.rb DESTINATION lib/ruby/ignition)

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

# Generate a configuration file.
# Note that the major version of the library is included in the name.
# Ex: fuel0.yaml
configure_file(
"gazebo.yaml.in"
"${CMAKE_CURRENT_BINARY_DIR}/gazebo${PROJECT_VERSION_MAJOR}.yaml" @ONLY)

# Install the yaml configuration files in an unversioned location.
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gazebo${PROJECT_VERSION_MAJOR}.yaml DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/ignition/)

#===============================================================================
# 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/cmdgazebo${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_configured_test "${cmd_script_generated_test}.configured")

# Set the library_location variable to the full path of the library file within
# the build directory.
set(IGN_LIBRARY_NAME "$<TARGET_FILE:${PROJECT_LIBRARY_TARGET_NAME}>")

configure_file(
"cmdgazebo.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/cmdgazebo${PROJECT_VERSION_MAJOR}")

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

0 comments on commit 7dbc19e

Please sign in to comment.