The RMP Motion Controller APIs
Quick Start

Learn how to create a MotionController, set an AxisCount and get Axis status.

Warning
This is a sample program to assist in the integration of the RMP motion controller with your application. It may not contain all of the logic and safety features that your application requires. We recommend that you wire an external hardware emergency stop (e-stop) button for safety when using our code sample apps. Doing so will help ensure the safety of you and those around you and will prevent potential injury or damage.

The sample apps assume that the system (network, axes, I/O) are configured prior to running the code featured in the sample app. See the Configuration page for more information.
Precondition
A helper function to check each response for errors.
// Check each response header for errors. Stop execution if errors were received.
private static void CheckErrors(ResponseHeader header)
{
if (header.Errors.Count > 0)
{
string message = "RPC had errors!\n";
foreach (var error in header.Errors)
{
message += " " + error.Message + "\n";
}
Assert.Fail(message);
}
}


📜 Client Creation
Create an instance of RMPServiceClient. Channel is a class from the C# gRPC API that establishes a connection to the server listening at the specified IP and port.

channel = new Channel(ipAddress, PORT, ChannelCredentials.Insecure);
rmpClient = new RMPService.RMPServiceClient(channel);


📜 Create a Motion Controller
Create a motion controller on the server.

// First, before doing any other RapidCodeRemote RPCs, create the motion controller on the server
MotionControllerResponse motionControllerResponse = rmpClient.MotionController(new MotionControllerRequest
{
Action = new MotionControllerAction { Create = new MotionControllerAction.Types.Create() },
});
CheckErrors(motionControllerResponse.Header);


📜 Set the Axis count
Set the axis count within the motion controller.

// Next, set the axis count so we have axes to work with.
motionControllerResponse = rmpClient.MotionController(new MotionControllerRequest
{
Config = new MotionControllerConfig { AxisCount = Constants.AXIS_COUNT },
});
CheckErrors(motionControllerResponse.Header);
Assert.That(motionControllerResponse.Config.AxisCount, Is.EqualTo(Constants.AXIS_COUNT), "Expected returned axis count to be what we set it to!");


📜 Check the status of an Axis
Check the current state within the status message of an Axis.

// Check the state of the axis at index 0
AxisResponse axisResponse = rmpClient.Axis(new AxisRequest { Index = 0 });
CheckErrors(axisResponse.Header);
Assert.That(axisResponse.Status.State, Is.EqualTo(RSI.RapidCodeRemote.RSIState.Idle), "Expected axis state to be IDLE!");