Skip to content
Snippets Groups Projects
Commit 9ca95d47 authored by Joan Solà Ortega's avatar Joan Solà Ortega
Browse files

Change order in Prb::getState(void and ts)

parent 769e641a
No related branches found
No related tags found
1 merge request!380Resolve "Problem::getState/getTimeStamp considering not initialized processors"
Pipeline #5668 passed
...@@ -448,15 +448,7 @@ VectorComposite Problem::getState(const StateStructure& _structure) const ...@@ -448,15 +448,7 @@ VectorComposite Problem::getState(const StateStructure& _structure) const
StateStructure structure = (_structure == "" ? getFrameStructure() : _structure); StateStructure structure = (_structure == "" ? getFrameStructure() : _structure);
VectorComposite state; VectorComposite state;
if ( processor_is_motion_list_.empty() ) // Use last estimated frame's state if (not processor_is_motion_list_.empty() ) // Compose from different processor motion
{
auto last_kf_or_aux = trajectory_ptr_->getLastKeyOrAuxFrame();
if (last_kf_or_aux)
state = last_kf_or_aux->getState(structure);
else
state = stateZero(structure);
}
else // Compose from different processor motion
{ {
// compose the states of all processor motions into one only state // compose the states of all processor motions into one only state
for (const auto& prc : processor_is_motion_list_) for (const auto& prc : processor_is_motion_list_)
...@@ -478,6 +470,15 @@ VectorComposite Problem::getState(const StateStructure& _structure) const ...@@ -478,6 +470,15 @@ VectorComposite Problem::getState(const StateStructure& _structure) const
} }
} }
else // Use last estimated frame's state
{
auto last_kf_or_aux = trajectory_ptr_->getLastKeyOrAuxFrame();
if (last_kf_or_aux)
state = last_kf_or_aux->getState(structure);
else
state = stateZero(structure);
}
return state; return state;
} }
...@@ -485,40 +486,45 @@ VectorComposite Problem::getState (const TimeStamp& _ts, const StateStructure& _ ...@@ -485,40 +486,45 @@ VectorComposite Problem::getState (const TimeStamp& _ts, const StateStructure& _
{ {
StateStructure structure = (_structure == "" ? getFrameStructure() : _structure); StateStructure structure = (_structure == "" ? getFrameStructure() : _structure);
if ( processor_is_motion_list_.empty() ) // Use last estimated frame's state VectorComposite state;
if (not processor_is_motion_list_.empty() )
{ {
const auto& last_kf_or_aux = trajectory_ptr_->closestKeyOrAuxFrameToTimeStamp(_ts); for (const auto& prc : processor_is_motion_list_)
if (last_kf_or_aux)
{ {
return last_kf_or_aux->getState(structure); const auto& prc_state = prc->getState(_ts);
// transfer processor vector blocks to problem state
for (const auto& pair_key_vec : prc_state)
{
const auto& key = pair_key_vec.first;
if (state.count(key) == 0) // Only write once. This gives priority to processors upfront in the list
state.insert(pair_key_vec);
}
} }
else
// check for empty blocks and fill them with zeros
for (const auto& ckey : frame_structure_)
{ {
return stateZero(structure); const auto& key = string(1,ckey);
if (state.count(key) == 0)
state.emplace(key, stateZero(key).at(key));
} }
} }
VectorComposite state; else // Use last estimated frame's state
for (const auto& prc : processor_is_motion_list_)
{ {
const auto& prc_state = prc->getState(_ts); const auto& last_kf_or_aux = trajectory_ptr_->closestKeyOrAuxFrameToTimeStamp(_ts);
if (last_kf_or_aux)
// transfer processor vector blocks to problem state
for (const auto& pair_key_vec : prc_state)
{ {
const auto& key = pair_key_vec.first; state = last_kf_or_aux->getState(structure);
}
if (state.count(key) == 0) // Only write once. This gives priority to processors upfront in the list else
state.insert(pair_key_vec); {
state = stateZero(structure);
} }
}
// check for empty blocks and fill them with zeros
for (const auto& ckey : frame_structure_)
{
const auto& key = string(1,ckey);
if (state.count(key) == 0)
state.emplace(key, stateZero(key).at(key));
} }
return state; return state;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment