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 sample applications are provided to help you integrate the RMP motion controller into your own projects. They are not production-ready and may lack critical logic or safety mechanisms required for your specific application.

If you are working with real hardware, we strongly recommend wiring an external hardware emergency stop (e-stop) button. This safeguard is essential to protect both people and equipment, reducing the risk of injury or damage when using these sample applications.

βœ… Prerequisites

  • .NET 10 SDK
    • Download the latest version: Download .NET 10.0
    • Verify that it is correctly installed by running

      dotnet --version
      # The output should show version 10.x.x
  • RMP SDK - The RMP must be installed on your system
  • Physical hardware - If using physical hardware, it must be properly configured

πŸ“‚ Files

  1. Navigate to the sample apps folder
    1. Open your RMP installation folder (the default is C:/RSI/X.X.X)
    2. Click on the examples folder, then on C#, so that you are in <YOUR_RMP_FOLDER>/examples/C#
  2. Verify that you have the following helper files:
General
_constants.cs Common configuration file for all sample apps (RMP path, default axis index, etc)
_helpers.cs Helper functions and utilities used across sample applications
_setup.cs Gets your controller/system ready for sample apps. (create controller, setup axis, etc)
_config.cs Helper functions for _setup.cs, including one you must implement (see Run with Hardware)
Directory.Build.targets MSBuild configuration that references RapidCode .NET dll and manages build settings

βš™οΈ Configure _constants.cs

🟒 (Required) General Constants

Use settings specific to your machine and hardware

Constant Windows Linux Description
RMP_WINDOWS_PATH βœ”οΈ RMP installation path. Default is C:\RSI\X.X.X for Windows
RMP_LINUX_PATH βœ”οΈ RMP installation path. Default is /rsi for Linux
RMP_NODE_NAME βœ”οΈ INtime node name (usually NodeA)
RMP_NIC_PRIMARY βœ”οΈ The name of the primary network card used by RMP (only required for physical axes)
RMP_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
AXIS_COUNT βœ”οΈ βœ”οΈ The number of axes connected to your system (see below).
MULTIAXIS_COUNT βœ”οΈ βœ”οΈ The number of MultiAxis objects you want to use with your sample apps. This must be at least 1 to run the MultiAxis samples

AXIS_COUNT Note: The sample apps will only ever use a maximum of 6 axes. If you are using hardware, you should always set AXIS_COUNT to the number of axes connected to your system, and extra axes will be ignored. If you are using phantom, you can leave this at 6 and RMP will simulate enough axes for all sample apps.

🟒 (Required) Axis-Specific Settings

You must set these for values of i from 0 to AXIS_COUNT - 1 (or set all of them if AXIS_COUNT >= 6)

Constant Windows Linux Description
AXIS_i_INDEX βœ”οΈ βœ”οΈ Change which axes will be used by the sample apps. See the comment in _constants.cs for details
AXIS_i_USER_UNITS βœ”οΈ βœ”οΈ The User Units for the i'th axis in your program. See Concepts > Configuration > Counts Per Unit in the documentation for more info

πŸ”˜ (Optional) Additional Constants

If you want to explore more advanced features or are having trouble, look at these additional constants

Constant Windows Linux Description
AMP_ENABLE_MS βœ”οΈ βœ”οΈ How many ms to wait for AmpEnableSet. You can increase this up to 1000ms if you are encountering amp faults.
RAPIDSERVER_IP βœ”οΈ βœ”οΈ The "server ip" displayed when starting your rapidserver
RAPIDSERVER_PORT βœ”οΈ βœ”οΈ The "grpc port" displayed when starting your rapidserver

πŸš€ Run a sample app

  1. Open Powershell (Windows) or Terminal (Linux)
  2. Navigate to the sample apps folder

    cd "C:\RSI\X.X.X\examples\C#" #Windows
    cd "/rsi/examples/C#" #Linux

    where X.X.X is your RMP version.

    For example:

    cd C:\RSI\10.7.2\examples\C#
  3. Clean existing builds

    dotnet clean _setup.cs
    • If encountering bugs, try repeating this step
  4. Run _setup.cs

    dotnet run _setup.cs --no-cache
    • If encountering bugs, try repeating this step

      Note: Repeat this step after any changes to _constants.cs

  5. Run a sample app

    For example:

    dotnet run axis-config-settling.cs --no-cache

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, re-run _setup.cs as above, or manually end the RMP firmware process (i.e., shutdown the controller in RapidSetupX or RapidSetup) before running your sample app again.

πŸ› Debugging in VS Code

If you wish to debug the sample apps with breakpoints and step-through debugging:

  1. Install the C# Dev Kit extension
    • Open VS Code
    • Go to Extensions (Ctrl+Shift+X)
    • Search for "C# Dev Kit" and install it
    • Or install directly: C# Dev Kit
  2. Open the sample file
    • Open the .cs file you want to debug in VS Code
  3. Set breakpoints
    • Click in the left margin next to line numbers to add breakpoints
  4. Start debugging
    • Press F5 or click "Run and Debug" from the sidebar
    • The debugger will stop at your breakpoints, allowing you to inspect variables and step through code

βš™οΈ Run with hardware

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

    Note: For more info on configuring hardware axes, see the axis-config sample apps and our Concepts > Configuration documentation

  4. Enable hardware by setting USE_HARDWARE = true in _constants.cs.
  5. Double-check constants again (especially those expressed in user units).
  6. Use dotnet run with the --no-cache flag to run the sample, monitoring hardware and e-stop readiness.
  7. Press 'y' when prompted to run with hardware
  1. When finished, set USE_HARDWARE = false so future runs revert to phantom axes.