Skip to content

Commit

Permalink
updated pioneer flocking example
Browse files Browse the repository at this point in the history
  • Loading branch information
rtv committed Nov 26, 2010
1 parent 8a62215 commit e7ae061
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/ctrl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SET( PLUGINS
source
wander
# wander_pioneer
# pioneer_flocking
pioneer_flocking
rasterize
dynamic
)
Expand Down
17 changes: 8 additions & 9 deletions examples/ctrl/pioneer_flocking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ using namespace Stg;

typedef struct
{
ModelLaser* laser;
ModelPosition* position;
ModelRanger* ranger;
ModelFiducial* fiducial;
Expand Down Expand Up @@ -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) )
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions worlds/pioneer_flocking.world
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
include "pioneer.inc"
include "map.inc"

speedup 100
speedup 0

paused 1

# low resolution gives fast raytracing. set this only as small as you need for your application
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
Expand Down

0 comments on commit e7ae061

Please sign in to comment.