16#include <imgui_internal.h>
22#include <fmt/format.h>
41 const auto* imuIntegrator =
static_cast<const ImuIntegrator*
>(node);
42 return !inputPin.queue.empty() && imuIntegrator->_inertialIntegrator.hasInitialPosition();
56 return "ImuIntegrator";
66 return "Data Processor";
71 if (ImGui::Checkbox(fmt::format(
"IMU Preintegration##{}",
size_t(
id)).c_str(), &
_imuPreintegration))
116 if (j.contains(
"imuPreintegration")) { j.at(
"imuPreintegration").get_to(
_imuPreintegration); }
118 if (j.contains(
"inertialIntegrator")) { j.at(
"inertialIntegrator").get_to(
_inertialIntegrator); }
119 if (j.contains(
"inertialPreintegrator")) { j.at(
"inertialPreintegrator").get_to(
_inertialPreintegrator); }
145 if (nodeData->insTime.empty())
147 LOG_ERROR(
"{}: Can't set new imuObs__t0 because the observation has no time tag (insTime)",
nameId());
151 std::shared_ptr<NAV::PosVelAtt> integratedPosVelAtt =
nullptr;
155 auto obs = std::static_pointer_cast<const ImuObs>(nodeData);
156 LOG_DATA(
"{}: recvImuObs at time [{}] (preintegration)",
nameId(), obs->insTime.toYMDHMS(
GPST));
167 auto dt =
static_cast<double>((obs->insTime -
_lastImuObs->insTime).count());
190 integratedPosVelAtt = std::make_shared<PosVelAtt>();
191 integratedPosVelAtt->insTime = obs->insTime;
192 integratedPosVelAtt->setPosVelAtt_e(pvaNew.position, pvaNew.velocity, pvaNew.attitude);
207 auto obs = std::static_pointer_cast<const ImuObsWDelta>(nodeData);
210 integratedPosVelAtt =
_inertialIntegrator.calcInertialSolutionDelta(obs->insTime, obs->dtime, obs->dvel, obs->dtheta, obs->imuPos,
nameId().c_str());
214 auto obs = std::static_pointer_cast<const ImuObs>(nodeData);
217 integratedPosVelAtt =
_inertialIntegrator.calcInertialSolution(obs->insTime, obs->p_acceleration, obs->p_angularRate, obs->imuPos,
nameId().c_str());
221 if (integratedPosVelAtt)
223 LOG_DATA(
"{}: e_position = {}",
nameId(), integratedPosVelAtt->e_position().transpose());
224 LOG_DATA(
"{}: e_velocity = {}",
nameId(), integratedPosVelAtt->e_velocity().transpose());
225 LOG_DATA(
"{}: rollPitchYaw = {}",
nameId(),
rad2deg(integratedPosVelAtt->rollPitchYaw()).transpose());
232 auto posVelAtt = std::static_pointer_cast<const PosVelAtt>(queue.
extract_front());
236 LOG_DATA(
"{}: recvPosVelAttInit at time [{}]",
nameId(), posVelAtt->insTime.toYMDHMS(
GPST));
240 LOG_DATA(
"{}: e_position = {}",
nameId(), posVelAtt->e_position().transpose());
241 LOG_DATA(
"{}: e_velocity = {}",
nameId(), posVelAtt->e_velocity().transpose());
nlohmann::json json
json namespace
Text Help Marker (?) with Tooltip.
Inertial Measurement Preintegrator.
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...
Utility class which specifies available nodes.
static constexpr size_t INPUT_PORT_INDEX_POS_VEL_ATT_INIT
Flow (PosVelAtt)
std::shared_ptr< const PosVelAtt > _lastPosVelAtt
Last position, velocity and attitude.
void deinitialize() override
Deinitialize the node.
void recvObservation(InputPin::NodeDataQueue &queue, size_t pinIdx)
Receive Function.
std::shared_ptr< const ImuObs > _lastImuObs
Last IMU measuremnt.
bool _preferAccelerationOverDeltaMeasurements
Prefer the raw acceleration measurements over the deltaVel & deltaTheta values.
static std::string category()
String representation of the Class Category.
static std::string typeStatic()
String representation of the Class Type.
void restore(const json &j) override
Restores the node from a json object.
bool _imuPreintegration
Wether IMU preintegration should be used.
std::string type() const override
String representation of the Class Type.
ImuIntegrator()
Default constructor.
void guiConfig() override
ImGui config window which is shown on double click.
bool initialize() override
Initialize the node.
~ImuIntegrator() override
Destructor.
static constexpr size_t OUTPUT_PORT_INDEX_INERTIAL_NAV_SOL
Flow (InertialNavSol)
InertialPreIntegrator _inertialPreintegrator
Inertial Preintegrator.
void recvPosVelAttInit(InputPin::NodeDataQueue &queue, size_t pinIdx)
Receive Function for the PosVelAtt initial values.
json save() const override
Saves the node into a json object.
bool _resetPreintegratorEveryEpoch
Resetting the preintegrator every epoch makes it behave like a normal integrator.
InertialIntegrator _inertialIntegrator
Inertial Integrator.
static constexpr size_t INPUT_PORT_INDEX_IMU_OBS
Flow (ImuObs)
static std::string type()
Returns the type of the data class.
static std::string type()
Returns the type of the data class.
GenericMeasurement< double > Measurement
Inertial measurements.
ImVec2 _guiConfigDefaultWindowSize
Node(std::string name)
Constructor.
std::vector< InputPin > inputPins
List of input pins.
OutputPin * CreateOutputPin(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.
std::string nameId() const
Node name and id.
std::string name
Name of the Node.
InputPin * CreateInputPin(const char *name, Pin::Type pinType, const std::vector< std::string > &dataIdentifier={}, InputPin::Callback callback=static_cast< InputPin::FlowFirableCallbackFunc >(nullptr), InputPin::FlowFirableCheckFunc firable=nullptr, int priority=0, int idx=-1)
Create an Input Pin object.
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 std::string type()
Returns the type of the data class.
auto extract_front()
Returns a copy of the first element in the container and removes it from the container.
bool NodeDataTypeAnyIsChildOf(const std::vector< std::string > &childTypes, const std::vector< std::string > &parentTypes)
Checks if any of the provided child types is a child of any of the provided parent types.
void ApplyChanges()
Signals that there have been changes to the flow.
bool InertialPreIntegratorGui(const char *label, InertialPreIntegrator &integrator, float width)
Shows a GUI for advanced configuration of the InertialPreIntegrator.
bool InertialIntegratorGui(const char *label, InertialIntegrator &integrator, bool &preferAccelerationOverDeltaMeasurements, float width)
Shows a GUI for advanced configuration of the InertialIntegrator.
constexpr auto rad2deg(const T &rad)
Convert Radians to Degree.
Position, velocity and attitude state.