-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read existing code base to summarize a good software architecture #6
Comments
Repasting image from #2 for reference,
A very preliminary idea is given below (subject to changes or even abandonment).
It will maintain a few shared resources and a few advanceable runners. For example, KinDynVIOManager members AdvanceableRunner<ImageProcessor> imgProcessorThread;
std::shared_ptr<ImageProcessor> imgProcessor;
std::shared_ptr< SharedResource <TimeStampedImg > > imgDataShared; Let's consider a visual inertial odoemtery using aruco markers and IMU measurements.
For example, the IMU measurements can be maintained in a struct, IMUPreintegratorInputstruct IMUPreintegratorInput
{
std::deque<double> ts;
std::deque<Eigen::Vector3d> linAcc; // m per second per second
std::deque<Eigen::Vector3d> gyro; // radians per second
std::deque<Eigen::Vector3d> orientRPY; // RPY in radians
gtsam::Key posei, posej; // IMU poses at ith and jth timestep
gtsam::Key vi, vj; // IMU linear velocities at ith and jth timestep
gtsam::Key bi, bj; // IMU biases at ith and jth timestep
};
Some other helper threads will be maintained for intermediate operations, for example multiple pre-integration threads between two image key frames, such that the all the pre-integration from different modules are carried out in parallel and once these computations finish, the threads are made to join the smoothing thread and destroyed. These minion threads include,
For example, given a IMU pre-integration block as follows, ForsterIMUPreintegratorclass ForsterIMUPreintegrator : public IMUPreintegrator<gtsam::CombinedImuFactor>
{
public:
ForsterIMUPreintegrator();
virtual ~ForsterIMUPreintegrator();
bool initialize(std::weak_ptr<const BipedalLocomotion::ParametersHandler::IParametersHandler> handler) final;
bool setInput(const IMUPreintegratorInput& input) final;
virtual bool advance() final;
const gtsam::CombinedImuFactor& getOutput() const final;
bool isOutputValid() const final;
virtual bool getPredictedState(const IMUState& currentState,
IMUState& predictedState) final;
virtual void resetIMUIntegration() final;
virtual void resetIMUIntegration(const gtsam::imuBias::ConstantBias& bias);
private:
class Impl;
std::unique_ptr<Impl> m_pimpl;
}; one call of advance computes all the necessary pre-integration from the gathered queue of IMU measurements between two keyframes. In the parallel, some other pre-integration thread would be doing a similar computation for a different set of measurements. For the future, where we might replace this IMU preintegration with other IMU preintegration factors, we templatized this class, Templatized IMUPreintegratortemplate <typename PreintegratedFactor>
class IMUPreintegrator : public BipedalLocomotion::System::Advanceable<IMUPreintegratorInput, PreintegratedFactor>
{
public:
virtual bool initialize(std::weak_ptr<const BipedalLocomotion::ParametersHandler::IParametersHandler> handler);
virtual bool setInput(const IMUPreintegratorInput& input) = 0;
virtual bool advance() = 0;
virtual const PreintegratedFactor& getOutput() const = 0;
virtual bool isOutputValid() const = 0;
virtual bool getPredictedState(const IMUState& currentState,
IMUState& predictedState) = 0;
virtual void resetIMUIntegration() = 0;
};
|
This might be a costly integration especially at the time of creation of the factor. It is preferable to integrate the measurement as soon as it is received, triggering the start of a certain preintegration and it stop using conditional variables, as recommended by @S-Dafarra. This is also recommended in GTSAM CombinedIMUFactor documentation. Also, creation of threads during run-time is an expensive operation, so we can forego the idea of the intermediate dispatching of helper threads. |
closed-loop control
The text was updated successfully, but these errors were encountered: