UnderAutomation
有问题吗?

[email protected]

联系我们
UnderAutomation
⌘Q
This page is only available in English.

Interpreter Mode

Send and execute URScript statement at runtime.

  • Example
  • Connect
  • Send script statements
  • End interpreter mode
  • Skip buffer
  • Get state
  • Try it with the Windows example
  • API reference

Interpreter Mode lets you send URScript statements while your program is running. To do this, your robot program must call the blocking function interpreter_mode(). While your robot program is in this mode, you can call any of the functions described below. For more information on Interpreter Mode for Universal Robots, please refer to the official documentation: https://www.universal-robots.com/articles/ur/programming/interpreter-mode

interpreter mode polyscope

In the robot, the Interpreter Mode Socket must be enabled in the Polyscope settings for security reasons, see : this page

Example

Once your robot program is in interpreter mode, you can play with the functions in robot.InterpreterMode.

using UnderAutomation.UniversalRobots;
class InterpreterMode
{
static void Main()
{
var robot = new UR();
var param = new ConnectParameters("192.168.0.1");
// Enable Interpreter Mode
param.InterpreterMode.Enable = true;
// Connect to robot
robot.Connect(param);
//...
// append lines of URScript to execute. The robot program should execute interpreter_mode() to run this.
robot.InterpreterMode.ExecuteCommand("movej([0.94, -1.3, 2.2, -2.6, -1, 4], a=1, v=1)");
robot.InterpreterMode.ExecuteCommand("set_digital_out(1, True)");
robot.InterpreterMode.ExecuteCommand("movej([0.94, -1.3, 2.2, -2.6, -1, 4], a=1, v=1)");
// ...
// Request the robot program to quit interpreter_mode() and continue the program
robot.InterpreterMode.EndInterpreter();
// Disconnect from interpreter mode only
robot.InterpreterMode.Disconnect();
}
}

Connect

To enable interpreter mode, you must enable it in the connect parameters.

C#
var param = new ConnectParameters("192.168.0.1");
// Enable Interpreter Mode
param.InterpreterMode.Enable = true;

Send script statements

Then, you can call ExecuteCommand() method to append script to the robot internal buffer.

End interpreter mode

The method EndInterpreterMode() allows to stop interpreter mode and force the robot to exit interpreter_mode() and continue the program execution.

Skip buffer

All script statements are stored in a buffer. You can empty this buffer with the method SkipBuffer().

Get state

Methods StateLastExecuted(), StateLastInterpreted(), StateLastCleared(), StateLastUnexecuted() returns informations about executing instructions.

Try it with the Windows example

interpreter mode

API reference

Class
InterpreterModeClientBaseinherits URServiceBase
C#Python
MemberTypeDescription
InterpreterModeClientBase()
Constructor
Connected
Property
read only
bool
Indicates that the interpreter mode client is connected and ready to send commands
IP
Property
read only
string
IP of the robot to connect to for sending commands
Port
Property
int
Interpreter mode server port
Abort()
Method
CommandResponse
The interpreter mode offers a mechanism to abort limited number of script functions, even if they are called from the main program. Currently only movej and movel can be aborted. Aborting a movement will result in a controlled stop if no blend radius is defined. If a blend radius is defined then a blend with the next movement will be initiated right away if not already in an initial blend, otherwise the command is ignored. Return value should be ignored
ClearInterpreter()
Method
CommandResponse
Clears all interpreted statements, objects, functions, threads, etc. generated in the current interpreter mode.Threads started in current interpreter session will be stopped, and deleted. Variables defined outside of the current interpreter mode will not be affected by a call to thisfunction. Only statements interpreted before the clear_interpreter() function will be cleared. Statements sent after clear_interpreter() will be queued. When cleaning is done, any statements queued are interpreted and responded to. Note that commands such as abort, skipbuffer and state commands are executed as soon as they are received.
ConnectInternal(string, int)
Method
void
Disconnect()
Method
void
Disconnect interpreter mode socket connection
EndInterpreter()
Method
CommandResponse
Ends the interpreter mode, and causes the interpreter_mode() function to return. This function can be compiled into the program by sending it to the interpreter socket(30020) as any other statement, or can be called from anywhere else in the program. By default everything interpreted will be cleared when ending, though the state of the robot, the modifications to local variables from the enclosing scope, and the global variables will remain affected by any changes made.The interpreter thread will be idle after this call.
ExecuteCommand(string)
Method
CommandResponse
Executes a command on the Interpreter Mode
  • command : URScript statement to execute
SkipBuffer()
Method
CommandResponse
The interpreter mode furthermore supports the opportunity to skip already sent but not executed statements.The interpreter thread will then(after finishing the currently executing statement) skip all received but not executed statements. After the skip, the interpreter thread will idle until new statements are received.skipbuffer will only skip already received statements, new statements can therefore be send right away. Return value should be ignored
StateLastCleared()
Method
CommandResponse
Replies with the id for the latest statement to be cleared from the interpreter mode. This clear can happen when ending interpreter mode, or by calls to clear_interpreter()
StateLastExecuted()
Method
CommandResponse
Replies with the largest id of a statement that has started being executed.
StateLastInterpreted()
Method
CommandResponse
Replies with the latest interpreted id, i.e. the highest number of interpreted statement so far.
StateLastUnexecuted()
Method
CommandResponse
Replies with the number of non executed statements, i.e. the number of statements that would have be skipped if skipbuffer was called instead.
Class
CommandResponse
C#Python

Response to an Interpreter Mode command

MemberTypeDescription
Body
Property
read only
string
Answer from the interpreter mode
Command
Property
read only
string
Command sent to the interpreter mode
Id
Property
read only
int
Command unique identifier
RawAnswer
Property
read only
string
Raw line sent from the controller
Status
Property
read only
CommandResponseStatus
Response type to check if command succeed
ToString()
Method
string
Enum
CommandResponseStatus
C#Python

Type of response of an Interpreter Mode command

NameValueDescription
Ack
0
The command compilation succeed and Interpreter mode will execute the statement
Discard
1
Program is not running or the statement results in a compilation or linker error
Error
-1
Something went wrong when receiving response
State
2
Answer from a state command
Class
InterpreterModeClientParametersBase
C#Python
MemberTypeDescription
InterpreterModeClientParametersBase()
Constructor
Port
Property
int
Interpreter Mode client TCP port. Default : 30020
DEFAULT_PORT
Field
int
Default Interpreter Mode server TCP port
Class
InterpreterModeConnectParametersinherits InterpreterModeClientParametersBase
C#Python

Setup Interpreter Mode Client

MemberTypeDescription
Enable
Property
bool
Enable Interpreter Mode client communication Default value is false

轻松将 Universal Robots、Fanuc、Yaskawa、ABB 或 Staubli 机器人集成到您的 .NET、Python、LabVIEW 或 Matlab 应用程序中

UnderAutomation
联系我们Legal

© All rights reserved.