diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index ce781423..04a81afe 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-common2_FOUND AND 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}) @@ -56,4 +60,3 @@ foreach(example_file ${example_files}) endif() endforeach() - 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; } /////////////////////////////////////////////////