Skip to content

Commit

Permalink
Include windows instructions in examples README.md and fix examples t…
Browse files Browse the repository at this point in the history
…o compile them on Windows (#48)

Signed-off-by: ahcorde <[email protected]>
  • Loading branch information
ahcorde authored Mar 30, 2021
1 parent 170c12f commit 53f0f68
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 5 deletions.
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

0 comments on commit 53f0f68

Please sign in to comment.