Behavior:Exercise3-Flocking
[edit]
Setup
This exercise will require a swarm of robots. Simulation is the cheapest way to create a swarm of robots for development use. See Group:Group Howto for an example of how to create a swarm of robots in simulation.
[edit]
Sensing Other Robots
The blobfinder proxy can be used to determine what other robots are in the area. The following code is an example:
PlayerCc::BlobfinderProxy* bp = (PlayerCc::BlobfinderProxy*)
clients[i]->GetProxy(PLAYER_BLOBFINDER_CODE,i);
int width = bp->GetWidth();
for( unsigned int j = 0; j < bp->GetCount(); j++ )
printf( "x: %d y: %d\n", bp->GetBlob(j).x, bp->GetBlob(j).y );
this will print out the x and y coordinates (from the camera's point of view) of every detected blob in the scene. Robots will show up as red squares in stage.
[edit]
Behaviors
1. Wander 2. Linear Safety 3. Angular Safety 4. Move toward robots
![[LOGO]](/workbook/skins/workbook/create_small2.png)



