37 ROS_INFO(
"Starting Detection And Tracking of Moving Objects");
42 n_private.
param(
"threshold_distance",
dth, 0.2);
58 visualization_msgs::Marker marker;
59 visualization_msgs::MarkerArray markera;
61 markera.markers.push_back(marker);
76 auto start = chrono::steady_clock::now();
78 vector<pointList> point_clusters_not_transformed;
82 vector<pointList> point_clusters;
83 for (
unsigned int i = 0; i < point_clusters_not_transformed.size(); ++i) {
86 point_clusters.push_back(point_cluster);
93 vector<bool> g_matched(point_clusters.size(),
false);
94 vector<bool> c_matched(
clusters.size(),
false);
96 double euclidean[point_clusters.size()][
clusters.size()];
99 double mean_x = 0, mean_y = 0;
101 for(
unsigned int g = 0; g<point_clusters.size();++g){
102 double sum_x = 0, sum_y = 0;
104 for(
unsigned int l =0; l<point_clusters[g].size(); l++){
105 sum_x = sum_x + point_clusters[g][l].first;
106 sum_y = sum_y + point_clusters[g][l].second;
108 mean_x = sum_x / point_clusters[g].size();
109 mean_y = sum_y / point_clusters[g].size();
111 for(
unsigned int c=0;c<
clusters.size();++c){
117 vector<pair <int,int>> pairs;
118 for(
unsigned int c=0; c<
clusters.size();++c){
119 unsigned int position;
121 for(
unsigned int g=0; g<point_clusters.size();++g){
122 if(euclidean[g][c] < min_distance){
123 min_distance = euclidean[g][c];
128 g_matched[position] =
true, c_matched[c] =
true;
129 pairs.push_back(pair<int,int>(c,position));
134 #pragma omp parallel for 135 for(
unsigned int p=0; p<pairs.size();++p){
136 clusters[pairs[p].first].update(point_clusters[pairs[p].second],
dt, ego_pose);
143 if(c_matched[o] ==
false){
148 std::swap(c_matched[o], c_matched.back());
149 c_matched.pop_back();
158 for(
unsigned int i=0; i<point_clusters.size();++i){
167 visualization_msgs::MarkerArray marker_array;
168 datmo::TrackArray track_array_box_kf;
169 for (
unsigned int i =0; i<
clusters.size();i++){
171 track_array_box_kf.tracks.push_back(
clusters[i].msg_track_box_kf);
174 marker_array.markers.push_back(
clusters[i].getClosestCornerPointVisualisationMessage());
175 marker_array.markers.push_back(
clusters[i].getBoundingBoxCenterVisualisationMessage());
176 marker_array.markers.push_back(
clusters[i].getArrowVisualisationMessage());
177 marker_array.markers.push_back(
clusters[i].getThetaL1VisualisationMessage());
178 marker_array.markers.push_back(
clusters[i].getThetaL2VisualisationMessage());
179 marker_array.markers.push_back(
clusters[i].getThetaBoxVisualisationMessage());
180 marker_array.markers.push_back(
clusters[i].getClusterVisualisationMessage());
181 marker_array.markers.push_back(
clusters[i].getBoundingBoxVisualisationMessage());
182 marker_array.markers.push_back(
clusters[i].getBoxModelKFVisualisationMessage());
183 marker_array.markers.push_back(
clusters[i].getLShapeVisualisationMessage());
184 marker_array.markers.push_back(
clusters[i].getLineVisualisationMessage());
185 marker_array.markers.push_back(
clusters[i].getBoxSolidVisualisationMessage());
200 visualization_msgs::MarkerArray marker_array;
202 visualization_msgs::Marker gpoints;
205 gpoints.ns =
"clustered_points";
206 gpoints.action = visualization_msgs::Marker::ADD;
207 gpoints.pose.orientation.w = 1.0;
208 gpoints.type = visualization_msgs::Marker::POINTS;
210 gpoints.scale.x = 0.04;
211 gpoints.scale.y = 0.04;
212 for(
unsigned int i=0; i<point_clusters.size(); ++i){
216 gpoints.color.g = rand() / double(RAND_MAX);
217 gpoints.color.b = rand() / double(RAND_MAX);
218 gpoints.color.r = rand() / double(RAND_MAX);
219 gpoints.color.a = 1.0;
221 for(
unsigned int j=0; j<point_clusters[i].size(); ++j){
223 p.x = point_clusters[i][j].first;
224 p.y = point_clusters[i][j].second;
226 gpoints.points.push_back(p);
228 marker_array.markers.push_back(gpoints);
229 gpoints.points.clear();
241 for (
unsigned int i = 0; i <
scan.ranges.size(); ++i){
242 if(isinf(
scan.ranges[i]) == 0){
246 const int c_points = cpoints;
249 vector< vector<float> > polar(c_points +1 ,vector<float>(2));
250 for(
unsigned int i = 0; i<
scan.ranges.size(); ++i){
251 if(!isinf(
scan.ranges[i])){
252 polar[j][0] =
scan.ranges[i];
253 polar[j][1] =
scan.angle_min + i*
scan.angle_increment;
259 polar[c_points] = polar[0];
265 vector<bool> clustered1(c_points+1 ,
false);
266 vector<bool> clustered2(c_points+1 ,
false);
271 for (
unsigned int i=0; i < c_points ; ++i){
272 double dtheta = polar[i+1][1]- polar[i][1];
273 double adaptive =
min(polar[i][0],polar[i+1][0]) * (
sin(
dth)) / (
sin(l - (
dth))) + s;
274 d =
sqrt(
pow(polar[i][0],2) +
pow(polar[i+1][0],2)-2 * polar[i][0]*polar[i+1][0]*
cos(polar[i+1][1] - polar[i][1]));
281 clustered1[i] =
true;
282 clustered2[i+1] =
true;}
285 clustered2[0] = clustered2[c_points];
293 while(i<c_points && flag==
true){
295 if (clustered1[i] ==
true && clustered2[i] ==
false && flag ==
true){
298 while(clustered2[i+1] ==
true && clustered1[i+1] ==
true ){
301 if(i==c_points-1 && flag ==
true){
311 if(clustered1[cpoints-1]==
true and clustered2[c_points-1] ==
false){
312 begin.push_back(cpoints-1);
315 while(clustered2[i] ==
true && clustered1[i] ==
true ){
323 int len = polar.size();
325 for(
unsigned int i=0; i<begin.size(); ++i){
333 while (j<nclus[i]+begin[i]){
334 if(j== len && fl ==
true) fl =
false;
337 x = polar[j][0] *
cos(polar[j][1]);
338 y = polar[j][0] *
sin(polar[j][1]);
341 x = polar[j-len][0] *
cos(polar[j-len][1]);
342 y = polar[j-len][0] *
sin(polar[j-len][1]);
344 cluster.push_back(
Point(x, y));
347 clusters.push_back(cluster);
355 geometry_msgs::PointStamped point_in, point_out;
359 for (
unsigned int i = 0; i < in.size(); ++i) {
360 point_in.point.x = in[i].first;
361 point_in.point.y = in[i].second;
363 point.first = point_out.point.x;
364 point.second= point_out.point.y;
365 out.push_back(point);
ros::Publisher pub_marker_array
#define ROS_WARN_DELAYED_THROTTLE(period,...)
tf::TransformListener tf_listener
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
std::pair< double, double > Point
void transformPointList(const pointList &, pointList &)
vector< Cluster > clusters
sensor_msgs::LaserScan scan
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
void publish(const boost::shared_ptr< M > &message) const
std::vector< Point > pointList
void Clustering(const sensor_msgs::LaserScan::ConstPtr &, vector< pointList > &)
ros::Publisher pub_tracks_box_kf
void visualiseGroupedPoints(const vector< pointList > &)
double euclidean_distance
double min(double a, double b)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
INLINE Rall1d< T, V, S > sqrt(const Rall1d< T, V, S > &arg)
INLINE Rall1d< T, V, S > pow(const Rall1d< T, V, S > &arg, double m)
INLINE Rall1d< T, V, S > abs(const Rall1d< T, V, S > &x)
void callback(const sensor_msgs::LaserScan::ConstPtr &)
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
unsigned long int cclusters
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)