Object.cpp
Go to the documentation of this file.
1 
18 #include "Object.h"
19 
20 
21 Object::Object():ObjectName("")
22 {
23  Average = ObjectPointSharedPointer(new ObjectPoint(0,0,0,-1)); //-1 is the ID for AveragePos point
24  ObjectsCount= 0;
25  PosVar = 0.0;
27  PresenceInScene = 0.0;
28  NormalizedPosVar = 0.0;
30  rankValue = 0.0;
31  RankingMethod = 0;
32  Alpha = 0;
33  Beta = 0;
34  Gamma = 0;
35 }
36 
37 Object::Object(std::string objectName, std::string observedId, int rankingMethodEntry, double alphaEntry, double betaEntry, double gammaEntry)
38 :ObjectName(objectName),ObservedId(observedId),RankingMethod(rankingMethodEntry),Alpha(alphaEntry),Beta(betaEntry),Gamma(gammaEntry)
39 {
40  Average = ObjectPointSharedPointer(new ObjectPoint(0,0,0,-1)); //-1 is the ID for AveragePos point
41  ObjectsCount= 0;
42  PosVar = 0.0;
44  PresenceInScene = 0.0;
45  NormalizedPosVar = 0.0;
47  rankValue = 0.0;
48 }
49 
51 {
52 
53 }
54 
56 {
57  double mx = 0;
58  double my = 0;
59  double mz = 0;
60  //To get the average pos we "sum" the points, that compose the Object.
61  for (std::vector<ObjectPointSharedPointer>::iterator pointIterator = PointList.begin() ; pointIterator != PointList.end(); ++pointIterator)
62  {
63  mx += (*pointIterator)->getX();
64  my += (*pointIterator)->getY();
65  mz += (*pointIterator)->getZ();
66  }
67  Average->updatePoint(mx/ObjectsCount,my/ObjectsCount,mz/ObjectsCount); //divide by the number of points recorded for the object.
68  ROS_DEBUG_STREAM("IObjects::CalcAveragePos object " << this->ObjectName << " average position (x,y,z):("
69  << Average->getX() << ", " << Average->getY() << ", " << Average->getZ() << ")");
70 }
71 
73 {
74 
75  double vx;
76  double vy;
77  double vz;
78  //for each point, calc the average distance to average position.
79  for (std::vector<ObjectPointSharedPointer>::iterator pointIterator = PointList.begin() ; pointIterator != PointList.end(); ++pointIterator)
80  {
81  vx = pow((*pointIterator)->getX() - Average->getX(),2);
82  vy = pow((*pointIterator)->getY() - Average->getY(),2);
83  vz = pow((*pointIterator)->getZ() - Average->getZ(),2);
84  ROS_DEBUG_STREAM("IObjects::CalcPosVar object " << this->ObjectName <<
85  " got values for position variation (vx,vy,vz):("
86  << vx << ", " << vy << ", " << vz << ")");
87  PosVar += sqrt(vx + vy + vz);
88  ROS_DEBUG_STREAM("IObjects::CalcPosVar incremented position variation " << this->PosVar);
89 
90  }
91  PosVar = PosVar/ObjectsCount; //divide result by number of points.
92  ROS_DEBUG_STREAM("IObjects::CalcPosVar final position variation " << this->PosVar);
93 }
94 
96 {
97  //Average the different criteria to get the rank value ( between 0 and 1 ) for the object.
98  if(RankingMethod == 0)
99  {
101  }
102  else if(RankingMethod == 1)
103  {
105  }
106 }
107 
109 {
110  ROS_DEBUG_STREAM("IObjects::DisplayStats displaying stats for object" << ObjectName);
111  ROS_DEBUG_STREAM("IObjects::DisplayStats presence in scene " << PresenceInScene);
112  ROS_DEBUG_STREAM("IObjects::DisplayStats average position variation " << PosVar);
113  ROS_DEBUG_STREAM("IObjects::DisplayStats normalized average position variation " << NormalizedPosVar);
114  ROS_DEBUG_STREAM("IObjects::DisplayStats average distance to other objects "
116  ROS_DEBUG_STREAM("IObjects::DisplayStats normalized average distance to other objects "
118  ROS_DEBUG_STREAM("IObjects::DisplayStats rank value " << rankValue);
119 }
120 
121 void Object::publishLogs(std::string filePath)
122 {
123  std::ofstream file(filePath, std::ios::out | std::ios::app);
124  if(file)
125  {
126  file << std::endl <<"Object " << this->ObjectName << std::endl;
127  file << "Pos Var " << PosVar << std::endl;
128  file << "Presence in scene " << PresenceInScene << std::endl;
129  file << "AverageDistanceToOtherObjects " << AverageDistanceToOtherObjects << std::endl;
130  file << "Normalized Pos " << NormalizedPosVar << std::endl;
131  file << "Normalized distance " << NormalizedAverageDistanceToOtherObjects << std::endl;
132  file << "Rank value " << rankValue << std::endl;
133  file.close();
134  }
135 }
double NormalizedPosVar
Definition: Object.h:40
double AverageDistanceToOtherObjects
Definition: Object.h:38
void publishLogs(std::string filePath)
Definition: Object.cpp:121
void rank()
Definition: Object.cpp:95
double Beta
Definition: Object.h:44
void CalcAveragePos()
Definition: Object.cpp:55
void CalcPosVar()
Definition: Object.cpp:72
std::string ObservedId
Definition: Object.h:33
int ObjectsCount
Definition: Object.h:35
double rankValue
Definition: Object.h:42
void DisplayStats()
Definition: Object.cpp:108
int RankingMethod
Definition: Object.h:36
double PresenceInScene
Definition: Object.h:39
double Gamma
Definition: Object.h:45
std::string ObjectName
Definition: Object.h:32
double PosVar
Definition: Object.h:37
#define ROS_DEBUG_STREAM(args)
Object()
Definition: Object.cpp:21
std::shared_ptr< ObjectPoint > ObjectPointSharedPointer
Definition: Object.h:28
virtual ~Object()
Definition: Object.cpp:50
double Alpha
Definition: Object.h:43
ObjectPointSharedPointer Average
Definition: Object.h:34
std::vector< ObjectPointSharedPointer > PointList
Definition: Object.h:46
double NormalizedAverageDistanceToOtherObjects
Definition: Object.h:41


asr_intermediate_object_generator
Author(s): Borella Jocelyn, Meißner Pascal
autogenerated on Thu Nov 21 2019 03:53:41