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;