Skip to content

Commit 6fcc684

Browse files
authored
Panel service (ros-industrial#19)
* Added v1_0::rw::PanelService class. * Supported ControllerState subscription for RWS 1.0 * Added ControllerState enum values documentation. * Supporting subscribing to operation mode. * Overloaded operator<<() for RAPIDExecutionState * Moved remaining Panel service functions from RWSClient to PanelService. * Fixed URL for controller state in RWS 2.0
1 parent a915afd commit 6fcc684

File tree

16 files changed

+515
-128
lines changed

16 files changed

+515
-128
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ set(
5050
src/connection_options.cpp
5151

5252
src/common/rw/rapid.cpp
53+
src/common/rw/panel.cpp
5354

5455
src/v1_0/rws.cpp
5556
src/v1_0/rws_client.cpp
5657
src/v1_0/rws_interface.cpp
5758
src/v1_0/rw/rapid.cpp
59+
src/v1_0/rw/panel.cpp
5860

5961
src/v2_0/rws.cpp
6062
src/v2_0/rws_client.cpp
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#pragma once
2+
3+
#include <abb_librws/rws.h>
4+
5+
#include <string>
6+
7+
8+
namespace abb :: rws :: rw
9+
{
10+
/**
11+
* \brief Robot controller state.
12+
*
13+
* The documentation strings are taken from https://developercenter.robotstudio.com/api/RWS?urls.primaryName=Panel%20Service
14+
*/
15+
enum class ControllerState
16+
{
17+
// The robot is starting up. It will shift to state motors off when it has started.
18+
init,
19+
// The robot is in a standby state where there is no power to the robot's motors.
20+
// The state has to be shifted to motors on before the robot can move.
21+
motorOff,
22+
// The robot is ready to move, either by jogging or by running programs.
23+
motorOn,
24+
// The robot is stopped because the safety runchain is opened. For instance, a door to the robot's cell might be open.
25+
guardStop,
26+
// The robot is stopped because emergency stop was activated.
27+
emergencyStop,
28+
// The robot is ready to leave emergency stop state. The emergency stop is no longer activated, but the state transition isn't yet confirmed.
29+
emergencyStopReset,
30+
// The robot is in a system failure state. Restart required.
31+
sysFail
32+
};
33+
34+
35+
std::ostream& operator<<(std::ostream& os, ControllerState state);
36+
37+
38+
/**
39+
* \brief Create \a ControllerState from string.
40+
*
41+
* \param str source string
42+
*
43+
* \return \a ControllerState matching the value of \a str
44+
*
45+
* \throw \a std::invalid_argument if \a str is not from the set of valid strings.
46+
*/
47+
ControllerState makeControllerState(std::string const& str);
48+
49+
50+
/**
51+
* @brief Robot operation mode.
52+
*
53+
* The documentation strings are taken from https://developercenter.robotstudio.com/api/rwsApi/panel_opmode_get_page.html
54+
*/
55+
enum class OperationMode
56+
{
57+
// State init
58+
init,
59+
// State change request for automatic mode
60+
autoCh,
61+
// State change request for manual mode & full speed
62+
manFCh,
63+
// State manual mode & reduced speed
64+
manR,
65+
// State manual mode & full speed
66+
manF,
67+
// State automatic mode
68+
automatic,
69+
// Undefined
70+
undef
71+
};
72+
73+
74+
std::ostream& operator<<(std::ostream& os, OperationMode mode);
75+
76+
77+
/**
78+
* \brief Create \a OperationMode from string.
79+
*
80+
* \param str source string
81+
*
82+
* \return \a OperationMode matching the value of \a str
83+
*
84+
* \throw \a std::invalid_argument if \a str is not from the set of valid strings.
85+
*/
86+
OperationMode makeOperationMode(std::string const& str);
87+
}

include/abb_librws/common/rw/rapid.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <abb_librws/rws.h>
44

55
#include <string>
6+
#include <iosfwd>
67

78

89
namespace abb :: rws :: rw
@@ -41,6 +42,9 @@ namespace abb :: rws :: rw
4142
};
4243

4344

45+
std::ostream& operator<<(std::ostream& os, RAPIDExecutionState const& state);
46+
47+
4448
/**
4549
* \brief Create \a RAPIDExecutionState from string.
4650
*

include/abb_librws/rws_resource.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,29 @@ namespace abb :: rws
108108

109109

110110
/**
111-
* \brief RAPID execution state as a resource
111+
* \brief RAPID execution state subscription resource
112112
*/
113113
struct RAPIDExecutionStateResource
114114
{
115115
};
116116

117117

118+
/**
119+
* \brief Controller operation mode subscription resource
120+
*/
121+
struct OperationModeResource
122+
{
123+
};
124+
125+
126+
/**
127+
* \brief Controller state subscription resource
128+
*/
129+
struct ControllerStateResource
130+
{
131+
};
132+
133+
118134
/**
119135
* \brief A class for representing a file resource.
120136
*/

include/abb_librws/rws_subscription.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "rws_error.h"
66

77
#include <abb_librws/common/rw/rapid.h>
8+
#include <abb_librws/common/rw/panel.h>
89

910
#include <Poco/DOM/DOMParser.h>
1011
#include <Poco/Net/WebSocket.h>
@@ -95,6 +96,21 @@ namespace abb :: rws
9596
*/
9697
virtual std::string getResourceURI(RAPIDExecutionStateResource const&) const = 0;
9798

99+
/**
100+
* \brief Get URI for subscribing to controller state
101+
*
102+
* \return Subscription URI
103+
*/
104+
virtual std::string getResourceURI(ControllerStateResource const&) const = 0;
105+
106+
107+
/**
108+
* \brief Get URI for subscribing to operation mode
109+
*
110+
* \return Subscription URI
111+
*/
112+
virtual std::string getResourceURI(OperationModeResource const&) const = 0;
113+
98114
/**
99115
* \brief Process subscription event.
100116
*
@@ -196,6 +212,30 @@ namespace abb :: rws
196212
};
197213

198214

215+
/**
216+
* \brief Event received when controller state changes.
217+
*/
218+
struct ControllerStateEvent
219+
{
220+
/**
221+
* \brief Controller state
222+
*/
223+
rw::ControllerState state;
224+
};
225+
226+
227+
/**
228+
* \brief Event received when operation mode changes.
229+
*/
230+
struct OperationModeEvent
231+
{
232+
/**
233+
* \brief Operation mode
234+
*/
235+
rw::OperationMode mode;
236+
};
237+
238+
199239
/**
200240
* \brief Defines callbacks for different types of RWS subscription events.
201241
*/
@@ -204,6 +244,8 @@ namespace abb :: rws
204244
public:
205245
virtual void processEvent(IOSignalStateEvent const& event);
206246
virtual void processEvent(RAPIDExecutionStateEvent const& event);
247+
virtual void processEvent(ControllerStateEvent const& event);
248+
virtual void processEvent(OperationModeEvent const& event);
207249
};
208250

209251

include/abb_librws/v1_0/rw/panel.h

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#pragma once
2+
3+
#include <abb_librws/v1_0/rws_client.h>
4+
5+
#include <abb_librws/rws.h>
6+
#include <abb_librws/common/rw/panel.h>
7+
8+
#include <Poco/DOM/DOMParser.h>
9+
10+
#include <string>
11+
12+
13+
namespace abb :: rws :: v1_0 :: rw
14+
{
15+
using namespace rws::rw;
16+
17+
18+
class PanelService
19+
{
20+
public:
21+
explicit PanelService(RWSClient& client);
22+
23+
/**
24+
* \brief A method for retrieving the controller state.
25+
*
26+
* \return RWSResult containing the result.
27+
*
28+
* \throw \a RWSError if something goes wrong.
29+
*/
30+
ControllerState getControllerState();
31+
32+
33+
/**
34+
* @brief Set controller state
35+
*
36+
* @param state new controller state
37+
*
38+
* @throw @a RWSError if something goes wrong.
39+
*/
40+
void setControllerState(ControllerState state);
41+
42+
43+
/**
44+
* \brief A method for retrieving the operation mode of the controller.
45+
*
46+
* \return RWSResult containing the result.
47+
*
48+
* \throw \a RWSError if something goes wrong.
49+
*/
50+
OperationMode getOperationMode();
51+
52+
53+
/**
54+
* \brief A method for retrieving the robot controller's speed ratio for RAPID motions (e.g. MoveJ and MoveL).
55+
*
56+
* \return RWSResult containing the result.
57+
*
58+
* \throw \a RWSError if something goes wrong.
59+
*/
60+
unsigned getSpeedRatio();
61+
62+
63+
/**
64+
* \brief A method for setting the robot controller's speed ratio for RAPID motions (e.g. MoveJ and MoveL).
65+
*
66+
* Note: The ratio must be an integer in the range [0, 100] (ie: inclusive).
67+
*
68+
* \param ratio specifying the new ratio.
69+
*
70+
* \return RWSResult containing the result.
71+
*
72+
* \throw std::out_of_range if argument is out of range.
73+
* \throw \a RWSError if something goes wrong.
74+
*/
75+
void setSpeedRatio(unsigned int ratio);
76+
77+
private:
78+
79+
RWSClient& client_;
80+
Poco::XML::DOMParser parser_;
81+
};
82+
}

include/abb_librws/v1_0/rws_client.h

Lines changed: 2 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -183,33 +183,6 @@ class RWSClient
183183
*/
184184
RWSResult getRobotWareSystem();
185185

186-
/**
187-
* \brief A method for retrieving the robot controller's speed ratio for RAPID motions (e.g. MoveJ and MoveL).
188-
*
189-
* \return RWSResult containing the result.
190-
*
191-
* \throw \a RWSError if something goes wrong.
192-
*/
193-
RWSResult getSpeedRatio();
194-
195-
/**
196-
* \brief A method for retrieving the controller state.
197-
*
198-
* \return RWSResult containing the result.
199-
*
200-
* \throw \a RWSError if something goes wrong.
201-
*/
202-
RWSResult getPanelControllerState();
203-
204-
/**
205-
* \brief A method for retrieving the operation mode of the controller.
206-
*
207-
* \return RWSResult containing the result.
208-
*
209-
* \throw \a RWSError if something goes wrong.
210-
*/
211-
RWSResult getPanelOperationMode();
212-
213186
/**
214187
* \brief A method for setting the value of an IO signal.
215188
*
@@ -220,36 +193,6 @@ class RWSClient
220193
*/
221194
void setIOSignal(const std::string& iosignal, const std::string& value);
222195

223-
/**
224-
* \brief A method for turning on the robot controller's motors.
225-
*
226-
* \throw \a RWSError if something goes wrong.
227-
*/
228-
void setMotorsOn();
229-
230-
/**
231-
* \brief A method for turning off the robot controller's motors.
232-
*
233-
* \throw \a RWSError if something goes wrong.
234-
*/
235-
void setMotorsOff();
236-
237-
/**
238-
* \brief A method for setting the robot controller's speed ratio for RAPID motions (e.g. MoveJ and MoveL).
239-
*
240-
* Note: The ratio must be an integer in the range [0, 100] (ie: inclusive).
241-
*
242-
* \param ratio specifying the new ratio.
243-
*
244-
* \return RWSResult containing the result.
245-
*
246-
* \throw std::out_of_range if argument is out of range.
247-
* \throw std::runtime_error if failed to create a string from the argument.
248-
*
249-
* \throw \a RWSError if something goes wrong.
250-
*/
251-
void setSpeedRatio(unsigned int ratio);
252-
253196
/**
254197
* \brief A method for retrieving a file from the robot controller.
255198
*
@@ -316,6 +259,8 @@ class RWSClient
316259
std::string getResourceURI(IOSignalResource const& io_signal) const override;
317260
std::string getResourceURI(RAPIDResource const& resource) const override;
318261
std::string getResourceURI(RAPIDExecutionStateResource const&) const override;
262+
std::string getResourceURI(ControllerStateResource const&) const override;
263+
std::string getResourceURI(OperationModeResource const&) const override;
319264
void processEvent(Poco::AutoPtr<Poco::XML::Document> content, SubscriptionCallback& callback) const override;
320265

321266

0 commit comments

Comments
 (0)