APIs, concepts, guides, and more
πŸš€ Get started

Learn RapidCode C++ with these sample applications.

C++ Sample Apps

These C++ examples, located in the examples/ folder under your RMP install directory (e.g., C:/RSI/X.X.X/examples/ or /rsi/examples/), show how to control the RMP EtherCAT motion controller with the RapidCode API. Use these projects to explore API features, validate configurations, and jump‑start your own apps.

⚠️ Important Note

These samples focus on demonstrating API usage. They may not include the complete safety logic required for your machine. When working with real hardware always wire an external emergency stop, verify limits, and start with conservative motion constants.

βœ… Prerequisites

  • RapidCode / RMP SDK installed (includes firmware, drivers, and license tools)
  • Build Tools
    • Windows: Visual Studio (or the Build Tools edition) with the Desktop development with C++ workload installed
      • Note: At this time, Visual Studio 2026 requires additional configuration. For this reason, we recommend Visual Studio 2022 or 2019
    • Linux (Debian/Ubuntu): GCC or Clang toolchain with standard build essentials available on your distro
  • CMake 3.15+
  • Recommended: Visual Studio Code with C/C++ Extension Pack + CMake Tools

⬇️ Windows: Install Visual Studio

  1. Visit the Visual Studio - Older Downloads page
  2. Select either 2022 or 2019
  3. Download either a full Visual Studio installation or the Visual Studio Build Tools

⬇️ Linux (Debian/Ubuntu): Install GCC

  1. Install the build-essential meta-package

    sudo apt update
    sudo apt install build-essential
  2. Verify that GCC has been installed

    gcc --version
    g++ --version

⬇️ Linux (Debian/Ubuntu): Install Clang

  1. Install Clang directly

    sudo apt update
    sudo apt install clang
  2. Verify the installation

    clang --version
    clang++ --version

πŸ“œ About the RTTaskFunctions library

Samples such as HelloRTTasks and RandomWalk load the RTTaskFunctions library at runtime. The host sample (C++, C#, or Python) connects to the RTTaskManager, while deterministic motion/processing is executed inside the real-time tasks defined in examples/RTTaskFunctions/src/. See the rttasks documentation for the full architecture.

πŸ“‚ Layout

Path / File Description
src/ Modern CMake samples organized by topic (AxisConfiguration, Motion, etc.)
src/config.h User-editable configuration (RMP path, NIC, CPU affinity, hardware flag, …)
src/helpers.h Shared helper utilities (network start/stop, error handling, console output)
VisualStudioGeneratorScripts/ Helper .bat scripts that call CMake to generate Visual Studio solutions

βš™οΈ Linux setup

  1. Allow YubiKey access (license check)

    sudo usermod -aG plugdev <your_username>
    sudo tee /etc/udev/rules.d/99-plugdev-yubikey.rules <<'EOF'
    SUBSYSTEM=="usb", ATTR{idVendor}=="1050", GROUP="plugdev", MODE="0660"
    EOF
    sudo udevadm control --reload-rules
    sudo udevadm trigger

    Replug the key, verify with lsusb, then confirm ownership:

    ls -l /dev/bus/usb/<bus>/<device>
  2. Copy the examples

    cp -r /rsi/examples ~/rapidcode-examples
  3. Isolate a CPU core (recommended)

    Add or update the GRUB entry (replace <cpu> with the chosen core):

    sudo nano /etc/default/grub
    GRUB_CMDLINE_LINUX="isolcpus=<cpu> processor.max_cstate=0 intel_idle.max_cstate=0 idle=poll \
    nohz_full=<cpu> rcu_nocbs=<cpu> rcu_nocb_poll nosmt"

    Reboot, then set Config::CPU_AFFINITY to that core.

βš™οΈ Configuration

Edit src/config.h before running the samples:

Constant Windows Linux Value
RMP_PATH βœ”οΈ βœ”οΈ RMP installation path. Usually /rsi (Linux) or C:\RSI\X.X.X (Windows)
NIC_PRIMARY βœ”οΈ The name of the primary network card (only required for physical axes)
NODE_NAME βœ”οΈ INtime node name (usually NodeA)
CPU_AFFINITY βœ”οΈ Isolated CPU core you want to use. Find it with cat /sys/devices/system/cpu/isolated
USE_HARDWARE βœ”οΈ βœ”οΈ Start with false to test your sample app with phantom axes. When you're ready to use physical motors, see the "Run with Hardware" section below

Tip: Use rsiconfig to back up your axis settings before running samples that may overwrite firmware values. Visit Software Tools > rsiconfig in our documentation to learn more.

πŸš€ Build and Run the sample apps

There are 3 supported options for building and running the sample apps

  • VSCode with CMake Tools (Recommended)
  • Visual Studio
  • CMake CLI

Each of these options is explained more in-depth in the sections below

Remember: Rebuild the sample app(s) after any changes to the source code

πŸ› οΈπŸš€ Building and Running with VS Code (Recommended)

Use C/C++ Extension Pack + CMake Tools for configure/build/debug. Remote/headless targets can be driven via Remote - SSH.

  1. Open VS Code to the C++ examples folder
  2. Click the CMake icon in the activity bar
  3. Open the Project Status dropdown
  4. Under the Folder dropdown, verify it says "C++"
  5. Under the Configure dropdown, choose your build kit
    1. Click the Select a Kit button
    2. Choose [Scan for kits] to detect your build kit
    3. Click Select a Kit again
    4. Choose the appropriate build kit for your system
      • Windows: Select a Visual Studio kit (either 2022 or 2019) for amd64
      • Linux: Select your GCC or Clang build kit
  6. Hover over the Configure tab and click the Configure button so CMake can generate the appropriate files
  7. Set your Build Target
    1. Under the Build dropdown, click the Set Build Target button
    2. Select the sample app you want to build (or the ALL_BUILD target to build all sample apps)
  8. Set your Launch Target
    1. Under the Debug or Launch dropdown, click the Set Launch/Debug Target
    2. Select the sample app you want to run
  9. Run your sample app
    • To run with debugging: Click on the Debug button next to the Debug dropdown
    • To run without debugging: Click on the Run in Terminal button next to the Launch dropdown

Note: You can also right-click in the Project Outline dropdown to set the build and debug/launch target

πŸ› οΈπŸš€ Building and Running with Visual Studio

  1. Run one of the scripts in VisualStudioGeneratorScripts/ (e.g., generate_build_files_vs2022.bat)
  2. Navigate to ./build/<VSVersion> (e.g., ./build/vs2022)
  3. Open the solution file SampleApps.sln
  4. Right click on your target in the Solution Explorer and click Set as Startup Project
  5. Click one of the green play buttons at the top of the window to build and run with or without debugging

πŸ› οΈπŸš€ Building and Running with CMake CLI

Use the CMake CLI workflow:

cmake -S . -B build
cmake --build build --config Release
./bin/Release/<sample>

⚠️ Warning

Unless you call MotionController::Shutdown(), the RMP firmware will continue your run after your sample app finishes. This can also happen if you started it through RapidSetup or RapidSetupX. If you believe this is causing issues with your execution, end the RMP firmware process before running your sample app again.

βš™οΈ Run with hardware

  1. Choose a sample in src/ and run it with phantom axes to understand its behavior.
  2. Adjust any motion constants (position, velocity, acceleration, jerk) to safe values.
  3. Update src/config.h (user units, limits, network settings) and implement Config::ConfigureHardwareAxes if you are not using rsiconfig.

Note: For more info on configuring hardware axes, see the axis-configuration.cpp sample app and our Concepts > Configuration documentation

  1. Enable hardware by setting Config::USE_HARDWARE = true.
  2. Double-check constants again (especially those expressed in user units).
  3. Build and run the sample while monitoring hardware and e-stop readiness.
  4. When finished, set Config::USE_HARDWARE = false so future runs revert to phantom axes.