31 void CGillAnemometer::loadConfig_sensorSpecific(
37 configSource.
read_string(iniSection,
"COM_port_WIN",
"COM1",
true);
40 configSource.
read_string(iniSection,
"COM_port_LIN",
"/dev/tty0",
true);
43 com_bauds = configSource.
read_int(iniSection,
"COM_baudRate", 9600,
false);
45 pose_x = configSource.
read_float(iniSection,
"pose_x", 0,
true);
46 pose_y = configSource.
read_float(iniSection,
"pose_y", 0,
true);
47 pose_z = configSource.
read_float(iniSection,
"pose_z", 0,
true);
48 pose_roll = configSource.
read_float(iniSection,
"pose_roll", 0,
true);
49 pose_pitch = configSource.
read_float(iniSection,
"pose_pitch", 0,
true);
50 pose_yaw = configSource.
read_float(iniSection,
"pose_yaw", 0,
true);
56 bool CGillAnemometer::tryToOpenTheCOM()
58 if (COM.isOpen())
return true;
61 cout <<
"[CGillAnemometer] Opening " << com_port <<
" @ " << com_bauds
67 COM.setConfig(com_bauds, 0, 8, 1);
68 COM.setTimeouts(50, 1, 100, 1, 20);
73 catch (std::exception& e)
75 std::cerr <<
"[CGillAnemometer::tryToOpenTheCOM] Error opening or " 76 "configuring the serial port:" 84 std::cerr <<
"[CGillAnemometer::tryToOpenTheCOM] Error opening or " 85 "configuring the serial port." 95 void CGillAnemometer::doProcess()
98 if (!tryToOpenTheCOM())
101 printf(
"ERROR: No observation received from the Anemometer!\n");
106 mrpt::make_aligned_shared<mrpt::obs::CObservationWindSensor>();
107 bool have_reading =
false;
109 bool time_out =
false;
113 while (!have_reading)
123 wind_reading = COM.ReadString(500, &time_out);
126 cout <<
"[CGillAnemometer] " << com_port <<
" @ " << com_bauds
127 <<
" - measurement Timed-Out" << endl;
128 std::this_thread::sleep_for(10ms);
135 std::deque<std::string> list;
137 if (list.size() == 6)
140 int status = atoi(list.at(4).c_str());
148 obsPtr->speed = atof(s_speed.c_str());
149 else if (s_units ==
"K")
150 obsPtr->speed = atof(s_speed.c_str()) * 1000 / 3600;
154 "ERROR: WindSonic measurement units not supported: " 161 obsPtr->direction = atof(s_direction.c_str());
164 obsPtr->sensorLabel = m_sensorLabel;
167 pose_x, pose_y, pose_z, pose_yaw, pose_pitch, pose_roll);
168 appendObservation(obsPtr);
171 printf(
"ERROR: WindSonic error code %u\n",
status);
173 else if (list.size() == 5)
177 int status = atoi(list.at(3).c_str());
185 obsPtr->speed = atof(s_speed.c_str());
186 else if (s_units ==
"K")
187 obsPtr->speed = atof(s_speed.c_str()) * 1000 / 3600;
191 "ERROR: WindSonic measurement units not supported: " 197 obsPtr->direction = 0.0;
200 obsPtr->sensorLabel = m_sensorLabel;
203 pose_x, pose_y, pose_z, pose_yaw, pose_pitch, pose_roll);
204 appendObservation(obsPtr);
207 printf(
"ERROR: WindSonic error code %u\n",
status);
212 "ERROR: Windsonic reading incorrect format: %s [%u]\n",
213 wind_reading.c_str(),
static_cast<unsigned int>(list.size()));
216 catch (std::exception& e)
218 std::cerr <<
"[CGillAnemometer::doProcess] Error:" << std::endl
223 std::cerr <<
"[CGillAnemometer::doProcess] Unknown Error" << std::endl;
std::string read_string(const std::string §ion, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
#define THROW_EXCEPTION(msg)
mrpt::system::TTimeStamp getCurrentTime()
Returns the current (UTC) system time.
Contains classes for various device interfaces.
float read_float(const std::string §ion, const std::string &name, float defaultValue, bool failIfNotFound=false) const
void tokenize(const std::string &inString, const std::string &inDelimiters, OUT_CONTAINER &outTokens, bool skipBlankTokens=true) noexcept
Tokenizes a string according to a set of delimiting characters.
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
This class allows loading and storing values and vectors of different types from a configuration text...
GLsizei const GLchar ** string
#define IMPLEMENTS_GENERIC_SENSOR(class_name, NameSpace)
This must be inserted in all CGenericSensor classes implementation files:
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
This class implements a driver for the Gill Windsonic Option 1 Anemometer The sensor is accessed via ...