UnderAutomation
Any question?

[email protected]

Contact us
UnderAutomation
⌘Q

Registers

Read and write numeric registers (R[]), position registers (PR[]), string registers (SR[]), and flags (F[]) via SNPX.

  • Numeric registers (R[])
  • Position registers (PR[])
  • String registers (SR[]) and flags (F[])
  • Complete example
  • API reference

SNPX provides fast read and write access to all register types: numeric (R[]), position (PR[]), string (SR[]), and flags (F[]).

Numeric registers (R[])

Numeric registers store floating-point, 32-bit integer, or 16-bit integer values.

parameters.Snpx.Enable = true;
robot.Connect(parameters);
// Read R[1] as float (default)
float value = robot.Snpx.NumericRegisters.Read(1);
// Write R[1]
robot.Snpx.NumericRegisters.Write(1, 123.45f);
// Read as 32-bit integer
int intValue = robot.Snpx.NumericRegistersInt32.Read(1);
robot.Snpx.NumericRegistersInt32.Write(1, 999);
// Read as 16-bit integer
short shortValue = robot.Snpx.NumericRegistersInt16.Read(1);
}
}
Click to see the full code

Position registers (PR[])

Position registers store joint or Cartesian positions with tool and frame info.

parameters.Snpx.Enable = true;
robot.Connect(parameters);
// Read PR[1]
Position posReg = robot.Snpx.PositionRegisters.Read(1);
// Access Cartesian values
double x = posReg.CartesianPosition.X;
short userFrame = posReg.UserFrame;
short userTool = posReg.UserTool;
// Access joint values
double j1 = posReg.JointsPosition.J1;
// Write Cartesian position to PR[1]
robot.Snpx.PositionRegisters.Write(1, new CartesianPosition(100, 200, 300, 0, 90, 0));
// Write joint position to PR[1]
robot.Snpx.PositionRegisters.Write(1, new JointsPosition { J1 = 0, J2 = 0, J3 = 0, J4 = 0, J5 = 0, J6 = 45 });
}
}
Click to see the full code

String registers (SR[]) and flags (F[])

The default string length is 80 characters. You can change it with StringRegisters.StringLength (must be even, >= 2).

parameters.Snpx.Enable = true;
robot.Connect(parameters);
// Read SR[1]
string text = robot.Snpx.StringRegisters.Read(1);
// Write SR[1]
robot.Snpx.StringRegisters.Write(1, "Hello, Robot!");
// Read F[1]
bool flag = robot.Snpx.Flags.Read(1);
// Write F[1]
robot.Snpx.Flags.Write(1, true);
}
}
Click to see the full code

Complete example

using UnderAutomation.Fanuc;
using UnderAutomation.Fanuc.Common;
public class SnpxRegisters
{
public static void Main()
{
// Create a FanucRobot instance
FanucRobot robot = new FanucRobot();
// Set SNPX connection parameters (example values)
ConnectionParameters parameters = new ConnectionParameters("192.168.0.1");
parameters.Snpx.Enable = true;
// Connect with SNPX enabled
robot.Connect(parameters);
// 1) Numeric Registers: Read & Write
ReadWriteNumericRegisters(robot);
// 2) Position Registers: Read & Write
ReadWritePositionRegisters(robot);
// 3) String Registers: Read & Write
ReadWriteStringRegisters(robot);
}
private static void ReadWriteNumericRegisters(FanucRobot robot)
{
// Read numeric register R[1]
float numReg1 = robot.Snpx.NumericRegisters.Read(1);
Console.WriteLine($"📊 R[1] = {numReg1}");
// Write numeric register R[1]
robot.Snpx.NumericRegisters.Write(1, 123.45f);
Console.WriteLine("✅ Wrote 123.45 to R[1]");
}
private static void ReadWritePositionRegisters(FanucRobot robot)
{
// Read position register PR[1]
Position posReg1 = robot.Snpx.PositionRegisters.Read(1);
Console.WriteLine("\n🤖 Current PR[1]:");
Console.WriteLine($" UserFrame = {posReg1.UserFrame}");
Console.WriteLine($" UserTool = {posReg1.UserTool}");
// If the register is Cartesian
if (posReg1.CartesianPosition != null)
{
Console.WriteLine(" CartesianPosition:");
Console.WriteLine($" X = {posReg1.CartesianPosition.X}");
Console.WriteLine($" Y = {posReg1.CartesianPosition.Y}");
Console.WriteLine($" Z = {posReg1.CartesianPosition.Z}");
Console.WriteLine($" W = {posReg1.CartesianPosition.W}");
Console.WriteLine($" P = {posReg1.CartesianPosition.P}");
Console.WriteLine($" R = {posReg1.CartesianPosition.R}");
Console.WriteLine(" Configuration :");
Console.WriteLine($" ArmFrontBack = {posReg1.CartesianPosition.Configuration.ArmFrontBack}");
Console.WriteLine($" ArmLeftRight = {posReg1.CartesianPosition.Configuration.ArmLeftRight}");
Console.WriteLine($" ArmUpDown = {posReg1.CartesianPosition.Configuration.ArmUpDown}");
Console.WriteLine($" WristFlip = {posReg1.CartesianPosition.Configuration.WristFlip}");
}
// If the register is Joint-based
if (posReg1.JointsPosition != null)
{
Console.WriteLine(" JointsPosition:");
Console.WriteLine($" J1 = {posReg1.JointsPosition.J1}");
Console.WriteLine($" J2 = {posReg1.JointsPosition.J2}");
Console.WriteLine($" J3 = {posReg1.JointsPosition.J3}");
Console.WriteLine($" J4 = {posReg1.JointsPosition.J4}");
Console.WriteLine($" J5 = {posReg1.JointsPosition.J5}");
Console.WriteLine($" J6 = {posReg1.JointsPosition.J6}");
}
// Write a Cartesian position to PR[1]
Console.WriteLine("\n✅ Writing Cartesian position to PR[1]...");
robot.Snpx.PositionRegisters.Write(1, new CartesianPosition(x: 0.1f, y: 0.2f, z: 0.3f, w: 0.4f, p: 0.5f, r: 0.6f));
// Write a Joint position to PR[1]
Console.WriteLine("✅ Writing Joint position to PR[1]...");
robot.Snpx.PositionRegisters.Write(1, new JointsPosition { J1 = 0, J2 = 0, J3 = 0, J4 = 0, J5 = 0, J6 = 45 });
}
private static void ReadWriteStringRegisters(FanucRobot robot)
{
// Read string register SR[1]
string strReg1 = robot.Snpx.StringRegisters.Read(1);
Console.WriteLine($"\n💬 SR[1] = '{strReg1}'");
// Write string register SR[1]
robot.Snpx.StringRegisters.Write(1, "Hello, Robot!");
Console.WriteLine("✅ Wrote 'Hello, Robot!' to SR[1]");
}
}

API reference

Class
NumericRegistersinherits NumericRegistersBase<float,NumericRegistersBatchAssignment>
C#Python

Provides access to numeric registers as float (R[]) on the robot via SNPX.

MemberTypeDescription
CreateBatchAssignment(int, int)
Method
NumericRegistersBatchAssignment
Creates a batch assignment for reading multiple numeric registers.
  • startIndex : The starting register index.
  • count : The number of consecutive registers.
ReadFromClient(int, int)
Method
float
Reads a value from the client at the specified memory offset.
WriteInClient(int, int, float)
Method
void
Writes a value to the robot at the specified offset.
Class
PositionRegistersinherits SnpxWritableAssignableIndexableElements<Position,PositionRegistersBatchAssignment>
C#Python

Provides access to position registers (PR[]) on the robot via SNPX.

MemberTypeDescription
CreateBatchAssignment(int, int)
Method
PositionRegistersBatchAssignment
Creates a batch assignment for reading multiple position registers.
  • startIndex : The starting register index.
  • count : The number of consecutive registers.
GetAssignmentName(int)
Method
string
GetAssignmentSize(int)
Method
int
GetAssignmentTarget(int)
Method
string
Read(int)
Method
Position
Reads the position at the specified register index.
  • index : The register index.
ReadFromClient(int, int)
Method
Position
Reads a value from the client at the specified memory offset.
Write(int, CartesianPosition)
Method
void
Writes a Cartesian position to the specified position register.
  • index : The register index.
  • cartesianPosition : The Cartesian position to write.
Write(int, ExtendedCartesianPosition)
Method
void
Writes an extended Cartesian position to the specified position register.
  • index : The register index.
  • extendedCartesianPosition : The extended Cartesian position to write.
Write(int, JointsPosition)
Method
void
Writes a joints position to the specified position register.
  • index : The register index.
  • jointsPosition : The joints position to write.
WriteInClient(int, int, Position)
Method
void
Writes a value to the robot at the specified offset.
Class
Position
C#Python

Robot position with joints and cartesian representations

MemberTypeDescription
Position()
Constructor
Default constructor
Position(short, short, JointsPosition, ExtendedCartesianPosition)
Constructor
Constructor with user frame, tool, joints and cartesian position
CartesianPosition
Property
ExtendedCartesianPosition
Cartesian position with extended axes
JointsPosition
Property
JointsPosition
Joint values in degrees
UserFrame
Property
short
User frame index
UserTool
Property
short
User tool index
Equals(object)
Method
bool
GetHashCode()
Method
int
ToString()
Method
string
Class
JointsPosition
C#Python

Joints position in degrees

MemberTypeDescription
JointsPosition()
Constructor
Default constructor
JointsPosition(double, double, double, double, double, double)
Constructor
Constructor with 6 joint values in degrees
JointsPosition(double, double, double, double, double, double, double, double, double)
Constructor
Constructor with 9 joint values in degrees
JointsPosition(double[])
Constructor
Constructor from an array of joint values in degrees
this[int]
Property
double
Gets or sets the joint value at the specified index
J1
Property
double
Joint 1 in degrees
J2
Property
double
Joint 2 in degrees
J3
Property
double
Joint 3 in degrees
J4
Property
double
Joint 4 in degrees
J5
Property
double
Joint 5 in degrees
J6
Property
double
Joint 6 in degrees
J7
Property
double
Joint 7 in degrees
J8
Property
double
Joint 8 in degrees
J9
Property
double
Joint 9 in degrees
Values
Property
read only
double[]
Numeric values for each joints
Equals(object)
Method
bool
GetHashCode()
Method
int
IsNear(JointsPosition, JointsPosition, double)
Method
static
bool
Check if joints position is near to expected joints position with a tolerance value
ToString()
Method
string
Class
ExtendedCartesianPositioninherits CartesianPosition
C#Python

Cartesian position with extended axes (E1, E2, E3)

MemberTypeDescription
ExtendedCartesianPosition()
Constructor
Default constructor
ExtendedCartesianPosition(double, double, double, double, double, double, double, double, double)
Constructor
Constructor with position, rotations, and extended axes
E1
Property
double
Extended axis 1 value
E2
Property
double
Extended axis 2 value
E3
Property
double
Extended axis 3 value
Equals(object)
Method
bool
GetHashCode()
Method
int
ToString()
Method
string
Class
CartesianPositioninherits XYZWPRPosition
C#Python

Fanuc cartesian position and rotations

MemberTypeDescription
CartesianPosition()
Constructor
Default constructor
CartesianPosition(double, double, double, double, double, double)
Constructor
Constructor with position and rotations
CartesianPosition(double, double, double, double, double, double, Configuration)
Constructor
Constructor with position, rotations and configuration
CartesianPosition(CartesianPosition)
Constructor
Copy constructor
CartesianPosition(XYZPosition, double, double, double)
Constructor
Constructor from an XYZ position with rotations
Configuration
Property
Configuration
Position configuration
Equals(object)
Method
bool
FromHomogeneousMatrix(double[,])
Method
static
CartesianPosition
Create a CartesianPosition with unknow configuration from a homogeneous rotation and translation 4x4 matrix
  • R : Homogeneous 4x4 matrix
GetHashCode()
Method
int
IsNear(CartesianPosition, CartesianPosition, double, double)
Method
static
bool
Check if two Cartesian positions are near each other within specified tolerances
NormalizeAngle(double)
Method
static
double
Normalize an angle to the range ]-180, 180]
NormalizeAngles(CartesianPosition)
Method
static
void
Normalize the W, P, R angles to the range ]-180, 180]
ToHomogeneousMatrix()
Method
double[,]
Convert position to a homogeneous rotation and translation 4x4 matrix
ToString()
Method
string

Easily integrate Universal Robots, Fanuc, Yaskawa, ABB or Staubli robots into your .NET, Python, LabVIEW or Matlab applications

UnderAutomation
Contact usLegal

© All rights reserved.