Class ReverseInterface

Inheritance Relationships

Derived Types

Class Documentation

class ReverseInterface

The ReverseInterface class handles communication to the robot. It starts a server and waits for the robot to connect via its URCaps program.

Subclassed by urcl::control::ScriptCommandInterface, urcl::control::TrajectoryPointInterface

Public Functions

ReverseInterface() = delete
ReverseInterface(uint32_t port, std::function<void(bool)> handle_program_state, std::chrono::milliseconds step_time = std::chrono::milliseconds(8))

Creates a ReverseInterface object including a TCPServer.

Parameters:
  • port – Port the Server is started on

  • handle_program_state – Function handle to a callback on program state changes.

  • step_time – The robots step time

virtual ~ReverseInterface() = default

Disconnects possible clients so the reverse interface object can be safely destroyed.

virtual bool write(const vector6d_t *positions, const comm::ControlMode control_mode = comm::ControlMode::MODE_IDLE, const RobotReceiveTimeout &robot_receive_timeout = RobotReceiveTimeout::millisec(20))

Writes needed information to the robot to be read by the URCaps program.

Parameters:
  • positions – A vector of joint targets for the robot

  • control_mode – Control mode assigned to this command. See documentation of comm::ControlMode for details on possible values.

  • robot_receive_timeout – The read timeout configuration for the reverse socket running in the external control script on the robot. Use with caution when dealing with realtime commands as the robot expects to get a new control signal each control cycle. Note the timeout cannot be higher than 1 second for realtime commands.

Returns:

True, if the write was performed successfully, false otherwise.

bool writeTrajectoryControlMessage(const TrajectoryControlMessage trajectory_action, const int point_number = 0, const RobotReceiveTimeout &robot_receive_timeout = RobotReceiveTimeout::millisec(200))

Writes needed information to the robot to be read by the URScript program.

Parameters:
  • trajectory_action – 1 if a trajectory is to be started, -1 if it should be stopped

  • point_number – The number of points of the trajectory to be executed

  • robot_receive_timeout – The read timeout configuration for the reverse socket running in the external control script on the robot. If you want to make the read function blocking then use RobotReceiveTimeout::off() function to create the RobotReceiveTimeout object

Returns:

True, if the write was performed successfully, false otherwise.

bool writeFreedriveControlMessage(const FreedriveControlMessage freedrive_action, const RobotReceiveTimeout &robot_receive_timeout = RobotReceiveTimeout::millisec(200))

Writes needed information to the robot to be read by the URScript program.

Parameters:
  • freedrive_action – 1 if freedrive mode is to be started, -1 if it should be stopped and 0 to keep it running

  • robot_receive_timeout – The read timeout configuration for the reverse socket running in the external control script on the robot. If you want to make the read function blocking then use RobotReceiveTimeout::off() function to create the RobotReceiveTimeout object

Returns:

True, if the write was performed successfully, false otherwise.

virtual void setKeepaliveCount(const uint32_t count)

Set the Keepalive count. This will set the number of allowed timeout reads on the robot.

Parameters:

count – Number of allowed timeout reads on the robot.

Public Static Attributes

static const int32_t MULT_JOINTSTATE = 1000000

Protected Functions

virtual void connectionCallback(const int filedescriptor)
virtual void disconnectionCallback(const int filedescriptor)
virtual void messageCallback(const int filedescriptor, char *buffer, int nbytesrecv)
template<typename T>
inline size_t append(uint8_t *buffer, T &val)

Protected Attributes

int client_fd_
comm::TCPServer server_
std::function<void(bool)> handle_program_state_
std::chrono::milliseconds step_time_
uint32_t keepalive_count_
bool keep_alive_count_modified_deprecated_

Protected Static Attributes

static const int MAX_MESSAGE_LENGTH = 8