ROBOTC.net forums
http://www.robotc.net/forums/

Could anybody give help with my project ^^
http://www.robotc.net/forums/viewtopic.php?f=15&t=3800
Page 1 of 1

Author:  mozhanmeng [ Wed Nov 30, 2011 8:41 am ]
Post subject:  Could anybody give help with my project ^^

Hello, everyone. I currently get a project. The robot need to detect little green circles on a white cradborad. Where out side the white cardborad is black carpet. The robot is not permitted to leave the field. The map however is uploaded as attachment. Below is code I have written, could anybody check if please.


#pragma config(Sensor, S1, senSound, sensorSoundDB)
#pragma config(Sensor, S2, senLIGHT2, sensorLightActive)
#pragma config(Sensor, S3, senLIGHT1, sensorLightActive)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
while(true)

{
if (SensorValue(senLIGHT1)>57) // white carborad is lighter than 57, so when continue to run around and around on the map//
{
motor[motorB] = 100;
motor[motorC] = 80;
}

else if(SensorValue(senLIGHT1)<34.5) // the robot meet black carpet, so turn right, then continue to run around on the map//

{ motor[motorB] = 50;
motor[motorC] = -50;

wait1Msec(1000);
}




else //the robot meet green circles, display " yeah" on the screen of brick//
{
nxtDisplayScringAt(0,31, "yeah");

wait1Msec(1000);
motor[motorB] = -50;
motor[motorC] = 50;

}
}
}

I know there are many errors in this code. Could anybody point out or fix, thank you very much! :)

Attachments:
map.PNG
map.PNG [ 9.65 KiB | Viewed 8424 times ]

Author:  magicode [ Wed Nov 30, 2011 10:07 am ]
Post subject:  Re: Could anybody give help with my project ^^

What is your ultimate goal? Do you want to find all the green circles? Or just run around randomly until you find one?

Author:  mozhanmeng [ Wed Nov 30, 2011 8:06 pm ]
Post subject:  Re: Could anybody give help with my project ^^

Hello,magicode. Thanks for replying. The final goal is to collect all circles. All tpyes of sensors can be used.

Author:  magicode [ Wed Nov 30, 2011 8:14 pm ]
Post subject:  Re: Could anybody give help with my project ^^

So are you looking on help finding an algorithm to find the circles, or are you asking what is wring with the current code you have presented? If it is the latter, what results are you expecting from the code, and what is actually happening?

Author:  mozhanmeng [ Wed Nov 30, 2011 8:36 pm ]
Post subject:  Re: Could anybody give help with my project ^^

The robot would run around and around on the map. It would collect one circle then finish. >< but I know my code would work at this stage. Could u tell me how I can make it better? or tell me what should the expected algorithm be ~

Author:  magicode [ Wed Nov 30, 2011 9:10 pm ]
Post subject:  Re: Could anybody give help with my project ^^

Are the green circles always in the same positions? If they are, then the approach would be different than if they aren't. If they are, you would go toward the first one and look around in the area where it should be, then turn toward the next one..ect. If they aren't: Well, if you want to spiral out to the edge of the map, it's going to be quite a complicated procedure. You will have to keep track of your position, and adjust the motor position accordingly to make bigger and bigger spirals. Or, one random running around way would be keep going until you hit the sides and then turn randomly.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/