Fawkes API  Fawkes Development Version
RobotinoSensorInterface.h
1 
2 /***************************************************************************
3  * RobotinoSensorInterface.h - Fawkes BlackBoard Interface - RobotinoSensorInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2012-2016 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_ROBOTINOSENSORINTERFACE_H_
25 #define __INTERFACES_ROBOTINOSENSORINTERFACE_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(RobotinoSensorInterface)
37  /// @endcond
38  public:
39  /* constants */
40 
41  private:
42  /** Internal data storage, do NOT modify! */
43  typedef struct __attribute__((packed)) {
44  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
45  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
46  float mot_velocity[3]; /**< Velocities of the wheels. */
47  int32_t mot_position[3]; /**< Positions of the wheels. */
48  float mot_current[3]; /**< Motor currents. */
49  bool bumper; /**< Bumper pressed indicator. */
50  float distance[9]; /**< Distance sensor values. */
51  bool digital_in[8]; /**< Digital input values. */
52  bool digital_out[8]; /**< Digital output values. */
53  float analog_in[8]; /**< Analog input values. */
54  bool bumper_estop_enabled; /**<
55  True if emergency stop on bumper contact is enabled, false otherwise.
56  */
57  } RobotinoSensorInterface_data_t;
58 
59  RobotinoSensorInterface_data_t *data;
60 
61  public:
62  /* messages */
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  bool enabled; /**<
71  True to enable emergency stop on bumper contact, false to
72  disable. This will persist over OpenRobotino stated restarts.
73  */
74  } SetBumperEStopEnabledMessage_data_t;
75 
76  SetBumperEStopEnabledMessage_data_t *data;
77 
78  public:
79  SetBumperEStopEnabledMessage(const bool ini_enabled);
82 
84  /* Methods */
85  bool is_enabled() const;
86  void set_enabled(const bool new_enabled);
87  size_t maxlenof_enabled() const;
88  virtual Message * clone() const;
89  };
90 
92  {
93  private:
94  /** Internal data storage, do NOT modify! */
95  typedef struct __attribute__((packed)) {
96  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
97  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
98  uint8_t digital_out; /**<
99  The number of the digital output to set.
100  */
101  bool enabled; /**<
102  True to enable digital out, false to disable.
103  */
104  } SetDigitalOutputMessage_data_t;
105 
106  SetDigitalOutputMessage_data_t *data;
107 
108  public:
109  SetDigitalOutputMessage(const uint8_t ini_digital_out, const bool ini_enabled);
112 
114  /* Methods */
115  uint8_t digital_out() const;
116  void set_digital_out(const uint8_t new_digital_out);
117  size_t maxlenof_digital_out() const;
118  bool is_enabled() const;
119  void set_enabled(const bool new_enabled);
120  size_t maxlenof_enabled() const;
121  virtual Message * clone() const;
122  };
123 
124  virtual bool message_valid(const Message *message) const;
125  private:
128 
129  public:
130  /* Methods */
131  float * mot_velocity() const;
132  float mot_velocity(unsigned int index) const;
133  void set_mot_velocity(unsigned int index, const float new_mot_velocity);
134  void set_mot_velocity(const float * new_mot_velocity);
135  size_t maxlenof_mot_velocity() const;
136  int32_t * mot_position() const;
137  int32_t mot_position(unsigned int index) const;
138  void set_mot_position(unsigned int index, const int32_t new_mot_position);
139  void set_mot_position(const int32_t * new_mot_position);
140  size_t maxlenof_mot_position() const;
141  float * mot_current() const;
142  float mot_current(unsigned int index) const;
143  void set_mot_current(unsigned int index, const float new_mot_current);
144  void set_mot_current(const float * new_mot_current);
145  size_t maxlenof_mot_current() const;
146  bool is_bumper() const;
147  void set_bumper(const bool new_bumper);
148  size_t maxlenof_bumper() const;
149  float * distance() const;
150  float distance(unsigned int index) const;
151  void set_distance(unsigned int index, const float new_distance);
152  void set_distance(const float * new_distance);
153  size_t maxlenof_distance() const;
154  bool * is_digital_in() const;
155  bool is_digital_in(unsigned int index) const;
156  void set_digital_in(unsigned int index, const bool new_digital_in);
157  void set_digital_in(const bool * new_digital_in);
158  size_t maxlenof_digital_in() const;
159  bool * is_digital_out() const;
160  bool is_digital_out(unsigned int index) const;
161  void set_digital_out(unsigned int index, const bool new_digital_out);
162  void set_digital_out(const bool * new_digital_out);
163  size_t maxlenof_digital_out() const;
164  float * analog_in() const;
165  float analog_in(unsigned int index) const;
166  void set_analog_in(unsigned int index, const float new_analog_in);
167  void set_analog_in(const float * new_analog_in);
168  size_t maxlenof_analog_in() const;
169  bool is_bumper_estop_enabled() const;
170  void set_bumper_estop_enabled(const bool new_bumper_estop_enabled);
171  size_t maxlenof_bumper_estop_enabled() const;
172  virtual Message * create_message(const char *type) const;
173 
174  virtual void copy_values(const Interface *other);
175  virtual const char * enum_tostring(const char *enumtype, int val) const;
176 
177 };
178 
179 } // end namespace fawkes
180 
181 #endif
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
Fawkes library namespace.
int32_t * mot_position() const
Get mot_position value.
float * mot_current() const
Get mot_current value.
bool is_bumper_estop_enabled() const
Get bumper_estop_enabled value.
size_t maxlenof_mot_velocity() const
Get maximum length of mot_velocity value.
bool * is_digital_out() const
Get digital_out value.
size_t maxlenof_mot_position() const
Get maximum length of mot_position value.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
size_t maxlenof_digital_in() const
Get maximum length of digital_in value.
void set_analog_in(unsigned int index, const float new_analog_in)
Set analog_in value at given index.
size_t maxlenof_mot_current() const
Get maximum length of mot_current value.
RobotinoSensorInterface Fawkes BlackBoard Interface.
size_t maxlenof_analog_in() const
Get maximum length of analog_in value.
const char * type() const
Get type of interface.
Definition: interface.cpp:651
float * analog_in() const
Get analog_in value.
size_t maxlenof_bumper() const
Get maximum length of bumper value.
bool is_bumper() const
Get bumper value.
void set_bumper_estop_enabled(const bool new_bumper_estop_enabled)
Set bumper_estop_enabled value.
SetBumperEStopEnabledMessage Fawkes BlackBoard Interface Message.
void set_digital_out(unsigned int index, const bool new_digital_out)
Set digital_out value at given index.
void set_mot_velocity(unsigned int index, const float new_mot_velocity)
Set mot_velocity value at given index.
virtual void copy_values(const Interface *other)
Copy values from other interface.
void set_digital_in(unsigned int index, const bool new_digital_in)
Set digital_in value at given index.
float * distance() const
Get distance value.
size_t maxlenof_bumper_estop_enabled() const
Get maximum length of bumper_estop_enabled value.
size_t maxlenof_digital_out() const
Get maximum length of digital_out value.
void set_distance(unsigned int index, const float new_distance)
Set distance value at given index.
SetDigitalOutputMessage Fawkes BlackBoard Interface Message.
void set_mot_current(unsigned int index, const float new_mot_current)
Set mot_current value at given index.
void set_mot_position(unsigned int index, const int32_t new_mot_position)
Set mot_position value at given index.
virtual Message * create_message(const char *type) const
Create message based on type name.
void set_bumper(const bool new_bumper)
Set bumper value.
bool * is_digital_in() const
Get digital_in value.
float * mot_velocity() const
Get mot_velocity value.
size_t maxlenof_distance() const
Get maximum length of distance value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.