Asked
— Edited
I remember DJ commenting a few weeks ago that using the waitforchange command takes just a little bit more resources then a loop using a GoTo command. It seems that most proficient script writers here are under the impression that it's the other way around. I thought so too until I read DJ's comment. Did I misunderstand what DJ was saying and the waitforchange command is really most efficient way to go?
Also; if the waitforchange is truly a loop that runs in the background and constantly checks status of the $variable do we need to insert a Sleep command like a GoTo loop to help with freeing up resources?
Any thoughts or answers? Thanks!
Richard, Thanks for the kind words. I dont feel like I have leapfrogged but just have a programer background to leverage off of. I would love to have Dave's robot manufacturing skills and a lot of the skills you possess. The thing that I love about the community is that we can all leverage off of each others strengths to all have some incredible robots (along to a huge thanks to DJ and the EZ-Robot team for allowing this to happen).
I also think you helped me wrap my head around what was happening in ARC (along with others here). Understanding is key with scripting and with pretty much everything that we do here. Fear to learn is the thing that keeps most people back. This community doesn't have that fear which makes it a very powerful community.
@David.... no group hug coming
... You're right, everyone brings something to the table... I did ok writing code for the basic stamp microcontroller and arduino.... But it wasn't until I came here that I "really" learned how to program on a respectable level... It's not just coding, but I learned concepts as well....
Simply put, I personally use WaitForChange when I need the script to wait until something has changed and use Goto loops when I need loops. The clue is in the command
For instance, the digital clock I wrote for the LCD display in Melvin used WaitForChange to check the time and update every second but I could have written more code and used an If and Goto loop.
The good code was (simplified to print rather than I2C commands);
The same result could be done by checking the seconds using an IF statement and looping until the seconds changed (I won't post the code since it's pointless).
Similar is the RepeatUntil command, this can also be achieved by using an IF statement however it's pointless and more code if you do use an IF statement to loop so many times. If I can save on writing 1 extra line of code I will.
Thanks again for taking the time to help me understand this concept in terms I can understand. You guys are good teachers. David's right, we need each other's skills to make good robots that work like we want them to.
Very Interesting. So all processing for a script takes place on the PC? Like WaitForChange. It is actually a loop running in the background and the processing for it takes place entirely on the PC. Likewise, all the variables queried actually reside on the PC. Is that right? If it is, my question becomes, what changes the state of the variables (stored on the PC) and when does that happen?
I ask because I had envisioned that the V4 was running a process "in the background" (a thread), looking at a variable on board itself and returned a point of data when the variable changes, placing it in a variable in the PCs memory.
Variables are set and changed by script commands inside controls or EZ Scripts within ARC. ARC uses the power of your computer to do the work and sends the command off to the EZB.
ARC is the controlling software and code runs there. There is a connection to the ezb via wifi. The ezb is controlling your hardware devices and waiting for commands to be sent to it from ARC. ARC can retrieve the data from the hardware devices via the ezb. If you set a value from one of these to a variable, that is happening in the ARC software. The ezb doesn't know or care about variables. Image processing is happening in ARC. For example, if you are using face tracking, the ARC software is telling the ezb to move the servos to track the face. It ezb is just sending the data and is responding to the requests to move the servos.
This allows the pc to be used for all of the heavy lifting. The ezb is basically a communication bus. This is why DJ described EZROBOT as a software company. It also allows updates to be made without having to update the EZB. It is also why ARC can run without being connected to the ezb.
What I said.... Be careful David, your teacher is showing.
And don't stop letting it show. We'er lucky to have you here on the forum and being so engaged. 