Asked
— Edited
Hi.
quick questions for scripting.
1. Is there a command that says "if __________ is said(microphone), start this script."?
2. Is there a way to say "if this script starts, do this."?
So as an example (My pseudo code, not ez script, you'll have to port it yourself. I'm trying to mix english and code so it makes sense.)
Assuming that 2. is the code for the function you are calling.
2.
IF sevo.d1.position = 45 (Then? does ezb use if then or just if?)
servo.d2.position=45
ENDIF
So, that says, if servo.d1(RightArm) is at position 45 then move servo.d2(LeftArm) to position 45. I've read enough of your posts to know that you know what I'm trying to show you. The mail came and went so no ezb till monday. So while I'm not experienced in EZScript, it seems to be an object oriented language. And I have yet to meet an OOL that I haven't been able to talk to ;-)
As far as OOL programing goes, the phrase "I walked the dog." means "I walked the dog." in any language you say it. (I wish human languages were as simple.) It's usually a matter of getting a syntax reference. The concept of programming is the same, you just have to think in things in terms of a language you already understand and then just look up the equivalent in the language you need to use. All of the OOL have fairly similar commands. One thing that gets people is the End Of Line or more to the point, what I call End Of Phrase.
Some languages simply treat a newline [Enter] as the end of a line of code or phrase. Others require the semicolon ( ; ) . Some languages use If () then {}, some use just, if(){}. () being where conditions go, and {} being where the code goes. I'm pretty sure when it comes to arrays, that ALL languages start at 0. You always have to be mindful of what I call 0 based returns and 1 based returns. Arrays start at 0. But Array.Count() in most languages starts at 1. So if you use Array.Count, it returns 5. But if you call or reference Array[5] it could error because, it is beyond the scope of Array. "It said I have 5 items in the Array." Yes, 0-4 is five items. So to call or reference the 5th Array object you'd use Array[4]. I said could error because you can define a max length of an Array and some languages fill the spots as some sort of "existing but empty" so it may throw an error while some languages see them all as "non-existent" or "undefined" and that would throw an error.
It may sound trivial but if you plan to explore multiple programming languages, especially object oriented, things like that are gonna be the best place to start looking when you go to porting code or learning a new language. They really are all very similar. OOL seems to be the current standard. I've never touched "C" and only dabbled very minimally in "C++". I've never had to use them to do anything I've ever wanted to do. But then I've never tried to start building robots till now ;-)
The first computer I owned, was a Commodore 128, back when I was about your age. I learned basic, where a novella's worth of code got a balloon to scroll across a monochrome screen. Oh the good old days of no-def computing. But I digress, Then I got into HTML and web design. Which led to JavaScript and PHP (I've always been a big fan of PHP.) Which lead to SQL, MySql. And then I was just sor of known as the computer guy. Alot of my skills after that came from people saying, "I'll give you $XX - $XXXX if you can do this for me." And I'd tell them up front that I don't know how long it would take, ask them if they had any language requirements, and a no money back lack of guarantee. Then they would say "Shut the hell up, you know you can do that sh*t."
I've always been more integrated in being able to do stuff, not getting paid to do stuff. Now that I'm older I sure do appreciate being paid, but I love to learn stuff and share what I've learned. That's what computers were about when I was your age. I've helped a few small businesses get off the ground. One folded, one screwed me. Quick lesson, when it comes to money, get a contract. I learned the hard way. But I'm not upset. That code is all super old now. It's not like they turned into a million dollar company off of my code. (I hope their still not using that old code, my lord. It was a rats nest).
You seem to have an aptitude towards this. I've no doubts that if you pursue your robotics interests the rest of your life you will make the world a better place or be solely responsible for the end of it. ;-)
With my coding, I could use variables and each script sets off a variable.
To start another script when one is started you can just add ControlCommand( "Script Manager", ScriptStart, "MyScript" ) at the start. So you set up voice recognition.
Phrase: "Jarvis test rc car robot"
Code:
Then at the start of the RCCarTest script you add in
Code:
Or you could do it a different way...
At the start of the first script, in this case RCCarTest you add in a variable so that ARC knows it's started...
Code:
Whenever the script can stop running add the following before where it stops
Code:
In your other script you use a WaitForChange() command and an IF (the IF may not be required but it makes it more accurate).
Code:
Or you could just let it loop around the :wait part, but this will use up more resources.
You could also use WaitForServoMove(servoport), Servo_Wait(digital port, higher/lower/equals, value), Digital_Wait(digitalport, on/off/true/false), ADC_Wait(adcport,higher/lower/equals, value), ADC_Wait_Between(adcport, low, high)... and a few more, just type in wait in the search box to the right of the script box to see all of those options.
and thanks rich
If you can think logically you just need to find the correct syntax for the commands, it's very easy to use.
You can play with it before you get the EZ-B too.
Wall-VIS?
JARL-e?
I don't know. which one is betterÉ
AWWWWW COME ON!
Servos, digital, movement etc. just add the servo/digital/movement controls and watch the script change them (ignoring the debug window throwing errors constantly)
Sensors, you can use random numbers to emulate sensors, check my PingRoam script for the test mode which I left in.
It'll also include a cool little lighting control idea I have had for my stair case for a while
And, don't forget to look at the examples in the cloud.
You could probably do it through Pandora Bot, EZ-Script and a lot of work. Pandora Bot is the only part of ARC which supports dictation, all others require a phrase list.
Code:
It all seems like going about things the long and messy way when you could achieve much better results through other software. You can pass information to ARC from other software quite easily using telnet, a lot of the fun scripts and actions I added to Melvin tonight use other software and pass results and variables (which act as triggers) to ARC through telnet via EventGhost's python scripting.