diff --git a/examples/ctrl/CMakeLists.txt b/examples/ctrl/CMakeLists.txt index bab2b0207..04d36a94f 100644 --- a/examples/ctrl/CMakeLists.txt +++ b/examples/ctrl/CMakeLists.txt @@ -5,7 +5,7 @@ SET( PLUGINS source wander # wander_pioneer -# pioneer_flocking + pioneer_flocking rasterize dynamic ) diff --git a/examples/ctrl/pioneer_flocking.cc b/examples/ctrl/pioneer_flocking.cc index 4e93edde2..2d80c84c3 100644 --- a/examples/ctrl/pioneer_flocking.cc +++ b/examples/ctrl/pioneer_flocking.cc @@ -15,7 +15,6 @@ using namespace Stg; typedef struct { - ModelLaser* laser; ModelPosition* position; ModelRanger* ranger; ModelFiducial* fiducial; @@ -73,8 +72,8 @@ int RangerUpdate( ModelRanger* rgr, robot_t* robot ) // use the front-facing sensors only for( unsigned int i=0; i < 8; i++ ) { - dx += sensors[i].range * cos( sensors[i].pose.a ); - dy += sensors[i].range * sin( sensors[i].pose.a ); + dx += sensors[i].ranges[0] * cos( sensors[i].pose.a ); + dy += sensors[i].ranges[0] * sin( sensors[i].pose.a ); } if( (dx == 0) || (dy == 0) ) @@ -86,12 +85,12 @@ int RangerUpdate( ModelRanger* rgr, robot_t* robot ) double turn_speed = EXPAND_WGAIN * resultant_angle; // if the front is clear, drive forwards - if( (sensors[3].range > SAFE_DIST) && // forwards - (sensors[4].range > SAFE_DIST) && - (sensors[5].range > SAFE_DIST ) && // - (sensors[6].range > SAFE_DIST/2.0) && - (sensors[2].range > SAFE_DIST ) && - (sensors[1].range > SAFE_DIST/2.0) && + if( (sensors[3].ranges[0] > SAFE_DIST) && // forwards + (sensors[4].ranges[0] > SAFE_DIST) && + (sensors[5].ranges[0] > SAFE_DIST ) && // + (sensors[6].ranges[0] > SAFE_DIST/2.0) && + (sensors[2].ranges[0] > SAFE_DIST ) && + (sensors[1].ranges[0] > SAFE_DIST/2.0) && (fabs( resultant_angle ) < SAFE_ANGLE) ) { forward_speed = VSPEED; diff --git a/worlds/pioneer_flocking.world b/worlds/pioneer_flocking.world index 489a24f8b..84e409ec5 100644 --- a/worlds/pioneer_flocking.world +++ b/worlds/pioneer_flocking.world @@ -5,7 +5,7 @@ include "pioneer.inc" include "map.inc" -speedup 100 +speedup 0 paused 1 @@ -13,7 +13,7 @@ paused 1 resolution 0.1 # this is very helpful if you have multiple CPUs - a good value is $(number of CPU cores) - -# threads 2 +threads 4 # configure the GUI window window