Oh dear... I may be in over my head.
Well, I may be in over my head when it comes time for the coding, to say the least...· I recently purchased an Epilog Laser Cutter/Engraver to work with Lexan.· I've been working on a robot chassis design in a CAD program for about 6 months, and I finally got build it out of Lexan.· I knew what all electronics i wanted to use, so I went ahead and bought them too.· I'm just now getting everything hooked up, and it dawned on me that i'm in trouble...· I'm no master programmer like some of you guys on here are, I'm just good at designing.· I can program the BS2, but I think my project may be a little too advanced for me.
Here's some of the parts that I'm using, and some goals that I would like to accomplish.· I would appreciate your input on as to whether a novice/intermediate programmer, such as myself, could tackle this project.
I'm using a BS2, and a BS2 carrier board
2x SRF08 Ultrasonic sensors mounted on servo turrets at the front of the bot
4x servos for driving.· skid steer.
Pololu 8 serial servo controller
1x servo with a wireless video cam on it, just so i can see what it sees.
7 servos total.
Here's what i would like it to do.· Drive around not running into anything, and if it comes to something such as a doorway, to navigate itself through the middle of the doorway.· Choose the best path around an object.
Now at first, all that sounded simple to me, but then it hit me.· There's gonna be SOOO many variables, especially since the sensors are mounted on turrets that can rotate and check in different directions.
Am I right about this?· I'm having doubts as to whether I can finish this, though i would really like to.· Are my choice in parts a good combination to resolve my goals?· I appreciate any feedback you guys may have on this.
Thanks a lot
-Tim
Here's some of the parts that I'm using, and some goals that I would like to accomplish.· I would appreciate your input on as to whether a novice/intermediate programmer, such as myself, could tackle this project.
I'm using a BS2, and a BS2 carrier board
2x SRF08 Ultrasonic sensors mounted on servo turrets at the front of the bot
4x servos for driving.· skid steer.
Pololu 8 serial servo controller
1x servo with a wireless video cam on it, just so i can see what it sees.
7 servos total.
Here's what i would like it to do.· Drive around not running into anything, and if it comes to something such as a doorway, to navigate itself through the middle of the doorway.· Choose the best path around an object.
Now at first, all that sounded simple to me, but then it hit me.· There's gonna be SOOO many variables, especially since the sensors are mounted on turrets that can rotate and check in different directions.
Am I right about this?· I'm having doubts as to whether I can finish this, though i would really like to.· Are my choice in parts a good combination to resolve my goals?· I appreciate any feedback you guys may have on this.
Thanks a lot
-Tim
Comments
Some of us around here can help out on individual components, but in the end it's up to you to put it all together. Sounds like you have some good gear. I have a folder full of 08 ranger stuff (running two at a time, etc.) that might help you out. Boy I'd kill for a laser cutter for lexan...I do all my plastics with my saws...lol.
Remember...master one component at a time, understand it, save those programs and backup like crazy. I think this is a better approach than slapping it all together and expecting to program it all at once.
Good luck with your bot! Let me know how it's going.
PS...Here's my bot http://www.lynxmotion.com/images/html/proj071.htm· ...I expect pictures of yours soon!
Post Edited (cabojoe) : 10/25/2004 8:40:24 AM GMT
Basically, what i'm trying to do is, take a reading from the left sensor ($e0) and store it to a variable.
Then, take a reading from the right sensor ($e2), and store it to a variable.
Then, compare the two readings.· If both responses returned are greater than say, 10 inches, not to even worry about it, keep going Forward.· But if the value returned is less than 10, compare the two to see which is greater, and go that direction, either left or right.
Does that make sense?· It does to me, but i cant seem to get it to work...· I've got subroutines for "Forward:" , "Left:", "Right:", and one called "Stop:", in case something jumps out in front all of the sudden, and the distances are less than say 4 or 5 inches.
Even though my SRF08's are mounted on servos right now, they are fixed stationary to the front.· I just want to get a grasp on how to use them for simple object avoiding right now.·
Do i at least have the right idea on how to approach this?
Thanks for all the help.
-Tim
can you give som help with a start project?
Secondly, i have attatched the code that I was using to check the two SRF08 rangers, and display their values on the debug screen.· I found this code on the net, and its been really the only SRF08 code that i could find.·
My question is, is all of that code necessary just to fire the 2 rangers and store the first ping (result) in a variable so that i can compare the results to each other?· I'm kinda confused about all of that.· I would understand it more, if it was JUST doing what i am needing it to do.·
I hate to ask this, but if someone could please simplify that code down to what i am needing it to do, i would REALLY appreciate it.· I've been messing with this for a few days now, and i cant grasp it.· I would be able to learn it easier if it was simpler... lol.
Anyway, thanks for all the help so far.· I really do appreciate it.
-Tim
I'm sure Jon Williams could explain the bit bashing part of it to you, and as a matter of fact he's got a good article in this month's Nuts and Volts magazine on this. As far as trying to make sense of what's happening in the program, just try to understand the flow of the main part of the program...try to just ignore in your mind for now what comes after the I2C subroutine headings...that might be what is confusing you.
It says in that code, that· I2cReg = 2·· 'address of first ranging result
that is in BOTH the left and right ranger code.· And to display your results on your LCD, you put ....... DEC4 I2cData
So, i take it that the ranges are stored in the variable I2cData, correct?· My question is, how do I compare the Left ranger's I2cData to the Right ranger's I2cData?· I want to use an IF THEN statement to do it, or if there is a better way, i could try that.· This is kinda what i have in mind:
IF I2cData (Right Side) > I2cData (Left Side)
THEN GOSUB TurnLeft
That's a shortened version of what im wanting to do.· I dont think it will work with the data from both stored in the same variable.
Is that the best way to go about this?
Thanks a bunch,
-Tim
I can't believe I didnt think of that...· Wow.· Thank you.· That accomplishes everything that I was trying to grasp...· I really don't know what to say.· My guess is that all the Acks and Naks and I2Cs threw me off so far that I couldn't remember the basics.· Either way though, I can now do as I had hoped, and compare those 2 results.
Once again, thanks so much
-Tim
Here's what it does...
When the Right sensor is less than 15, and the Left sensor is greater than 15, it goes Left.· Just likes its supposed to.
When JUST the Left sensor is less than 15, it well, does nothing.· It keeps going forward.· On the debug screen, it shows that the Left sensor is reading just fine.· Also, when both sensors are less than 15, it is supposed to go backward.· BUT, JUST the rear 2 wheels(servos) go backward.· The front 2 keep going forward... Weird.·
Also, MOST of the time the left sensor will just suddenly read 5355 on the debug screen, and when it does that, the right sensor will continue to display its correct reading, but the robot just jumps to ForwardFast and stays there..
Now, i do not have pull up resistors on the two I2c pins.· could that be the problem of all of this?
I plan on installing them tomorrow sometime.· However, i would think that if that were the case, they just wouldnt give correct readings, and not mess with the other code.· Like my first problem for example.
If you have any ideas, please feel free to let me know.·
Thanks
-Tim
Larry
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Larry
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Tim
EDIT: Your code is very well organized and easy to read...great job.
Post Edited (cabojoe) : 10/30/2004 5:30:23 AM GMT
-Tim
Init:···························· 'initialize SRF08 range and gain settings
'left SRF08 ranger
I2cAddr = $e2··············· 'left address
I2cReg = 2···················· 'range register
I2cData = 24··················'set range to 1 meter max
GOSUB I2cByteWrite······ · 'write
PAUSE 70····················· ·'delay
I2cAddr = $e2··············· ·'left address
I2cReg = 1···················· 'gain register
I2cData = 16················ ·'set gain to 177 max
GOSUB I2cByteWrite········ 'write
PAUSE 70····················· ·'delay·· ADDED
'right SRF08 ranger
I2cAddr = $e0··············· ·'right address
I2cReg = 2··················· ·'range register
I2cData = 24················ ·'set range to 1 meter max
GOSUB I2cByteWrite······· 'write
PAUSE 70···················· ·'delay
I2cAddr = $e0··············· 'right address
I2cReg = 1··················· ·'gain register
I2cData = 16················ ·'set gain to 177 max
GOSUB I2cByteWrite······ ·'write
PAUSE 70···················· ·'delay
Left sensor displays correctly on debug screen, but no change in wheel movement.
Right sensor displays and works correctly. Changes wheel movement
Both sensors triggered = ONLY 2 servos (servos1 and 3) spinning in reverse, while the others keep going forward....
If i trigger the right sensor, THEN trigger the left. it locks up and goes into ForwardFast (loops over and over)
On the original code with mine mixed here i get:
The same as yours, only it never "locks" up on me"
I cant figure out what's wrong here...
It works like it should now...
I dont understand why it has problems sending commands to the servo controller. I will try a different baud rate and see if that changes anything..
When using 84 in the SEROUT commands (9600baud) it will "lock up the program" and cause the left SRF08 to display 5355 on the debug screen.
When using 396 (2400baud) it never locks up, but it still doesnt work the way it should.
Any suggestions? Does this point to anything?
Here's what i've found out. About the BackUp only making 2 wheels go in reverse, i fixed that. My error, i had the servo numbers wrong in the Subroutine.
In Cabojoe's code that i am currently using, my Left sensor works and displays the range, but it wont go to the subroutine GoRight.
However, i can reverse the addresses of the 2 sensors in the code, and it changes which sensor doesnt work properly. When i reverse all the $e0's to $e2's and vice versa, its the Right sensor that is doing it. So, that tells me it may be somewhere in that code. BUT, it does just the same thing on the original code that i had....
Here's another thing that i noticed while debugging. If i change all MY gosub commands to DEBUG....(whichever sub it WOULD be going to) here's what i get:
When i put my hand in front of the Right sensor, it reads "GoLeft" and it doesnt flicker or anything. <---normal
When i put my hand in front of both sensors, it reads "BackUp" and it doesnt flicker. <---normal
When i put something in front of both sensors that is closer than 20inches but more than 15 inches it reads, "ForwardSlow" with no flicker. <---normal.
BUT when i just put in hand in front of the Left sensor, it reads "GoRight", but it flickers a LOT. I dont know what that means, but i know that's part of the problem.
Hopefully i can get this thing workin right.
Thanks
-Tim
Post Edited (cabojoe) : 10/30/2004 9:39:48 AM GMT
I've hit another wall though. When on a stand at my desk, it works just fine. Never locks up. BUT, when i put it down on the floor, it sometimes just goes in reverse like something is right in front of it, but there's not. I think it is reading off of the floor maybe. I tried using address 4 for reading the ping, which would be the next HIGH byte returned, but that just didnt work at all... Is there a way i can turn the sensitivity down?
Thanks
-TIm
EDIT:· When on the floor, it VERY MUCH likes to lock up and get stuck in ForwardFast and go straight for the wall.