84 const std::string& type ) :
85 Model( world, parent, type ),
113 return( ! finder->
IsRelated( candidate ));
119 double epsilon = 1e-5;
120 return( fabs(a.
r - b.
r) < epsilon &&
121 fabs(a.
g - b.
g) < epsilon &&
122 fabs(a.
b - b.
b) < epsilon );
125 void ModelBlobfinder::ModelBlobfinder::AddColor(
Color col )
165 for(
unsigned int c=0; c<
count; c++ )
167 char* colorstr = NULL;
195 if( samples[
s].mod == NULL )
198 unsigned int right =
s;
206 while(
s < scan_width && samples[
s].mod &&
213 unsigned int left =
s - 1;
220 for(
unsigned int c=0; c<
colors.size(); c++ )
232 double robotHeight = 0.6;
236 for(
unsigned int t=right; t<=left; t++ )
237 range += samples[t].range;
238 range /= left-right + 1;
240 double startyangle = atan2( robotHeight/2.0, range );
241 double endyangle = -startyangle;
242 int blobtop =
scan_height/2 - (int)(startyangle/yRadsPerPixel);
243 int blobbottom =
scan_height/2 -(int)(endyangle/yRadsPerPixel);
245 blobtop = std::max( blobtop, 0 );
246 blobbottom = std::min( blobbottom, (
int)
scan_height );
250 blob.
color = blobcol;
251 blob.
left = scan_width - left - 1;
253 blob.
right = scan_width - right - 1;;
262 blobs.push_back( blob );
302 :
Visualizer(
"Blobfinder",
"blobfinder_vis" )
318 GLUquadric* quadric = gluNewQuadric();
322 gluQuadricDrawStyle( quadric, GLU_SILHOUETTE );
323 gluPartialDisk( quadric,
331 gluDeleteQuadric( quadric );
342 glRotatef(
rtod(-gpose.a),0,0,1 );
345 glTranslatef( -2.5, -1.5, 0.5 );
349 pitch = - cam->
pitch();
352 glRotatef( robotAngle - yaw, 0,0,1 );
353 glRotatef( -pitch, 1,0,0 );
356 glScalef( 0.025, 0.025, 1 );
363 glTranslatef(0,0,0.01 );
365 glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
369 glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
372 for(
unsigned int s=0;
s<bf->
blobs.size();
s++ )
virtual void PushColor(Color col)
Worldfile * GetWorldFile()
static const radians_t DEFAULT_BLOBFINDERFOV
std::vector< Blob > blobs
int subs
the number of subscriptions to this model
static const meters_t DEFAULT_BLOBFINDERRANGE
The Stage library uses its own namespace.
int ReadTuple(const int entity, const char *name, const unsigned int first, const unsigned int num, const char *format,...)
std::vector< Color > colors
#define PRINT_DEBUG2(m, a, b)
static const unsigned int DEFAULT_BLOBFINDERSCANHEIGHT
RaytraceResult Raytrace(const Pose &pose, const meters_t range, const ray_test_func_t func, const void *arg, const bool ztest=true)
ModelBlobfinder(World *world, Model *parent, const std::string &type)
static const watts_t DEFAULT_BLOBFINDERWATTS
void RemoveColor(Color col)
bool IsRelated(const Model *testmod) const
Pose GetGlobalPose() const
bool PropertyExists(int section, const char *token)
static bool blob_match(Model *candidate, Model *finder, const void *dummy)
Color color
the color struck by this beam
static const unsigned int DEFAULT_BLOBFINDERRESOLUTION
void AddVisualizer(Visualizer *custom_visual, bool on_by_default)
virtual void Visualize(Model *mod, Camera *cam)
static const unsigned int DEFAULT_BLOBFINDERSCANWIDTH
static const unsigned int DEFAULT_BLOBFINDERINTERVAL_MS
double ReadFloat(int entity, const char *name, double value)
void SetWatts(watts_t watts)
static const radians_t DEFAULT_BLOBFINDERPAN
int ReadInt(int entity, const char *name, int value)
radians_t a
rotation about the z axis.
Stg::ModelBlobfinder::Vis vis
double ReadAngle(int entity, const char *name, double value)
static bool ColorMatchIgnoreAlpha(Color a, Color b)