UnderAutomation
Any question?

[email protected]

Contact us
UnderAutomation
⌘Q

CGTP overview

CGTP is an HTTP-based protocol providing the richest feature set: program management, variables, registers, I/O, kinematics, batch operations, and file access.

  • Key features
  • Quick example
  • Robot options
  • Firmware compatibility
  • Connection
  • Authentication
  • KCL over CGTP
  • Next steps
  • API reference

CGTP is the web server running on Fanuc robots (port 80/3080). It provides HTTP-based access to programs, variables, registers, I/O, positions, and files.

Key features

  • Program management: Create, delete, rename, run, pause, abort programs
  • Variables & registers: Read/write any variable, numeric/position/string registers
  • I/O control: Read, write, simulate, and unsimulate I/O ports
  • Position reading: Read current Cartesian and joint positions
  • Online kinematics: Forward and inverse kinematics on the controller
  • Batch operations: Read/write groups of registers and variables in one request
  • Comments: Read/write register, I/O, and user alarm descriptions
  • File access: List and download controller files via HTTP
  • KCL commands: Execute KCL commands over CGTP

Quick example

using UnderAutomation.Fanuc;
using UnderAutomation.Fanuc.Common;
using UnderAutomation.Fanuc.Cgtp;
public class Cgtp
{
public static void Main()
{
FanucRobot robot = new FanucRobot();
ConnectionParameters parameters = new ConnectionParameters("192.168.0.1");
parameters.Cgtp.Enable = true;
robot.Connect(parameters);
// Read a variable
CgtpVariableValue var = robot.Cgtp.ReadVariable("$RMT_MASTER");
int rmtMaster = var.IntegerValue;
// Write a variable
robot.Cgtp.WriteVariable("$RMT_MASTER", 1);
// Read a numeric register with comment
NumericRegisterWithComment reg = robot.Cgtp.ReadNumericRegisterWithComment(1);
// Read I/O
int di1 = robot.Cgtp.ReadIo(CgtpIoPortType.DI, 1);
// Write I/O
robot.Cgtp.WriteIo(CgtpIoPortType.DO, 1, 1);
// Read current Cartesian position
CartesianPosition pos = robot.Cgtp.ReadCartesianPosition();
// Run a program
robot.Cgtp.RunProgram("MY_PROGRAM");
}
}

Robot options

CGTP does not require any additional options. The robot typically listens on port 80 or 3080.

Most features require firmware V8.30 or later. Some features (program management, position reading) require V9.10+.

Firmware compatibility

FeatureMin. firmware
Variable read/writeV8.30
I/O read/write/simulateV8.30
Program managementV9.10
Position readingV9.10
Program execution (Run)V9.30
File listingV9.40

Connection

static void Main()
{
// Via FanucRobot
var robot = new FanucRobot();
var parameters = new ConnectionParameters("192.168.0.1");
parameters.Cgtp.Enable = true; // enabled by default
parameters.Cgtp.Port = 80; // default port
parameters.Cgtp.RequestTimeoutMs = 3000; // default timeout
robot.Connect(parameters);
// Or standalone
var cgtp = new CgtpClient();
cgtp.Connect("192.168.0.1");
}
}
Click to see the full code

Authentication

Some robots require authentication. Pass credentials during connection:

FanucRobot robot = new FanucRobot();
var parameters = new ConnectionParameters("192.168.0.1");
// Via FanucRobot
parameters.Cgtp.Login = "admin";
parameters.Cgtp.Password = "password";
robot.Connect(parameters);
// Or standalone
var cgtp = new CgtpClient();
cgtp.Connect("192.168.0.1", login: "admin", password: "password");
}
}
Click to see the full code

KCL over CGTP

CGTP provides an embedded KCL client accessible via robot.Cgtp.Kcl. This allows executing KCL commands without a Telnet connection:

FanucRobot robot = new FanucRobot();
robot.Connect("192.168.0.1");
robot.Cgtp.Kcl.SetVariable("$RMT_MASTER", 1);
TaskInformationResult taskInfo = robot.Cgtp.Kcl.GetTaskInformation("MY_PROGRAM");
robot.Cgtp.Kcl.AddBreakpoint("MY_PROGRAM", line: 10);
}
}
Click to see the full code

Next steps

  • Program management : Create, run, pause, abort programs
  • Registers & variables : Read/write registers and variables
  • Inputs & Outputs : Read, write, simulate I/O
  • Position & kinematics : Read position, FK/IK
  • Alarms, comments & files : Comments, user alarms, file listing

API reference

Class
CgtpClientinherits CgtpClientBase
C#Python

Standalone CGTP Web Server client for direct use without FanucRobot.

MemberTypeDescription
CgtpClient()
Constructor
Creates a new instance of the CGTP Web Server client.
Connect(string, int, int, string, string)
Method
void
Connect to the CGTP Web Server on the controller.
  • ip : Controller IP address or hostname.
  • port : HTTP port number (default: 3080).
  • requestTimeoutMs : Request timeout in milliseconds (default: 3000).
  • login : Login for HTTP Basic authentication (optional).
  • password : Password for HTTP Basic authentication (optional).
Class
CgtpClientBase
C#Python

Base implementation for the CGTP Web Server client.

MemberTypeDescription
CgtpClientBase()
Constructor
Enabled
Property
read only
bool
Indicates whether the client is currently connected to the CGTP Web Server.
Http
Property
read only
CgtpHttpClient
Provides methods to download and decode files from the controller via HTTP.
Kcl
Property
read only
CgtpKclClient
KCL client for executing KCL commands over CGTP.
Language
Property
Languages
Controller language (default is English)
AbortTask(string)
Method
void
Abort the task specified by progName. Set to null to abort all user tasks. From firmware 9.10
ChangeActiveProgram(string)
Method
void
Change the active TP program to progName. From firmware 9.10
CreateProgram(string, string, string, int, CgtpProgramSubType)
Method
void
Create a new TP program on the controller. From firmware 9.10
  • progName : New program name
  • owner : Owner name (optional)
  • comment : Comment (optional)
  • defaultGroup : Default motion group (0 = omit)
  • subType : Program sub-type (default: None)
DeleteProgram(string)
Method
void
Delete the program progName from the controller. From firmware 9.10
  • progName : Program name
DeleteSourceLines(string, int, int)
Method
void
Delete count lines starting at lineNum in program progName. From firmware 9.10
Disconnect()
Method
void
Disconnect from the CGTP Web Server. After calling this method, the client must be reconnected before it can be used again.
ForwardKinematics(int, JointsPosition, int, int)
Method
CartesianPosition
Compute the forward kinematics on the controller: convert joint angles to a Cartesian position.
  • group : Motion group number to use for kinematics calculation.
  • jointPosition : A joint position to convert. Its StringValue is sent to the controller.
  • userTool : Optional user tool number to use for kinematics calculation, or -1 for flange.
  • userFrame : Optional user frame number to use for kinematics calculation, or -1 for world.
GetComments(CgtpCommentType)
Method
string[]
Read all comments for the specified element type. For I/O types (RI, RO, DI, DO, GI, GO, AI, AO), returns the input or output comments accordingly.
  • type : The type of element to read comments for.
GetFileAsString(string)
Method
string
Download the content of a file from the controller as a string. From firmware 9.10
  • pathName : File path on the controller (e.g. "MD:/filename.ls").
GetIoComments(CgtpCommentIoType)
Method
IOComments
Read all I/O comments for the specified I/O type.
  • type : The type of I/O pair to read comments for.
GetIoSimulationStatus(CgtpIoPortType, int)
Method
bool
Check whether I/O port at index of type portType is simulated. From firmware 8.30
GetProgramComment(string)
Method
string
Get the comment of program progName. From firmware 9.10
GetProgramIgnorePause(string)
Method
bool
Get whether program progName ignores pause requests. From firmware 9.10
GetProgramOwner(string)
Method
string
Get the owner of program progName. From firmware 9.10
GetProgramStackSize(string)
Method
int
Get the stack size of program progName. From firmware 9.10
GetProgramSubType(string)
Method
CgtpProgramSubType
Get the sub-type of program progName. From firmware 9.10
GetProgramWriteProtect(string)
Method
bool
Get whether program progName is write-protected. From firmware 9.10
InsertSourceLine(string, string, int)
Method
void
Insert a source line before lineNum in program progName. From firmware 9.10
InvertKinematics(int, CartesianPosition, int, int)
Method
JointsPosition
Compute the inverse kinematics on the controller: convert a Cartesian position to joint angles.
  • group : Motion group number to use for kinematics calculation.
  • cartesianPosition : A Cartesian position to convert. Its StringValue is sent to the controller.
  • userTool : Optional user tool number to use for kinematics calculation, or -1 for flange.
  • userFrame : Optional user frame number to use for kinematics calculation, or -1 for world.
ListFiles(string)
Method
string[]
List files at the specified path on the controller. From firmware 9.40
ListPrograms(CgtpProgramType, CgtpProgramSubType)
Method
string[]
List all TP or Karel programs on the controller
  • type : TP or Karel
  • subType : Sub-type of the program (none, macro, job, ...)
ListTpPrograms()
Method
string[]
List all TP programs on the controller, regardless of their sub-type.
PauseAllPrograms()
Method
void
Pause program execution on the controller. From firmware 9.10
ReadBatchVariables(CgtpBatchVariables)
Method
CgtpBatchReadResult
Read multiple variables from the controller in a single batch operation. Each variable in variables will be updated with the value read from the controller.
  • variables : Collection of variables to read. Each variable will have its value, Exists, IsUninitialized and IsReadOnly properties set after the call.
ReadCartesianPosition(int)
Method
CartesianPosition
Read the current Cartesian position of motion group groupNum. From firmware 9.10
ReadIo(CgtpIoPortType, int)
Method
int
Read the value of I/O port at index of type portType. From firmware 8.30
ReadJointPosition(int)
Method
JointsPosition
Read the current joint angles of motion group groupNum. From firmware 9.10
ReadNumericRegisterWithComment(int)
Method
NumericRegisterWithComment
Read the numeric register (R[]) at index. From firmware 9.10
ReadNumericRegistersWithComment()
Method
NumericRegisterWithComment[]
Read all numeric registers (R[]) with their comments and values.
ReadPositionRegisterWithComment(int, int)
Method
PositionRegisterWithComment
Read the position register (PR[]) at index for motion group groupNum. From firmware 9.10
ReadStringRegistersWithComment()
Method
StringRegisterWithComment[]
Read all string registers (SR[]) with their comments and values.
ReadUserAlarms()
Method
UserAlarmDefinition[]
Read all user alarm definitions with their comments and severity.
ReadVariable(string, string)
Method
CgtpVariableValue
Read the typed value of variable varName in program progName. From firmware 9.10
  • varName : Full variable name (e.g. "$RMT_MASTER").
  • progName : Program name, or null for system variables.
ReadVariableAsString(string, string)
Method
string
Read the value of variable varName in program progName. From firmware 9.10
RenameProgram(string, string)
Method
void
Rename program sourceName to newName. From firmware 9.10
ReplaceSourceLine(string, string, int)
Method
void
Replace the source line at lineNum in program progName. From firmware 9.10
RunProgram(string, int)
Method
void
Run the specified program starting at lineNum. From firmware 9.30
SelectProgram(string, int)
Method
void
Open the TP program progName and move cursor to lineNum. From firmware 9.10
SetComment(CgtpCommentType, int, string)
Method
void
Set the comment of a register or I/O port identified by type and index.
  • type : The type of element to set the comment for.
  • index : 1-based index of the element.
  • comment : The comment to set.
SetProgramComment(string, string)
Method
void
Set the comment of program progName. From firmware 9.10
SetProgramIgnorePause(string, bool)
Method
void
Set whether program progName ignores pause requests. From firmware 9.10
SetProgramOwner(string, string)
Method
void
Set the owner of program progName. From firmware 9.10
SetProgramPosition(string, int, Position)
Method
void
Set position at index positionIndex in program progName to the given position. Supports both joint and Cartesian representations. Only the first motion group is supported via CGTP. From firmware 9.10
  • progName : Program name
  • positionIndex : 1-based position index in the program (P[n])
  • position : Position to write. Either CartesianPosition or JointsPosition must be set.
SetProgramPositionToCurrentCartesianPosition(string, int, int)
Method
CartesianPosition
Set position at index positionIndex to the current Cartesian position in program progName and return the updated position.
SetProgramStackSize(string, int)
Method
void
Set the stack size of program progName. From firmware 9.10
SetProgramSubType(string, CgtpProgramSubType)
Method
void
Set the sub-type of program progName. From firmware 9.10
SetProgramWriteProtect(string, bool)
Method
void
Set whether program progName is write-protected. From firmware 9.10
SetUserAlarmSeverity(int, int)
Method
void
Set the severity of a user alarm.
  • index : 1-based alarm index.
  • severity : Severity value to set.
SimulateIo(CgtpIoPortType, int)
Method
void
Set I/O port at index of type portType to simulated. From firmware 8.30
UnsimulateIo(CgtpIoPortType, int)
Method
void
Remove simulation from I/O port at index of type portType. From firmware 8.30
WriteBatchVariables(CgtpBatchVariables)
Method
CgtpBatchWriteResult
Write multiple variables to the controller in a single batch operation.
  • variables : Collection of variables to write. Each variable must have its value set before calling this method.
WriteIo(CgtpIoPortType, int, int)
Method
void
Set the value of I/O port at index of type portType. From firmware 8.30
WriteNumericRegisterAsDouble(int, double)
Method
void
Write a real (double) value to numeric register R[index].
  • index : 1-based register index.
  • value : Value to write.
WriteNumericRegisterAsInteger(int, int)
Method
void
Write an integer value to numeric register R[index].
  • index : 1-based register index.
  • value : Value to write.
WritePositionRegisterAsCartesian(int, CartesianPosition, int)
Method
void
Write a cartesian position value to a position register (PR[])
  • index : 1-based register index.
  • value : Cartesian position value to write.
  • groupNum : Motion group number (1-based). Default is 1.
WritePositionRegisterAsJoint(int, JointsPosition, int)
Method
void
Write a joint position value to a position register (PR[])
  • index : 1-based register index.
  • value : Joint position value to write.
  • groupNum : Motion group number (1-based). Default is 1.
WriteStringRegister(int, string)
Method
void
Write a string value to string register SR[index].
  • index : 1-based register index.
  • value : String value to write.
WriteVariable(string, double, string)
Method
void
Write a real (double) value to variable varName in program progName. From firmware 8.30
WriteVariable(string, int, string)
Method
void
Write an integer value to variable varName in program progName. From firmware 8.30
WriteVariable(string, string, string)
Method
void
Write value to variable varName in program progName. From firmware 8.30

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

UnderAutomation
Contact usLegal

© All rights reserved.