Basic Train - Colour detection - Multitasking #1941
-
So I watched the video: https://www.youtube.com/watch?v=kwnSbnlhOkA and learnt a lot I have a train happily going about and detecting the tiles correctly.. what I would like to do, is combine both parts, and have the train constantly output what colour it is driving over I've attempted to use the multitask block, but it's not working - what am I doing wrong? Have read through half a dozen discussions regarding multitasking in here, but couldn't get anything to work I suspect it's something to do with each subroutine... as I get console Print output when it stops at each colour (and when the program first starts, if it's sitting on a plain piece of track) Thanks for any assistance :) |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
Your blocks look right; This should be working, so maybe it is something under the hood. Which version of the app are you using? (See app settings, click on Can you share the generated Python code and copy it here? Do you get any errors while doing this? Now that I think about it, is it saying anything about not using the same resource (like the sensor) in two parallel tasks at once? (As an aside, you can even skip the explicit multitask and the two tasks you made: you could just take another start block. This generates exactly the same code though, so it's just a matter of preference and should not make a difference for this issue.) If by any chance you are using the beta version, make sure to install the corresponding firmware as well. |
Beta Was this translation helpful? Give feedback.
-
I actually tried that first! two seperate stacks! I wonder if that's the issue.. yes I'm coding in the Beta.. but the hub I grabbed didn't have the latest, and since it was late last night, and I was in a hurry, I skipped the firmware update.. (it's mostly likely on the previous beta one, as it's only been a month since I last sat down and did some programming. Again.. it's working OK when the motors pause, and it's sitting over the coloured end tiles (Orange/Green).. and I get 4-5 lines output, during the wait cycle... but it doesn't output "Blue Track", nor any of the other 2 colours it passes over. Will try the firmware update tonight, and report back. |
Beta Was this translation helpful? Give feedback.
-
So.. I couldn't wait.. and ducked out to my workshed before going to work today... and did a quick firmware update it was on 3.5.0 before... updated now to 3.6.0b2, and working exactly as expected, without any changes to the code blocks! thanks! (I guess I shouldn't ignore firmware updates!!) |
Beta Was this translation helpful? Give feedback.
-
A side question while I'm here: I have both Colour and Distance Sensor, as well as the Spike Colour sensor - what are the pros and cons of each one? with regards to this application (automated train) Does either one perform this task better than the other? I'm currently using the Colour sensor, but might switch back to the other, as it's a bit smaller, and easier to fit inside the small monorail train I'm building. |
Beta Was this translation helpful? Give feedback.
Your blocks look right; This should be working, so maybe it is something under the hood. Which version of the app are you using? (See app settings, click on
about
).Can you share the generated Python code and copy it here? Do you get any errors while doing this? Now that I think about it, is it saying anything about not using the same resource (like the sensor) in two parallel tasks at once?
(As an aside, you can even skip the explicit multitask and the two tasks you made: you could just take another start block. This generates exactly the same code though, so it's just a matter of preference and should not make a difference for this issue.)
If by any chance you are using the beta version…