3333#include " ur_client_library/comm/control_mode.h"
3434#include " ur_client_library/types.h"
3535#include " ur_client_library/log.h"
36+ #include " ur_client_library/ur/robot_receive_timeout.h"
3637#include < cstring>
3738#include < endian.h>
3839#include < condition_variable>
@@ -76,8 +77,10 @@ class ReverseInterface
7677 *
7778 * \param port Port the Server is started on
7879 * \param handle_program_state Function handle to a callback on program state changes.
80+ * \param step_time The robots step time
7981 */
80- ReverseInterface (uint32_t port, std::function<void (bool )> handle_program_state);
82+ ReverseInterface (uint32_t port, std::function<void (bool )> handle_program_state,
83+ std::chrono::milliseconds step_time = std::chrono::milliseconds(8 ));
8184
8285 /* !
8386 * \brief Disconnects possible clients so the reverse interface object can be safely destroyed.
@@ -90,39 +93,53 @@ class ReverseInterface
9093 * \param positions A vector of joint targets for the robot
9194 * \param control_mode Control mode assigned to this command. See documentation of comm::ControlMode
9295 * for details on possible values.
96+ * \param robot_receive_timeout The read timeout configuration for the reverse socket running in the external
97+ * control script on the robot. Use with caution when dealing with realtime commands as the robot
98+ * expects to get a new control signal each control cycle. Note the timeout cannot be higher than 1 second for
99+ * realtime commands.
93100 *
94101 * \returns True, if the write was performed successfully, false otherwise.
95102 */
96- virtual bool write (const vector6d_t * positions, const comm::ControlMode control_mode = comm::ControlMode::MODE_IDLE);
103+ virtual bool write (const vector6d_t * positions, const comm::ControlMode control_mode = comm::ControlMode::MODE_IDLE,
104+ const RobotReceiveTimeout& robot_receive_timeout = RobotReceiveTimeout::millisec(20 ));
97105
98106 /* !
99107 * \brief Writes needed information to the robot to be read by the URScript program.
100108 *
101109 * \param trajectory_action 1 if a trajectory is to be started, -1 if it should be stopped
102110 * \param point_number The number of points of the trajectory to be executed
111+ * \param robot_receive_timeout The read timeout configuration for the reverse socket running in the external
112+ * control script on the robot. If you want to make the read function blocking then use RobotReceiveTimeout::off()
113+ * function to create the RobotReceiveTimeout object
103114 *
104115 * \returns True, if the write was performed successfully, false otherwise.
105116 */
106- bool writeTrajectoryControlMessage (const TrajectoryControlMessage trajectory_action, const int point_number = 0 );
117+ bool
118+ writeTrajectoryControlMessage (const TrajectoryControlMessage trajectory_action, const int point_number = 0 ,
119+ const RobotReceiveTimeout& robot_receive_timeout = RobotReceiveTimeout::millisec(200 ));
107120
108121 /* !
109122 * \brief Writes needed information to the robot to be read by the URScript program.
110123 *
111124 * \param freedrive_action 1 if freedrive mode is to be started, -1 if it should be stopped and 0 to keep it running
125+ * \param robot_receive_timeout The read timeout configuration for the reverse socket running in the external
126+ * control script on the robot. If you want to make the read function blocking then use RobotReceiveTimeout::off()
127+ * function to create the RobotReceiveTimeout object
112128 *
113129 * \returns True, if the write was performed successfully, false otherwise.
114130 */
115- bool writeFreedriveControlMessage (const FreedriveControlMessage freedrive_action);
131+ bool
132+ writeFreedriveControlMessage (const FreedriveControlMessage freedrive_action,
133+ const RobotReceiveTimeout& robot_receive_timeout = RobotReceiveTimeout::millisec(200 ));
116134
117135 /* !
118136 * \brief Set the Keepalive count. This will set the number of allowed timeout reads on the robot.
119137 *
120138 * \param count Number of allowed timeout reads on the robot.
121139 */
122- virtual void setKeepaliveCount (const uint32_t & count)
123- {
124- keepalive_count_ = count;
125- }
140+ [[deprecated(" Set keepaliveCount is deprecated, instead use the robot receive timeout directly in the write "
141+ " commands." )]] virtual void
142+ setKeepaliveCount (const uint32_t count);
126143
127144protected:
128145 virtual void connectionCallback (const int filedescriptor);
@@ -145,7 +162,10 @@ class ReverseInterface
145162 static const int MAX_MESSAGE_LENGTH = 8 ;
146163
147164 std::function<void (bool )> handle_program_state_;
165+ std::chrono::milliseconds step_time_;
166+
148167 uint32_t keepalive_count_;
168+ bool keep_alive_count_modified_deprecated_;
149169};
150170
151171} // namespace control
0 commit comments