terrain_estimator
TerrainConfiguration.hpp
Go to the documentation of this file.
1 #ifndef __TERRAIN_CONFIGURATION_TYPES__
2 #define __TERRAIN_CONFIGURATION_TYPES__
3 
4 #include <vector>
5 #include <base/Time.hpp>
6 #include <base/Eigen.hpp>
7 
8 namespace terrain_estimator {
9 
15  };
16 
23  double probability;
25  : type(UNKNOWN){}
26  };
27 
34  base::Time time;
35  int wheel_idx;
36  std::vector<TerrainProbability> terrain;
37 
48  static TerrainClassification fromRGB( const base::Vector3d& color )
49  {
51  tp.probability = 0.9;
52  // TODO perturb the output and also add other classes
53 
54  // HACK converting rgb values of the MLS into a
55  // classification
56  // red - path
57  // green - grass
58  // blue - pebbles
59  int max_idx;
60  if( color.maxCoeff( &max_idx ) > 0.0 )
61  {
62  switch( max_idx )
63  {
64  case(0): tp.type = terrain_estimator::PATH; break;
65  case(1): tp.type = terrain_estimator::GRASS; break;
66  case(2): tp.type = terrain_estimator::PEBBLES; break;
67  }
68  }
69  else
71 
73  tc.terrain.push_back( tp );
74 
75  return tc;
76  }
77 
84  const base::Vector3d toRGB() const
85  {
86  // since currently the map patches provide a color
87  // information we also convert the
88  // terrain_classification information into a color
89  // information based on the terrain classes.
90 
91  base::Vector3d prop_terrain = base::Vector3d::Zero();
92 
93  for( std::vector<terrain_estimator::TerrainProbability>::const_iterator it = terrain.begin();
94  it != terrain.end(); it++)
95  {
97  switch( tp.type )
98  {
99  case terrain_estimator::PATH: prop_terrain[0] = tp.probability; break;
100  case terrain_estimator::GRASS: prop_terrain[1] = tp.probability; break;
101  case terrain_estimator::PEBBLES: prop_terrain[2] = tp.probability; break;
102  default: break;
103  }
104  }
105 
106  return prop_terrain;
107  }
108 
117  {
118  // for now, do this in RGB space
119  // TODO this only works when there are only 3 classes
120  // will need to update for more classes later
121  base::Vector3d prop_terrain( toRGB() );
122  base::Vector3d visual_terrain( tc.toRGB() );
123 
124  // for now use the crudest way possible to get the probability
125  // for the measurement
126  //double prob = 1.0 - (visual_terrain - prop_terrain).norm() / sqrt( 3.0 );
127 
128  int idx1, idx2;
129  prop_terrain.maxCoeff( &idx1 );
130  visual_terrain.maxCoeff( &idx2 );
131 
132  double prob = (idx1 == idx2) ? 0.9 : 0.1;
133 
134  return prob;
135  }
136  };
137 
138 
150  std::vector<double> function;
151  double offset;
156  #ifndef __orogen
158  : lower_type(UNKNOWN),
160  #endif
161  };
162 }
163 #endif
164 
165 
Definition: TerrainConfiguration.hpp:11
TerrainType type
Definition: TerrainConfiguration.hpp:22
double probability
Definition: TerrainConfiguration.hpp:23
Definition: TerrainConfiguration.hpp:13
double jointProbability(const TerrainClassification &tc)
calculate joint Probability of visual and proprioceptive terrain estimation
Definition: TerrainConfiguration.hpp:116
TerrainType lower_type
Definition: TerrainConfiguration.hpp:153
double lower_threshold
Definition: TerrainConfiguration.hpp:152
Definition: TerrainConfiguration.hpp:14
std::vector< TerrainProbability > terrain
Definition: TerrainConfiguration.hpp:36
TerrainType upper_type
Definition: TerrainConfiguration.hpp:155
TerrainProbability()
Definition: TerrainConfiguration.hpp:24
static TerrainClassification fromRGB(const base::Vector3d &color)
convert an RGB color value into a terrain classification object
Definition: TerrainConfiguration.hpp:48
Definition: TerrainConfiguration.hpp:149
Definition: TerrainConfiguration.hpp:12
TerrainType
Definition: TerrainConfiguration.hpp:10
double offset
Definition: TerrainConfiguration.hpp:151
Definition: TerrainConfiguration.hpp:21
SVMConfiguration()
Definition: TerrainConfiguration.hpp:157
double upper_threshold
Definition: TerrainConfiguration.hpp:154
Definition: TerrainConfiguration.hpp:33
base::Time time
Definition: TerrainConfiguration.hpp:34
const base::Vector3d toRGB() const
convert TerrainProbability to rgb value
Definition: TerrainConfiguration.hpp:84
int wheel_idx
Definition: TerrainConfiguration.hpp:35