Wildman Posted December 21, 2010 Posted December 21, 2010 Hello, I'm a student from The Netherlands. I'm in Gymnasium 6 (VWO 6) and have a assignment. I'm making a Lego Mindstorms NXT which is working on solar energy. The robot needs to detect the highest light source and drive to it so the robot can "recharge" himself. We have equipped 3 solar panels on the robot and are using 4 Lego Mindstorms Light sensors. But I have a problem. I don't know exactly how to program this. How can the robot detect the highest light source and drive to it? I think the program needs to compare the 4 Lego light sensors and go to the direction where the robot measures the highest light intensity. But how? I hope somebody can help me. Thanks, Wildman (wildman31@gmail.com) Quote
imajor Posted December 21, 2010 Posted December 21, 2010 Maybe you could use a single sensor, rotate it around, and record the light amount at different angles? Then choose the angle where it measured the most light? Quote
DLuders Posted December 21, 2010 Posted December 21, 2010 Have you seen Justin Fisher's webpage about LEGO Solar Rover Autonomous Robots? There is a lot of good stuff there. Quote
Wildman Posted December 21, 2010 Author Posted December 21, 2010 Maybe you could use a single sensor, rotate it around, and record the light amount at different angles? Then choose the angle where it measured the most light? I did consider that. But with 4 sensors you will have a much better (continual) measure. If you let the robot rotate, it costs time. I want a continual measure / adjustment to the direction with the highest light intensity. Anyone can help me with that please ? Thanks. Quote
imajor Posted December 21, 2010 Posted December 21, 2010 I didn't mean rotating the robot itself, I meant just rotating the sensor on top of the robot. Maybe you could keep rotating it while the robot is moving forward. What exactly is your problem? Do you have issues writing the program itself for the brick? Quote
Wildman Posted December 21, 2010 Author Posted December 21, 2010 Have you seen Justin Fisher's webpage about LEGO Solar Rover Autonomous Robots? There is a lot of good stuff there. Thanks, that will help a bit. It's unfortunately a other robot which he used. I'm using Lego Mindstorms NXT with the software it provided. I'm trying to make the robot measure and compare the results. But I'm stuck at the moment :P Thanks, Wildman Quote
DLuders Posted December 21, 2010 Posted December 21, 2010 There may be portions of this 6-page "Lego Robots Tutorials -- Light Sensors" PDF document that may be helpful. Maybe you could adapt some of the programming to your Solar Follower robot. Quote
Wildman Posted December 21, 2010 Author Posted December 21, 2010 There may be portions of this 6-page "Lego Robots Tutorials -- Light Sensors" PDF document that may be helpful. Maybe you could adapt some of the programming to your Solar Follower robot. Thanks for your comment. Some bits of the article will help. unfortunately that Lego robot, is a old version. So programming is different now (same basics I think, but other specifications). I´m using Lego Mindstorms NXT ( http://en.wikipedia.org/wiki/Lego_Mindstorms ) with the programming language provided: Lego Mindstorms NXT. Thanks, Wildman Quote
legolijntje Posted December 21, 2010 Posted December 21, 2010 (edited) Maybe you can ask it to NXT programs (Dave Parker). Or ask it to Laurens Valk. Both are very good whit Mindstorms. Edited December 21, 2010 by legolijntje Quote
Wildman Posted December 21, 2010 Author Posted December 21, 2010 I have made a screen shot of the program (it's in Dutch). http://img227.imageshack.us/img227/9821/legomindstormsnxtprogra.jpg I don't know which one I need to use. Do I need to compare them separately and how can I compare more then 2 sensors at the same time? Or do I need a circuit? Or... ? Some suggestions/tips? ;) Thanks, Wildman @Legolijntje I will contact them. Thanks ! Quote
dolittle Posted December 21, 2010 Posted December 21, 2010 I have made a screen shot of the program (it's in Dutch). http://img227.images...msnxtprogra.jpg I don't know which one I need to use. Do I need to compare them separately and how can I compare more then 2 sensors at the same time? Or do I need a circuit? Or... ? Some suggestions/tips? ;) Thanks, Wildman @Legolijntje I will contact them. Thanks ! Hi, The solution is quite "easy". You need to point the sensors in 90 degree angles from each other, so that one points South, North, West and East. Measure the light intensity from each by putting a block that feeds a Logical comparison, and finds the highest value. You will need to compare two pairs, and then the "winner" between them. Once you know which one "has the highest value" you need to rotate to that direction, either you rotate, 90 degrees left, 90 degrees right, or 180 degrees (left or right). Then do another measurement and continue. If the comparison found the values to be equal, you need to rotate 45 degrees in that direction And so forth, finally it will be in the direction of the light source and will arrive at your destination Good luck Thanks, Noam Quote
Wildman Posted December 21, 2010 Author Posted December 21, 2010 Hi, The solution is quite "easy". You need to point the sensors in 90 degree angles from each other, so that one points South, North, West and East. Measure the light intensity from each by putting a block that feeds a Logical comparison, and finds the highest value. You will need to compare two pairs, and then the "winner" between them. Once you know which one "has the highest value" you need to rotate to that direction, either you rotate, 90 degrees left, 90 degrees right, or 180 degrees (left or right). Then do another measurement and continue. If the comparison found the values to be equal, you need to rotate 45 degrees in that direction And so forth, finally it will be in the direction of the light source and will arrive at your destination Good luck Thanks, Noam Thank you very much! I have made a list what the robot needs to do: Step 1: Start the program, by pressing a button on the Lego Mindstorms (done) Step 2: The robot needs to measure the light intensity (from the four Lego light sensors, which are in 90 degrees of each other) (trying, but stuck) Step 3: The robot needs to compare the measured values. (trying, but stuck how to compare all the four sensors. I can't find where you can compare four values.) Step 4: The robot needs to find the highest sensor value. (trying, but stuck how to find the highest value) Step 5: Drive toward the light source. Step 6: Keep measuring and compare the measured sensor values. Step 7: If the new sensor values are higher then the old (highest) sensor value adjust the direction. If the new sensor values are lower then the old (highest) sensor value keep driving the same direction. Step 8: Stop the program, by pressing a button on the Lego Mindstorms (done) I'm trying to achieve that. Still in progress. Thanks, Wildman Quote
dolittle Posted December 21, 2010 Posted December 21, 2010 Thank you very much! I have made a list what the robot needs to do: Step 1: Start the program, by pressing a button on the Lego Mindstorms (done) Step 2: The robot needs to measure the light intensity (from the four Lego light sensors, which are in 90 degrees of each other) (trying, but stuck) Step 3: The robot needs to compare the measured values. (trying, but stuck how to compare all the four sensors. I can't find where you can compare four values.) Step 4: The robot needs to find the highest sensor value. (trying, but stuck how to find the highest value) Step 5: Drive toward the light source. Step 6: Keep measuring and compare the measured sensor values. Step 7: If the new sensor values are higher then the old (highest) sensor value adjust the direction. If the new sensor values are lower then the old (highest) sensor value keep driving the same direction. Step 8: Stop the program, by pressing a button on the Lego Mindstorms (done) I'm trying to achieve that. Still in progress. Thanks, Wildman I am answering from memory, I don't have the program at hand... You can't compare 4, but you can compare pairs... Compare 2 pairs (near each other, so S E, N W or something), make it spit out the bigger one. Then compare the end results of the two sets. The result is the biggest value. Now compare again the biggest value with each set from S N E W you have, when it EQUALS, this is where you need to rotate to. You can further "improve it" so that if two are equal you drive 45 degrees in that direction (in the "middle"). Is this clearer? Thanks, Noam Quote
legolijntje Posted December 21, 2010 Posted December 21, 2010 I have made a screen shot of the program (it's in Dutch). http://img227.imageshack.us/img227/9821/legomindstormsnxtprogra.jpg Thanks, Wildman I don't now if you now it, but the orange and the green blocks will do nothing if you start the program. Right at the start of the program you see 3 "ways". Yo can attach them to there (I think). Quote
Parax Posted December 21, 2010 Posted December 21, 2010 Thanks, that will help a bit. It's unfortunately a other robot which he used. I'm using Lego Mindstorms NXT with the software it provided. I'm trying to make the robot measure and compare the results. But I'm stuck at the moment :P Thanks, Wildman If you are stuck with NXT-G perhaps a back to basics approach will help. Lego very thoughtfully provided tutorials and instructions on how to program in NXT-G on the CD that came with the NXT kit. I'd start there! then when you understand NXT-G it really will be easy, and a lot more of these comments will make sense. As for using four sensors this is potentially a problem, as they will be calibrated differently and give different readings, so the one with the highest reading may not be in the brightest light! using one as suggested earlier and steering toward away to compare readings is probably the easiest and best solution, and is very (ok very very!) similar to a line follower (there are a great number of these on the web.) As for telling you what to do, It's for your teacher to decide how much help you get, and not for us to do your work. P. Quote
Wildman Posted December 21, 2010 Author Posted December 21, 2010 Thank you all, for your replies. I'm watching now some tutorials + programming some bit. Quote
dolittle Posted December 22, 2010 Posted December 22, 2010 Hi, I made a "drawing" of my solution, I don't have 4 light sensors to test this out... So I believe it will work, you can download it from here: http://www.4shared.com/file/mehNLRJY/Solar_Sensor.html Basically, I compare sensor 1 and 2, the outcome compare with 3 and 4, etc... Hope this gets you on your way. Quote
Wildman Posted December 22, 2010 Author Posted December 22, 2010 Hi, I made a "drawing" of my solution, I don't have 4 light sensors to test this out... So I believe it will work, you can download it from here: http://www.4shared.com/file/mehNLRJY/Solar_Sensor.html Basically, I compare sensor 1 and 2, the outcome compare with 3 and 4, etc... Hope this gets you on your way. Thank you !!! I did a test with your program and made some (little) changes. It works quite well. I have tested it with a flash light. The robot follows my flash light almost perfect now. (Tested with 4 sensors). I will make some adjustments later on. I will post a small video, when it's finished / it works. If you have further suggestions / tips / or just want to chat, please mail me (wildman31@gmail.com) or post reply Thank you again!, Wildman Quote
dolittle Posted December 22, 2010 Posted December 22, 2010 Thank you !!! I did a test with your program and made some (little) changes. It works quite well. I have tested it with a flash light. The robot follows my flash light almost perfect now. (Tested with 4 sensors). I will make some adjustments later on. I will post a small video, when it's finished / it works. If you have further suggestions / tips / or just want to chat, please mail me (wildman31@gmail.com) or post reply Thank you again!, Wildman Hi, Please be kind and post your final version so that others could learn from it ;] Thanks, Noam Quote
Wildman Posted December 22, 2010 Author Posted December 22, 2010 Hi, Please be kind and post your final version so that others could learn from it ;] Thanks, Noam I will do that I'm testing/editing now some bit. Thanks, Wildman Quote
Wildman Posted December 27, 2010 Author Posted December 27, 2010 The program what I now use is: https://sourceforge.net/apps/phpbb/mindboards/download/file.php?id=170 A reply with regard to the deviation problem: Cool project and nice work!Here's an idea that might help with the deviation problem: use some simple subtraction and the steering hub to guide the robot to the brightest area. The difference between two light sensor readings gives you a value that can be used to steer in the right direction and proper amount of turn. When both sensor readings are the same, the robot goes straight (presumably centered on the brightest light source). I've attached two programs written in NXT-G that help the bot seek the brightest light sources; one uses two light sensors and the other gets similar results using one light sensor and a motor to rotate it from side to side. They are both based on the basic tribot platform seen here: http://www.nxtprograms.com/explorer/index.html In fact, the "wobbler" design, using the light sensor, was an extension of the Explorer design and worked very well for me. Note that in the "2LSLS" design, the light sensors are mounted forward, facing about 45 deg off center in each direction. Cheers and good luck with your project. -Loopy Is this a good solution, or does I need to continue with searching/making a other solution ? (Loopy used 2 light sensors). Thanks, Wildman His attachments, where to big so I post some links: https://sourceforge.net/apps/phpbb/mindboards/download/file.php?id=167 https://sourceforge.net/apps/phpbb/mindboards/download/file.php?id=166 Quote
SlyOwl Posted December 27, 2010 Posted December 27, 2010 It should also be possible to use a vector-based solution, which would enable finer angles than 90'. Using cartesian axes, North and East are the positive directions (all compass-points are fixed to the robot). Have the 4 sensors at 90' angles to each other. Call the angle the robot needs to move at to get to the brightest light A, measured clockwise from North. Thus, we resolve to get: North - South = resultant vertical vector (V), and East - West = resultant horizontal vector (H). And then some simple trigonometry to find the angle: TanA = H/V, so A = Arctan(H/V). This process can be constantly repeated, as once it has rotated to the correct angle, the horizontal resultant vector will equal 0, so only the vertical is relevant, which will be in the direction of the light source. In terms of programming, you will want it to stop when it reaches the brightest light - so by taking the magnitude of the resultant vector, if it = 0, then the robot should stop moving (as it has reached its destination). Thinking about taking the project further, what if two equally bright lights are placed equidistant from the robot? It should end up finding the midpoint between them, providing the program works as it should. But it hasn't reached a point of maximum brightness (generally, speaking - it does depend how close the lamps are and how bright they are - the overlap area could be brighter than directly below a single lamp). A random movement function once it has reached equilibrium could resolve this - eg. it moves NW for 0.5 seconds. If there are equidistant lamps, it will then no longer be in the middle, and one will be brighter than the other (to the robot), so it will move in that direction. If it has genuinely reached the brightest point, then the program will move it back to the brightest point. A counter could be used to prevent it repeatedly moving randomly once it has reached equilibrium. Ach, I've been rambling on - apologies if none of this has been helpful! Good luck with the project - it's the kind of thing I would love to do. I'm afraid I'm no help with the programming, as I only have the RIS 2.0... Quote
Wildman Posted December 28, 2010 Author Posted December 28, 2010 I'm trying to improve the driving angle, so I started with some adding values etc. The software program (again to big to put it in attachments): https://sourceforge.net/apps/phpbb/mindboards/download/file.php?id=172 But it doesn't work any more. Only light sensor 1 (south) does react on a flash light (light sensor 1 is blinking, I don't know why). All the other light sensors (2/3/4 > East/North/West) doesn't react on the flash light. The robot is just driving straight on now. Anyone can help me ? I think I made a stupid fault somewhere. Thanks, Wildman Quote
dolittle Posted December 28, 2010 Posted December 28, 2010 I'm trying to improve the driving angle, so I started with some adding values etc. The software program (again to big to put it in attachments): https://sourceforge....file.php?id=172 But it doesn't work any more. Only light sensor 1 (south) does react on a flash light (light sensor 1 is blinking, I don't know why). All the other light sensors (2/3/4 > East/North/West) doesn't react on the flash light. The robot is just driving straight on now. Anyone can help me ? I think I made a stupid fault somewhere. Thanks, Wildman Hi, It is hard to say, but from what I saw it looks like your wires aren't connected, some of them at least, they are not going into an A/B etc slot. I would remove all of them and reconnect them and try again. Thanks, Noam Quote
Wildman Posted December 28, 2010 Author Posted December 28, 2010 Hi, It is hard to say, but from what I saw it looks like your wires aren't connected, some of them at least, they are not going into an A/B etc slot. I would remove all of them and reconnect them and try again. Thanks, Noam I have reconnect some / connect some I forgot :O But doesn't work. Same problems. Thanks, Wildman Updated program: https://sourceforge.net/apps/phpbb/mindboards/download/file.php?id=172 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.