using System.Threading;
Console.WriteLine("📜 Motion: G-Code");
try
{
string gcodeProgram = @"G91; Sets the programming mode to RELATIVE
G64; Turns off exact stop mode (Default)
G1 X1.0 Y0.0 Z0.0 A1.0 F60.0; Move on USERUNIT in positive x direction at 60in/min. Moves Free axis A to position 1.0.
G3 X1 Y1 I0 J1; Counter clockwise arc with a center point of 0,1,0 and end point of 1,1,0 relative to the current position
M80; Show how to use an M-code with GcodeCallback!";
const string xLabel = "X-Axis";
const string yLabel = "Y-Axis";
const string zLabel = "Z-Axis";
const string aLabel = "A-Axis";
MultiAxis jointsMultiAxis = controller.MultiAxisGet(0);
Axis[] axes = [xAxis, yAxis, zAxis, aAxis];
jointsMultiAxis.
AxesAdd(axes, axes.Length);
const string modelName = "RSI_XYZA";
const double scaling = 1.0;
const double offset = 0.0;
SampleGcodeCallback callback = new();
try
{
}
catch (Exception e)
{
Console.WriteLine($"Error loading G-Code: {e.Message}");
throw;
}
Console.WriteLine($"G-Code Line Count: {robot.Gcode.LineCountGet()}");
Console.WriteLine($"G-Code Error Log Count: {robot.Gcode.ErrorLogCountGet()}");
Console.WriteLine($"G-code estimated run time: {robot.Gcode.DurationGet()} seconds");
Int64 activeLineNumber = 0;
do
{
Thread.Sleep(200);
{
Console.WriteLine($"G-Code Line Number: {activeLineNumber}");
}
Robot.RobotDelete(controller, robot);
Console.WriteLine("✅ G-Code motion completed successfully");
}
finally
{
controller.Delete();
}
public class SampleGcodeCallback : GcodeCallback
{
public override void Execute(GcodeCallbackData data)
{
Console.WriteLine("G-Code Callback executed: " + data.LineNumber + " " + data.LineText);
}
}
Constants used in the C# sample apps.
const int AXIS_0_INDEX
Default: 0.
const int AXIS_3_INDEX
Default: 3.
const int AXIS_1_INDEX
Default: 1.
const int AXIS_2_INDEX
Default: 2.
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,...
void DefaultAccelerationSet(double acceleration)
Set the default acceleration in UserUnits.
void DefaultDecelerationSet(double deceleration)
Set the default deceleration in UserUnits.
void FreeAxisLetterSet(const char gcodeLetter, const int32_t freeAxisIndex)=0
Map a letter in a Gcode file to a free axis. It will be used to specify the free axis' motion.
void CallbackRegister(Cartesian::GcodeCallback *callback, bool containsMotion=false)=0
Register a catch-all M-code callback.
int32_t ExecutingLineNumberGet()=0
Get the currently executing line number.
void AccelerationRateSet(double programmingUnitsPerMinuteSquared)=0
REQUIRED before Load() or LoadFile(). Sets the target acceleration for the machine (units/minute^2)....
void Load(const char *const text)=0
Load a G-code program from a string.
void Run()=0
Run the loaded G-Code file (or string). The behavior is non-blocking. Use DoneWait() to block.
bool IsRunning()=0
Returns true if a Gcode program is executing, false otherwise.
void FreeAxisAdd(const ModelAxisMapping &freeAxis)
Map a free axis in the kinematic model. The Axis' DefaultVelocity/Acceleration will be used for free ...
The Builder for a linear kinematic model. Constructs a single Linear Kinematic Model to use when crea...
void JointAdd(const LinearJointMapping &joint)
adds a joint to the model using the configuration specified within the LinearJoint structure.
static Robot * RobotCreate(MotionController *controller, MultiAxis *multiAxis, KinematicModelBuilder *builder, uint32_t motionFrameBufferSize)
Create a Robot object to use G-Code, path motion, etc.
Represents a collection of joints in Cartesian space with forward and inverse kinematics....
RSI::RapidCode::Cartesian::Gcode * Gcode
An object to load and run Gcode files.
static constexpr int32_t AxisFrameBufferSizeDefault
The default value of the AxisFrameBufferSize, also the minimum allowable value.
static MotionController * Get()
Get an already running RMP EtherCAT controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
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...
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.
CartesianAxis
This enum specifies which Cartesian axis a LinearJointMapping maps a robot joint to.
Helpers namespace provides utility functions for common tasks in RMP applications.
Data for adding joint or free-axis mappings when building a kinematic model.