Fawkes API  Fawkes Development Version
IMUInterface.h
1 
2 /***************************************************************************
3  * IMUInterface.h - Fawkes BlackBoard Interface - IMUInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2014 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_IMUINTERFACE_H_
25 #define __INTERFACES_IMUINTERFACE_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 IMUInterface : public Interface
34 {
35  /// @cond INTERNALS
36  INTERFACE_MGMT_FRIENDS(IMUInterface)
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  char frame[32]; /**<
47  Coordinate frame in which the data is presented.
48  */
49  float orientation[4]; /**<
50  Rotation quaternion ordered as (x, y, z, w).
51  */
52  double orientation_covariance[9]; /**<
53  Covariance of orientation, row major about x, y, z axes.
54  */
55  float angular_velocity[3]; /**<
56  Angular velocities ordered as (x, y, z).
57  */
58  double angular_velocity_covariance[9]; /**<
59  Covariance of angular velocity, row major about x, y, z axes.
60  */
61  float linear_acceleration[3]; /**<
62  Linear acceleration ordered as (x, y, z).
63  */
64  double linear_acceleration_covariance[9]; /**<
65  Covariance of linear acceleration, row major about x, y, z axes.
66  */
67  } IMUInterface_data_t;
68 
69  IMUInterface_data_t *data;
70 
71  public:
72  /* messages */
73  virtual bool message_valid(const Message *message) const;
74  private:
75  IMUInterface();
76  ~IMUInterface();
77 
78  public:
79  /* Methods */
80  char * frame() const;
81  void set_frame(const char * new_frame);
82  size_t maxlenof_frame() const;
83  float * orientation() const;
84  float orientation(unsigned int index) const;
85  void set_orientation(unsigned int index, const float new_orientation);
86  void set_orientation(const float * new_orientation);
87  size_t maxlenof_orientation() const;
88  double * orientation_covariance() const;
89  double orientation_covariance(unsigned int index) const;
90  void set_orientation_covariance(unsigned int index, const double new_orientation_covariance);
91  void set_orientation_covariance(const double * new_orientation_covariance);
92  size_t maxlenof_orientation_covariance() const;
93  float * angular_velocity() const;
94  float angular_velocity(unsigned int index) const;
95  void set_angular_velocity(unsigned int index, const float new_angular_velocity);
96  void set_angular_velocity(const float * new_angular_velocity);
97  size_t maxlenof_angular_velocity() const;
98  double * angular_velocity_covariance() const;
99  double angular_velocity_covariance(unsigned int index) const;
100  void set_angular_velocity_covariance(unsigned int index, const double new_angular_velocity_covariance);
101  void set_angular_velocity_covariance(const double * new_angular_velocity_covariance);
103  float * linear_acceleration() const;
104  float linear_acceleration(unsigned int index) const;
105  void set_linear_acceleration(unsigned int index, const float new_linear_acceleration);
106  void set_linear_acceleration(const float * new_linear_acceleration);
107  size_t maxlenof_linear_acceleration() const;
108  double * linear_acceleration_covariance() const;
109  double linear_acceleration_covariance(unsigned int index) const;
110  void set_linear_acceleration_covariance(unsigned int index, const double new_linear_acceleration_covariance);
111  void set_linear_acceleration_covariance(const double * new_linear_acceleration_covariance);
113  virtual Message * create_message(const char *type) const;
114 
115  virtual void copy_values(const Interface *other);
116  virtual const char * enum_tostring(const char *enumtype, int val) const;
117 
118 };
119 
120 } // end namespace fawkes
121 
122 #endif
virtual Message * create_message(const char *type) const
Create message based on type name.
double * angular_velocity_covariance() const
Get angular_velocity_covariance value.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
size_t maxlenof_angular_velocity_covariance() const
Get maximum length of angular_velocity_covariance value.
void set_orientation(unsigned int index, const float new_orientation)
Set orientation value at given index.
Fawkes library namespace.
size_t maxlenof_frame() const
Get maximum length of frame value.
size_t maxlenof_linear_acceleration() const
Get maximum length of linear_acceleration value.
size_t maxlenof_orientation_covariance() const
Get maximum length of orientation_covariance value.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
void set_linear_acceleration_covariance(unsigned int index, const double new_linear_acceleration_covariance)
Set linear_acceleration_covariance value at given index.
void set_angular_velocity(unsigned int index, const float new_angular_velocity)
Set angular_velocity value at given index.
void set_frame(const char *new_frame)
Set frame value.
const char * type() const
Get type of interface.
Definition: interface.cpp:651
void set_orientation_covariance(unsigned int index, const double new_orientation_covariance)
Set orientation_covariance value at given index.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
void set_angular_velocity_covariance(unsigned int index, const double new_angular_velocity_covariance)
Set angular_velocity_covariance value at given index.
float * angular_velocity() const
Get angular_velocity value.
size_t maxlenof_angular_velocity() const
Get maximum length of angular_velocity value.
size_t maxlenof_linear_acceleration_covariance() const
Get maximum length of linear_acceleration_covariance value.
double * linear_acceleration_covariance() const
Get linear_acceleration_covariance value.
IMUInterface Fawkes BlackBoard Interface.
Definition: IMUInterface.h:33
virtual void copy_values(const Interface *other)
Copy values from other interface.
char * frame() const
Get frame value.
double * orientation_covariance() const
Get orientation_covariance value.
size_t maxlenof_orientation() const
Get maximum length of orientation value.
float * linear_acceleration() const
Get linear_acceleration value.
void set_linear_acceleration(unsigned int index, const float new_linear_acceleration)
Set linear_acceleration value at given index.
float * orientation() const
Get orientation value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.