16#include <imgui_internal.h>
23#include <fmt/format.h>
43 const auto* imuIntegrator =
static_cast<const ImuIntegrator*
>(node);
44 return !inputPin.queue.empty() && imuIntegrator->_inertialIntegrator.hasInitialPosition();
58 return "ImuIntegrator";
68 return "Data Processor";
73 if (ImGui::Checkbox(fmt::format(
"IMU Preintegration##{}",
size_t(
id)).c_str(), &
_imuPreintegration))
118 if (j.contains(
"imuPreintegration")) { j.at(
"imuPreintegration").get_to(
_imuPreintegration); }
120 if (j.contains(
"inertialIntegrator")) { j.at(
"inertialIntegrator").get_to(
_inertialIntegrator); }
121 if (j.contains(
"inertialPreintegrator")) { j.at(
"inertialPreintegrator").get_to(
_inertialPreintegrator); }
147 if (nodeData->insTime.empty())
149 LOG_ERROR(
"{}: Can't set new imuObs__t0 because the observation has no time tag (insTime)",
nameId());
153 std::shared_ptr<NAV::PosVelAtt> integratedPosVelAtt =
nullptr;
157 auto obs = std::static_pointer_cast<const ImuObs>(nodeData);
158 LOG_DATA(
"{}: recvImuObs at time [{}] (preintegration)",
nameId(), obs->insTime.toYMDHMS(
GPST));
169 auto dt =
static_cast<double>((obs->insTime -
_lastImuObs->insTime).count());
192 integratedPosVelAtt = std::make_shared<PosVelAtt>();
193 integratedPosVelAtt->insTime = obs->insTime;
194 integratedPosVelAtt->setPosVelAtt_e(pvaNew.position, pvaNew.velocity, pvaNew.attitude);
209 auto obs = std::static_pointer_cast<const ImuObsWDelta>(nodeData);
212 integratedPosVelAtt =
_inertialIntegrator.calcInertialSolutionDelta(obs->insTime, obs->dtime, obs->dvel, obs->dtheta, obs->imuPos,
nameId().c_str());
216 auto obs = std::static_pointer_cast<const ImuObs>(nodeData);
219 integratedPosVelAtt =
_inertialIntegrator.calcInertialSolution(obs->insTime, obs->p_acceleration, obs->p_angularRate, obs->imuPos,
nameId().c_str());
223 if (integratedPosVelAtt)
225 LOG_DATA(
"{}: e_position = {}",
nameId(), integratedPosVelAtt->e_position().transpose());
226 LOG_DATA(
"{}: e_velocity = {}",
nameId(), integratedPosVelAtt->e_velocity().transpose());
227 LOG_DATA(
"{}: rollPitchYaw = {}",
nameId(),
rad2deg(integratedPosVelAtt->rollPitchYaw()).transpose());
234 auto posVelAtt = std::static_pointer_cast<const PosVelAtt>(queue.
extract_front());
238 LOG_DATA(
"{}: recvPosVelAttInit at time [{}]",
nameId(), posVelAtt->insTime.toYMDHMS(
GPST));
242 LOG_DATA(
"{}: e_position = {}",
nameId(), posVelAtt->e_position().transpose());
243 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.
std::string nameId() const
Node name and id.
std::string name
Name of 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 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.
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.
InputPin * CreateInputPin(Node *node, 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.
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.