something about Blobfinder use in stage

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

something about Blobfinder use in stage

blueskydyliu
Hello everyone,
 I am a student in shanghai jiaotong university,these days I am studying player stage,Here i have some problems.

for fast running ,I programed in stage ,not used proxy in player.
I have used blobfinder to test some rubbishes , in world file is:
        # create another robot
 pioneer2dx
 (
  name "r1"
  color "red"

  pose [-5.5 -3.5 0 208]
  sicklaser()
 ctrl "src/imba.so"
# report error-free position in world coordinates
  localization "gps"
  localization_origin [ 0 0 0 0 ]

 blobfinder(
        colors_count 2
        colors [ "green" "purple"  ]
                alwayson 1
                range 4.0
                fov 60
    )
          )


but when i run my stage program by "stage imbar.wold", the image box with the robot can see the green color,that means our blobfinder detected a rubbish but the program output is not.the program is:(in .cc file )

int BlobfinderUpdate( Model* mod, iRobot* robot );
#define MAXROBOT 1000
iRobot* robotRef[MAXROBOT];
//Stage calls this when the model starts up
extern "C" int Init( Model* mod, CtrlArgs* args )
{
        iRobot* robot = new iRobot(mod);
        robotRef[robot->id] = robot;
        robot->pos->AddUpdateCallback( (stg_model_callback_t)PositionUpdate, robot );
        robot->laser->AddUpdateCallback( (stg_model_callback_t)LaserUpdate, robot );
        robot->blob->AddUpdateCallback( (stg_model_callback_t)BlobfinderUpdate, robot);

        robot->laser->Subscribe(); // starts the laser updates
        robot->pos->Subscribe(); // starts the position updates
        robot->blob->Subscribe();//starts the blobfinder updates
       
        return 0; //ok
}
int BlobfinderUpdate(Model* mod,iRobot* robot)
{
        std::cout<<"blobfiner"<<std::endl;
    uint32_t bcount = 10;
        std::cout<<"befor test is blob count is:"<<bcount<<std::endl;//out put initial count
    ModelBlobfinder::Blob* blobtemp = robot->blob->GetBlobs(&bcount);//?have problem?
        std::cout<<"after test is blob count is:"<<bcount<<std::endl;
        if(bcount)
    {
                               
            std::cout<<"blob see "<<bcount<<"blobs"<<std::endl;
            std::cout<<"going to clear the RUBBISH"<<std::endl;
            robot->pos->SetSpeed(0,0,0);
         }    
        return 0;
}


so after programed  "ModelBlobfinder::Blob* blobtemp = robot->blob->GetBlobs(&bcount); "
the bcount should changed form 10 (initial data) to 1 because detected a green rubbish.
but the proaram alway outout like this:

blobfiner
befor test is blob count is:10
after test is blob count is:0


the problem trouble me some days ,really need you help ,thank you very much .