View unanswered posts | View active topics It is currently Tue Sep 16, 2014 11:55 pm






Reply to topic  [ 6 posts ] 
Could anybody give help with my project ^^ 
Author Message
Rookie

Joined: Wed Nov 30, 2011 7:47 am
Posts: 3
Post 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 4137 times ]
Wed Nov 30, 2011 8:41 am
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post 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?

_________________
sudo rm -rf /


Wed Nov 30, 2011 10:07 am
Profile
Rookie

Joined: Wed Nov 30, 2011 7:47 am
Posts: 3
Post 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.


Wed Nov 30, 2011 8:06 pm
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post 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?

_________________
sudo rm -rf /


Wed Nov 30, 2011 8:14 pm
Profile
Rookie

Joined: Wed Nov 30, 2011 7:47 am
Posts: 3
Post 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 ~


Wed Nov 30, 2011 8:36 pm
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post 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.

_________________
sudo rm -rf /


Wed Nov 30, 2011 9:10 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.