The C++ example projects in this repository use CMake.
The following link has the instructions to install CMake.
- cmake >= 3.5: CMake install page
On Windows, make sure you add CMake to your PATH variable
To check which version of GCC is installed on Windows or Linux
Note: This procedure only works on Windows if you add the MinGW bin directory path to the PATH environment variable.
gcc --version
Procedure to install GCC under Linux (GCC 5.4 on Ubuntu 16.04, GCC 7.4 on Ubuntu 18.04, GCC 9.4 on Ubuntu 20.04)
sudo apt-get install build-essential
Because GCC is not coded for the Windows operating system, a GCC port of MinGW-w64 for Windows is required. The '-w64' suffix indicates that it can support a 32-bit or 64-bit environment. The 32-bit versions are still available and one of them will be used to compile the affected project.
- Go to https://sourceforge.net/projects/mingw-w64
- Start the installer and click
Next
until you reach the installation options page - On the options page ensure that the options look exactly like this (all options are the default values, except for version, which is the version of GCC we want to install - 5.4 in this case)
- Click
Next
until the end of the installation. The install directory by default is the one set in the build script included with the project. - Add the path of the bin directory to the system path to make all the MinGW commands and tools available system wide:
- Right-click on the
Start
Button - Select
System
from the context menu. - Click
Advanced system settings
- Go to the
Advanced
tab - Click
Environment Variables…
- Click variable called
Path
and clickEdit…
- Click
New
- Enter the path to the folder containing the binary you want on your
PATH
(e.g.C:\Program Files (x86)\mingw-w64\i686-5.4.0-posix-dwarf-rt_v5-rev0\mingw32\bin
)
- Right-click on the
The C++ examples use the Conan (V1.X) package manager for fetching its dependencies. This is done by default and requires Conan to be installed.
Instructions are for conan V1.X only and it won't work for versions >=2.0.0
You can refer to the Conan Installation Tutorial for installing Conan.
Note: It is recommended to install Python3 for Conan. You can download and install Python3 from https://www.python.org/
When installing conan
via pip
the new directory might not be appended to the PATH. This can be solved on Ubuntu by restarting the terminal or by using source ~/.profile
or by adding the installed PATH (that you can find with pip show conan
) to your PATH environnement variable in Windows.
Next, enable the revision feature for Artifactory plugin
conan config set general.revisions_enabled=1
Create an automatically detected default profile
conan profile new default --detect
After Conan is properly installed, build as specified in the build section.
Although building with Conan is recommended, it is possible to disable it.
Doing so requires calling cmake with an additional option: -DUSE_CONAN=OFF
.
Example (Linux):
mkdir build
cd build
cmake .. -DUSE_CONAN=OFF -DCMAKE_BUILD_TYPE=release [-DKORTEX_SUB_DIR=<kortex_api_sub_folder dir name>]
make
This applies to all the manual build commands. The build scripts can also be modified to add this option.
Example (build-mingw.bat)
(line 17) cmake .. -G "MinGW Makefiles" -DUSE_CONAN=OFF -DCMAKE_BUILD_TYPE=%build_type% -DKORTEX_SUB_DIR=%kortex_api_sub_folder% && mingw32-make
This will effectively revert to the old build method. It requires downloading the Kortex Api library:
- Download the archive via Kinova's Artifactory server: kortex_api
- Uncompress the content of the archive and place it in the directory
kortex_api
.
examples/kortex_api
┬
├ include/
├ lib/
└ ┬
├ debug/
└ release/
You can also uncompress the content of the archive in a sub-directory kortex_api/<Something>
. You will then have to use the KORTEX_SUB_DIR
CMake argument to specify the Kortex API sub-directory.
examples/kortex_api
┬
├ Something/ [e.g. linux_gcc_x86-64]
└ ┬
├ include/
├ lib/
└ ┬
├ debug/
└ release/
Note: The C++ examples use the Conan package manager by default. Refer to the Conan section on how to install Conan or revert to building without Conan.
To build, you need change the current directory to the example directory. The build instructions then depend on your OS and compiler (see below).
my_example_repo
┬
├ api_cpp/
└ ┬
├ doc/
└ examples/ (you have to cd here)
Linux Ubuntu
You can run the build script:
./scripts/build-gcc.sh {release|debug}
You can also build manually:
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=release [-DKORTEX_SUB_DIR=<kortex_api_sub_folder dir name>]
make
Note: the name of the executable is mingw32-make.exe
, even for the 64-bit version)
Windows - using GCC
You can run the build script:
scripts\build-mingw.bat {release|debug}
You can also build manually:
mkdir build
cd build
cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=release [-DKORTEX_SUB_DIR=<kortex_api_sub_folder dir name>]
mingw32-make
Windows - using Visual Studio 2017
mkdir build
cd build
cmake .. -G "Visual Studio 15 2017 [arch]" -DCMAKE_SH=CMAKE_SH-NOTFOUND -DCMAKE_BUILD_TYPE=release [-DKORTEX_SUB_DIR=<kortex_api_sub_folder dir name>]
Windows - using command-line MSVC build
Setup the build environment:
Note: Make sure to adjust the path to match the location of your installed BuildTools call:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat
You can run the build script:
scripts\build-msvc.bat {release|debug} {static|dynamic}
You can also build manually:
mkdir build
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release [-DKORTEX_SUB_DIR=<kortex_api_sub_folder dir name>]
nmake
We assume the robot is using its default IP address: 192.168.1.10
.
Before you start make sure you run the test in a safe area - some examples contain movement. Also verify that your robot is correctly afixed to your working surface.
Prerequisites:
- The examples require a wired connection to your computer
- Configure a static IP on your network interface (e.g:
192.168.1.11/24
)
Each example has its own main
function so you can run them individually from the examples folder.
On Linux :
./<your_build_folder>/<example_name>
On Windows :
<your_build_folder>\<example_name>.exe
Here is a link to the generated documentation:
API C++ Services Documentation
Google Proto Buffer generated C++: | https://developers.google.com/protocol-buffers/docs/reference/cpp-generated |