From: omnislash <sha...@gm...> - 2011-01-13 04:59:40
|
I am trying to run the bigbob example given in the manual. I can't seem to get the robot to go pick up the items. When I just copy and paste the code from the manual, it gets stuck next to an item and won't move. I tried changing the code in many ways and the robot will still get stuck. Changing the code has made me realize I don't really know what exactly is going on in the code (I thought I did, but it doesn't flow like it looks to me it should). For example, this part of the code in the function MoveToItem - playerc_blobfinder_blob_t blob; int turningSpeed = 10; //number of pixels away from the image center a blob can be, to be in front //of the robot. this is essentially the margin of error int margin = 10; //find the largest blob int biggestBlobArea = 0; int biggestBlob = 0; for(int i=0;i<noblobs;i++) { //get blob from proxy playerc_blobfinder_blob_t currBlob = bfp[i]; if(currBlob.area > biggestBlobArea) { biggestBlob = i; biggestBlobArea = currBlob.area; } //end if } //end for blob = bfp[biggestBlob]; //find center of image center = bfp.GetWidth()/2; printf("center is %d\n", center); printf("blob is %d\n", blob); printf("blob.x is %d\n", blob.x); First off I don't get what type a playerc_blobfinder_blob_t is. The main problem though are the values of center, blob, and blob.x. Center is always 80. Why does it never change? Shouldn't it be finding the center of an image, which should change as a new image is the blob the robot is going for? And that is what the robot bases how much to turn on? blob is always a huge number, such as 43746288. This confuses me. blob.x is always a larger number than I feel it should be. Normally between 50-130. Shouldn't blob.x just be the x value of the blob the robot is going for? Why does it change on every loop? I thought it might be the distance on the x axis the blob is away from the robot, but as the robot got closer sometimes blob.x would get bigger. Then whenever the robot gets right next to an item or a wall, it won't move. It just gets stuck even though AvoidObstacles is being called over and over. This is the biggest problem I have with the code working. Those are just the main questions that I can't seem to figure out looking at this code and tutorial. I am using the 2nd edition tutorial given out on April 16th, 2010 for Stage 3.2.X. I tried looking online for the answers, but could find none. I tried fiddling with the code for quite a while, but can only get it to pick up 1-2 items (although the robot will keep turning left to right when the item is right there in front of it) before getting stuck. Is there another legitimate tutorial out there I can look to for my first working simulation that does something more than just walk around? I'm extremely new to Player/Stage and robotics programming in general so maybe there is something else I should try to tackle first? I apologize if these questions are a waste of time, but like I said I am very new. -- View this message in context: http://old.nabble.com/Basic-questions-tp30659452p30659452.html Sent from the playerstage-users mailing list archive at Nabble.com. |