igvcsearchproblem.cpp
Go to the documentation of this file.
1 #include "igvcsearchproblem.h"
2 
3 using namespace pcl;
4 
6 {
7  pcl::KdTreeFLANN<pcl::PointXYZ> kdtree;
8  std::list<SearchMove> acts;
9 
10  if(Map == nullptr)
11  return acts;
12 
13  if(!Map->empty())
14  kdtree.setInputCloud(Map);
15 
16  double delta = 0.05;
17  double Wmin = -0.8;
18  double Wmax = 0.8;
19  for(double W = Wmin; W <= Wmax; W+=delta)
20  {
21  SearchMove move(Speed, W, DeltaT);
22  SearchLocation result = getResult(state, move);
23  pcl::PointXYZ searchPoint(result.x, result.y,0);
24  std::vector<int> pointIdxRadiusSearch;
25  std::vector<float> pointRadiusSquaredDistance;
26  if ( Map->empty() || kdtree.radiusSearch(searchPoint, Threshold, pointIdxRadiusSearch, pointRadiusSquaredDistance) == 0 )
27  {
28  acts.push_back(move);
29  }
30  }
31  if(acts.size() == 0)
32  {
33  for(double W = Wmin; W <= Wmax; W+=delta)
34  {
35  SearchMove move = SearchMove(-Speed, W, DeltaT);
36  SearchLocation result = getResult(state, move);
37  pcl::PointXYZ searchPoint = pcl::PointXYZ(result.x, result.y,0);
38  std::vector<int> pointIdxRadiusSearch;
39  std::vector<float> pointRadiusSquaredDistance;
40  if ( Map->empty() || kdtree.radiusSearch(searchPoint, Threshold, pointIdxRadiusSearch, pointRadiusSquaredDistance) == 0 )
41  {
42  acts.push_back(move);
43  }
44  }
45  }
46  if(PointTurnsEnabled){
47  SearchMove move(0, TurningSpeed, DeltaT);
48  SearchLocation result = getResult(state, move);
49  pcl::PointXYZ searchPoint(result.x, result.y,0);
50  std::vector<int> pointIdxRadiusSearch;
51  std::vector<float> pointRadiusSquaredDistance;
52  if ( Map->empty() || kdtree.radiusSearch(searchPoint, Threshold, pointIdxRadiusSearch, pointRadiusSquaredDistance) == 0 )
53  {
54  acts.push_back(move);
55  }
56  move = SearchMove(0, -TurningSpeed, DeltaT);
57  result = getResult(state, move);
58  searchPoint = pcl::PointXYZ(result.x, result.y,0);
59  pointIdxRadiusSearch.clear();
60  pointRadiusSquaredDistance.clear();
61  if ( kdtree.radiusSearch(searchPoint, Threshold, pointIdxRadiusSearch, pointRadiusSquaredDistance) == 0 )
62  {
63  acts.push_back(move);
64  }
65  }
66 
67  return acts;
68 }
69 
71 {
72  SearchLocation result;
73  if(abs(action.W) > 1e-10)
74  {
75  double w = action.W;
76  double R = action.V / action.W;
77  double ICCx = state.x - ( R * cos(M_PI - state.theta) );
78  double ICCy = state.y - ( R * sin(M_PI - state.theta) );
79  using namespace Eigen;
80  Matrix3d T;
81  double wdt = w*DeltaT;
82  T << cos(wdt), sin(wdt), 0, -sin(wdt), cos(wdt), 0, 0, 0, 1;
83  Vector3d a(state.x - ICCx, state.y - ICCy, state.theta);
84  Vector3d b = T*a;
85  Vector3d c = b + Vector3d(ICCx, ICCy, wdt);
86  //Vector3d b(ICCx, ICCy, wdt);
87  //Vector3d c = T * a + b;
88  result.x = c[0];
89  result.y = c[1];
90  result.theta = c[2];
91  while(result.theta < 0)
92  result.theta += 2*M_PI;
93  while(result.theta > 2*M_PI)
94  result.theta -= 2*M_PI;
95  }
96  else
97  {
98  result.theta = state.theta;
99  result.x = state.x + ( cos(M_PI_2 - result.theta) * action.V * DeltaT );
100  result.y = state.y + ( sin(M_PI_2 - result.theta) * action.V * DeltaT );
101  }
102  return result;
103 }
double V
Definition: searchmove.h:9
std::list< SearchMove > getActions(SearchLocation state)
SearchLocation getResult(SearchLocation state, SearchMove action)
igvc_msgs::lights state
double W
Definition: searchmove.h:9


igvc
Author(s): Matthew Barulic , Al Chaussee
autogenerated on Sun May 10 2015 16:18:45