Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
KatanaInterface.h
1 
2 /***************************************************************************
3  * KatanaInterface.h - Fawkes BlackBoard Interface - KatanaInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2009 Tim Niemueller
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __INTERFACES_KATANAINTERFACE_H_
25 #define __INTERFACES_KATANAINTERFACE_H_
26 
27 #include <interface/interface.h>
28 #include <interface/message.h>
29 #include <interface/field_iterator.h>
30 
31 namespace fawkes {
32 
33 class KatanaInterface : public Interface
34 {
35  /// @cond INTERNALS
36  INTERFACE_MGMT_FRIENDS(KatanaInterface)
37  /// @endcond
38  public:
39  /* constants */
40  static const uint32_t SENSOR_IR_RIGHT_INNER_MIDDLE;
41  static const uint32_t SENSOR_IR_RIGHT_INNER_FRONT;
42  static const uint32_t SENSOR_RESERVED_2;
43  static const uint32_t SENSOR_COND_BOTH;
44  static const uint32_t SENSOR_IR_RIGHT_OUTER_FRONT;
45  static const uint32_t SENSOR_IR_RIGHT_BOTTOM_FRONT;
46  static const uint32_t SENSOR_FORCE_RIGHT_REAR;
47  static const uint32_t SENSOR_FORCE_RIGHT_FRONT;
48  static const uint32_t SENSOR_IR_LEFT_INNER_MIDDLE;
49  static const uint32_t SENSOR_IR_LEFT_INNER_FRONT;
50  static const uint32_t SENSOR_RESERVED_10;
51  static const uint32_t SENSOR_IR_CENTER_GRIPPER;
52  static const uint32_t SENSOR_IR_LEFT_OUTER_FRONT;
53  static const uint32_t SENSOR_IR_LEFT_BOTTOM_FRONT;
54  static const uint32_t SENSOR_FORCE_LEFT_REAR;
55  static const uint32_t SENSOR_FORCE_LEFT_FRONT;
56  static const uint32_t ERROR_NONE;
57  static const uint32_t ERROR_UNSPECIFIC;
58  static const uint32_t ERROR_CMD_START_FAILED;
59  static const uint32_t ERROR_NO_SOLUTION;
60  static const uint32_t ERROR_COMMUNICATION;
61  static const uint32_t ERROR_MOTOR_CRASHED;
62 
63  private:
64 #pragma pack(push,4)
65  /** Internal data storage, do NOT modify! */
66  typedef struct {
67  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
68  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
69  uint8_t sensor_value[16]; /**< Sensor
70  values. Use SENSOR_* indexes for accessing the values. */
71  float x; /**< DEPRECATED! X-Coordinate for tool position
72  compared to base coordinate system. */
73  float y; /**< DEPRECATED! Y-Coordinate for tool position
74  compared to base coordinate system. */
75  float z; /**< DEPRECATED! Z-Coordinate for tool position
76  compared to base coordinate system. */
77  float phi; /**< DEPRECATED! Euler angle Phi of tool orientation. */
78  float theta; /**< DEPRECATED! Euler angle Theta of tool orientation. */
79  float psi; /**< DEPRECATED! Euler angle Psi of tool orientation. */
80  int32_t encoders[6]; /**< Encoder values of motors */
81  float angles[6]; /**< Angle values of motors */
82  uint32_t msgid; /**< The ID of the message that is currently being
83  processed, or 0 if no message is being processed. */
84  bool final; /**< True, if the last goto command has been finished,
85  false if it is still running */
86  uint32_t error_code; /**< Failure code set if
87  final is true. 0 if no error occured, an error code from ERROR_*
88  constants otherwise (or a bit-wise combination). */
89  bool enabled; /**< Are motors enabled? */
90  bool calibrated; /**< Has arm been calibrated? */
91  uint8_t max_velocity; /**< Maximum velocity */
92  uint8_t num_motors; /**< Number of motors */
93  } KatanaInterface_data_t;
94 #pragma pack(pop)
95 
96  KatanaInterface_data_t *data;
97 
98  public:
99  /* messages */
100  class StopMessage : public Message
101  {
102  private:
103 #pragma pack(push,4)
104  /** Internal data storage, do NOT modify! */
105  typedef struct {
106  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
107  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
108  } StopMessage_data_t;
109 #pragma pack(pop)
110 
111  StopMessage_data_t *data;
112 
113  public:
114  StopMessage();
115  ~StopMessage();
116 
117  StopMessage(const StopMessage *m);
118  /* Methods */
119  virtual Message * clone() const;
120  };
121 
122  class FlushMessage : public Message
123  {
124  private:
125 #pragma pack(push,4)
126  /** Internal data storage, do NOT modify! */
127  typedef struct {
128  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
129  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
130  } FlushMessage_data_t;
131 #pragma pack(pop)
132 
133  FlushMessage_data_t *data;
134 
135  public:
136  FlushMessage();
137  ~FlushMessage();
138 
139  FlushMessage(const FlushMessage *m);
140  /* Methods */
141  virtual Message * clone() const;
142  };
143 
144  class ParkMessage : public Message
145  {
146  private:
147 #pragma pack(push,4)
148  /** Internal data storage, do NOT modify! */
149  typedef struct {
150  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
151  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
152  } ParkMessage_data_t;
153 #pragma pack(pop)
154 
155  ParkMessage_data_t *data;
156 
157  public:
158  ParkMessage();
159  ~ParkMessage();
160 
161  ParkMessage(const ParkMessage *m);
162  /* Methods */
163  virtual Message * clone() const;
164  };
165 
166  class LinearGotoMessage : public Message
167  {
168  private:
169 #pragma pack(push,4)
170  /** Internal data storage, do NOT modify! */
171  typedef struct {
172  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
173  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
174  float theta_error; /**< Error range of theta rotation, gives more flexibility
175  for IK-solution searching. */
176  float offset_xy; /**< Offset to target. Distance in m (on the way to the target) */
177  bool straight; /**< Move in a straight line? */
178  char trans_frame[32]; /**< tf frame-id of origin's coordinate system,
179  regarding the translation */
180  char rot_frame[32]; /**< tf frame-id of origin's coordinate system,
181  regarding the rotation. In most cases, this is the robot's base coordinate system. */
182  float x; /**< DEPRECATED! X-Coordinate for tool position
183  compared to base coordinate system. */
184  float y; /**< DEPRECATED! Y-Coordinate for tool position
185  compared to base coordinate system. */
186  float z; /**< DEPRECATED! Z-Coordinate for tool position
187  compared to base coordinate system. */
188  float phi; /**< DEPRECATED! Euler angle Phi of tool orientation. */
189  float theta; /**< DEPRECATED! Euler angle Theta of tool orientation. */
190  float psi; /**< DEPRECATED! Euler angle Psi of tool orientation. */
191  } LinearGotoMessage_data_t;
192 #pragma pack(pop)
193 
194  LinearGotoMessage_data_t *data;
195 
196  public:
197  LinearGotoMessage(const float ini_theta_error, const float ini_offset_xy, const bool ini_straight, const char * ini_trans_frame, const char * ini_rot_frame, const float ini_x, const float ini_y, const float ini_z, const float ini_phi, const float ini_theta, const float ini_psi);
200 
202  /* Methods */
203  float theta_error() const;
204  void set_theta_error(const float new_theta_error);
205  size_t maxlenof_theta_error() const;
206  float offset_xy() const;
207  void set_offset_xy(const float new_offset_xy);
208  size_t maxlenof_offset_xy() const;
209  bool is_straight() const;
210  void set_straight(const bool new_straight);
211  size_t maxlenof_straight() const;
212  char * trans_frame() const;
213  void set_trans_frame(const char * new_trans_frame);
214  size_t maxlenof_trans_frame() const;
215  char * rot_frame() const;
216  void set_rot_frame(const char * new_rot_frame);
217  size_t maxlenof_rot_frame() const;
218  float x() const;
219  void set_x(const float new_x);
220  size_t maxlenof_x() const;
221  float y() const;
222  void set_y(const float new_y);
223  size_t maxlenof_y() const;
224  float z() const;
225  void set_z(const float new_z);
226  size_t maxlenof_z() const;
227  float phi() const;
228  void set_phi(const float new_phi);
229  size_t maxlenof_phi() const;
230  float theta() const;
231  void set_theta(const float new_theta);
232  size_t maxlenof_theta() const;
233  float psi() const;
234  void set_psi(const float new_psi);
235  size_t maxlenof_psi() const;
236  virtual Message * clone() const;
237  };
238 
240  {
241  private:
242 #pragma pack(push,4)
243  /** Internal data storage, do NOT modify! */
244  typedef struct {
245  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
246  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
247  float x; /**< X-Coordinate for tool position
248  compared to base libkni coordinate system. */
249  float y; /**< Y-Coordinate for tool position
250  compared to base libkni coordinate system. */
251  float z; /**< Z-Coordinate for tool position
252  compared to base libkni coordinate system. */
253  float phi; /**< Euler angle Phi of tool orientation. */
254  float theta; /**< Euler angle Theta of tool orientation. */
255  float psi; /**< Euler angle Psi of tool orientation. */
256  } LinearGotoKniMessage_data_t;
257 #pragma pack(pop)
258 
259  LinearGotoKniMessage_data_t *data;
260 
261  public:
262  LinearGotoKniMessage(const float ini_x, const float ini_y, const float ini_z, const float ini_phi, const float ini_theta, const float ini_psi);
265 
267  /* Methods */
268  float x() const;
269  void set_x(const float new_x);
270  size_t maxlenof_x() const;
271  float y() const;
272  void set_y(const float new_y);
273  size_t maxlenof_y() const;
274  float z() const;
275  void set_z(const float new_z);
276  size_t maxlenof_z() const;
277  float phi() const;
278  void set_phi(const float new_phi);
279  size_t maxlenof_phi() const;
280  float theta() const;
281  void set_theta(const float new_theta);
282  size_t maxlenof_theta() const;
283  float psi() const;
284  void set_psi(const float new_psi);
285  size_t maxlenof_psi() const;
286  virtual Message * clone() const;
287  };
288 
289  class ObjectGotoMessage : public Message
290  {
291  private:
292 #pragma pack(push,4)
293  /** Internal data storage, do NOT modify! */
294  typedef struct {
295  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
296  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
297  char object[32]; /**< Name of object */
298  float rot_x; /**< Rotation of object on its x-axis */
299  } ObjectGotoMessage_data_t;
300 #pragma pack(pop)
301 
302  ObjectGotoMessage_data_t *data;
303 
304  public:
305  ObjectGotoMessage(const char * ini_object, const float ini_rot_x);
308 
310  /* Methods */
311  char * object() const;
312  void set_object(const char * new_object);
313  size_t maxlenof_object() const;
314  float rot_x() const;
315  void set_rot_x(const float new_rot_x);
316  size_t maxlenof_rot_x() const;
317  virtual Message * clone() const;
318  };
319 
320  class CalibrateMessage : public Message
321  {
322  private:
323 #pragma pack(push,4)
324  /** Internal data storage, do NOT modify! */
325  typedef struct {
326  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
327  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
328  } CalibrateMessage_data_t;
329 #pragma pack(pop)
330 
331  CalibrateMessage_data_t *data;
332 
333  public:
336 
338  /* Methods */
339  virtual Message * clone() const;
340  };
341 
343  {
344  private:
345 #pragma pack(push,4)
346  /** Internal data storage, do NOT modify! */
347  typedef struct {
348  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
349  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
350  } OpenGripperMessage_data_t;
351 #pragma pack(pop)
352 
353  OpenGripperMessage_data_t *data;
354 
355  public:
358 
360  /* Methods */
361  virtual Message * clone() const;
362  };
363 
365  {
366  private:
367 #pragma pack(push,4)
368  /** Internal data storage, do NOT modify! */
369  typedef struct {
370  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
371  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
372  } CloseGripperMessage_data_t;
373 #pragma pack(pop)
374 
375  CloseGripperMessage_data_t *data;
376 
377  public:
380 
382  /* Methods */
383  virtual Message * clone() const;
384  };
385 
386  class SetEnabledMessage : public Message
387  {
388  private:
389 #pragma pack(push,4)
390  /** Internal data storage, do NOT modify! */
391  typedef struct {
392  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
393  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
394  bool enabled; /**< Are motors enabled? */
395  } SetEnabledMessage_data_t;
396 #pragma pack(pop)
397 
398  SetEnabledMessage_data_t *data;
399 
400  public:
401  SetEnabledMessage(const bool ini_enabled);
404 
406  /* Methods */
407  bool is_enabled() const;
408  void set_enabled(const bool new_enabled);
409  size_t maxlenof_enabled() const;
410  virtual Message * clone() const;
411  };
412 
414  {
415  private:
416 #pragma pack(push,4)
417  /** Internal data storage, do NOT modify! */
418  typedef struct {
419  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
420  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
421  uint8_t max_velocity; /**< Maximum velocity */
422  } SetMaxVelocityMessage_data_t;
423 #pragma pack(pop)
424 
425  SetMaxVelocityMessage_data_t *data;
426 
427  public:
428  SetMaxVelocityMessage(const uint8_t ini_max_velocity);
431 
433  /* Methods */
434  uint8_t max_velocity() const;
435  void set_max_velocity(const uint8_t new_max_velocity);
436  size_t maxlenof_max_velocity() const;
437  virtual Message * clone() const;
438  };
439 
441  {
442  private:
443 #pragma pack(push,4)
444  /** Internal data storage, do NOT modify! */
445  typedef struct {
446  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
447  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
448  char plannerparams[1024]; /**< Planner parameters */
449  bool straight; /**< Parameters for straight movement? */
450  } SetPlannerParamsMessage_data_t;
451 #pragma pack(pop)
452 
453  SetPlannerParamsMessage_data_t *data;
454 
455  public:
456  SetPlannerParamsMessage(const char * ini_plannerparams, const bool ini_straight);
459 
461  /* Methods */
462  char * plannerparams() const;
463  void set_plannerparams(const char * new_plannerparams);
464  size_t maxlenof_plannerparams() const;
465  bool is_straight() const;
466  void set_straight(const bool new_straight);
467  size_t maxlenof_straight() const;
468  virtual Message * clone() const;
469  };
470 
472  {
473  private:
474 #pragma pack(push,4)
475  /** Internal data storage, do NOT modify! */
476  typedef struct {
477  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
478  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
479  uint32_t nr; /**< Motor number */
480  uint32_t enc; /**< Encoder value */
481  } SetMotorEncoderMessage_data_t;
482 #pragma pack(pop)
483 
484  SetMotorEncoderMessage_data_t *data;
485 
486  public:
487  SetMotorEncoderMessage(const uint32_t ini_nr, const uint32_t ini_enc);
490 
492  /* Methods */
493  uint32_t nr() const;
494  void set_nr(const uint32_t new_nr);
495  size_t maxlenof_nr() const;
496  uint32_t enc() const;
497  void set_enc(const uint32_t new_enc);
498  size_t maxlenof_enc() const;
499  virtual Message * clone() const;
500  };
501 
503  {
504  private:
505 #pragma pack(push,4)
506  /** Internal data storage, do NOT modify! */
507  typedef struct {
508  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
509  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
510  uint32_t nr; /**< Motor number */
511  uint32_t enc; /**< Encoder value */
512  } MoveMotorEncoderMessage_data_t;
513 #pragma pack(pop)
514 
515  MoveMotorEncoderMessage_data_t *data;
516 
517  public:
518  MoveMotorEncoderMessage(const uint32_t ini_nr, const uint32_t ini_enc);
521 
523  /* Methods */
524  uint32_t nr() const;
525  void set_nr(const uint32_t new_nr);
526  size_t maxlenof_nr() const;
527  uint32_t enc() const;
528  void set_enc(const uint32_t new_enc);
529  size_t maxlenof_enc() const;
530  virtual Message * clone() const;
531  };
532 
534  {
535  private:
536 #pragma pack(push,4)
537  /** Internal data storage, do NOT modify! */
538  typedef struct {
539  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
540  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
541  uint32_t nr; /**< Motor number */
542  float angle; /**< Angle value (positive: increase; negative: decrease) */
543  } SetMotorAngleMessage_data_t;
544 #pragma pack(pop)
545 
546  SetMotorAngleMessage_data_t *data;
547 
548  public:
549  SetMotorAngleMessage(const uint32_t ini_nr, const float ini_angle);
552 
554  /* Methods */
555  uint32_t nr() const;
556  void set_nr(const uint32_t new_nr);
557  size_t maxlenof_nr() const;
558  float angle() const;
559  void set_angle(const float new_angle);
560  size_t maxlenof_angle() const;
561  virtual Message * clone() const;
562  };
563 
565  {
566  private:
567 #pragma pack(push,4)
568  /** Internal data storage, do NOT modify! */
569  typedef struct {
570  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
571  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
572  uint32_t nr; /**< Motor number */
573  float angle; /**< Angle value (positive: increase; negative: decrease) */
574  } MoveMotorAngleMessage_data_t;
575 #pragma pack(pop)
576 
577  MoveMotorAngleMessage_data_t *data;
578 
579  public:
580  MoveMotorAngleMessage(const uint32_t ini_nr, const float ini_angle);
583 
585  /* Methods */
586  uint32_t nr() const;
587  void set_nr(const uint32_t new_nr);
588  size_t maxlenof_nr() const;
589  float angle() const;
590  void set_angle(const float new_angle);
591  size_t maxlenof_angle() const;
592  virtual Message * clone() const;
593  };
594 
595  virtual bool message_valid(const Message *message) const;
596  private:
597  KatanaInterface();
598  ~KatanaInterface();
599 
600  public:
601  /* Methods */
602  uint8_t * sensor_value() const;
603  uint8_t sensor_value(unsigned int index) const;
604  void set_sensor_value(unsigned int index, const uint8_t new_sensor_value);
605  void set_sensor_value(const uint8_t * new_sensor_value);
606  size_t maxlenof_sensor_value() const;
607  float x() const;
608  void set_x(const float new_x);
609  size_t maxlenof_x() const;
610  float y() const;
611  void set_y(const float new_y);
612  size_t maxlenof_y() const;
613  float z() const;
614  void set_z(const float new_z);
615  size_t maxlenof_z() const;
616  float phi() const;
617  void set_phi(const float new_phi);
618  size_t maxlenof_phi() const;
619  float theta() const;
620  void set_theta(const float new_theta);
621  size_t maxlenof_theta() const;
622  float psi() const;
623  void set_psi(const float new_psi);
624  size_t maxlenof_psi() const;
625  int32_t * encoders() const;
626  int32_t encoders(unsigned int index) const;
627  void set_encoders(unsigned int index, const int32_t new_encoders);
628  void set_encoders(const int32_t * new_encoders);
629  size_t maxlenof_encoders() const;
630  float * angles() const;
631  float angles(unsigned int index) const;
632  void set_angles(unsigned int index, const float new_angles);
633  void set_angles(const float * new_angles);
634  size_t maxlenof_angles() const;
635  uint32_t msgid() const;
636  void set_msgid(const uint32_t new_msgid);
637  size_t maxlenof_msgid() const;
638  bool is_final() const;
639  void set_final(const bool new_final);
640  size_t maxlenof_final() const;
641  uint32_t error_code() const;
642  void set_error_code(const uint32_t new_error_code);
643  size_t maxlenof_error_code() const;
644  bool is_enabled() const;
645  void set_enabled(const bool new_enabled);
646  size_t maxlenof_enabled() const;
647  bool is_calibrated() const;
648  void set_calibrated(const bool new_calibrated);
649  size_t maxlenof_calibrated() const;
650  uint8_t max_velocity() const;
651  void set_max_velocity(const uint8_t new_max_velocity);
652  size_t maxlenof_max_velocity() const;
653  uint8_t num_motors() const;
654  void set_num_motors(const uint8_t new_num_motors);
655  size_t maxlenof_num_motors() const;
656  virtual Message * create_message(const char *type) const;
657 
658  virtual void copy_values(const Interface *other);
659  virtual const char * enum_tostring(const char *enumtype, int val) const;
660 
661 };
662 
663 } // end namespace fawkes
664 
665 #endif