Console.WriteLine("📜 Sample Apps Setup");
KillExistingController();
var creationParams = GetCreationParameters();
Console.WriteLine($"RMP path: {creationParams.RmpPath}");
Console.WriteLine($"Use hardware: {Constants.USE_HARDWARE}");
Console.WriteLine($"Axis count: {controller.AxisCountGet()}");
{
Axis? currentAxis = controller.AxisGet(axisNumber: i);
if (currentAxis != null)
{
Console.WriteLine($" Axis {i}: Motor Type = {currentAxis.MotorTypeGet()}");
Console.WriteLine($" Axis {i}: UserUnits = {currentAxis.UserUnitsGet()}");
}
}
{
#if WINDOWS
#elif LINUX
#endif
return createParams;
}
{
if (useHardware)
{
Helpers.ControllerSetup(controller);
}
else if (controller.NetworkStateGet() !=
RSINetworkState.RSINetworkStateUNINITIALIZED &&
{
throw new Exception(
"The Sample Apps are configured to use Phantom Axes, but the network is not in the UNINITIALIZED or SHUTDOWN state.\n" +
"If you intended to run with hardware, then set USE_HARDWARE to true in config.json\n" +
"Otherwise, shutdown the network before running the sample apps with phantom axes.");
}
int initialAxisCount = controller.AxisCountGet();
int initialMotionCount = controller.MotionCountGet();
if (useHardware)
{
int axisCount = controller.AxisCountGet();
if (axisCount < userAxisCount)
{
throw new Exception(
$"Error! Not enough axes configured. Expected {userAxisCount} axes but only found {axisCount} axes.\n" +
"Please configure the axes in your hardware setup.");
}
}
else
{
if (userAxisCount != initialAxisCount)
{
controller.AxisCountSet(userAxisCount);
}
for (int i = 0; i < userAxisCount; i++)
{
Axis phantomAxis = controller.AxisGet(i);
Helpers.PhantomAxisReset(phantomAxis);
}
}
}
static void KillExistingController()
{
try
{
controller.Shutdown();
}
catch
{
}
finally
{
controller.Delete();
}
}
Constants used in the C# sample apps.
const bool USE_HARDWARE
Default: false.
const int AXIS_COUNT
Default: 6.
const int RMP_CPU_AFFINITY
Default: 0.
const string RMP_LINUX_PATH
Default: /rsi.
const string RMP_NIC_PRIMARY
Default: "".
const string RMP_NODE_NAME
Default: NodeA.
const string RMP_WINDOWS_PATH
Default: .....
void UserUnitsSet(double countsPerUserUnit)
Sets the number of counts per User Unit.
Represents a single axis of motion control. This class provides an interface for commanding motion,...
static MotionController * Get()
Get an already running RMP EtherCAT controller.
static MotionController * Create(CreationParameters *creationParameters)
Initialize and start the RMP EtherCAT controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
RSINetworkState
State of network.
void SetupController(MotionController *controller, int numAxes=0)
Setup the controller and check if the network is in the correct state for the configuration.
MotionController::CreationParameters GetCreationParameters()
Returns a MotionController::CreationParameters object with user-defined parameters.
Helpers namespace provides utility functions for common tasks in RMP applications.
CreationParameters for MotionController::Create.