Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tf2/include/tf2/time_cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ class StaticCache : public TimeCacheInterface

private:
TransformStorage storage_;
bool populated_{false};
};
} // namespace tf2
#endif // TF2__TIME_CACHE_HPP_
19 changes: 14 additions & 5 deletions tf2/src/static_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ bool tf2::StaticCache::getData(
tf2::TimePoint time,
tf2::TransformStorage & data_out, std::string * error_str, TF2Error * error_code)
{
(void)error_code;
(void)error_str;
(void)time;
if (!populated_) {
if (error_str) {
*error_str = "Static cache is empty";
}
if (error_code) {
*error_code = TF2Error::TF2_LOOKUP_ERROR;
}
return false;
}
data_out = storage_;
data_out.stamp_ = time;
return true;
Expand All @@ -50,12 +58,13 @@ bool tf2::StaticCache::getData(
bool tf2::StaticCache::insertData(const tf2::TransformStorage & new_data)
{
storage_ = new_data;
populated_ = true;
return true;
}

void tf2::StaticCache::clearList() {}
void tf2::StaticCache::clearList() {populated_ = false;}

unsigned tf2::StaticCache::getListLength() {return 1;}
unsigned tf2::StaticCache::getListLength() {return populated_ ? 1 : 0;}

tf2::CompactFrameID tf2::StaticCache::getParent(
tf2::TimePoint time, std::string * error_str,
Expand All @@ -64,7 +73,7 @@ tf2::CompactFrameID tf2::StaticCache::getParent(
(void)time;
(void)error_code;
(void)error_str;
return storage_.frame_id_;
return populated_ ? storage_.frame_id_ : 0;
}

tf2::P_TimeAndFrameID tf2::StaticCache::getLatestTimeAndParent()
Expand Down