From bdc4d9cd7a3606176e8e00c20ff91eaa16f3d834 Mon Sep 17 00:00:00 2001 From: phesch <ulila@student.kit.edu> Date: Wed, 6 Jul 2022 20:06:37 +0200 Subject: [PATCH] Add documentation to `getSnapshotsInRange` --- .../libraries/armem/util/prediction_helpers.h | 26 ++++++++++++++++++- .../server/localization/Segment.cpp | 2 +- .../server/proprioception/Segment.cpp | 2 +- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/source/RobotAPI/libraries/armem/util/prediction_helpers.h b/source/RobotAPI/libraries/armem/util/prediction_helpers.h index 3e525d778..484797e3f 100644 --- a/source/RobotAPI/libraries/armem/util/prediction_helpers.h +++ b/source/RobotAPI/libraries/armem/util/prediction_helpers.h @@ -32,6 +32,10 @@ namespace armarx::armem { + /** + * Holds info on snapshot data extracted from a time range. + * Used for performing predictions. + */ template <typename DataType, typename LatestType> struct LatestSnapshotInfo { @@ -43,9 +47,29 @@ namespace armarx::armem LatestType latestValue; }; + /*! + * @brief Get data points for the snapshots of an entity in a given time range. + * + * The resulting `LatestSnapshotInfo` is useful for performing predictions. + * Data from the individual snapshots is given to the conversion functions + * before being stored in the result. + * Timestamps in the `timestampsSec` vector are relative to the endTime parameter + * to this function. + * Data from a snapshot is always retrieved from the instance with index 0. + * If some data cannot be retrieved, `success` is set to `false` + * and the `errorMessage` in the return value is set accordingly. + * + * @param segment the segment to get the snapshot data from + * @param entityID the entity to get the data for + * @param startTime the beginning of the time range + * @param endTime the end of the time range. Timestamps are relative to this value + * @param dictToData the conversion function from `DictPtr` to `DataType` + * @param dictToLatest the conversion function from `DictPtr` to `LatestType` + * @return the corresponding `LatestSnapshotInfo` + */ template <typename SegmentType, typename DataType, typename LatestType> LatestSnapshotInfo<DataType, LatestType> - getLatestSnapshots(const SegmentType* segment, + getSnapshotsInRange(const SegmentType* segment, const MemoryID& entityID, const DateTime& startTime, const DateTime& endTime, diff --git a/source/RobotAPI/libraries/armem_robot_state/server/localization/Segment.cpp b/source/RobotAPI/libraries/armem_robot_state/server/localization/Segment.cpp index 53b404e34..53e8d04fe 100644 --- a/source/RobotAPI/libraries/armem_robot_state/server/localization/Segment.cpp +++ b/source/RobotAPI/libraries/armem_robot_state/server/localization/Segment.cpp @@ -214,7 +214,7 @@ namespace armarx::armem::server::robot_state::localization doLocked( [&, this]() { - info = getLatestSnapshots<server::wm::CoreSegment, + info = getSnapshotsInRange<server::wm::CoreSegment, Eigen::Vector3d, arondto::Transform>( segmentPtr, diff --git a/source/RobotAPI/libraries/armem_robot_state/server/proprioception/Segment.cpp b/source/RobotAPI/libraries/armem_robot_state/server/proprioception/Segment.cpp index de7b389d4..8c2c431fd 100644 --- a/source/RobotAPI/libraries/armem_robot_state/server/proprioception/Segment.cpp +++ b/source/RobotAPI/libraries/armem_robot_state/server/proprioception/Segment.cpp @@ -231,7 +231,7 @@ namespace armarx::armem::server::robot_state::proprioception // Default capture because the number of variables was getting out of hand [&, this]() { - info = getLatestSnapshots<server::wm::CoreSegment, + info = getSnapshotsInRange<server::wm::CoreSegment, Eigen::VectorXd, aron::data::DictPtr>( segmentPtr, -- GitLab