Read and decode files
FTP is a protocol that allows you to read and decode files from a Fanuc robot, such as variables, programs, diagnosis, etc.
FTP (File Transfer Protocol) provides access to internal controller files, as well as fast parsing and decoding, including .va variable files and .dg diagnostic files.
Manipulate files
The SDK lets you send files, download files, rename, delete and more.
Here are some examples :
robot.Ftp.DirectFileHandling.DownloadFileFromController(@"C:\temp\MyPrg.tp", "md:/MyPrg.tp);robot.Ftp.DirectFileHandling.UploadFileToController(@"C:\temp\MyPrg.tp", "md:/MyPrg.tp);robot.Ftp.DirectFileHandling.DeleteFile("md:/MyPrg.tp");robot.Ftp.DirectFileHandling.CreateDirectory("md:/NewDirectory");robot.Ftp.DirectFileHandling.DeleteDirectory("md:/NewDirectory");
Read variables
Variables are read in bulk (note that TELNET also allows variables to be read one by one).
Variables are also written by TELNET, see previous chapter.
robot.Ftp.KnownVariableFiles allows access to known and commonly used variables on robots.
Members of Ftp.FtpListItem :// Enumerates variables filesFtpListItem[] VariablesFiles = robot.Ftp.EnumerateVariableFiles();// Get all variables declared in the controllervar allVariables = robot.Ftp.GetAllVariables();// Get all variables declared in one specific filevar variables = robot.Ftp.GetVariablesFromFile("myFile.va");// For known variables, you can access it directly.// Example with $RMT_MASTER :int RmtMaster = robot.Ftp.KnownVariableFiles.GetSystemFile().RmtMaster;// Example with CellGrpCartesianPositionVariable cellFrame = robot.Ftp.KnownVariableFiles.GetSysframeFile().CellGrp[0].CellFrame;// cellFrame.X => 0.2// cellFrame.Y => -0.1// cellFrame.Z => 0// cellFrame.Configuration.ArmFront => Back// cellFrame.Configuration.WristFlip => NoFlip
public class FtpListItem {// Gets the file permissions in the CHMOD format.public int Chmod { get; }// Gets the created date of the object.public DateTime Created { get; }// Gets the full path name to the object.public string FullName { get; }// Gets the last write time of the object.public DateTime Modified { get; }// Gets name to the object.public string Name { get; }// Gets the size of the object.public long Size { get; }// Gets the type of file system object.public FtpFileSystemObjectType Type { get; }}
Read safety status
Members of Ftp.Diagnosis.SafetyStatus :SafetyStatus safetyStatus = robot.Ftp.GetSafetyStatus();
public class SafetyStatus : IFanucContent {public SafetyStatus()public bool BeltBroken { get; }// External emergency stop activepublic bool ExternalEStop { get; }public bool FenceOpen { get; }public bool HandBroken { get; }public bool LowAirAlarm { get; }// File name : sftysig.dgpublic string Name { get; }public bool NonTeacherEnb { get; }public bool OverTravel { get; }// Emergency stop active by SOP signalpublic bool SOPEStop { get; }public bool SVOFFDetect { get; }// The deadman switch of the teach pendant is activepublic bool TPDeadman { get; }// Emergency stop active on teach peandantpublic bool TPEStop { get; }// Teach pendant is enabledpublic bool TPEnable { get; }}
Read IO State
The SDK rovides a list of IO states. Telnet KCL allows you to write or simulate their status.
Members of Ftp.Diagnosis.IOState :IOState ioState = robot.Ftp.GetIOState();
public class IOState : IFanucContent {public IOState()// File name : iostate.dgpublic string Name { get; }// Status of all controller inputs and outputspublic IOStatus[] States { get; }}
public class IOStatus {public IOStatus()// Digital port IDpublic int Id { get; }// IO Namepublic string Name { get; }// Digital port typepublic DigitalPorts Port { get; }// String representation like : DIN[1]=Truepublic override string ToString()// Digital port valuepublic bool Value { get; }}
public enum DigitalPorts {// Digital inputDIN = 0// Digital outputsDOUT = 1// FlagsFLG = 8RI = 6RO = 7SI = 4SO = 5// User inputsUI = 2// User outputsUO = 3}
Get current position
The SDK allows you to retrieve the robot arm's current position in both joint and Cartesian form, in the world frame and in user frames, with a single function call.
Members of Ftp.Diagnosis.CurrentPosition :CurrentPosition currentPosition = robot.Ftp.GetCurrentPosition();
public class CurrentPosition : IFanucContent {public CurrentPosition()// Position of each robots handled by this controllerpublic GroupPosition[] GroupsPosition { get; }// File name : curpos.dgpublic string Name { get; }}
public class GroupPosition {public GroupPosition()// Group IDpublic int Id { get; }// Joint positions : the position of each robot anglespublic JointsPosition JointsPosition { get; }// Position of each tools in each user framespublic CartesianPositionWithUserFrame[] UserFramePositions { get; }// Position of each tools in world coordinatespublic CartesianPositionWithTool[] WorldPositions { get; }}
public class JointsPosition {public JointsPosition()public JointsPosition(double j1Deg, double j2Deg, double j3Deg, double j4Deg, double j5Deg, double j6Deg)public JointsPosition(double j1Deg, double j2Deg, double j3Deg, double j4Deg, double j5Deg, double j6Deg, double j7Deg, double j8Deg, double j9Deg)public JointsPosition(double[] values)// Check if joints position is near to expected joints position with a tolerance valuepublic static bool IsNear(JointsPosition j1, JointsPosition j2, double degreesTolerance)public double this[int i] { get; set; }// Joint 1 in degreespublic double J1 { get; set; }// Joint 2 in degreespublic double J2 { get; set; }// Joint 3 in degreespublic double J3 { get; set; }// Joint 4 in degreespublic double J4 { get; set; }// Joint 5 in degreespublic double J5 { get; set; }// Joint 6 in degreespublic double J6 { get; set; }// Joint 7 in degreespublic double J7 { get; set; }// Joint 8 in degreespublic double J8 { get; set; }// Joint 9 in degreespublic double J9 { get; set; }public override string ToString()// Numeric values for each jointspublic double[] Values { get; }}
public class CartesianPositionWithUserFrame : CartesianPositionWithTool {public CartesianPositionWithUserFrame()public CartesianPositionWithUserFrame(double x, double y, double z, double w, double p, double r, int tool, int frame)// Frame ID in the controllerpublic int Frame { get; }public override string ToString()}
public class CartesianPositionWithTool : CartesianPosition {public CartesianPositionWithTool()public CartesianPositionWithTool(double x, double y, double z, double w, double p, double r, int tool)public override string ToString()// Tool IDpublic int Tool { get; set; }}
public class CartesianPositionWithTool : CartesianPosition {public CartesianPositionWithTool()public CartesianPositionWithTool(double x, double y, double z, double w, double p, double r, int tool)public override string ToString()// Tool IDpublic int Tool { get; set; }}
public class CartesianPosition : XYZPosition {// Default constructorpublic CartesianPosition()// Constructor with position and rotationspublic CartesianPosition(double x, double y, double z, double w, double p, double r)public CartesianPosition(double x, double y, double z, double w, double p, double r, Configuration configuration)public CartesianPosition(CartesianPosition position)public CartesianPosition(XYZPosition position, double w, double p, double r)// Position configurationpublic Configuration Configuration { get; }// Create a CartesianPosition with unknow configuration from a homogeneous rotation and translation 4x4 matrixpublic static CartesianPosition FromHomogeneousMatrix(double[,] R)// Check if two Cartesian positions are near each other within specified tolerancespublic static bool IsNear(CartesianPosition a, CartesianPosition b, double mmTolerance, double degreesTolerance)// Normalize an angle to the range ]-180, 180]public static double NormalizeAngle(double angle)// Normalize the W, P, R angles to the range ]-180, 180]public static void NormalizeAngles(CartesianPosition pose)// P rotation in degrees (Ry)public double P { get; set; }// R rotation in degrees (Rz)public double R { get; set; }// Convert position to a homogeneous rotation and translation 4x4 matrixpublic double[,] ToHomogeneousMatrix()public override string ToString()// W rotation in degrees (Rx)public double W { get; set; }}
public class XYZPosition {public XYZPosition()public XYZPosition(double x, double y, double z)public override string ToString()// X coordinate in millimeterspublic double X { get; set; }// Y coordinate in millimeterspublic double Y { get; set; }// Z coordinate in millimeterspublic double Z { get; set; }}
Get installed options (features)
The SDK allows you to retrieve the list of installed options on the robot controller.
// Get all installed featuresFeatures features = _robot.Ftp.GetSummaryDiagnostic().Features;// Get feature name and Order NoFeature[] FeaturesList = features.FeaturesList;// Check if a specific feature is availablebool isSnpxAvailable = features.HasSnpxbool isTelnetAvailable = features.HasTelnet
Try it
You can download the Windows Example to these features. It can be downloaded from the download page.
