Skip to content

Commit

Permalink
Migrate CLI
Browse files Browse the repository at this point in the history
Signed-off-by: methylDragon <[email protected]>
  • Loading branch information
methylDragon committed Jun 18, 2022
1 parent a795c2a commit 1707ef7
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 39 deletions.
6 changes: 3 additions & 3 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
1. Add PKGCONFIG information to ignition-tools ign_find_package
* [Pull Request 44](https://github.com/gazebosim/gz-launch/pull/44)

1. Fix factory.ign launch file
1. Fix factory.gz launch file
* [Pull Request 55](https://github.com/gazebosim/gz-launch/pull/55)

1. Use random name for manager semaphore
Expand Down Expand Up @@ -298,13 +298,13 @@

### Gazebo Launch 1.0.0 (2019-05-21)

1. Enable logging with `<record>` tag in ign launch file.
1. Enable logging with `<record>` tag in gz launch file.
* [BitBucket pull request 23](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-launch/pull-requests/23)

1. Fix gazebo gui to use GuiRunner.
* [BitBucket pull request 22](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-launch/pull-requests/22)

1. Fix parsing positional argument to ign tool.
1. Fix parsing positional argument to gz tool.
* [BitBucket pull request 21](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-launch/pull-requests/21)

1. Added world stats to Websocket server.
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Sample launch configuration files are in the [examples directory](https://github
1. Run a configuration that launches [Gazebo](https://gazebosim.org/libs/gazebo).

```
ign launch gazebo.ign
gz launch gazebo.ign
```
## Known issue of command line tools
Expand All @@ -78,7 +78,7 @@ A workaround for a single package is to define the environment variable
`GZ_CONFIG_PATH` to point to the location of the Ignition library installation,
where the YAML file for the package is found, such as
```
export GZ_CONFIG_PATH=/usr/local/share/ignition
export GZ_CONFIG_PATH=/usr/local/share/gz
```
However, that environment variable only takes a single path, which means if the
Expand All @@ -89,9 +89,9 @@ line is using symbolic links to each library's YAML file.
```
mkdir ~/.ignition/tools/configs -p
cd ~/.ignition/tools/configs/
ln -s /usr/local/share/ignition/fuel4.yaml .
ln -s /usr/local/share/ignition/transport7.yaml .
ln -s /usr/local/share/ignition/transportlog7.yaml .
ln -s /usr/local/share/gz/fuel4.yaml .
ln -s /usr/local/share/gz/transport7.yaml .
ln -s /usr/local/share/gz/transportlog7.yaml .
...
export GZ_CONFIG_PATH=$HOME/.ignition/tools/configs
```
Expand Down
4 changes: 2 additions & 2 deletions examples/gazebo.ign
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version='1.0'?>
<ignition version='1.0'>
<executable name='gazebo-server'>
<command>ign gazebo -s</command>
<command>gz sim -s</command>
</executable>

<executable name='gazebo-client'>
<command>ign gazebo -g</command>
<command>gz sim -g</command>
<auto_restart>true</auto_restart>
</executable>

Expand Down
4 changes: 2 additions & 2 deletions examples/gazebo_plugins.ign
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version='1.0'?>
<!-- Usage: ign launch gazebo_plugins.ign [worldName:=<worldName>]
<!-- Usage: gz launch gazebo_plugins.ign [worldName:=<worldName>]
The [worldName] command line argument is optional. If left blank, or not
specified, then "diff_drive" is used for the world name.
Example that loads the shapes.sdf world instead of diff_drive:
ign launch gazebo_plugins.ign worldName:=shapes
gz launch gazebo_plugins.ign worldName:=shapes
-->
<%
# Check if worldName is not defined or is empty/nil
Expand Down
2 changes: 1 addition & 1 deletion examples/plugins.ign
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</plugin>

<executable name='gazebo'>
<command>ign gazebo diff_drive.sdf</command>
<command>gz sim diff_drive.sdf</command>
</executable>

</ignition>
2 changes: 1 addition & 1 deletion plugins/websocket_server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ign-gazebo -v 4
source tree.

```
ign launch -f examples/websocket.ign -v 4
gz launch -f examples/websocket.ign -v 4
```

5. Open the `plugins/websocket_server/index.html` in a web browser.
Expand Down
4 changes: 2 additions & 2 deletions plugins/websocket_server/WebsocketServer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ namespace gz
///
/// 2. Run the launch file
///
/// `ign launch -v 4 websocket.ign`
/// `gz launch -v 4 websocket.ign`
///
/// 3. Open the [index.html](https://github.com/gazebosim/gz-launch/blob/main/plugins/websocket_server/index.html) webpage.
///
Expand All @@ -164,7 +164,7 @@ namespace gz

/// \brief Callback when an image is received on a topic
/// \param[in] _msg Image msg
/// \param[in] _info ign transport message info
/// \param[in] _info gz transport message info
private: void OnWebsocketSubscribedImageMessage(
const gz::msgs::Image &_msg,
const gz::transport::MessageInfo &_info);
Expand Down
22 changes: 11 additions & 11 deletions src/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
# "gtest_sources" variable.
gz_get_libsources_and_unittests(sources gtest_sources)

add_library(ign STATIC ign.cc)
target_include_directories(ign PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(ign PUBLIC
add_library(gz STATIC gz.cc)
target_include_directories(gz PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(gz PUBLIC
${PROJECT_LIBRARY_TARGET_NAME}
ignition-common${IGN_COMMON_MAJOR_VER}::ignition-common${IGN_COMMON_MAJOR_VER}
)

set(launch_executable ign-launch)
add_executable(${launch_executable} launch_main.cc)
target_link_libraries(${launch_executable}
ign
gz
ignition-utils${IGN_UTILS_VER}::cli
ignition-common${IGN_COMMON_MAJOR_VER}::ignition-common${IGN_COMMON_MAJOR_VER}
)
Expand All @@ -30,7 +30,7 @@ gz_build_tests(TYPE UNIT SOURCES ${gtest_sources}
LIB_DEPS ${EXTRA_TEST_LIB_DEPS})

foreach(test ${test_list})
target_link_libraries(${test} ign)
target_link_libraries(${test} gz)

# Inform each test of its output directory so it knows where to call the
# auxiliary files from. Using a generator expression here is useful for
Expand All @@ -41,9 +41,9 @@ foreach(test ${test_list})

endforeach()

if (TARGET UNIT_ign_TEST)
if (TARGET UNIT_gz_TEST)
set_tests_properties(
UNIT_ign_TEST
UNIT_gz_TEST
PROPERTIES
ENVIRONMENT
"GZ_CONFIG_PATH=${CMAKE_BINARY_DIR}/test/conf/$<CONFIG>"
Expand All @@ -55,7 +55,7 @@ endif()
# Note that the major version of the library is included in the name.
# Ex: cmdlaunch6.rb

set(cmd_script_generated_test "${CMAKE_BINARY_DIR}/test/lib/$<CONFIG>/ruby/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_generated_test "${CMAKE_BINARY_DIR}/test/lib/$<CONFIG>/ruby/gz/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_configured_test "${CMAKE_CURRENT_BINARY_DIR}/test_cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb.configured")

# Set the library_location variable to the full path of the library file within
Expand Down Expand Up @@ -94,7 +94,7 @@ file(GENERATE
OUTPUT "${cmd_script_generated}"
INPUT "${cmd_script_configured}")

set(gz_library_path "${CMAKE_BINARY_DIR}/test/lib/$<CONFIG>/ruby/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}")
set(gz_library_path "${CMAKE_BINARY_DIR}/test/lib/$<CONFIG>/ruby/gz/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.
Expand All @@ -108,7 +108,7 @@ file(GENERATE
INPUT "${CMAKE_CURRENT_BINARY_DIR}/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml.configured")

# Used for the installed version.
set(gz_library_path "${CMAKE_INSTALL_PREFIX}/lib/ruby/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}")
set(gz_library_path "${CMAKE_INSTALL_PREFIX}/lib/ruby/gz/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}")

# Generate the configuration file that is installed.
# Note that the major version of the library is included in the name.
Expand All @@ -122,4 +122,4 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${IGN_DESIGNATION}${PROJECT_VERSION_MA
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/ignition/)

# 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/gz)
2 changes: 1 addition & 1 deletion src/cmd/gz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <gz/common/Console.hh>

#include "gz/launch/config.hh"
#include "ign.hh"
#include "gz.hh"
#include "../Manager.hh"

//////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/gz.hh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extern "C" char *gzVersion();
extern "C" void cmdVerbosity(
const int _verbosity);

/// \brief External hook to execute 'ign fuel list -t model' from the command
/// \brief External hook to execute 'gz fuel list -t model' from the command
/// line.
/// \param[in] _config Config file to run.
/// \return 1 if successful, 0 if not.
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/gz_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ std::string get_config_path(const std::string filename)
/////////////////////////////////////////////////
TEST(CmdLine, Ls)
{
std::string cmd = "ign launch " + get_config_path("ls.ign");
std::string cmd = "gz launch " + get_config_path("ls.ign");
std::string output = customExecStr(cmd);
EXPECT_TRUE(output.find("CMakeFiles") != std::string::npos) << output;
EXPECT_TRUE(output.find("Makefile") != std::string::npos) << output;
Expand All @@ -71,15 +71,15 @@ TEST(CmdLine, Ls)
TEST(CmdLine, EchoSelf)
{
std::string filePath = get_config_path("echo.ign");
std::string cmd = "ign launch " + filePath;
std::string cmd = "gz launch " + filePath;
std::string output = customExecStr(cmd);
EXPECT_EQ(filePath, output) << output;
}

/////////////////////////////////////////////////
TEST(CmdLine, HelpSelf)
{
std::string output = customExecStr("ign launch --help");
std::string output = customExecStr("gz launch --help");
EXPECT_NE(std::string::npos,
output.find("Introspect Ignition launch")) << output;
}
Expand All @@ -88,7 +88,7 @@ TEST(CmdLine, HelpSelf)
TEST(CmdLine, EchoErb)
{
std::string filePath = get_config_path("erb.ign");
std::string cmd = "ign launch " + filePath + " testVar:=erb1234";
std::string cmd = "gz launch " + filePath + " testVar:=erb1234";
std::string output = customExecStr(cmd);
EXPECT_EQ("erb1234", output) << output;
}
Expand All @@ -97,7 +97,7 @@ TEST(CmdLine, EchoErb)
TEST(CmdLine, EchoBadErb)
{
std::string filePath = get_config_path("erb.ign");
std::string cmd = " ign launch " + filePath + " badargument";
std::string cmd = " gz launch " + filePath + " badargument";
std::string output = customExecStr(cmd);
EXPECT_NE(std::string::npos, output.find("is wrong for erb")) << output;
}
2 changes: 1 addition & 1 deletion src/cmd/launch_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <gz/utils/cli/CLI.hpp>

#include "gz/launch/config.hh"
#include "ign.hh"
#include "gz.hh"

#ifdef _WIN32
#define popen _popen
Expand Down
8 changes: 4 additions & 4 deletions tutorials/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ We can do many things:

To run a script use

`ign launch LAUNCH_FILE_NAME`
`gz launch LAUNCH_FILE_NAME`

## Launch files

Expand All @@ -30,7 +30,7 @@ Take a look at the [gazebo.ign](../examples/gazebo.ign) launch file. This script

```xml
<executable name='gazebo-server'>
<command>ign gazebo -s</command>
<command>gz sim -s</command>
</executable>
```

Expand All @@ -48,13 +48,13 @@ plugin also launches into a separate process and transforms a `joystick` message

The script can take a world as an argument. To run this script.

`ign launch gazebo_plugins.ign [worldName:=<worldName>]`
`gz launch gazebo_plugins.ign [worldName:=<worldName>]`

The [worldName] command line argument is optional. If left blank, or not specified, then "diff_drive" is used for the world name.

Example to load `the shapes.sdf`:

`ign launch gazebo_plugins.ign worldName:=shapes`
`gz launch gazebo_plugins.ign worldName:=shapes`

## Launch file lookup

Expand Down

0 comments on commit 1707ef7

Please sign in to comment.