Class ReverseInterface
Defined in File reverse_interface.h
Inheritance Relationships
Derived Types
public urcl::control::ScriptCommandInterface
(Class ScriptCommandInterface)public urcl::control::TrajectoryPointInterface
(Class TrajectoryPointInterface)
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
-
ReverseInterface(const ReverseInterfaceConfig &config)
-
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.
-
inline uint32_t registerDisconnectionCallback(std::function<void(const int)> disconnection_fun)
Register a callback for the robot-based disconnection.
The callback will be called when the robot disconnects from the reverse interface.
- Parameters:
disconnection_fun – The function to be called on disconnection.
- Returns:
A unique handler ID for the registered callback. This can be used to unregister the callback later.
-
inline void unregisterDisconnectionCallback(const uint32_t handler_id)
Unregisters a disconnection callback.
- Parameters:
handler_id – The ID of the handler to be unregistered as obtained from registerDisconnectionCallback.
-
inline bool isConnected() const
Checks if the reverse interface is connected to the robot.
- Returns:
True, if the interface is connected, false otherwise.
Public Static Attributes
-
static const int32_t MULT_JOINTSTATE = 1000000
Protected Functions
Protected Attributes
-
std::list<HandlerFunction<void(const int)>> disconnect_callbacks_
-
uint32_t next_disconnect_callback_id_ = 0
-
VersionInformation robot_software_version_
-
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
-
ReverseInterface() = delete