Feature.cpp
Go to the documentation of this file.
1 #include "omip_common/Feature.h"
2 
3 #include <ros/ros.h>
4 
5 using namespace omip;
6 
8 
10  _id(Feature::_feature_id_generator++), _first_location(0.0, 0.0, 0.0), _birthday(
11  -1)
12 {
13 }
14 
15 Feature::Feature(int feature_birthday, Location first_fl_in) :
17  feature_birthday)
18 {
19  this->_trajectory.push_back(first_fl_in);
20 }
21 
22 // To be used when the feature Ids are set externally
23 Feature::Feature(int feature_birthday, Location first_fl_in, Id f_id) :
24  _id(f_id), _first_location(first_fl_in), _birthday(feature_birthday)
25 {
26  this->_trajectory.push_back(first_fl_in);
27 }
28 
30 {
31  this->_id = f.getId();
33  this->_birthday = f.getFeatureBirthday();
34  this->_trajectory = f.getTrajectory();
35 }
36 
38 {
39 
40 }
41 
43 {
44  return (Ptr(doClone()));
45 }
46 
48 {
49  if (this->_trajectory.size() == 0)
50  {
51  this->_first_location = fl_in;
52  }
53  this->_trajectory.push_back(fl_in);
54 }
55 
57 {
58  return this->_id;
59 }
60 
62 {
63  return this->_first_location;
64 }
65 
67 {
68  if (this->_trajectory.size() == 0)
69  {
71  "Feature.getLastLocation",
72  "Feature with Id " << this->_id << " has no last location.");
73  return Location();
74  }
75  else
76  {
77  return this->_trajectory.back();
78  }
79 }
80 
82 {
83  if (this->_trajectory.size() < 2)
84  {
86  "Feature.getNextToLastLocation",
87  "Feature with Id " << this->_id << " has no next to last location.");
88  return Location();
89  }
90  else
91  {
92  return this->_trajectory.at(this->_trajectory.size() - 2);
93  }
94 }
95 
97 {
99 }
100 
102 {
103  if ((int)this->_trajectory.size() - frames_to_last - 1 < 0)
104  {
106  "Feature.getNToLastLocation",
107  "Feature with Id " << this->_id << " was not born at that time (" << frames_to_last << " frames to last < feature age = " << this->_trajectory.size() <<").");
108  return Location();
109  }
110  else
111  {
112  return this->_trajectory.at(this->_trajectory.size() - frames_to_last -1);
113  }
114 }
115 
117 {
118  return this->_trajectory;
119 }
120 
121 //void Feature::getTrajectory(const Feature::Trajectory& feat_traject) const
122 //{
123 // feat_traject = this->_trajectory;
124 //}
125 
127 {
128  return this->_trajectory.size();
129 }
130 
132 {
133  return this->_birthday;
134 }
135 
136 double Feature::getLastX() const
137 {
138  return boost::tuples::get<0>(this->getLastLocation());
139 }
140 
141 double Feature::getLastY() const
142 {
143  return boost::tuples::get<1>(this->getLastLocation());
144 }
145 
146 double Feature::getLastZ() const
147 {
148  return boost::tuples::get<2>(this->getLastLocation());
149 }
150 
151 void Feature::setFeatureBirthday(int feature_birthday)
152 {
153  this->_birthday = feature_birthday;
154 }
155 
Location getFirstLocation() const
Definition: Feature.cpp:61
virtual Feature * doClone() const
Definition: Feature.h:208
boost::shared_ptr< Feature > Ptr
Definition: Feature.h:53
boost::tuple< double, double, double > Location
Definition: Feature.h:59
double getLastX() const
Definition: Feature.cpp:136
Location getNToLastLocation(int frames_to_last) const
Definition: Feature.cpp:101
#define ROS_ERROR_STREAM_NAMED(name, args)
void addLocation(Location fl_in)
Definition: Feature.cpp:47
static Id _feature_id_generator
Definition: Feature.h:193
Minimal class that represents a Point of Interest by an ID and stores its successive locations $Autho...
Definition: Feature.h:48
double getLastY() const
Definition: Feature.cpp:141
Location _first_location
Definition: Feature.h:202
std::pair< Location, Location > LocationPair
Definition: Feature.h:65
int _birthday
Definition: Feature.h:205
const Trajectory & getTrajectory() const
Definition: Feature.cpp:116
Ptr clone() const
Definition: Feature.cpp:42
Location getLastLocation() const
Definition: Feature.cpp:66
size_t getFeatureAge() const
Definition: Feature.cpp:126
Id getId() const
Definition: Feature.cpp:56
std::vector< Location > Trajectory
Definition: Feature.h:62
void setFeatureBirthday(int feature_birthday)
Definition: Feature.cpp:151
Location getNextToLastLocation() const
Definition: Feature.cpp:81
double getLastZ() const
Definition: Feature.cpp:146
Trajectory _trajectory
Definition: Feature.h:199
Definition: Feature.h:40
int getFeatureBirthday() const
Definition: Feature.cpp:131
virtual ~Feature()
Definition: Feature.cpp:37
LocationPair getTwoLastLocations() const
Definition: Feature.cpp:96


omip_common
Author(s): Roberto Martín-Martín
autogenerated on Mon Jun 10 2019 14:06:05