Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

Get Started
Asked — Edited

Halloween Is Coming Soon

Hello To All,

This time of year my old plc controllers and arduino ends up at my friends Halloween Barn. I program a number of displays for our friends, both fiends and ghouls amusement.

This year my poor robots will become brainless for a while and two of my ezbv4's will become an addition to the party. One may run a talking head with facial tracking.

I was wondering if the object tracking mode works with an IR camera hooked to my computer? I would like to use my second ezb to run servos and a couple relays using object location and tracking (people) in the dark.

Any experiences or ideas?

Ron R


ARC Pro

Upgrade to ARC Pro

Harnessing the power of ARC Pro, your robot can be more than just a simple automated machine.

#19  
One problem I see is the amount of time you have given the Control Commands to execute may not be long enough. The Sleep time is in milliseconds so ;

Code:


Sleep(1000) # sleep for 1 second
Sleep(5) # sleep for 5 milliseconds

Maybe try increasing the sleep commands to give time for everything to run.
#20  
I have changed the time ranges from 50 to 500 and still had the same problem. The original time was 500. It signals and advances every time, but the problem is the effect on the script. I seems to slow the script it calls way down. I don't know how to make it pulse the "Script start" ?

Ron R
#21  
How long does it take for each of your CC ' s to run? I know in my scripting if it takes 3 seconds for a CC to run, I have a 3 second Sleep after it. That way the script won't move to the next function until that one has run. If I don't give a CC enough time to run weird things happen.
#22  
My scripts are driven by a sequencer. When a push button hooked to D8 is pushed the script starts. The problem is the servos move real steppy and slow. If I shut the script box which holds the button and sequencer script off while the script is running, everything speeds up to normal. If I operate a script using the script manager the scripts work fine.

The problem is in the button / sequencer script, but I don't know why. I messed with timing, but it doesn't change or resolve the problem.

Ron R
#23  
Hi @bhouston

I got weird things happening so I will add a lot of sleep time (5000) and give it a try. I will let you know if it helps

Thanks,

Ron R
#24  
Try using ScriptStartWait instead of ScriptStart. This keeps the program from proceeding until the skit ends. There may be unintended interactions occurring by letting the program flow continue right after starting the script for a given skit. That way the timing should not be so critical either.
#25  
Thanks, I will give that a shot too.

Ron R
#26  
Hello @bhouston and @WBS00001. You guys were right ! It was a timing issue. I put a 20 second sleep (upper average skit time) in between the CC and the problem went away.

I will put the program on the cloud when I am done.

Thanks for the replies which helped a lot.

I will post a video soon.

Ron R
#27  
Right on ! Glad you got it working. Looking forward to seeing the video.
#28  
I'm curious, did you try the ScriptStartWait thing? I would have thought it would have eliminated the need for any delay since it would have prevented anything from proceeding until the skit was done. Also, the same goes for any of the sub-scripts you run for the actual actions. If there are any CC calls there, they should be using the ScriptStartWait as well.

The only thing I can think of, offhand, that the ScriptStartWait would not take into consideration would be the actual movement of the servos since they are asynchronous to everything. That's where I would think delays might be needed. To give the servos time to do their thing before allowing the script to proceed.
#29  
Hi @WSB00001

When I tried the ScriptStartWait it didn't seem to work. The servos did the same slow step thing, but the audio still ran ok like normal. I then tried writing a Sleep with a time of 30 seconds (just a guess number) and the problem went away. The real problem is the interaction between my sequencer and the script manager and the sleep time assures enough time to run the script/skit. I am past my deadline so I loaded the sleeps based on the longest script/skit time, which fixed / patched the problem. Once everything is running, I will review the whole Sequercer / ContolCommand section and see if I can debug more and simplify it.

I will be posting the whole program to the cloud once it is done as it is now. That way you can look at what I did and how it runs.

I am a beginner at writing scripts so you may see weird program logic, but I am happy I wrote something with everyone's help that works.

Thanks for the thought of ScriptStartWait. (I learned a new command). It still may be the way to go.

Ron R
#30  
Would like to see a video of this project in action when you get the chance....:)
#31  
I will be posting it soon. Look for it under the post "the Great Madame Ninndo"

Ron R
#32  
@ANDY ROID Have you changed the servo speeds at all or are you running all servos at the default "full" speed? Also be aware that the autopostioner controls servo speeds to an extent depending on whether you are using "jump to" or "Transition to" and CC commands...

Can you post an example of one of your actual servo movement scripts?
#33  
Hi Richard, I am working today so It will be a while. Just for information, I only had the problem when I ran the sequencer. The Auto Position scripts work fine from the Auto Position panel. (I am using some old VEX servos I was given, which are not the greatest, and run a bit lumpy, but they work.)

I am using the default settings for the servos, and the CC command is like we discussed earlier. I think the problem was caused by the control command. Maybe this caused a loop which would "pulse" the Auto Position file and cause the "steppy" problem. Once I added a time delay to allow the script to run to the end, the problem went away.

I would think the servo action shouldn't change by using the sequencer the way it did ? The added time delay seems to have fixed the original problem.

Anyway I will try to post it later today.

Thanks,

Ron R
#34  
Hello @Richard R,

I posted to the cloud, the whole program of Madame Ninndo. I think you can look at the programming I used, instead of me posting pieces.

What you see works. I hope to refine it once I complete all my other projects. I need it running for the party so it is rough, but works. I have to add more "fortunes" and steps which will take some time and we are getting down to the last minute and I still have two more displays to get running.

If you look it over and see a problem I should fix, let me know.

Thanks for your help on this project. Remember, I am new to this programming.

Ron R
#35  
Saw the videos of the Madam, they were great. As is the project.

Anyway, I've had a little time to look over your code and I thought I'd make one recommendation now. All those If-ElseIF statements in the main script can be eliminated by doing this:

Code:


$counter=0
:loop
WaitForChange(GetDigital(D8))
Sleep(5)

if(GetDigital(D8)=1) # button press was true
$counter++
ControlCommand("Script Manager", ScriptStart, "Script "+$Counter)
Sleep (25000)
endif
Goto(loop)


The "Script "+$Counter part is the trick. It makes the appropriate string such that the proper script will be called.

NOTE: Don't leave out the space at the end of the word Script. If you do, the script name would be Script1 or Script10, instead of Script 1 or Script 10 like it must be to match the actual script names.

A variation on that would be to use the GetRandomUnique() function like this:

Code:


$counter=0
:loop
WaitForChange(GetDigital(D8))
Sleep(5)
if(GetDigital(D8)=1) # button press was true
$Counter =GetRandomUnique(1,21)
if($Counter > 21)
$Counter =20
endif
ControlCommand("Script Manager", ScriptStart, "Script "+$Counter)
Sleep (25000)
endif
Goto(loop)

That will run one of the 20 scripts at random each time the button ispressed.

FYI, the GetRandom and GetRandomUnique functions have a bug in them that won't allow the max value to come up very often, if ever. That's why the extra lines are in the code above:

Code:


if($Counter > 21)
$Counter =20
endif

Notice that I put 21 in the GetRandomUnique function as the max value and not 20. Doing that makes 20 come up as often as any other number, overcoming the bug. But there is no 21st routine to run, so if 21 ever does come up, it will be set right back to 20. In this particular case, if it tried to call the nonexistent Script 21 nothing would probably happen anyway, but it's better to be safe.

I think I see why the ScriptStartWait I had recommended in a previous post didn't work as I thought it would, but I'll need to run some tests to be sure. I'll get back to you on it.
#36  
Hi @WBS00001,

I had hoped you enjoyed the project. The scripting was my first attempt and proved to be a challenge. I thank you for your original help.

This new scripting you have shown me really improves the opportunities. I had planned on adding more fortunes to the program and the changes you proposed will really add a lot to the overall running.

I also have a project I have been working on,(Lillian) which, with this scripting, will make it work more like I want. It will run the phrases so they don't sound like "out of the can".

Thanks for the information and again I am happy you liked the "Madame".

Ron R
#37  
Good, I hope the changes help. At least you won't have to add another elseif if you add another skit. In fact if you define the max number of skits at the start of the code, you won't have to change the number in all the places it's used. Like this:
$MaxLoop =20

That way, in the places you use 20 (or a number based on 20), you can do this instead:

Code:


|
if($Counter >= $MaxLoop )
$Counter =$MaxLoop
endif
|

Same for the Random number chooser:

Code:


$Counter =GetRandomUnique(1,$MaxLoop+1)
if($Counter >= $MaxLoop+1)
$Counter =MaxLoop
endif


That way you only have to change the $MaxLoop =20 to whatever number of skits is at any given time. All the places the number is used will automatically change to work properly.

Also, I realized I put the line Sleep(5) in the wrong place. It should have gone right after the WaitForChange(GetDigital(D8)) line. It needs to happen before you check it's state. I changed it in the pervious post.

Annnnd, I left out the set back to 0 at the count of 20 in the overall loop in the first example. No doubt you would have realized that, but being the stickler (meaning pest) I tend to be I thought I'd mention it anyway. :)
#38  
Thanks for the updates.. and the details. I will try it soon, and will post any questions.

Ron R