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

Include windows instructions in examples README.md and fix examples to compile them on Windows #48

Merged
merged 3 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -56,4 +60,3 @@ foreach(example_file ${example_files})
endif()

endforeach()

41 changes: 41 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -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`
2 changes: 1 addition & 1 deletion examples/plugins/CrashBot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions examples/robot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*
*/

#include <array>
#include <cassert>
#include <iostream>
#include <set>
Expand Down Expand Up @@ -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;
}

/////////////////////////////////////////////////
Expand Down