Skip to content
Snippets Groups Projects
Commit f310dc03 authored by Matteo Pancotti's avatar Matteo Pancotti
Browse files

propagator with acceleration

parent 434855b5
Branches
Tags
No related merge requests found
...@@ -31,6 +31,8 @@ using namespace Eigen; ...@@ -31,6 +31,8 @@ using namespace Eigen;
namespace Boardcore namespace Boardcore
{ {
static constexpr bool useAcceleration = true; //set true to use the propagator with acceleration
Propagator::Propagator(std::chrono::milliseconds pUpdatePeriod) Propagator::Propagator(std::chrono::milliseconds pUpdatePeriod)
: updatePeriod(static_cast<float>(pUpdatePeriod.count()) / 1000), state() : updatePeriod(static_cast<float>(pUpdatePeriod.count()) / 1000), state()
{ {
...@@ -52,10 +54,24 @@ void Propagator::step() ...@@ -52,10 +54,24 @@ void Propagator::step()
getRocketNasState()) getRocketNasState())
: oldState); : oldState);
// Update Position propagating it with velocity if(useAcceleration) // Update Position assuming constant acceleration
{
// checking that last two states are not propagated
if(state.nPropagations == 0 && oldState.nPropagations == 0)
state.setAProp((state.getVProp() - oldState.getVProp()) / updatePeriod);
state.setVProp((state.getVProp() + state.getAProp()) * updatePeriod);
state.setXProp((state.getXProp() + state.getVProp()) * updatePeriod);
state.nPropagations++;
state.timestamp = TimestampTimer::getTimestamp();
}
else // Update Position propagating assuming costant velocity
{
state.setXProp(state.getXProp() + state.getVProp() * updatePeriod); state.setXProp(state.getXProp() + state.getVProp() * updatePeriod);
state.nPropagations++; state.nPropagations++;
state.timestamp = TimestampTimer::getTimestamp(); state.timestamp = TimestampTimer::getTimestamp();
}
// Log propagator state // Log propagator state
PropagatorState logState(state); PropagatorState logState(state);
......
...@@ -42,6 +42,8 @@ struct PropagatorState ...@@ -42,6 +42,8 @@ struct PropagatorState
uint32_t nPropagations; ///< Predictions from last received NAS state uint32_t nPropagations; ///< Predictions from last received NAS state
NASState nas; NASState nas;
Eigen::Vector3f acceleration = Eigen::Vector3f::Zero();
PropagatorState() : timestamp(0), nPropagations(0), nas() {} PropagatorState() : timestamp(0), nPropagations(0), nas() {}
PropagatorState(uint64_t timestamp, uint32_t nPropagations, PropagatorState(uint64_t timestamp, uint32_t nPropagations,
...@@ -102,6 +104,24 @@ struct PropagatorState ...@@ -102,6 +104,24 @@ struct PropagatorState
nas.vd = vProp(2); nas.vd = vProp(2);
} }
/**
* @brief Setter for the vector acceleration
*/
void setAProp(Eigen::Vector3f aProp)
{
acceleration = aProp;
}
/**
* @brief Getter for the vector acceleration
*
* @return Eigen::Vector3f acceleration
*/
Eigen::Vector3f getAProp() const
{
return acceleration;
}
/** /**
* @brief Getter for the vector of quaternions * @brief Getter for the vector of quaternions
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment