From 629e08f2bbc792f8b48295eeacd6c91ef6ada0dd Mon Sep 17 00:00:00 2001 From: ahcorde Date: Fri, 26 Mar 2021 19:53:58 +0100 Subject: [PATCH 1/2] Include windows instructions in examples README.md and fix examples to compile them on Windows Signed-off-by: ahcorde --- examples/CMakeLists.txt | 6 +++++- examples/README.md | 41 ++++++++++++++++++++++++++++++++++++ examples/plugins/CrashBot.cc | 2 +- examples/robot.cc | 5 +++-- 4 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 examples/README.md diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index ce781423..b8eb22b6 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -8,9 +8,13 @@ set(IGN_PLUGIN_VER ${ignition-plugin1_VERSION_MAJOR}) find_package(ignition-common2 QUIET) set(IGN_COMMON_VER ${ignition-common2_VERSION_MAJOR}) if(NOT ignition-common2_FOUND) - find_package(ignition-common3 QUIET REQUIRED) + find_package(ignition-common3 QUIET) set(IGN_COMMON_VER ${ignition-common3_VERSION_MAJOR}) endif() +if(NOT ignition-common3_FOUND) + find_package(ignition-common4 QUIET REQUIRED) + set(IGN_COMMON_VER ${ignition-common4_VERSION_MAJOR}) +endif() find_package(ignition-math5 QUIET) set(IGN_MATH_VER ${ignition-math5_VERSION_MAJOR}) diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 00000000..e964ebe0 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,41 @@ +# Examples + +These examples demonstrate various Ignition Plugin features. + +## Build + +After installing Ignition Plugin, from source or from binaries, build with: + +``` +git clone https://github.com/ignitionrobotics/ign-plugin/ +cd ign-plugin/examples +mkdir build +cd build +cmake .. +``` + +### Ubuntu and MacOS + +```bash +make +``` + +### Windows + +```bash +cmake --build . --config Release +``` + +## Run + +Two executables are created inside the `build` folder for each example. + +You can run each executable from the build folder with `./executablename`. For example: + +### Ubuntu and MacOS + +`./robot` + +### Windows + +`.\Release\robot.exe` diff --git a/examples/plugins/CrashBot.cc b/examples/plugins/CrashBot.cc index 1d160714..172d3f36 100644 --- a/examples/plugins/CrashBot.cc +++ b/examples/plugins/CrashBot.cc @@ -41,7 +41,7 @@ class CrashBot return ignition::math::Vector3d(1.0, 0.0, 0.0); // If we have not detected a wall, drive in a spiral, searching for a wall - return ignition::math::Vector3d(0.5, 0.0, 20.0*M_PI/180.0); + return ignition::math::Vector3d(0.5, 0.0, 20.0*IGN_PI/180.0); } // Documentation inherited diff --git a/examples/robot.cc b/examples/robot.cc index 9d650a65..b258231c 100644 --- a/examples/robot.cc +++ b/examples/robot.cc @@ -15,6 +15,7 @@ * */ +#include #include #include #include @@ -206,14 +207,14 @@ void Simulate(const EnvironmentPluginPtr &_environment, if (_printState) { std::cout << "Location: (" << x[0] << "m, " << x[1] << "m) | Yaw: " - << 180.0*theta/M_PI << "-degrees | Time: " << time + << 180.0*theta/IGN_PI << "-degrees | Time: " << time << "s |==| Velocity output: " << vel << std::endl; } } std::cout << "The simulation has finished (time: " << time << "s).\n" << " -- Final robot location: (" << x[0] << "m, " << x[1] << "m)\n" - << " -- Yaw: " << 180.0*theta/M_PI << "-degrees\n" << std::endl; + << " -- Yaw: " << 180.0*theta/IGN_PI << "-degrees\n" << std::endl; } ///////////////////////////////////////////////// From cc6f546db7688f9ac93621ac16367eb23d8cb889 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Tue, 30 Mar 2021 08:50:11 +0200 Subject: [PATCH 2/2] updated Signed-off-by: ahcorde --- examples/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b8eb22b6..04a81afe 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,7 +11,7 @@ if(NOT ignition-common2_FOUND) find_package(ignition-common3 QUIET) set(IGN_COMMON_VER ${ignition-common3_VERSION_MAJOR}) endif() -if(NOT ignition-common3_FOUND) +if(NOT ignition-common2_FOUND AND NOT ignition-common3_FOUND) find_package(ignition-common4 QUIET REQUIRED) set(IGN_COMMON_VER ${ignition-common4_VERSION_MAJOR}) endif() @@ -60,4 +60,3 @@ foreach(example_file ${example_files}) endif() endforeach() -