3131#ifndef UR_CLIENT_LIBRARY_PRIMARY_CLIENT_H_INCLUDED
3232#define UR_CLIENT_LIBRARY_PRIMARY_CLIENT_H_INCLUDED
3333
34+ #include < chrono>
3435#include < memory>
3536#include < deque>
3637
@@ -89,6 +90,58 @@ class PrimaryClient
8990
9091 bool checkCalibration (const std::string& checksum);
9192
93+ /* !
94+ * \brief Commands the robot to power on.
95+ *
96+ * \param validate If true, the function will block until the robot is powered on or the timeout
97+ * passed by.
98+ * \param timeout The maximum time to wait for the robot to confirm the power on command.
99+ *
100+ * \returns true on successful power on, false otherwise.
101+ */
102+ bool commandPowerOn (const bool validate = true ,
103+ const std::chrono::milliseconds timeout = std::chrono::milliseconds(5000 ));
104+
105+ /* !
106+ * \brief Commands the robot to power off.
107+ *
108+ * \param validate If true, the function will block until the robot is powered off or the timeout
109+ * passed by.
110+ * \param timeout The maximum time to wait for the robot to confirm the power off command.
111+ *
112+ * \returns true on successful power off, false otherwise.
113+ */
114+ bool commandPowerOff (const bool validate = true ,
115+ const std::chrono::milliseconds timeout = std::chrono::milliseconds(5000 ));
116+
117+ /* !
118+ * \brief Commands the robot to release the brakes
119+ *
120+ * \param validate If true, the function will block until the robot is running or the timeout
121+ * passed by.
122+ * \param timeout The maximum time to wait for the robot to confirm it is running.
123+ *
124+ * \returns true on successful brake release, false otherwise.
125+ */
126+ bool commandBrakeRelease (const bool validate = true ,
127+ const std::chrono::milliseconds timeout = std::chrono::milliseconds(5000 ));
128+
129+ /* !
130+ * \brief Get the latest robot mode.
131+ *
132+ * The robot mode will be updated in the background. This will always show the latest received
133+ * robot mode independent of the time that has passed since receiving it.
134+ */
135+ RobotMode getRobotMode ()
136+ {
137+ std::shared_ptr<RobotModeData> robot_mode_data = consumer_->getRobotModeData ();
138+ if (robot_mode_data == nullptr )
139+ {
140+ return RobotMode::UNKNOWN;
141+ }
142+ return static_cast <RobotMode>(consumer_->getRobotModeData ()->robot_mode_ );
143+ }
144+
92145private:
93146 /* !
94147 * \brief Reconnects the primary stream used to send program to the robot.
@@ -99,6 +152,9 @@ class PrimaryClient
99152 */
100153 bool reconnectStream ();
101154
155+ bool waitFor (std::function<bool ()> condition, const std::chrono::milliseconds timeout,
156+ const std::chrono::milliseconds check_interval = std::chrono::milliseconds(50 ));
157+
102158 // The function is called whenever an error code message is received
103159 void errorMessageCallback (ErrorCode& code);
104160
0 commit comments