50 return "Data Provider";
74 if (ImGui::BeginTable(fmt::format(
"##VectorNavHeaders ({})",
id.AsPointer()).c_str(), 2,
75 ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg))
77 ImGui::TableSetupColumn(
"Basic", ImGuiTableColumnFlags_WidthFixed);
78 ImGui::TableSetupColumn(
"IMU", ImGuiTableColumnFlags_WidthFixed);
79 ImGui::TableHeadersRow();
81 auto TextColoredIfExists = [
this](
int index,
const char* displayText,
const char* searchText,
bool alwaysNormal =
false) {
82 ImGui::TableSetColumnIndex(index);
85 ImGui::TextUnformatted(displayText);
89 ImGui::TextDisabled(
"%s", displayText);
93 ImGui::TableNextRow();
94 TextColoredIfExists(0,
"GpsTime",
"GpsToW [s]");
95 TextColoredIfExists(1,
"UnCompMag",
"UnCompMagX [Gauss]");
96 ImGui::TableNextRow();
97 TextColoredIfExists(0,
"TimeStartup",
"TimeStartup [ns]");
98 TextColoredIfExists(1,
"UnCompAcc",
"UnCompAccX [m/s^2]");
99 ImGui::TableNextRow();
100 TextColoredIfExists(0,
"Temperature",
"Temperature [Celsius]");
101 TextColoredIfExists(1,
"UnCompGyro",
"UnCompGyroX [rad/s]");
102 ImGui::TableNextRow();
103 TextColoredIfExists(0,
"Status",
"Status");
104 ImGui::TableNextRow();
105 TextColoredIfExists(0,
"SequenceNumber",
"SequenceNumber");
112 ImGui::TextUnformatted(
"Binary file");
132 if (j.contains(
"FileReader"))
136 if (j.contains(
"Imu"))
165 std::shared_ptr<KvhObs> obs =
nullptr;
170 std::unique_ptr<uart::protocol::Packet> packet =
nullptr;
171 while (!
eof() &&
read(
reinterpret_cast<char*
>(&i), 1))
173 packet =
_sensor.findPacket(i);
175 if (packet !=
nullptr)
186 obs = std::make_shared<KvhObs>(
_imuPos, *packet);
189 if (obs->raw.getRawDataLength() == 0)
198 obs = std::make_shared<KvhObs>(
_imuPos);
204 line.erase(line.begin(), std::ranges::find_if(line, [](
int ch) { return std::isgraph(ch); }));
212 std::stringstream lineStream(line);
215 std::optional<uint16_t> gpsCycle = 0;
216 std::optional<uint16_t> gpsWeek;
217 std::optional<long double> gpsToW;
218 std::optional<double> magX;
219 std::optional<double> magY;
220 std::optional<double> magZ;
221 std::optional<double> accelX;
222 std::optional<double> accelY;
223 std::optional<double> accelZ;
224 std::optional<double> gyroX;
225 std::optional<double> gyroY;
226 std::optional<double> gyroZ;
231 if (std::getline(lineStream, cell,
','))
234 cell.erase(std::ranges::find_if(cell, [](
int ch) {
return std::iscntrl(ch); }), cell.end());
240 if (column ==
"GpsCycle")
242 gpsCycle =
static_cast<uint16_t
>(std::stoul(cell));
244 else if (column ==
"GpsWeek")
246 gpsWeek =
static_cast<uint16_t
>(std::stoul(cell));
248 else if (column ==
"GpsToW [s]")
250 gpsToW = std::stold(cell);
252 else if (column ==
"MagX [Gauss]")
254 magX = std::stod(cell);
256 else if (column ==
"MagY [Gauss]")
258 magY = std::stod(cell);
260 else if (column ==
"MagZ [Gauss]")
262 magZ = std::stod(cell);
264 else if (column ==
"AccX [m/s^2]")
266 accelX = std::stod(cell);
268 else if (column ==
"AccY [m/s^2]")
270 accelY = std::stod(cell);
272 else if (column ==
"AccZ [m/s^2]")
274 accelZ = std::stod(cell);
276 else if (column ==
"GyroX [rad/s]")
278 gyroX = std::stod(cell);
280 else if (column ==
"GyroY [rad/s]")
282 gyroY = std::stod(cell);
284 else if (column ==
"GyroZ [rad/s]")
286 gyroZ = std::stod(cell);
288 else if (column ==
"Temperature [Celsius]")
290 obs->temperature.emplace(std::stod(cell));
292 else if (column ==
"Status")
294 obs->status = std::bitset<8>{ cell };
296 else if (column ==
"SequenceNumber")
298 obs->sequenceNumber =
static_cast<uint8_t
>(std::stoul(cell));
303 if (!gpsCycle || !gpsWeek || !gpsToW)
305 LOG_ERROR(
"{}: Fields 'GpsCycle', 'GpsWeek', 'GpsToW [s]' are needed.",
nameId());
308 if (!accelX || !accelY || !accelZ)
310 LOG_ERROR(
"{}: Fields 'AccX [m/s^2]', 'AccY [m/s^2]', 'AccZ [m/s^2]' are needed.",
nameId());
313 if (!gyroX || !gyroY || !gyroZ)
315 LOG_ERROR(
"{}: Fields 'GyroX [rad/s]', 'GyroY [rad/s]', 'GyroZ [rad/s]' are needed.",
nameId());
318 obs->insTime =
InsTime(gpsCycle.value(), gpsWeek.value(), gpsToW.value());
319 obs->p_acceleration = { accelX.value(), accelY.value(), accelZ.value() };
320 obs->p_angularRate = { gyroX.value(), gyroY.value(), gyroZ.value() };
322 if (magX && magY && magZ)
324 obs->p_magneticField.emplace(magX.value(), magY.value(), magZ.value());
328 LOG_DATA(
"DATA({}): {}, {}, {}, {}, {}",
name, obs->sequenceNumber, obs->temperature.value(),
329 obs->p_acceleration.x(), obs->p_acceleration.y(), obs->p_acceleration.z());
354 if (filestream.good())
358 std::array<char, 4> buffer;
362 if (filestream.readsome(un.buffer.data(),
sizeof(uint32_t)) ==
sizeof(uint32_t))
375 filestream.seekg(0, std::ios_base::beg);
377 std::getline(filestream, line);
380 auto n = std::ranges::count(line,
',');
nlohmann::json json
json namespace
File Reader for Kvh log files.
Data storage class for one KVH Imu observation.
Helper Functions to work with Kvh Sensors.
Utility class for logging to console and file.
#define LOG_DEBUG
Debug information. Should not be called on functions which receive observations (spamming)
#define LOG_DATA
All output which occurs repeatedly every time observations are received.
#define LOG_ERROR
Error occurred, which stops part of the program to work, but not everything.
#define LOG_WARN
Error occurred, but a fallback option exists and program continues to work normally.
#define LOG_TRACE
Detailled info to trace the execution of the program. Should not be called on functions which receive...
bool initialize()
Initialize the file reader.
void restore(const json &j)
Restores the node from a json object.
std::string _path
Path to the file.
FileType
File Type Enumeration.
FileType _fileType
File Type.
auto eof() const
Check whether the end of file is reached.
auto & read(char *__s, std::streamsize __n)
Extraction without delimiters.
std::filesystem::path getFilepath()
Returns the path of the file.
@ PATH_CHANGED
The path changed and exists.
std::vector< std::string > _headerColumns
Header Columns of a CSV file.
GuiResult guiConfig(const char *vFilters, const std::vector< std::string > &extensions, size_t id, const std::string &nameId)
ImGui config.
void resetReader()
Moves the read cursor to the start.
auto & getline(std::string &str)
Reads a line from the filestream.
json save() const
Saves the node into a json object.
void deinitialize()
Deinitialize the file reader.
json save() const override
Saves the node into a json object.
void restore(const json &j) override
Restores the node from a json object.
void guiConfig() override
ImGui config window which is shown on double click.
Imu(const Imu &)=delete
Copy constructor.
ImuPos _imuPos
Position and rotation information for conversion from platform to body frame.
The class is responsible for all time-related tasks.
static constexpr size_t OUTPUT_PORT_INDEX_KVH_OBS
Flow (KvhObs)
~KvhFile() override
Destructor.
KvhFile()
Default constructor.
static std::string typeStatic()
String representation of the Class Type.
bool resetNode() override
Resets the node. Moves the read cursor to the start.
void deinitialize() override
Deinitialize the node.
uint8_t _prevSequenceNumber
Previous Sequence number to check for order errors.
void restore(const json &j) override
Restores the node from a json object.
static std::string category()
String representation of the Class Category.
vendor::kvh::KvhUartSensor _sensor
Sensor Object.
void guiConfig() override
ImGui config window which is shown on double click.
FileType determineFileType() override
Determines the type of the file.
std::shared_ptr< const NodeData > pollData()
Polls data from the file.
std::string type() const override
String representation of the Class Type.
json save() const override
Saves the node into a json object.
bool initialize() override
Initialize the node.
static std::string type()
Returns the type of the data class.
bool doDeinitialize(bool wait=false)
Asks the node worker to deinitialize the node.
ImVec2 _guiConfigDefaultWindowSize
bool callbacksEnabled
Enables the callbacks.
std::string nameId() const
Node name and id.
std::string name
Name of the Node.
bool doReinitialize(bool wait=false)
Asks the node worker to reinitialize the node.
void invokeCallbacks(size_t portIndex, const std::shared_ptr< const NodeData > &data)
Calls all registered callbacks on the specified output port.
bool _hasConfig
Flag if the config window should be shown.
static constexpr uint32_t HEADER_FMT_XBIT2
Header Format X Bit 2.
static constexpr uint32_t HEADER_FMT_A
Header Format A.
static constexpr uint32_t HEADER_FMT_B
Header Format B.
static constexpr uart::Endianness ENDIANNESS
Endianess of the sensor.
static constexpr uint32_t HEADER_FMT_C
Header Format C.
static constexpr uint32_t HEADER_FMT_XBIT
Header Format X Bit.
OutputPin * CreateOutputPin(Node *node, const char *name, Pin::Type pinType, const std::vector< std::string > &dataIdentifier, OutputPin::PinData data=static_cast< void * >(nullptr), int idx=-1)
Create an Output Pin object.
void ApplyChanges()
Signals that there have been changes to the flow.
void decryptKvhObs(const std::shared_ptr< NAV::KvhObs > &obs)
Decrypts the provided Kvh observation.