APIs, concepts, guides, and more
|
Learn how to run a sample app in C++.
Our guides typically assume these IDEs, but the general steps provided should be applicable to any IDE you choose.
For Older Versions of RMP
- For versions in the range v9.x.x to v10.5.2, see Run a sample app in C++ (pre v10.5.3)
- For versions in the range 8.x.x, see Run a sample app in C++ (v8.x.x)
Before you can build and run these sample applications, you must have the following installed:
Ensure that your development environment is set up according to the specifications of the RMP motion controller as defined in the Setup page of our knowledge base.
First, you need to ensure that RMP is able to read your YubiKey for license verification. Complete the following steps:
Add your user to the plugdev
group
Create a Udev rule for the YubiKey
append the following:
Reload Udev rules
Verify that the new rule was applied
lsusb
. The output will be in the following form:[bus_number]
and [device_number]
from the lsusb
output:plugdev
in the outputThen you will want to copy the examples to somewhere in your home directory.
You will want to copy the examples to somewhere within your home directory and give ownership to the current user to avoid permission issues. This can be accomplished by running the following commands:
sudo cp -r /rsi/examples ~/<destination folder>
sudo chown -R $(whoami):$(whoami) ~/<destination folder>
If you are on version 10.5.3
, then you must also modify RapidSoftware.cmake
which is located in ~/<destination folder>/C++
. On line 8, replace:
set(RMP_DIRECTORY ${CMAKE_SOURCE_DIR}/../..)
with:
set(RMP_DIRECTORY /rsi)
Then you must specify which CPU core the sample apps will run on in include/SampleAppsHelper.h
. In the SampleAppsConfig
struct, set the CPU affinity to an isolated core. If you are unsure if you have an isolated core, then run the following command to list your isolated cpu's (if you have any):
The first step is to set your motion controller creation parameters in include/SampleAppsHelper.h
. For most situations, the default values will be acceptable to get started, but it is recommended to read through the comments and understand what each parameter does regardless.
Then choose one of the following methods:
Install the C/C++ Extension Pack by Microsoft. Then use the CMake Tools extension to build, debug, and run the samples.
If your system is headless, then you can connect to it remotely using the Remote - SSH extension.
Use one of our helper scripts located in the VisualStudioGeneratorScripts
directory. Run generate_build_files_<Visual Studio Version>.bat
to use CMake to generate a solution file for your version of Visual Studio. Then navigate to the build/<Visual Studio Version>
and open the .sln file located there.
Use the CMake CLI to generate build files and build the samples. Then navigate to /bin/<Configuration>
and run the executables located there.
By default the sample apps will run using "Phantom Axes" without the EtherCAT network running. If you wish to run the samples using hardware then complete the following:
src
directory. Read through the code and run it with phantoms until you have a good understanding of how it worksinclude/SampleAppsHelper.h
and configure the SampleAppsConfig
struct to have appropriate constants for your setup. - This will include setting the User Units for your motors, which is the number of motor encoder counts per RMP unit. For instance, if your motor has 1000 encoder counts per rotation, then setting the User Units to 1000 would mean that one RMP unit is one rotation (i.e. a position of 1 is 1 rotation from the origin, a velocity of 1 is 1 rotation per second etc.). Typically, the number of encoder counts per rotation will be a power of 2 based on the encoder resolutionSampleAppsConfig::ConfigureHardwareAxes
according to your setupSampleAppsConfig::USE_HARDWARE
to true. Now ALL sample apps will use your hardware until you set this back to falseSampleAppsConfig::USE_HARDWARE
back to false, so that you don't accidentally run the samples with hardware in the future