cluster.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, Robobrain.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 /* Author: Konstantinos Konstantinidis */
31 
32 #pragma once
33 #include <ros/ros.h>
34 #include "l_shape_tracker.hpp"
35 #include <Eigen/Dense>
36 #include <tf/transform_listener.h>
37 #include <visualization_msgs/Marker.h>
38 #include "datmo/Track.h"
41 #include <vector>
42 
43 using namespace Eigen;
44 
45 typedef std::pair<double, double> Point;
46 typedef std::vector<Point> pointList;
47 
48 class Cluster {
49 public:
50 
51  Cluster(unsigned long int id, const pointList&, const double&, const std::string&, const tf::Transform& ego_pose);
52 
53 
54  std::string frame_name;
56 
57  datmo::Track msg_track_box_kf;
58 
59  unsigned long int id; //identifier for the cluster
60  unsigned long int age; //age of the cluster
61  float r, g, b, a; //color of the cluster
62 
63  visualization_msgs::Marker getBoundingBoxCenterVisualisationMessage();
64  visualization_msgs::Marker getClosestCornerPointVisualisationMessage();
65  visualization_msgs::Marker getClusterVisualisationMessage();
66  visualization_msgs::Marker getLineVisualisationMessage();
67  visualization_msgs::Marker getArrowVisualisationMessage();
68  visualization_msgs::Marker getThetaL2VisualisationMessage();
69  visualization_msgs::Marker getThetaL1VisualisationMessage();
70  visualization_msgs::Marker getThetaBoxVisualisationMessage();
71  visualization_msgs::Marker getBoundingBoxVisualisationMessage();
72  visualization_msgs::Marker getBoxModelKFVisualisationMessage();
73  visualization_msgs::Marker getLShapeVisualisationMessage();
74  visualization_msgs::Marker getBoxSolidVisualisationMessage();
75 
76  void update(const pointList&, const double dt, const tf::Transform& ego_pose);
77 
78  std::pair<double, double> mean() { return mean_values; }; //Return mean of cluster.
79  double meanX() { return mean_values.first; };
80  double meanY() { return mean_values.second;};
81 
82  LshapeTracker Lshape;
83 
84  double old_thetaL1;
85  double L1, L2, thetaL1, thetaL2;
86  double cx, cy, cvx, cvy, L1_box, L2_box, th, psi, comega, length_box, width_box;
87  double x_ukf, y_ukf, vx_ukf, vy_ukf, omega_ukf;
88 
89 private:
90 
92  std::vector<Point> corner_list;
93  tf2::Quaternion quaternion; //used for transformations between quaternions and angles
94  std::vector<Point> l1l2; //save coordinates of the three points that define the lines
95 
96  // mean value of the cluster
97  std::pair<double, double> mean_values;
98  std::pair<double, double> previous_mean_values;
99 
101 
102 
103  visualization_msgs::Marker boxcenter_marker_;
104  void populateTrackingMsgs(const double& dt);
105  void calcMean(const pointList& ); //Find the mean value of the cluster
106  void rectangleFitting(const pointList& ); //Search-Based Rectangle Fitting
107  double areaCriterion(const VectorXd&, const VectorXd& );
108  double closenessCriterion(const VectorXd& ,const VectorXd&, const double& );
109  Point lineIntersection(double& , double& , double& , double& , double& , double& );
110  double perpendicularDistance(const Point&, const Point&, const Point&);
111  void ramerDouglasPeucker(const std::vector<Point>&, double, std::vector<Point>&);
112 };
pointList new_cluster
Definition: cluster.hpp:91
datmo::Track msg_track_box_kf
Definition: cluster.hpp:57
std::vector< Point > corner_list
Definition: cluster.hpp:92
double meanX()
Definition: cluster.hpp:79
std::vector< Point > l1l2
Definition: cluster.hpp:94
visualization_msgs::Marker boxcenter_marker_
Definition: cluster.hpp:103
Point closest_corner_point
Definition: cluster.hpp:100
double width_box
Definition: cluster.hpp:86
std::pair< double, double > Point
Definition: cluster.hpp:45
tf::Vector3 Point
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
unsigned long int age
Definition: cluster.hpp:60
float r
Definition: cluster.hpp:61
std::string frame_name
Definition: cluster.hpp:54
std::vector< Point > pointList
Definition: cluster.hpp:46
unsigned long int id
Definition: cluster.hpp:59
double y_ukf
Definition: cluster.hpp:87
double meanY()
Definition: cluster.hpp:80
double old_thetaL1
Definition: cluster.hpp:84
tf2::Quaternion quaternion
Definition: cluster.hpp:93
double thetaL2
Definition: cluster.hpp:85
Point ego_coordinates
Definition: cluster.hpp:55
std::pair< double, double > mean_values
Definition: cluster.hpp:97
std::pair< double, double > previous_mean_values
Definition: cluster.hpp:98
std::pair< double, double > mean()
Definition: cluster.hpp:78


datmo
Author(s): Kostas Konstantinidis
autogenerated on Tue May 2 2023 02:58:06