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 
33 class RobotinoSensorInterface : public Interface
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 {
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 */
63  class SetBumperEStopEnabledMessage : 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  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 
91  class SetDigitalOutputMessage : public Message
92  {
93  private:
94  /** Internal data storage, do NOT modify! */
95  typedef struct {
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
fawkes::RobotinoSensorInterface::set_digital_in
void set_digital_in(unsigned int index, const bool new_digital_in)
Set digital_in value at given index.
Definition: RobotinoSensorInterface.cpp:399
fawkes::RobotinoSensorInterface::SetBumperEStopEnabledMessage::maxlenof_enabled
size_t maxlenof_enabled() const
Get maximum length of enabled value.
Definition: RobotinoSensorInterface.cpp:666
fawkes::RobotinoSensorInterface::set_mot_position
void set_mot_position(unsigned int index, const int32_t new_mot_position)
Set mot_position value at given index.
Definition: RobotinoSensorInterface.cpp:188
fawkes::RobotinoSensorInterface::maxlenof_mot_current
size_t maxlenof_mot_current() const
Get maximum length of mot_current value.
Definition: RobotinoSensorInterface.cpp:226
fawkes::RobotinoSensorInterface::set_bumper_estop_enabled
void set_bumper_estop_enabled(const bool new_bumper_estop_enabled)
Set bumper_estop_enabled value.
Definition: RobotinoSensorInterface.cpp:556
fawkes::RobotinoSensorInterface::SetBumperEStopEnabledMessage::set_enabled
void set_enabled(const bool new_enabled)
Set enabled value.
Definition: RobotinoSensorInterface.cpp:679
fawkes::Message
Definition: message.h:40
fawkes::RobotinoSensorInterface::SetDigitalOutputMessage
Definition: RobotinoSensorInterface.h:100
fawkes::RobotinoSensorInterface::is_digital_out
bool * is_digital_out() const
Get digital_out value.
Definition: RobotinoSensorInterface.cpp:412
fawkes::RobotinoSensorInterface::maxlenof_mot_velocity
size_t maxlenof_mot_velocity() const
Get maximum length of mot_velocity value.
Definition: RobotinoSensorInterface.cpp:106
fawkes::RobotinoSensorInterface::maxlenof_bumper
size_t maxlenof_bumper() const
Get maximum length of bumper value.
Definition: RobotinoSensorInterface.cpp:271
fawkes::RobotinoSensorInterface::set_mot_velocity
void set_mot_velocity(unsigned int index, const float new_mot_velocity)
Set mot_velocity value at given index.
Definition: RobotinoSensorInterface.cpp:128
fawkes::RobotinoSensorInterface::set_mot_current
void set_mot_current(unsigned int index, const float new_mot_current)
Set mot_current value at given index.
Definition: RobotinoSensorInterface.cpp:248
fawkes::RobotinoSensorInterface::SetBumperEStopEnabledMessage::is_enabled
bool is_enabled() const
Get enabled value.
Definition: RobotinoSensorInterface.cpp:656
fawkes::RobotinoSensorInterface::set_analog_in
void set_analog_in(unsigned int index, const float new_analog_in)
Set analog_in value at given index.
Definition: RobotinoSensorInterface.cpp:519
fawkes::Interface::type
const char * type() const
Get type of interface.
Definition: interface.cpp:643
fawkes::RobotinoSensorInterface::SetDigitalOutputMessage::set_enabled
void set_enabled(const bool new_enabled)
Set enabled value.
Definition: RobotinoSensorInterface.cpp:811
fawkes::RobotinoSensorInterface::maxlenof_mot_position
size_t maxlenof_mot_position() const
Get maximum length of mot_position value.
Definition: RobotinoSensorInterface.cpp:166
fawkes::RobotinoSensorInterface::maxlenof_distance
size_t maxlenof_distance() const
Get maximum length of distance value.
Definition: RobotinoSensorInterface.cpp:317
fawkes::RobotinoSensorInterface::maxlenof_bumper_estop_enabled
size_t maxlenof_bumper_estop_enabled() const
Get maximum length of bumper_estop_enabled value.
Definition: RobotinoSensorInterface.cpp:544
fawkes::RobotinoSensorInterface::SetDigitalOutputMessage::set_digital_out
void set_digital_out(const uint8_t new_digital_out)
Set digital_out value.
Definition: RobotinoSensorInterface.cpp:777
fawkes::RobotinoSensorInterface::mot_velocity
float * mot_velocity() const
Get mot_velocity value.
Definition: RobotinoSensorInterface.cpp:81
fawkes::RobotinoSensorInterface::SetDigitalOutputMessage::SetDigitalOutputMessage
SetDigitalOutputMessage()
Constructor.
Definition: RobotinoSensorInterface.cpp:718
fawkes::RobotinoSensorInterface::SetBumperEStopEnabledMessage::clone
virtual Message * clone() const
Clone this message.
Definition: RobotinoSensorInterface.cpp:690
fawkes::RobotinoSensorInterface::SetDigitalOutputMessage::~SetDigitalOutputMessage
~SetDigitalOutputMessage()
Destructor.
Definition: RobotinoSensorInterface.cpp:730
fawkes::RobotinoSensorInterface::is_bumper
bool is_bumper() const
Get bumper value.
Definition: RobotinoSensorInterface.cpp:261
fawkes::RobotinoSensorInterface::SetDigitalOutputMessage::is_enabled
bool is_enabled() const
Get enabled value.
Definition: RobotinoSensorInterface.cpp:789
fawkes
fawkes::RobotinoSensorInterface
Definition: RobotinoSensorInterface.h:37
fawkes::RobotinoSensorInterface::set_distance
void set_distance(unsigned int index, const float new_distance)
Set distance value at given index.
Definition: RobotinoSensorInterface.cpp:339
fawkes::RobotinoSensorInterface::SetBumperEStopEnabledMessage::~SetBumperEStopEnabledMessage
~SetBumperEStopEnabledMessage()
Destructor.
Definition: RobotinoSensorInterface.cpp:630
fawkes::RobotinoSensorInterface::create_message
virtual Message * create_message(const char *type) const
Definition: RobotinoSensorInterface.cpp:564
fawkes::Interface
Definition: interface.h:77
fawkes::RobotinoSensorInterface::SetDigitalOutputMessage::clone
virtual Message * clone() const
Clone this message.
Definition: RobotinoSensorInterface.cpp:822
fawkes::RobotinoSensorInterface::SetDigitalOutputMessage::maxlenof_enabled
size_t maxlenof_enabled() const
Get maximum length of enabled value.
Definition: RobotinoSensorInterface.cpp:799
fawkes::RobotinoSensorInterface::SetDigitalOutputMessage::maxlenof_digital_out
size_t maxlenof_digital_out() const
Get maximum length of digital_out value.
Definition: RobotinoSensorInterface.cpp:765
fawkes::RobotinoSensorInterface::distance
float * distance() const
Get distance value.
Definition: RobotinoSensorInterface.cpp:292
fawkes::RobotinoSensorInterface::maxlenof_digital_in
size_t maxlenof_digital_in() const
Get maximum length of digital_in value.
Definition: RobotinoSensorInterface.cpp:377
fawkes::RobotinoSensorInterface::mot_current
float * mot_current() const
Get mot_current value.
Definition: RobotinoSensorInterface.cpp:201
fawkes::RobotinoSensorInterface::copy_values
virtual void copy_values(const Interface *other)
Copy values from other interface.
Definition: RobotinoSensorInterface.cpp:581
fawkes::RobotinoSensorInterface::maxlenof_digital_out
size_t maxlenof_digital_out() const
Get maximum length of digital_out value.
Definition: RobotinoSensorInterface.cpp:437
fawkes::RobotinoSensorInterface::SetBumperEStopEnabledMessage
Definition: RobotinoSensorInterface.h:72
fawkes::RobotinoSensorInterface::SetDigitalOutputMessage::digital_out
uint8_t digital_out() const
Get digital_out value.
Definition: RobotinoSensorInterface.cpp:755
fawkes::RobotinoSensorInterface::SetBumperEStopEnabledMessage::SetBumperEStopEnabledMessage
SetBumperEStopEnabledMessage()
Constructor.
Definition: RobotinoSensorInterface.cpp:619
fawkes::RobotinoSensorInterface::mot_position
int32_t * mot_position() const
Get mot_position value.
Definition: RobotinoSensorInterface.cpp:141
fawkes::RobotinoSensorInterface::message_valid
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
Definition: RobotinoSensorInterface.cpp:831
fawkes::RobotinoSensorInterface::set_bumper
void set_bumper(const bool new_bumper)
Set bumper value.
Definition: RobotinoSensorInterface.cpp:281
fawkes::RobotinoSensorInterface::is_bumper_estop_enabled
bool is_bumper_estop_enabled() const
Get bumper_estop_enabled value.
Definition: RobotinoSensorInterface.cpp:534
fawkes::RobotinoSensorInterface::analog_in
float * analog_in() const
Get analog_in value.
Definition: RobotinoSensorInterface.cpp:472
fawkes::RobotinoSensorInterface::set_digital_out
void set_digital_out(unsigned int index, const bool new_digital_out)
Set digital_out value at given index.
Definition: RobotinoSensorInterface.cpp:459
fawkes::RobotinoSensorInterface::is_digital_in
bool * is_digital_in() const
Get digital_in value.
Definition: RobotinoSensorInterface.cpp:352
fawkes::RobotinoSensorInterface::enum_tostring
virtual const char * enum_tostring(const char *enumtype, int val) const
Definition: RobotinoSensorInterface.cpp:592
fawkes::RobotinoSensorInterface::maxlenof_analog_in
size_t maxlenof_analog_in() const
Get maximum length of analog_in value.
Definition: RobotinoSensorInterface.cpp:497