Go to the documentation of this file.00001
00063 #ifndef __SENSOR_MODEL_H__
00064 #define __SENSOR_MODEL_H__
00065
00066 #include "cob_3d_mapping_common/polygon.h"
00067 #include <list>
00068 #include <algorithm>
00069
00070 namespace cob_3d_mapping
00071 {
00075 class PrimeSense
00076 {
00077 public:
00078 typedef Eigen::Map<const Eigen::Matrix<float,4,4,Eigen::RowMajor> > MatMap;
00079
00083 PrimeSense() {}
00087 ~PrimeSense() {}
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 inline static bool areNeighbors(float query,
00099 float neighbor,
00100 float tolerance = 2.0f)
00101 {
00102 float dist_th = tolerance * 0.003f * query * query;
00103
00104 return (fabs(query - neighbor) < dist_th);
00105 }
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 inline static bool areNeighbors(const Eigen::Vector3f& query,
00117 const Eigen::Vector3f& neighbor,
00118 float tolerance = 4.0f)
00119 {
00120
00121 tolerance += max( 0.0f, 1.0f * (4.0f - min(fabs(query(0)),fabs(query(1))) * 10.0f) );
00122 float dist_th = tolerance * 0.003f * query(2) * query(2);
00123 return (fabs(query(2) - neighbor(2)) < dist_th);
00124 }
00125
00126 inline static Eigen::Matrix4f tf_unit_cube() { return MatMap(mat); }
00127
00128
00129 static const float fov_h;
00130 static const float fov_v;
00131 static const float f;
00132 static const float n;
00133 static const float l;
00134 static const float r;
00135 static const float t;
00136 static const float b;
00137 static const float w;
00138 static const float h;
00139 static const float aspect;
00140 static const float mat[];
00141 };
00142
00143 const float PrimeSense::fov_h = 49.0f / 180.0f * M_PI;
00144 const float PrimeSense::fov_v = 43.0f / 180.0f * M_PI;
00145 const float PrimeSense::f = 5.0f;
00146 const float PrimeSense::n = 0.5f;
00147 const float PrimeSense::r = PrimeSense::n * tan(PrimeSense::fov_h * 0.5f);
00148 const float PrimeSense::l = - PrimeSense::r;
00149 const float PrimeSense::t = PrimeSense::n * tan(PrimeSense::fov_v * 0.5f);
00150 const float PrimeSense::b = - PrimeSense::t;
00151 const float PrimeSense::w = 640.0f;
00152 const float PrimeSense::h = 480.0f;
00153 const float PrimeSense::aspect = PrimeSense::w / PrimeSense::h;
00154
00155 const float PrimeSense::mat[] =
00156 {
00157 1.0f / ( PrimeSense::aspect * tan(0.5f * PrimeSense::fov_h) ),
00158 0,
00159 0,
00160 0,
00161
00162 0,
00163 1.0f / ( tan(0.5f * PrimeSense::fov_h) ),
00164 0,
00165 0,
00166
00167 0,
00168 0,
00169 (PrimeSense::n + PrimeSense::f) / (PrimeSense::n - PrimeSense::f),
00170 -2.0f * PrimeSense::f * PrimeSense::n / (PrimeSense::n - PrimeSense::f),
00171
00172 0,
00173 0,
00174 1,
00175 0
00176 };
00177
00178 }
00179
00180 #endif