Go to the documentation of this file.
37 std::chrono::milliseconds step_time)
40 , handle_program_state_(handle_program_state)
41 , step_time_(step_time)
42 , keep_alive_count_modified_deprecated_(false)
46 std::placeholders::_2, std::placeholders::_3));
56 const int message_length = 7;
62 uint8_t* b_pos = buffer;
64 int read_timeout = 100;
72 auto read_timeout_resolved = read_timeout;
80 int32_t val = read_timeout_resolved;
82 b_pos +=
append(b_pos, val);
84 if (positions !=
nullptr)
86 for (
auto const& pos : *positions)
90 b_pos +=
append(b_pos, val);
95 b_pos += 6 *
sizeof(int32_t);
102 b_pos +=
append(b_pos, val);
106 b_pos +=
append(b_pos, val);
114 const int point_number,
117 const int message_length = 3;
123 uint8_t* b_pos = buffer;
128 auto read_timeout_resolved = read_timeout;
136 int32_t val = read_timeout_resolved;
138 b_pos +=
append(b_pos, val);
141 b_pos +=
append(b_pos, val);
143 val = htobe32(point_number);
144 b_pos +=
append(b_pos, val);
150 b_pos +=
append(b_pos, val);
154 b_pos +=
append(b_pos, val);
164 const int message_length = 2;
170 uint8_t* b_pos = buffer;
175 auto read_timeout_resolved = read_timeout;
183 int32_t val = read_timeout_resolved;
185 b_pos +=
append(b_pos, val);
188 b_pos +=
append(b_pos, val);
194 b_pos +=
append(b_pos, val);
198 b_pos +=
append(b_pos, val);
207 URCL_LOG_WARN(
"DEPRECATION NOTICE: Setting the keepalive count has been deprecated. Instead you should set the "
208 "timeout directly in the write commands. Please change your code to set the read timeout in the write "
210 "directly. This keepalive count will overwrite the timeout passed to the write functions.");
219 URCL_LOG_INFO(
"Robot connected to reverse interface. Ready to receive control commands.");
225 URCL_LOG_ERROR(
"Connection request to ReverseInterface received while connection already established. Only one "
226 "connection is allowed at a time. Ignoring this request.");
232 URCL_LOG_INFO(
"Connection to reverse interface dropped.", filedescriptor);
239 URCL_LOG_WARN(
"Message on ReverseInterface received. The reverse interface currently does not support any message "
240 "handling. This message will be ignored.");
ControlMode
Control modes as interpreted from the script runnning on the robot.
@ MODE_FORWARD
Set when trajectory forwarding is active.
virtual void disconnectionCallback(const socket_t filedescriptor)
int verifyRobotReceiveTimeout(const comm::ControlMode control_mode, const std::chrono::milliseconds step_time) const
Helper function to verify that the robot receive timeout is configured appropriately given the curren...
void start()
Start event handling.
virtual void setKeepaliveCount(const uint32_t count)
Set the Keepalive count. This will set the number of allowed timeout reads on the robot.
size_t append(uint8_t *buffer, T &val)
static const int32_t MULT_JOINTSTATE
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.
#define URCL_LOG_ERROR(...)
uint32_t keepalive_count_
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.
@ MODE_FREEDRIVE
Set when freedrive mode is active.
std::array< double, 6 > vector6d_t
void setMaxClientsAllowed(const uint32_t &max_clients_allowed)
Set the maximum number of clients allowed to connect to this server.
void setDisconnectCallback(std::function< void(const socket_t)> func)
This callback will be triggered on clients disconnecting from the server.
virtual void connectionCallback(const socket_t filedescriptor)
TrajectoryControlMessage
Control messages for forwarding and aborting trajectories.
virtual void messageCallback(const socket_t filedescriptor, char *buffer, int nbytesrecv)
static const int MAX_MESSAGE_LENGTH
void setMessageCallback(std::function< void(const socket_t, char *, int)> func)
This callback will be triggered on messages received on the socket.
std::chrono::milliseconds step_time_
bool write(const socket_t fd, const uint8_t *buf, const size_t buf_len, size_t &written)
Writes to a client.
bool keep_alive_count_modified_deprecated_
std::function< void(bool)> handle_program_state_
#define URCL_LOG_INFO(...)
@ MODE_STOPPED
When this is set, the program is expected to stop and exit.
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.
ReverseInterface()=delete
constexpr std::underlying_type< E >::type toUnderlying(const E e) noexcept
Converts an enum type to its underlying type.
#define URCL_LOG_WARN(...)
RobotReceiveTimeout class containing a timeout configuration.
void setConnectCallback(std::function< void(const socket_t)> func)
This callback will be triggered on clients connecting to the server.
FreedriveControlMessage
Control messages for starting and stopping freedrive mode.
ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Mon May 26 2025 02:35:58