13#if !__APPLE__ && !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32)
14 #include "Navio/Common/MPU9250.h"
15 #include "Navio/Navio2/LSM9DS1.h"
16 #include "Navio/Common/Util.h"
46 return "Navio2Sensor";
56 return "Data Provider";
61 if (
auto imuType =
static_cast<int>(
_imuType);
62 ImGui::Combo(
"IMU", &imuType,
"MPU9250\0LSM9DS1\0\0"))
96 if (j.contains(
"Frequency"))
100 if (j.contains(
"Imu"))
115#if !__APPLE__ && !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32)
118 _sensor = std::make_unique<MPU9250>();
122 _sensor = std::make_unique<LSM9DS1>();
136 int outputInterval =
static_cast<int>(1.0 /
static_cast<double>(
_outputFrequency) * 1000.0);
137 _startTime = std::chrono::steady_clock::now();
152#if !__APPLE__ && !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32)
161 auto obs = std::make_shared<ImuObs>(navio->_imuPos);
163#if !__APPLE__ && !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32)
164 navio->_sensor->update();
166 navio->_sensor->read_accelerometer(&navio->_ax, &navio->_ay, &navio->_az);
167 navio->_sensor->read_gyroscope(&navio->_gx, &navio->_gy, &navio->_gz);
168 navio->_sensor->read_magnetometer(&navio->_mx, &navio->_my, &navio->_mz);
170 obs->temperature = navio->_sensor->read_temperature();
173 obs->p_acceleration = { navio->_ax, navio->_ay, navio->_az };
174 obs->p_angularRate = { navio->_gx, navio->_gy, navio->_gz };
178 obs->p_magneticField.emplace(navio->_mx, navio->_my, navio->_mz);
183 LOG_DATA(
"DATA({}): {}°C, a=({}, {}, {})", navio->name, obs->temperature.value(),
184 navio->_ax, navio->_ay, navio->_az);
186 if (
InsTime currentTime = util::time::GetCurrentInsTime();
187 !currentTime.
empty())
189 obs->insTime = currentTime;
nlohmann::json json
json namespace
Parent Class for all IMU Observations.
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_TRACE
Detailled info to trace the execution of the program. Should not be called on functions which receive...
Keeps track of the current real/simulation time.
static std::string type()
Returns the type of the data class.
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.
The class is responsible for all time-related tasks.
constexpr bool empty() const
Checks if the Time object has a value.
CallbackTimer _timer
Timer object to handle async data requests.
bool initialize() override
Initialize the node.
static void readImuThread(void *userData)
Function which performs the async data reading.
std::string type() const override
String representation of the Class Type.
static std::string typeStatic()
String representation of the Class Type.
Navio2Sensor()
Default constructor.
void guiConfig() override
ImGui config window which is shown on double click.
bool resetNode() override
Resets the node. It is guaranteed that the node is initialized when this is called.
json save() const override
Saves the node into a json object.
~Navio2Sensor() override
Destructor.
static constexpr size_t OUTPUT_PORT_INDEX_IMU_OBS
Flow (ImuObs)
void restore(const json &j) override
Restores the node from a json object.
int _outputFrequency
OutputFrequency to calculate rateDivisor field.
std::chrono::time_point< std::chrono::steady_clock > _startTime
Start Time to calculate the TimeSinceStartup.
static std::string category()
String representation of the Class Category.
ImuType _imuType
The Imu type.
void deinitialize() override
Deinitialize the node.
std::unique_ptr< InertialSensor > _sensor
Sensor object.
bool doDeinitialize(bool wait=false)
Asks the node worker to deinitialize the node.
ImVec2 _guiConfigDefaultWindowSize
std::string nameId() const
Node name and id.
std::string name
Name of the Node.
bool _onlyRealTime
Whether the node can run in post-processing or only real-time.
bool _hasConfig
Flag if the config window should be shown.
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.