Update of /cvsroot/playerstage/code/stage/examples/ctrl
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26853/examples/ctrl

Modified Files:
        Makefile.am 
Added Files:
        lasernoise.cc 
Log Message:
added laser noise generating plugin as a demo

Index: Makefile.am
===================================================================
RCS file: /cvsroot/playerstage/code/stage/examples/ctrl/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Makefile.am 3 Mar 2008 06:02:25 -0000       1.2
--- Makefile.am 4 Mar 2008 02:09:56 -0000       1.3
***************
*** 5,9 ****
  
  
! lib_LTLIBRARIES = wander.la fasr.la source.la sink.la
  
  # WANDER CONTROLLER
--- 5,9 ----
  
  
! lib_LTLIBRARIES = wander.la fasr.la source.la sink.la lasernoise.la
  
  # WANDER CONTROLLER
***************
*** 22,23 ****
--- 22,27 ----
  sink_la_SOURCES = sink.cc ../../libstage/stage.hh
  sink_la_LDFLAGS = -module 
+ 
+ # laser noise
+ lasernoise_la_SOURCES = lasernoise.cc ../../libstage/stage.hh
+ lasernoise_la_LDFLAGS = -module

--- NEW FILE: lasernoise.cc ---
/* 
   File lasernoise.cc: laser noise plugin demo for Stage
   Author: Richard Vaughan
   Date: 3 March 2008
   CVS: $Id: lasernoise.cc,v 1.1 2008/03/04 02:09:56 rtv Exp $
*/

#include "stage.hh"
using namespace Stg;

const double DEVIATION = 0.05;

double SimpleNormalDeviate( double mean, double stddev )
{
  double x = 0.0;
  
  for( int i=0; i<12; i++ )
    x += rand()/(RAND_MAX+1.0);
  
  return ( stddev * (x - 6.0) + mean );  
}

// process the laser data
int LaserUpdate( StgModelLaser* mod, void* dummy )
{
  // get the data
  uint32_t sample_count=0;
  stg_laser_sample_t* scan = mod->GetSamples( &sample_count );
  
  if( scan )
    for( int i=0; i<sample_count; i++ )
      scan[i].range *= SimpleNormalDeviate( 1.0, DEVIATION );
  
  return 0; // run again
}

// Stage calls this when the model starts up. we just add a callback to
// the model that gets called just after the sensor update is done.
extern "C" int Init( StgModel* mod )
{
  mod->AddUpdateCallback( (stg_model_callback_t)LaserUpdate, NULL );
  return 0; // ok
}



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to