My Project
1.0
Holistic Fusion: A Generic Framework for Multimodal Sensor Fusion
Loading...
Searching...
No Matches
Trajectory.h
Go to the documentation of this file.
1
#ifndef HOLISTIC_FUSION_TRAJECTORY_H
2
#define HOLISTIC_FUSION_TRAJECTORY_H
3
4
#include "
holistic_fusion/geometry/Pose.h
"
5
6
namespace
holistic_fusion
{
7
12
class
Trajectory
{
13
public
:
14
Trajectory
() :
_poses
(std::vector<
Pose
>()) {}
15
16
Trajectory
(
const
Trajectory
& other) :
_poses
(other.
_poses
) {}
17
18
void
addPose
(Eigen::Vector3d position,
double
time) {
19
Pose
newPose(position, Eigen::Vector4d(0.0, 0.0, 0.0, 1.0), time);
20
_poses
.push_back(newPose);
21
}
22
23
void
addPose
(
Pose
pose) {
_poses
.push_back(pose); }
24
25
double
distance
() {
26
double
distance
= 0.0;
27
if
(
_poses
.size() < 2)
return
distance
;
28
Eigen::Vector3d lastPose =
_poses
.front().position();
29
for
(
auto
poseIt = std::next(
_poses
.begin()); poseIt !=
_poses
.end(); ++poseIt) {
30
distance
+= ((poseIt->position() - lastPose).norm());
31
lastPose = poseIt->position();
32
}
33
34
return
distance
;
35
}
36
37
bool
isStanding
(
const
double
rate,
const
double
seconds,
const
double
& noMovementThreshold) {
38
if
(
_poses
.size() < rate * seconds) {
39
return
false
;
40
}
41
42
double
distance
= 0.0;
43
Eigen::Vector3d lastPose = (
_poses
.end() - rate * seconds)->position();
44
for
(
auto
poseIt =
_poses
.end() - rate * seconds + 1; poseIt !=
_poses
.end(); ++poseIt) {
45
distance
+= ((poseIt->position() - lastPose).norm());
46
lastPose = poseIt->position();
47
}
48
return
distance
< noMovementThreshold;
49
}
50
51
std::vector<Pose>
poses
()
const
{
return
_poses
; }
52
53
// Cut the trajectory to the time window
54
void
cutTrajectory
(
const
double
& startTime,
const
double
& endTime) {
55
// Find the first pose that is within the time window
56
auto
firstPose = std::find_if(
_poses
.begin(),
_poses
.end(), [startTime](
const
Pose
& pose) { return pose.time() >= startTime; });
57
// Find the last pose that is within the time window
58
auto
lastPose = std::find_if(
_poses
.rbegin(),
_poses
.rend(), [endTime](
const
Pose
& pose) { return pose.time() <= endTime; });
59
// Erase the poses outside the time window
60
_poses
.erase(lastPose.base(),
_poses
.end());
61
_poses
.erase(
_poses
.begin(), firstPose);
62
}
63
64
// Downsample the trajectory by a factor
65
void
downsample
(
const
int
& factor) {
66
std::vector<Pose> downsampledPoses;
67
for
(
int
i = 0; i <
_poses
.size(); i += factor) {
68
downsampledPoses.push_back(
_poses
[i]);
69
}
70
_poses
= downsampledPoses;
71
}
72
73
private
:
74
std::vector<Pose>
_poses
;
75
};
76
77
}
// namespace holistic_fusion
78
79
#endif
// HOLISTIC_FUSION_TRAJECTORY_H
Pose.h
holistic_fusion::Pose
Class for holding a pose.
Definition
Pose.h:12
holistic_fusion::Trajectory::addPose
void addPose(Eigen::Vector3d position, double time)
Definition
Trajectory.h:18
holistic_fusion::Trajectory::cutTrajectory
void cutTrajectory(const double &startTime, const double &endTime)
Definition
Trajectory.h:54
holistic_fusion::Trajectory::Trajectory
Trajectory(const Trajectory &other)
Definition
Trajectory.h:16
holistic_fusion::Trajectory::downsample
void downsample(const int &factor)
Definition
Trajectory.h:65
holistic_fusion::Trajectory::addPose
void addPose(Pose pose)
Definition
Trajectory.h:23
holistic_fusion::Trajectory::poses
std::vector< Pose > poses() const
Definition
Trajectory.h:51
holistic_fusion::Trajectory::_poses
std::vector< Pose > _poses
Definition
Trajectory.h:74
holistic_fusion::Trajectory::distance
double distance()
Definition
Trajectory.h:25
holistic_fusion::Trajectory::Trajectory
Trajectory()
Definition
Trajectory.h:14
holistic_fusion::Trajectory::isStanding
bool isStanding(const double rate, const double seconds, const double &noMovementThreshold)
Definition
Trajectory.h:37
holistic_fusion
Absolute.
Definition
AdmissibleGtsamSymbols.h:11
holistic_fusion
include
holistic_fusion
geometry
Trajectory.h
Generated by
1.15.0