How to make alogrith for a artificial intelligence line follower.
![RITESH KAKKAR](https://images.v-cdn.net/banned_large.png)
hi guys,
I have decided to make a line follower robot which sound easier but viewing the arena of it.
makes me confuse how to make control over robot for deciding the right path as give here in end.
any help will be appreciated,
thanks
I have decided to make a line follower robot which sound easier but viewing the arena of it.
makes me confuse how to make control over robot for deciding the right path as give here in end.
any help will be appreciated,
thanks
Comments
Here is my logic:-
I am using 5 LDR sensors middle 3 will will work for finding the tract and last will triggers at T junction. (0-> black 1-> white)
1.) Robot will be on tract so 11011
2.) then 11000
3.) at T junction 00000 at this instance the robot will move in right side.
4.) then 11000
5.) " 00011
6.) move straight 00000
7.) move right 00000
8.) " 00000
.............................
like this.
I want a solution regarding repeating loop and testing condition
for eg:-
If defied inputs are matched with statement the outputs goes high in one loop but repeating this loop 2nd time the uC should again check this condition and work...
Till now i have used CASE, IF else statement and waitpeq....they only work once after this they 2nd check condition .
please reply and figure out the problem.
NOTE:- I am testing the inputs to uC with DIP not using sensors just for now and all outputs are seen on QS board LED.
You are also going to need to store state within the robot. So for example when it passes the wider part of the line and then it goes narrow the robot knows bot the previous and current reading.
I have tried repeat instruction at the end of code with any untill,etc...but seems to be no use in my code it was running as it is..!!
Storing and reading current value will not good for beginner (like me)
Please help.
One thing you might want to consider is spending an evening writing Computer Science 101 programs in Spin until you are confident that you understand the language. Are you familiar with the Parallax serial terminal and the serial monitor on the PC? Here's a hello world with a repeat forever as well:
Try a set of simple exercises and constructs until you are comfortable, then try using those skills to solve a robotics problem.
Not at all.......
This QS was gifted by Sir Duane of this forum.
Martin has several good points. You really need to learn programming in general and Spin programming in specific and understand the basics of the language - Computer Science 101. Then you need to start coding a solution to your problem - a line following robot.
The forum members will be very helpful if you post your code and have questions about it when you get stuck on something. The forum members won't write your code for you and solve all your problems. We had this same problem last time when your were starting to learn Spin and the QuickStart board. I'm not sure what you've learned about Spin programming since then but you do need a basic understanding to get this project started.
First get your robot so it will follow lines without any intelligence - it just needs to stay on the line and make some decision when it reaches the end of a line. Once it can do this, it can start maze solving and you can build maze solving on top of the working line following algorithms. There is a TON of information you can find via Google about Maze solving algorithms but you need to research it and start writing the code to implement it.
I have seen the procedure of its working:
here is the problem
I was testing my code in uC board itself.....
I was trying to write code with dozen of case or if else statement and waitpeq ( wait for pin too go as per logic it pause the up i.e. Cog) these all are syntax.
The code was working well on first attempt mean 1st loop ..after continuing second loop it forget the condition and run on previous value.
I am using DIP switch which are taking position of LDR sensors just for testing code.!!
So, problem is that the code should check the condition in every loop and process the output not blind outputs.
The Parallax Serial Termainal (PST) makes it easy to display information from the Propeller chip.
You might have an icon for PST on your desktop. If not you can find it at:
Start \ All Programs \ Parallax Inc \ Propeller Tool v1.3 \ Parallax Serial Terminal
You want to make sure the baud rate is the same in PST as the rate you are using in the Propeller.
Can you open PST on your computer?
Duane
Yes it has black screen with some txt serial baund rate enable, etc........
VAR
BYTE A ' DECLARING A VARIABLE NAME
PUB LINE
A:=INA[16..20] '16 17 18 19 20 AS INPUTS PINS
DIRA[16..22]:= % 0000011 ' 0 FOR INPUTS 1 FOR % FOR BINARY DIGIT
CASE A
00100: OUTA[21..22] ' MOVE STRAIGHT
00010: OUTA[21] ' MOVE RIGHT
If you won't help us we can't help you.
Both REPEAT and CASE use the indentation to know what to repeat and what items belong to the CASE statement.
Please notice the added := and %. I don't think your code would work without them.
Duane
I was on another PC so i was late to post code.
What are you using to control the motor?
I often use these H-bridge chips to control relatively small motors. I couldn't find any H-bridge chips at the robokits.co.in.
You could also use relays to turn motors on and off.
Did you notice that "A := INA[16..20]" is checked with each loop in the code I wrote?
Duane
HI again,
That mean now it will work fine??
please tell me how to place REPEAT in code??
I was thinking to use transistor at one side only not bidirectional method of H bridge and is there any need of buffer chip at output of uC i.e. QS board??
and you were talking about serial transfer....how to use it ??
If you are really having problems with knowing how to use repeat in your code I do urge that you forget about any kind of robot or artificial inteligence for a while. Instead spend some time learning about programming first. There are many tutorials, examples and so on out there. Starting with the Propeller manual itself.
Everyone starts with the simple things, like flashing a single LED using repeat. Then moving up to more complicated programs.
You have to know the basics of the language, in this case Spin, and how to use it before you can get on with "algorithms" and robots and AI or whatever it is you want to do.
As always, everyone here is quite willing to help even if you are stuck at the flash a LED stage.
OK OK, so it was same REPEAT instruction as i have it any time sorry i was confused i know if it is written like this
repeat 10
for flashing LED the LED will work for 5 cyles...
Sorry for confusing.
thanks.
Hi again,
Please help me to how to use this serial transfer data??
There is more about serial tranfer on page 97 of the Propeller Education Kit (available from the help menu of the Propeller Tool).
Duane
It was something like CTRA instruction give any hint to start it.......
one thing more the motor i bot was of 375 RPM which is pretty fast for an line follower without any PID control so i want PWM to control RPM of motor
can we use PID control in propeller chip??
any hint will be useful..
.
What is OBEX??