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 
33 class GripperInterface : public Interface
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 {
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 {
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 
79  explicit OpenGripperMessage(const OpenGripperMessage *m);
80  /* Methods */
81  virtual Message * clone() const;
82  };
83 
84  class CloseGripperMessage : public Message
85  {
86  private:
87  /** Internal data storage, do NOT modify! */
88  typedef struct {
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 
100  explicit CloseGripperMessage(const CloseGripperMessage *m);
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
fawkes::GripperInterface::CloseGripperMessage::CloseGripperMessage
CloseGripperMessage()
Constructor.
Definition: GripperInterface.cpp:216
fawkes::GripperInterface::gripper_state
GripperState gripper_state() const
Get gripper_state value.
Definition: GripperInterface.cpp:93
fawkes::GripperInterface::OpenGripperMessage
Definition: GripperInterface.h:72
fawkes::Message
Definition: message.h:40
fawkes::GripperInterface::set_gripper_state
void set_gripper_state(const GripperState new_gripper_state)
Set gripper_state value.
Definition: GripperInterface.cpp:115
fawkes::GripperInterface::OpenGripperMessage::clone
virtual Message * clone() const
Clone this message.
Definition: GripperInterface.cpp:204
fawkes::Interface::type
const char * type() const
Get type of interface.
Definition: interface.cpp:643
fawkes::GripperInterface::CLOSED
Gripper is closed.
Definition: GripperInterface.h:58
fawkes::GripperInterface::OpenGripperMessage::OpenGripperMessage
OpenGripperMessage()
Constructor.
Definition: GripperInterface.cpp:168
fawkes::GripperInterface::CloseGripperMessage::clone
virtual Message * clone() const
Clone this message.
Definition: GripperInterface.cpp:252
fawkes::GripperInterface::message_valid
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
Definition: GripperInterface.cpp:261
fawkes::GripperInterface::create_message
virtual Message * create_message(const char *type) const
Definition: GripperInterface.cpp:123
fawkes
fawkes::GripperInterface::OpenGripperMessage::~OpenGripperMessage
~OpenGripperMessage()
Destructor.
Definition: GripperInterface.cpp:180
fawkes::GripperInterface
Definition: GripperInterface.h:37
fawkes::Interface
Definition: interface.h:77
fawkes::interface_enum_map_t
std::map< int, std::string > interface_enum_map_t
Map of enum integer to string values.
Definition: types.h:59
fawkes::GripperInterface::copy_values
virtual void copy_values(const Interface *other)
Copy values from other interface.
Definition: GripperInterface.cpp:140
fawkes::GripperInterface::enum_tostring
virtual const char * enum_tostring(const char *enumtype, int val) const
Definition: GripperInterface.cpp:151
fawkes::GripperInterface::tostring_GripperState
const char * tostring_GripperState(GripperState value) const
Convert GripperState constant to string.
Definition: GripperInterface.cpp:77
fawkes::GripperInterface::CloseGripperMessage::~CloseGripperMessage
~CloseGripperMessage()
Destructor.
Definition: GripperInterface.cpp:228
fawkes::GripperInterface::CloseGripperMessage
Definition: GripperInterface.h:93
fawkes::GripperInterface::GripperState
GripperState
Indicator of current or desired gripper state.
Definition: GripperInterface.h:51
fawkes::GripperInterface::maxlenof_gripper_state
size_t maxlenof_gripper_state() const
Get maximum length of gripper_state value.
Definition: GripperInterface.cpp:103
fawkes::GripperInterface::OPEN
Gripper is open.
Definition: GripperInterface.h:57