APIs, concepts, guides, and more
path-motion.cs
/* This sample demonstrates how to set up and run path motion with a Robot object.
Shows how to create kinematic models, program path movements using lines and arcs,
and execute coordinated multi-axis motion.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
using System.Threading;
Console.WriteLine("📜 Motion: Path");
// get rmp objects
try
{
Helpers.CheckErrors(controller);
// set robot axis labels
const string xLabel = "X-Axis";
const string yLabel = "Y-Axis";
const string zLabel = "Z-Axis";
const string aLabel = "A-Axis";
const string bLabel = "B-Axis";
const string cLabel = "C-Axis";
// get the 6 axis needed for XYZABC robot
Axis xAxis = controller.AxisGet(Constants.AXIS_0_INDEX);
Axis yAxis = controller.AxisGet(Constants.AXIS_1_INDEX);
Axis zAxis = controller.AxisGet(Constants.AXIS_2_INDEX);
Axis aAxis = controller.AxisGet(Constants.AXIS_3_INDEX);
Axis bAxis = controller.AxisGet(Constants.AXIS_4_INDEX);
Axis cAxis = controller.AxisGet(Constants.AXIS_5_INDEX);
// configure phantom axes
// set axis labels
xAxis.UserLabelSet(xLabel);
yAxis.UserLabelSet(yLabel);
zAxis.UserLabelSet(zLabel);
aAxis.UserLabelSet(aLabel);
bAxis.UserLabelSet(bLabel);
cAxis.UserLabelSet(cLabel);
// create multi-axis object for joints
MultiAxis jointsMultiAxis = controller.MultiAxisGet(0);
Axis[] axes = [ xAxis, yAxis, zAxis, aAxis, bAxis, cAxis ];
jointsMultiAxis.AxesAdd(axes, axes.Length);
jointsMultiAxis.ClearFaults();
// create kinematic model with 6-axis configuration
const LinearUnits units = LinearUnits.Meters;
const string modelName = "RSI_XYZABC_Meters";
const double scaling = 1.0;
const double offset = 0.0;
LinearModelBuilder builder = new(modelName);
builder.UnitsSet(units);
builder.JointAdd(new LinearJointMapping(0, CartesianAxis.X) { ExpectedLabel = xLabel, Scaling = scaling, Offset = offset });
builder.JointAdd(new LinearJointMapping(1, CartesianAxis.Y) { ExpectedLabel = yLabel, Scaling = scaling, Offset = offset });
builder.JointAdd(new LinearJointMapping(2, CartesianAxis.Z) { ExpectedLabel = zLabel, Scaling = scaling, Offset = offset });
builder.JointAdd(new LinearJointMapping(3, CartesianAxis.Roll) { ExpectedLabel = aLabel, Scaling = scaling, Offset = offset });
builder.JointAdd(new LinearJointMapping(4, CartesianAxis.Pitch) { ExpectedLabel = bLabel, Scaling = scaling, Offset = offset });
builder.JointAdd(new LinearJointMapping(5, CartesianAxis.Yaw) { ExpectedLabel = cLabel, Scaling = scaling, Offset = offset });
// create Robot object with multi axis and kinematic model
Robot robot = Robot.RobotCreate(controller, jointsMultiAxis, builder, MotionController.AxisFrameBufferSizeDefault);
// print some robot info
Console.WriteLine($"Robot model: {robot.ModelGet().NameGet()}");
Console.WriteLine($"Robot units: {robot.ModelGet().UnitsGet()}");
// set path motion parameters
robot.PathAccelerationSet(1000); // user units per sec squared
robot.PathVelocitySet(50); // user units per sec
// program path motion
robot.PathProgrammingModeSet(PathMode.Absolute);
robot.PathLine(target: new Pose(1, 1, 1));
robot.PathArc(
target: new Pose(0, 2, 1),
center: new Vector3d(0, 1, 1),
direction: RotationDirection.Clockwise);
// enable amplifiers
jointsMultiAxis.AmpEnableSet(true);
// start path motion (non-blocking)
robot.Run();
// monitor motion
while (robot.IsRunning())
{
Thread.Sleep(100);
Console.WriteLine("Path motion executing...");
}
// cleanup
Robot.RobotDelete(controller, robot);
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
static void ConfigurePhantomAxis(Axis phantomAxis)
Configures a phantom axis on the controller.
Definition _helpers.cs:144
static void CheckErrors(RapidCodeObject rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...
Definition _helpers.cs:15
Helpers class provides static methods for common tasks in RMP applications.
Definition _helpers.cs:5
void UserLabelSet(const char *const userLabel)
Set the axis User defined Label.
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5870
Axis * AxisGet(int32_t axisNumber)
AxisGet returns a pointer to an Axis object and initializes its internals.
static constexpr int32_t AxisFrameBufferSizeDefault
The default value of the AxisFrameBufferSize, also the minimum allowable value.
Definition rsi.h:854
static MotionController * Get()
Get an already running RMP EtherCAT controller.
void Delete(void)
Delete the MotionController and all its objects.
MultiAxis * MultiAxisGet(int32_t motionSupervisorNumber)
MultiAxisGet returns a pointer to a MultiAxis object and initializes its internals.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:800
void AxesAdd(Axis **axes, int32_t axisCount)
Represents multiple axes of motion control, allows you to map two or more Axis objects together for e...
Definition rsi.h:10804
void ClearFaults()
Clear all faults for an Axis or MultiAxis.
int32_t AmpEnableSet(bool enable, int32_t ampActiveTimeoutMilliseconds=AmpEnableTimeoutMillisecondsDefault, bool overrideRestrictedState=false)
Enable all amplifiers.