lasernoise.cc
Go to the documentation of this file.
1 /*
2  File rangernoise.cc: ranger noise plugin demo for Stage
3  Author: Richard Vaughan
4  Date: 3 March 2008
5  CVS: $Id: rangernoise.cc,v 1.1 2008-03-04 02:09:56 rtv Exp $
6 */
7 
8 #include "stage.hh"
9 using namespace Stg;
10 
11 const double DEVIATION = 0.05;
12 
13 double simple_normal_deviate( double mean, double stddev )
14 {
15  double x = 0.0;
16 
17  for( int i=0; i<12; i++ )
18  x += rand()/(RAND_MAX+1.0);
19 
20  return ( stddev * (x - 6.0) + mean );
21 }
22 
23 // process the ranger data
24 int RangerUpdate( ModelRanger* mod, void* dummy )
25 {
26  // get the data
27  std::vector<meters_t>& scan = mod->GetSensorsMutable()[0].ranges;
28 
29  if( scan.size()>0 )
30  FOR_EACH( it, scan )
31  *it *= simple_normal_deviate( 1.0, DEVIATION );
32 
33  return 0; // run again
34 }
35 
36 // Stage calls this when the model starts up. we just add a callback to
37 // the model that gets called just after the sensor update is done.
38 extern "C" int Init( Model* mod )
39 {
41 
42  // add this so we can see the effects immediately, without needing
43  // anyone else to subscribe to the ranger
44  mod->Subscribe();
45 
46  return 0; // ok
47 }
48 
const double DEVIATION
Definition: lasernoise.cc:11
Model class
Definition: stage.hh:1742
The Stage library uses its own namespace.
Definition: canvas.hh:8
void Init(int *argc, char **argv[])
Definition: stage.cc:18
std::vector< Sensor > & GetSensorsMutable()
Definition: stage.hh:2808
int(* model_callback_t)(Model *mod, void *user)
Definition: stage.hh:568
void AddCallback(callback_type_t type, model_callback_t cb, void *user)
int RangerUpdate(ModelRanger *mod, void *dummy)
Definition: lasernoise.cc:24
void Subscribe()
Definition: model.cc:646
double simple_normal_deviate(double mean, double stddev)
Definition: lasernoise.cc:13
ModelRanger class
Definition: stage.hh:2747
#define FOR_EACH(I, C)
Definition: stage.hh:616


stage
Author(s): Richard Vaughan , Brian Gerkey , Reed Hedges , Andrew Howard , Toby Collett , Pooya Karimian , Jeremy Asher , Alex Couture-Beil , Geoff Biggs , Rich Mattes , Abbas Sadat
autogenerated on Mon Jun 10 2019 15:06:09