Skip to content

Commit e7ae061

Browse files
committed
updated pioneer flocking example
1 parent 8a62215 commit e7ae061

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

examples/ctrl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ SET( PLUGINS
55
source
66
wander
77
# wander_pioneer
8-
# pioneer_flocking
8+
pioneer_flocking
99
rasterize
1010
dynamic
1111
)

examples/ctrl/pioneer_flocking.cc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ using namespace Stg;
1515

1616
typedef struct
1717
{
18-
ModelLaser* laser;
1918
ModelPosition* position;
2019
ModelRanger* ranger;
2120
ModelFiducial* fiducial;
@@ -73,8 +72,8 @@ int RangerUpdate( ModelRanger* rgr, robot_t* robot )
7372
// use the front-facing sensors only
7473
for( unsigned int i=0; i < 8; i++ )
7574
{
76-
dx += sensors[i].range * cos( sensors[i].pose.a );
77-
dy += sensors[i].range * sin( sensors[i].pose.a );
75+
dx += sensors[i].ranges[0] * cos( sensors[i].pose.a );
76+
dy += sensors[i].ranges[0] * sin( sensors[i].pose.a );
7877
}
7978

8079
if( (dx == 0) || (dy == 0) )
@@ -86,12 +85,12 @@ int RangerUpdate( ModelRanger* rgr, robot_t* robot )
8685
double turn_speed = EXPAND_WGAIN * resultant_angle;
8786

8887
// if the front is clear, drive forwards
89-
if( (sensors[3].range > SAFE_DIST) && // forwards
90-
(sensors[4].range > SAFE_DIST) &&
91-
(sensors[5].range > SAFE_DIST ) && //
92-
(sensors[6].range > SAFE_DIST/2.0) &&
93-
(sensors[2].range > SAFE_DIST ) &&
94-
(sensors[1].range > SAFE_DIST/2.0) &&
88+
if( (sensors[3].ranges[0] > SAFE_DIST) && // forwards
89+
(sensors[4].ranges[0] > SAFE_DIST) &&
90+
(sensors[5].ranges[0] > SAFE_DIST ) && //
91+
(sensors[6].ranges[0] > SAFE_DIST/2.0) &&
92+
(sensors[2].ranges[0] > SAFE_DIST ) &&
93+
(sensors[1].ranges[0] > SAFE_DIST/2.0) &&
9594
(fabs( resultant_angle ) < SAFE_ANGLE) )
9695
{
9796
forward_speed = VSPEED;

worlds/pioneer_flocking.world

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
include "pioneer.inc"
66
include "map.inc"
77

8-
speedup 100
8+
speedup 0
99

1010
paused 1
1111

1212
# low resolution gives fast raytracing. set this only as small as you need for your application
1313
resolution 0.1
1414

1515
# this is very helpful if you have multiple CPUs - a good value is $(number of CPU cores) -
16-
# threads 2
16+
threads 4
1717

1818
# configure the GUI window
1919
window

0 commit comments

Comments
 (0)