AuboCaps  0.6.0
payload_contribution_model.h
Go to the documentation of this file.
1 #ifndef AUBO_SCOPE_PAYLOAD_CONTRIBUTION_MODEL_H
2 #define AUBO_SCOPE_PAYLOAD_CONTRIBUTION_MODEL_H
3 
6 
7 namespace arcs {
8 namespace aubo_scope {
9 ARCS_CLASS_FORWARD(PayloadContributionModel);
10 
12 {
13 public:
17 
18  /**
19  * <p>
20  * Add a payload to the current installation in AuboScope.
21  * </p>
22  *
23  * <p>
24  * This makes the payload selectable by the end user as well as available to
25  * other AuboCap contributions (through the
26  * {@link PayloadModel} interface). The payload is not modifiable by the end
27  * user or other AuboCaps.
28  * </p>
29  *
30  * <p>
31  * A default guess for the inertia matrix for the payload will be computed
32  * based on the specified payload mass and center of gravity. If data for
33  * the payload's inertia matrix is available, the method
34  * {@link #addPayload(String, String, Mass, Position, InertiaMatrix)} can
35  * used instead (this might give better performance of the robot arm).
36  * </p>
37  *
38  * <p>
39  * <b>Note:</b> The specified payload mass must be the total mass of the
40  * payload attached to the tool output flange of the robot.
41  * </p>
42  *
43  * The valid range for the payload mass and the coordinates of the center of
44  * gravity (CoG) are available through the
45  * {@link RobotLimits} interface which can be accessed with {@link
46  * RobotModel#getRobotLimits()} (an instance of the
47  * {@link RobotModel} interface can be retrieved through {@link
48  * SystemAPI#getRobotModel()}).
49  *
50  * @param idKey The key to identify this payload by, not <code>null</code>
51  * nor an empty string. The key is for this AuboCap only, i.e. it only has
52  * to be unique for this AuboCap and not "globally" for other AuboCaps.
53  * @param suggestedName Suggested name for the payload, not
54  * <code>null</code> nor an empty string. Valid names must match regex
55  * [a-zA-Z][a-zA-Z0-9_]{0,14} for a total of 15 characters. The final name
56  * can be retrieved from the returned payload instance.
57  * @param mass The total mass of the payload attached to the tool output
58  * flange of the robot, not <code>null</code>. Create it using {@link
59  * SimpleValueFactory#createMass(double, Mass.Unit)}.
60  * @param centerOfGravity The center of gravity (CoG), also referred to as
61  * center of mass, for the payload. It is defined as the offset between the
62  * center of the tool output flange and the center of gravity of the
63  * attached payload. Cannot be <code>null</code>. Create it using the {@link
64  * PositionFactory} interface.
65  * @return The payload created and registered in AuboScope.
66  * @throws PayloadAlreadyAddedException If a payload has previously been
67  * added using the same <code>idKey</code> identifier. Use {@link
68  * #getPayload(String)} to check if the payload has already been added to
69  * the current installation. Use {@link #updatePayload(String, Mass,
70  * Position)} or
71  * {@link #updatePayload(String, Mass,
72  * Position, InertiaMatrix)} to update the payload if the payload parameters
73  * have changed.
74  * @throws IllegalPayloadNameException If the suggested name does not match
75  * required regex.
76  * @throws IllegalMassException If the specified mass is not inside the
77  * valid range as defined by AuboScope.
78  * @throws IllegalCenterOfGravityException If any of the values of the
79  * specified center of gravity are not inside the valid range as defined by
80  * AuboScope.
81  */
82  PayloadPtr addPayload(const std::string &id_key,
83  const std::string &suggested_name, double mass,
84  const std::vector<double> &center_of_gravity);
85 
86  /**
87  * <p>
88  * Add a payload to the current installation in AuboScope.
89  * </p>
90  *
91  * <p>
92  * This makes the payload selectable by the end user as well as available to
93  * other AuboCap contributions (through the
94  * {@link PayloadModel} interface). The payload is not modifiable by the end
95  * user or other AuboCaps.
96  * </p>
97  *
98  * Use the {@link #addPayload(String, String, Mass, Position,
99  * InertiaMatrix)} method instead if data for the payload's inertia matrix
100  * is not available.
101  *
102  * <p>
103  * <b>Note:</b> The specified payload mass must be the total mass of the
104  * payload attached to the tool output flange of the robot.
105  * </p>
106  *
107  * The valid range for the payload mass and the coordinates of the center of
108  * gravity (CoG) are available through the
109  * {@link RobotLimits} interface which can be accessed with {@link
110  * RobotModel#getRobotLimits()} (an instance of the
111  * {@link RobotModel} interface can be retrieved through {@link
112  * SystemAPI#getRobotModel()}).
113  *
114  * @param idKey The key to identify this payload by, not <code>null</code>
115  * nor an empty string. The key is for this AuboCap only, i.e. it only has
116  * to be unique for this AuboCap and not "globally" for other AuboCaps.
117  * @param suggestedName Suggested name for the payload, not
118  * <code>null</code> nor an empty string. Valid names must match regex
119  * [a-zA-Z][a-zA-Z0-9_]{0,14} for a total of 15 characters. The final name
120  * can be retrieved from the returned payload instance.
121  * @param mass The total mass of the payload attached to the tool output
122  * flange of the robot, not <code>null</code>. Create it using {@link
123  * SimpleValueFactory#createMass(double, Mass.Unit)}.
124  * @param centerOfGravity The center of gravity (CoG), also referred to as
125  * center of mass, for the payload. It is defined as the offset between the
126  * center of the tool output flange and the center of gravity of the
127  * attached payload. Cannot be <code>null</code>. Create it using the {@link
128  * PositionFactory} interface.
129  * @param inertiaMatrix The inertia matrix of the payload, defined in a
130  * coordinate system with center at the payload's center of gravity and the
131  * axes aligned with the tool output flange coordinate system (axes). Cannot
132  * be <code>null</code>. Create it using
133  * {@link #createInertiaMatrix(double, double, double,
134  * double, double, double, MomentOfInertia.Unit)}.
135  * @return The payload created and registered in AuboScope.
136  * @throws PayloadAlreadyAddedException If a payload has previously been
137  * added using the same <code>idKey</code> identifier. Use {@link
138  * #getPayload(String)} to check if the payload has already been added to
139  * the current installation.
140  * Use {@link #updatePayload(String, Mass,
141  * Position)} or
142  * {@link #updatePayload(String, Mass,
143  * Position, InertiaMatrix)} to update the payload if the payload parameters
144  * have changed.
145  * @throws IllegalPayloadNameException If the suggested name does not match
146  * required regex.
147  * @throws IllegalMassException If the specified mass is not inside the
148  * valid range as defined by AuboScope.
149  * @throws IllegalCenterOfGravityException If any of the values of the
150  * specified center of gravity are not inside the valid range as defined by
151  * AuboScope.
152  * @throws IllegalInertiaMatrixException If any of the values of the
153  * specified inertia matrix are not inside the valid range as defined by
154  * AuboScope.
155  */
156  PayloadPtr addPayload(const std::string &id_key,
157  const std::string &suggested_name, double mass,
158  const std::vector<double> &center_of_gravity,
159  const std::vector<double> &inertiaMatrix);
160 
161  /**
162  * Returns the payload previously added by this AuboCap using the same
163  * <code>idKey</code> identifier. Use this to verify if the payload is
164  * present in the current installation.
165  *
166  * @param idKey The key to identify this payload by, not <code>null</code>
167  * nor an empty string.
168  * @return The payload previously added by this AuboCap.
169  * Returns <code>null</code> if no payload exists in current
170  * installation (with the specified <code>idKey</code> identifier).
171  */
172  PayloadPtr getPayload(const std::string &id_key);
173 
174  /**
175  * <p>
176  * Update the mass and center of gravity (CoG) of an existing payload added
177  *by this AuboCap.
178  * </p>
179  *
180  * <b>Note:</b> If an inertia matrix has been specified for the payload,
181  *calling this method will replace (overwrite) it with a computed default
182  *guess based the new specified payload mass and center of gravity. To avoid
183  *overwriting an existing inertia matrix (or to update an existing inertia
184  *matrix), instead use the method
185  *{@link #updatePayload(String, Mass, Position, InertiaMatrix)}.
186  *
187  * @param idKey The key to identify the payload, not <code>null</code> nor
188  *an empty string. A payload must have been added using the same key prior
189  *to calling this method.
190  * @param mass The total mass of the payload attached to the tool output
191  *flange of the robot, not <code>null</code>. Create it using {@link
192  *SimpleValueFactory#createMass(double, Mass.Unit)}.
193  * @param centerOfGravity The center of gravity of the payload, not {@code
194  *null}. Create it using the
195  * {@link PositionFactory} interface.
196  * @throws PayloadNotFoundException If no payload exists with the provided
197  *<code>idKey</code> identifier in the current installation.
198  * @throws IllegalMassException If the specified mass is not inside the
199  *valid range as defined by AuboScope.
200  * @throws IllegalCenterOfGravityException If any of the values of the
201  *specified center of gravity are not inside the valid range as defined by
202  *AuboScope.
203  */
204 
205  void updatePayload(const std::string &id_key, double mass,
206  const std::vector<double> &center_of_gravity);
207 
208  /**
209  * Update the mass, center of gravity (CoG) and inertia matrix of an
210  * existing payload added by this AuboCap.
211  *
212  * @param idKey The key to identify the payload, not <code>null</code> nor
213  * an empty string. A payload must have been added using the same key prior
214  * to calling this method.
215  * @param mass The total mass of the payload attached to the tool output
216  * flange of the robot, not <code>null</code>. Create it using {@link
217  * SimpleValueFactory#createMass(double, Mass.Unit)}.
218  * @param centerOfGravity The center of gravity of the payload, not {@code
219  * null}. Create it using the
220  * {@link PositionFactory} interface.
221  * @param inertiaMatrix The inertia matrix of the payload, not
222  * <code>null</code>. Create it using
223  * {@link #createInertiaMatrix(double, double, double,
224  * double, double, double, MomentOfInertia.Unit)}
225  * @throws PayloadNotFoundException If no payload exists with the provided
226  * <code>idKey</code> identifier in the current installation.
227  * @throws IllegalMassException If the specified mass is not inside the
228  * valid range as defined by AuboScope.
229  * @throws IllegalCenterOfGravityException If any of the values of the
230  * specified center of gravity are not inside the valid range as defined by
231  * AuboScope.
232  * @throws IllegalInertiaMatrixException If any of the values of the
233  * specified inertia matrix are not inside the valid range as defined by
234  * AuboScope.
235  */
236  void updatePayload(const std::string id_key, double mass,
237  const std::vector<double> &center_of_gravity,
238  const std::vector<double> &inertia_matrix);
239 
240  /**
241  * Remove a payload added by this AuboCap from AuboScope. Program nodes
242  * using the payload will be become undefined because the payload is no
243  * longer resolvable.
244  *
245  * @param idKey The identifier key used to add the payload with, not {@code
246  * null} nor an empty string.
247  * @throws PayloadNotFoundException If no payload exists with the provided
248  * <code>idKey</code> identifier in the current installation.
249  */
250  void removePayload(const std::string &id_key);
251 
252 private:
253  friend class DataSwitch;
255  void *d_{ nullptr };
256 };
257 } // namespace aubo_scope
258 } // namespace arcs
259 
260 #endif // AUBO_SCOPE_PAYLOAD_CONTRIBUTION_MODEL_H
ARCS_CLASS_FORWARD(GripForceCapability)
#define ARCS_ABI_EXPORT
Definition: class_forward.h:16