@@ -55,9 +55,9 @@ std::optional<Mat::RTMat> RT_API::get_edge_RT_as_rtmat(const Edge &edge, std::u
5555 const auto &r = r_o.value ().get ();
5656 if (timestamp == 0 ) // return with the first 3 elements of the arrays
5757 {
58- if (head_o.has_value () and tstamps_o. has_value () )
58+ if (head_o.has_value ())
5959 {
60- const auto &head = head_o.value ();
60+ const auto &head = prev ( head_o.value (), t. size (), 3 );
6161 // qInfo() << __FUNCTION__ << " ZERO " << static_cast<int64_t>(timestamp) << static_cast<int64_t>(tstamps_o.value().get()[(int)(head/BLOCK_SIZE)]);
6262 return Mat::RTMat (Eigen::Translation3d (t[head], t[head+1 ], t[head+2 ]) *
6363 Eigen::AngleAxisd (r[head], Eigen::Vector3d::UnitX ()) *
@@ -117,9 +117,10 @@ std::optional<Eigen::Vector3d> RT_API::get_translation(const Node &n, uint64_t t
117117 const auto &t = t_o.value ().get ();
118118 if (timestamp == 0 )
119119 {
120- if (head_o.has_value () and tstamps_o.has_value ())
121- return Eigen::Vector3d (t[head_o.value ()], t[head_o.value () + 1 ], t[head_o.value () + 2 ]);
122- else
120+ if (head_o.has_value () and tstamps_o.has_value ()){
121+ auto h = prev (head_o.value (), t.size (), 3 );
122+ return Eigen::Vector3d (t[h], t[h + 1 ], t[h + 2 ]);
123+ } else
123124 return Eigen::Vector3d (t[0 ], t[1 ], t[2 ]);
124125 }
125126 else // timestamp not 0
@@ -216,8 +217,6 @@ void RT_API::insert_or_assign_edge_RT(Node &n, uint64_t to, const std::vector<fl
216217 std::chrono::system_clock::now ().time_since_epoch ()).count ());
217218
218219
219- constexpr auto next = [](auto v, auto size) { return (v + 1 ) % size; };
220- constexpr auto prev = [](auto v, auto size) { return (v > 0 ) ? v - 1 : size - 1 ; };
221220
222221 if (timestamp_v < time_stamps[prev (timestamp_index, HISTORY_SIZE)]) {
223222 std::vector<int64_t > diffs;
@@ -405,8 +404,6 @@ void RT_API::insert_or_assign_edge_RT(Node &n, uint64_t to, std::vector<float> &
405404 std::chrono::duration_cast<std::chrono::milliseconds>(
406405 std::chrono::system_clock::now ().time_since_epoch ()).count ());
407406
408- constexpr auto next = [](auto v, auto size) { return (v + 1 ) % size; };
409- constexpr auto prev = [](auto v, auto size) { return (v > 0 ) ? v - 1 : size - 1 ; };
410407
411408 if (timestamp_v < time_stamps[prev (timestamp_index, HISTORY_SIZE)]) {
412409 std::vector<int64_t > diffs;
0 commit comments