Skip to content
Snippets Groups Projects
Commit 70017378 authored by Joaquim Casals Buñuel's avatar Joaquim Casals Buñuel
Browse files

Add time tolerance check in CaptureBase

parent 921f43b0
No related branches found
No related tags found
1 merge request!376WIP: Resolve "Add time stamp tolerance to problem::check()"
Pipeline #5748 passed
......@@ -359,6 +359,8 @@ class ProcessorBase : public NodeBase, public std::enable_shared_from_this<Proce
int getDim() const;
double getTimeTolerance() const;
void link(SensorBasePtr);
template<typename classType, typename... T>
static std::shared_ptr<classType> emplace(SensorBasePtr _sen_ptr, T&&... all);
......@@ -426,6 +428,10 @@ inline int ProcessorBase::getDim() const
{
return dim_;
}
inline double ProcessorBase::getTimeTolerance() const
{
return params_->time_tolerance;
}
template<typename classType, typename... T>
std::shared_ptr<classType> ProcessorBase::emplace(SensorBasePtr _sen_ptr, T&&... all)
......
......@@ -363,7 +363,7 @@ CheckLog CaptureBase::localCheck(bool _verbose, CaptureBasePtr _cap_ptr, std::os
auto frm_cap = _cap_ptr->getFrame();
inconsistency_explanation << "Cap" << id() << " @ " << _cap_ptr
<< " ---> Frm" << frm_cap->id() << " @ " << frm_cap
<< " -X-> Frm" << id();
<< " -X-> Frm" << id() << "\n";
auto frm_cap_list = frm_cap->getCaptureList();
auto frame_has_cap = std::find_if(frm_cap_list.begin(), frm_cap_list.end(), [&_cap_ptr](CaptureBasePtr cap){ return cap == _cap_ptr;});
log.assertTrue(frame_has_cap != frm_cap_list.end(), inconsistency_explanation);
......@@ -375,6 +375,28 @@ CheckLog CaptureBase::localCheck(bool _verbose, CaptureBasePtr _cap_ptr, std::os
<< " -X-> Cap" << id();
log.assertTrue((f->getCapture() == _cap_ptr), inconsistency_explanation);
}
//Check that the capture is within time tolerance of some processor
auto frame = getFrame();
double time_diff = fabs(getTimeStamp() - frame->getTimeStamp());
//It looks like some gtests add captures by hand, without using processors, so the processor list is empty.
//This inicialization is needed because if the list empty the execution does not go into the loop and the
//assertion fails
bool match_any_prc_timetolerance;
if(getSensor() != nullptr )
{
match_any_prc_timetolerance = getSensor()->getProcessorList().empty();
for(auto const& prc : getSensor()->getProcessorList())
{
match_any_prc_timetolerance = match_any_prc_timetolerance or (time_diff <= prc->getTimeTolerance());
}
inconsistency_explanation << "Cap " << id() << " @ " << _cap_ptr
<< " ts =" << getTimeStamp() << ((frame->isKey()) ? "KFrm" : "Frm") << frame->id()
<< " ts = " << frame->getTimeStamp() << " their time difference (" << time_diff << ") does not match any time tolerance of"
<< " any processor in sensor " << getSensor()->id() << "\n";
log.assertTrue((match_any_prc_timetolerance), inconsistency_explanation);
}
return log;
}
bool CaptureBase::check(CheckLog& _log, std::shared_ptr<NodeBase> _node_ptr, bool _verbose, std::ostream& _stream, std::string _tabs) const
......
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