The Robot Control Service provides direct control of the robot through the Robot Control Service (RCS) API. It is designed for motion, monitoring, and system-level operations:
Connecting to the gRPC service can be performed by using the hostname or IP address followed by the port number.
| Hostname | Port |
|---|---|
| RobotControlService | 50300 |
The following example demonstrates how to connect to the gRPC channel and read a byte variable.
#include <grpc/grpc.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
#include <grpcpp/create_channel.h>
#include "rcs/v1/variable_api.grpc.pb.h"
#include <unistd.h>
#include <iostream>
using namespace rcs::v1;
int main(void) {
// Initialize the gRPC client
auto channel = grpc::CreateChannel("RobotControlService:50300" , grpc::InsecureChannelCredentials());
auto stub = VariableService::NewStub(channel)
// Call the GetByteVariable method
int index = 0; // Index for B000
grpc::ClientContext context;
GetByteVariableRequest request;
GetByteVariableResponse response;
request.set_no(index);
grpc::Status status = stub->GetByteVariable(&context, request, &response);
// Handle error status
if (!status.ok()) {
std::cerr << "Error calling GetByteVariable: " << status.error_message() << std::endl;
return 1;
}
// Print the variable value
std::string byte_value = response.value();
std::cout << "B[" << index << "]: " << byte_value << std::endl;
return 0;
}