Sensors

16 replies [Last post]
ruler501
ruler501's picture
Title: NooBot
Joined: 01/29/2012
Posts:
BotPoints: 367
User offline. Last seen 2 years 31 weeks ago.

What kind of system are you using to follow the line? If you post some code we can provide some critiques.

I personally like the idea of using PID control(a more advanced version of the usual system). You have to have 3 constants that depend on your robot(pPID, iPID, dPID)and you have code that does something like this

sumDifference += curSensorValue - GOALPOSITION;
turning = pPID*(curSensorValue - GOALPOSITION) + iPID*sumDifference + dPID*(curSensorValue-oldSensorValue);
oldSensorValue = curSensorValue;
drive(speed+turning,speed-turning);

rockyone
Title: NooBot
Joined: 02/17/2014
Posts:
BotPoints: 6
User offline. Last seen 3 years 41 weeks ago.

im using this :

int main() {
create_connect();
set_each_analog_state(1,1,0,0,0,0,0,0);
if(b_button()==0) {
printf("reflectance: %i ", analog10(0));
printf("light: %i\n", analog10(2));
printf("B button exits\n");
msleep(1000);
create_drive_direct(-300,-300);
sleep(20);
}
else {
ao();
}
return 0;
}

its only driving in one direction , its not following the line.
and one more thing is there a website or a manual that i can read to know more about those functions and the way they work ?

ruler501
ruler501's picture
Title: NooBot
Joined: 01/29/2012
Posts:
BotPoints: 367
User offline. Last seen 2 years 31 weeks ago.

you aren't looping at all so it will only ever move in one direction

Have code more like this

connect();
while b_button not pressed{
drive towards the line(use whatever algorithm you want for that, proportional, barrier, pid)
sleep small amount of time
}
turn everything off
return

rockyone
Title: NooBot
Joined: 02/17/2014
Posts:
BotPoints: 6
User offline. Last seen 3 years 41 weeks ago.

Thank u soo much :)
oh and do u have any manual or site that can help in case i get stuck in any of these functions ?

ruler501
ruler501's picture
Title: NooBot
Joined: 01/29/2012
Posts:
BotPoints: 367
User offline. Last seen 2 years 31 weeks ago.

I'm not sure where the official documentation is hosted but I have some unofficial documentation(compiled from github with doxygen) hosted at https://ruler501.tk/docs

Remember it is completely unofficial though so there may be problems and I take no responsibility if you use the functions wrong because something is wrong in the documentation.

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 1168
User offline. Last seen 2 years 29 weeks ago.

@rockyone: I think line following is usually in the workshop slides, although I haven't checked this years'. If you're coding something and it's not working, you're always welcome to post your code here and maybe someone will be able to tell you what's wrong.

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS