Fawkes API  Fawkes Development Version
GripperInterface.h
1 
2 /***************************************************************************
3  * GripperInterface.h - Fawkes BlackBoard Interface - GripperInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2013 Sebastian Reuter
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_GRIPPERINTERFACE_H_
25 #define __INTERFACES_GRIPPERINTERFACE_H_
26 
27 #include <interface/interface.h>
28 #include <interface/message.h>
29 #include <interface/field_iterator.h>
30 
31 namespace fawkes {
32 
34 {
35  /// @cond INTERNALS
36  INTERFACE_MGMT_FRIENDS(GripperInterface)
37  /// @endcond
38  public:
39  /* constants */
40 
41  /** Indicator of current or desired gripper state. */
42  typedef enum {
43  OPEN /**< Gripper is open */,
44  CLOSED /**< Gripper is closed */
45  } GripperState;
46  const char * tostring_GripperState(GripperState value) const;
47 
48  private:
49  /** Internal data storage, do NOT modify! */
50  typedef struct __attribute__((packed)) {
51  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
52  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
53  int32_t gripper_state; /**<
54  The current state of the gripper.
55  */
56  } GripperInterface_data_t;
57 
58  GripperInterface_data_t *data;
59 
60  interface_enum_map_t enum_map_GripperState;
61  public:
62  /* messages */
63  class OpenGripperMessage : public Message
64  {
65  private:
66  /** Internal data storage, do NOT modify! */
67  typedef struct __attribute__((packed)) {
68  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
69  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
70  } OpenGripperMessage_data_t;
71 
72  OpenGripperMessage_data_t *data;
73 
74  interface_enum_map_t enum_map_GripperState;
75  public:
78 
80  /* Methods */
81  virtual Message * clone() const;
82  };
83 
85  {
86  private:
87  /** Internal data storage, do NOT modify! */
88  typedef struct __attribute__((packed)) {
89  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
90  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
91  } CloseGripperMessage_data_t;
92 
93  CloseGripperMessage_data_t *data;
94 
95  interface_enum_map_t enum_map_GripperState;
96  public:
99 
101  /* Methods */
102  virtual Message * clone() const;
103  };
104 
105  virtual bool message_valid(const Message *message) const;
106  private:
108  ~GripperInterface();
109 
110  public:
111  /* Methods */
112  GripperState gripper_state() const;
113  void set_gripper_state(const GripperState new_gripper_state);
114  size_t maxlenof_gripper_state() const;
115  virtual Message * create_message(const char *type) const;
116 
117  virtual void copy_values(const Interface *other);
118  virtual const char * enum_tostring(const char *enumtype, int val) const;
119 
120 };
121 
122 } // end namespace fawkes
123 
124 #endif
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
CloseGripperMessage Fawkes BlackBoard Interface Message.
Fawkes library namespace.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
virtual Message * create_message(const char *type) const
Create message based on type name.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
GripperState gripper_state() const
Get gripper_state value.
void set_gripper_state(const GripperState new_gripper_state)
Set gripper_state value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
const char * type() const
Get type of interface.
Definition: interface.cpp:651
virtual void copy_values(const Interface *other)
Copy values from other interface.
const char * tostring_GripperState(GripperState value) const
Convert GripperState constant to string.
std::map< int, std::string > interface_enum_map_t
Map of enum integer to string values.
Definition: types.h:53
size_t maxlenof_gripper_state() const
Get maximum length of gripper_state value.
GripperState
Indicator of current or desired gripper state.
OpenGripperMessage Fawkes BlackBoard Interface Message.
GripperInterface Fawkes BlackBoard Interface.