About gRPC
The core of the gRPC implementation are the relevant Protobuf files. The main file looks as follows:
Protobuf
//ParametricRobotControlService provides an interface for simulating/controlling supported robots through GRPC.
service ParametricRobotControlService {
//Step 1: Setup the simulation/control environment.
rpc SetupRobot (SetupRobotRequest) returns (SetupRobotReply);
//Step 2: Define a task to be processed or simulated.
rpc AddRobotTask (AddRobotTaskRequest) returns (AddRobotTaskReply);
//Step 3: Subscribe to the feedback coming from the simulation/control environment.
rpc SubscribeRobotFeedback (SubscribeRobotFeedbackRequest) returns (stream RobotFeedback);
//Step 4: Request a simulation update, to be either provided directly or written to the feedback stream.
//The omit_variables request flag skips the global variable map in the reply (which otherwise
//carries every connected robot's variables), keeping state polls small for visualization-only clients.
rpc GetSimulatedRobotState (GetSimulatedRobotStateRequest) returns (RobotState);
//Optional: Set a variable on the robot. Always returns the current variables of all connected robots.
rpc UpdateVariable (UpdateVariableRequest) returns (UpdateVariableReply);
//Optional: Retrieve the resolved robot definition plus its live state (settings,
//variables, axis position, tool/flange frames, visualization transformations) for
//any robot that has already been set up. With exclude_geometry, the reply is cheap
//enough for high-frequency polling (30-60 Hz), e.g. for machine monitoring.
rpc GetRobotData (GetRobotDataRequest) returns (GetRobotDataReply);
//Optional: Ping the controller.
rpc SendPing (Ping) returns (Ping);
}gRPC has predefined messages that describe objects. For example, a JointTarget contains a list of (external) axis values and values for speed and acceleration.
Protobuf
//JointTarget contains the target position of the robot in joint space, as well as the speed and acceleration of the robot.
message JointTarget{
//The target position of the robot in joint space.
repeated float axis_values = 1;
//The speed of the robot, either one value per axis or a single value for all.
repeated float speed = 2;
//The acceleration of the robot, either one value per axis or a single value for all.
repeated float acceleration = 3;
//The position of any external axes of the robot.
repeated float external_axis_values = 4;
}On the other hand, a CartesianTarget defines a CartesianPosition, which can be defined by either a Matrix4x4, Euler values, or a CoordinateSystem.
Protobuf
//CartesianTarget contains the position defined as a CartesianPosition and addds information relating to the posture, speed, acceleration of the robot, as well as of its external axes.
message CartesianTarget{
//The CartesianPosition of the target.
CartesianPosition position = 1;
//The posture of the robot.
string posture = 2;
//The speed of the robot, either one value per axis or a single value for all.
repeated float speed = 3;
//The acceleration of the robot, either one value per axis or a single value for all.
repeated float acceleration = 4;
//The position of any external axes of the robot.
repeated float external_axis_values = 5;
}Protobuf
//CartesianPosition uses one of three definitions to define a Cartesian position, either as a matrix, through Euler values, or a coordinate system.
message CartesianPosition{
//The frame, defined either as matrix, Euler values, or coordinate system.
oneof frame {
Matrix4x4 matrix = 1;
Euler euler = 2;
CoordinateSystem cs = 3;
}
//The CartesianReference enum describes if the current frame is absolute, relative, or linked to a parent.
CartesianReference reference = 4;
//A parent matrix can be provided.
Matrix4x4 parent = 5;
}Based on the protobuf files, native code for languages such as C#, Python or Javascript can be automatically generated.
Parametric Robot Control