gusimplewhiteboard
SENSORSSonarSensors.hpp
Go to the documentation of this file.
1
10#ifndef SENSORSSonarSensors_DEFINED
11#define SENSORSSonarSensors_DEFINED
12
13#include "wb_sensors_sonar.h"
14
15namespace guWhiteboard
16{
17 namespace Sonar
18 {
19 typedef enum ReadingCodesEnum {
52
56 enum Giraff
57 {
68
73
84 };
85
86 enum Toto
87 {
92
97
101 sEight = Right3
102 };
103 }
104
120 {
121
122 public:
124 {
125
126 }
127
129 inline bool operator == (const SENSORSSonarSensors &s)
130 {
131 for(int i = Sonar::Left0; i < Sonar::NUMBER_OF_READINGS; i++)
132 {
133 if(this->sonar(i) != s.sonar(i))
134 return false;
135 else
136 continue;
137 }
138 return true;
139 }
140
142 inline bool operator != (const SENSORSSonarSensors &s)
143 {
144 return !(*this == s);
145 }
146
147#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
151 SENSORSSonarSensors(const std::string &str) { from_string(str); }
152
156 void from_string(const std::string &str)
157 {
158 std::istringstream iss(str);
159 std::string token;
160 for (int i=0; i< Sonar::NUMBER_OF_READINGS && getline(iss, token, ','); i++ )
161 { u_int8_t value = static_cast<u_int8_t>(atoi(token.c_str()));
162 set_sonar(value,i);
163 }
164 }
165
166#pragma clang diagnostic ignored "-Wcovered-switch-default"
167#pragma clang diagnostic ignored "-Wunreachable-code"
168
172 std::string description() const
173 {
174 std::stringstream ss;
175
176 for (int i = 0; i < (Sonar::NUMBER_OF_READINGS-1); i++)
177 ss << static_cast<int>(sonar(i)) << ",";
178 ss << static_cast<int>(sonar(Sonar::NUMBER_OF_READINGS-1)); //Don't want a ', ' for the last element.
179
180 return ss.str();
181 }
182#endif // WHITEBOARD_POSTER_STRING_CONVERSION
183
184 };
185}
186
187#endif //SENSORSSonarSensors_DEFINED
Contains the latest Sonar readings.
bool operator==(const SENSORSSonarSensors &s)
comparison operator
std::string description() const
pretty print method for showing the current property values
bool operator!=(const SENSORSSonarSensors &s)
compare two sonar sensor value records and return false if they are the same
void from_string(const std::string &str)
parse class properties from a string
SENSORSSonarSensors(const std::string &str)
string constructor (see from_string() below)
#define u_int8_t
Giraff
Indexes for the Giraff sonar sensors.
enum guWhiteboard::Sonar::ReadingCodesEnum ReadingCode
/file APM_Interface.h
Sonar sensors c struct.