
bobjacon

Don't laugh too hard...I'm a noob learning how servos work for the first time.
I am just learning how to script with EZBuilder manually...
Working with an inMOOV robotic arm/hand.
I have a script that moves 5 servos - 1 at a time for each finger.
The script looks like this...
SetServoMin(D0,1)
SetServoMax(D0,160)
SetServoMin(D1,1)
SetServoMax(D1,160)
SetServoMin(D2,1)
SetServoMax(D2,160)
SetServoMin(D3,1)
SetServoMax(D3,160)
SetServoMin(D4,1)
SetServoMax(D4,160)
Servo(D0,1)
Sleep(500)
Servo(D0,160)
Sleep(500)
Servo(D0,1)
Sleep(500)
Servo(D0,160)
Sleep(500)
Servo(D0,1)
Sleep(500)
Servo(D0,160)
Sleep(500)
Servo(D0,1)
Sleep(500)
Servo(D1,1)
Sleep(500)
Servo(D1,160)
Sleep(500)
Servo(D1,1)
Sleep(500)
Servo(D1,160)
Sleep(500)
Servo(D1,1)
Sleep(500)
Servo(D1,160)
Sleep(500)
Servo(D1,1)
sleep(500)
Servo(D2,1)
Sleep(500)
Servo(D2,160)
Sleep(500)
Servo(D2,1)
Sleep(500)
Servo(D2,160)
Sleep(500)
Servo(D2,1)
Sleep(500)
Servo(D2,160)
Sleep(500)
Servo(D2,1)
Sleep(500)
Servo(D3,1)
Sleep(500)
Servo(D3,160)
Sleep(500)
Servo(D3,1)
Sleep(500)
Servo(D3,160)
Sleep(500)
Servo(D3,1)
Sleep(500)
Servo(D3,160)
Sleep(500)
Servo(D3,1)
Sleep(500)
Servo(D4,1)
Sleep(1000)
Servo(D4,160)
Sleep(1000)
Servo(D4,1)
Sleep(500)
Servo(D4,160)
Sleep(500)
Servo(D4,1)
Sleep(500)
Servo(D4,160)
Sleep(500)
Servo(D4,1)
Sleep(500)
How can I get all 5 servos to move at the same time? Is there a way to execute 5 commands at the same time from the same script on the same line?
Can someone give me a short example? I want the robot to close his hand and then open his hand...or maybe open two fingers while 3 are closed.
Any help would be appreciated so I can see how this might be accomplished.
Thanks!
BobJ
Apart from the great advice @bhouston gave above about Auto Positon control which is a great feature, you can manually do it with scripts as you asked as well. You could use something like the following...
Code:
Or to have two fingers move at the same time...
Code:
And one final example of moving two fingers at the same time, but at a slower speed...
Code:
Hope that helps.
Learn reff: http://www.ez-robot.com/Tutorials/Help.aspx?id=180
Have a look at an example from my project
Tandem Inmoov Arm & Ezb
Code:
This assumes the finger servos are in sequence 1-5. What I'm wondering is will all the fingers open at once or will they open in sequence? I'm guessing all at once since Servo() is a non-blocking instruction. I can't test this for myself since I STILL don't have my JD after a month, nor do I have a hand of this type. This would also allow for settings in between as well such as $HandAThirdOpen, $HandAForthOpen, etc. Or any value in between by setting $HandPos with a number directly.
BobJ
Sure, you can do that - but why would you?
However, since you posted your script I would just point out that there's no need for it to be in that order. You could remove a goto by reordering the "TheStart" section to before the "MoveAllFingers". Why have the code jump around all over the place when there is no need for it to do so?
But, again, Auto Position would achieve everything you want to achieve (and more) easier and quicker than writing a script.
Well, as I see it, using the autopositioner is fine, but not very flexible. That is to say, the results from it are fixed and does what it does the same way every time you run the frames. And that's fine for things like the getting up task. That's a complex operation and will probably be the same every time you use it. Still, If you want to change anything, no matter how slight, you basically have to go back to the autopositioner software control to do it. Also fine by me for some things.
To me, the finger movement under discussion is different. Using autopositioner I can get it to open or close, yes, but, if I want something in between I have to go through the process of moving each finger in the AutoPosition setup to where I want them to be or move to. Then have it generate the script code for that particular sequence. Create a frame and group frames as needed, etc. If I want a different position, I have to do the same thing again. With the example I gave I can set the fingers of the hand to any position (not just full open or full close) with just two lines of code.
Now I'm a neophyte here and I understand that and there are ways to use autopositioner of which I am not aware I'm sure. I don't mean to step on any toes, I just wanted to see what others thought of that method. And to find out of it will actually work as described. Still don't have a JD yet so I can't test it out for myself, so I threw it out there.
Yes, you're right. Moving the "MoveAllFingers" to after the the calling section instead of before it would be better for this simple example. But I look at the MoveAllFingers routine as something that would be called many times in a given real program. Making sure it is always at the end of the main program sequence would become tedious every time I add to the overall program. Putting it up front eliminates that problem. The same for other routines I would call from several different points on the overall program. I would declare them all up front first. Generally makes it easier to add new such routines as well. Plus, what the hell, it's habit for me to do it that way.
Likewise with the variables I would use in the program. I would declare them up front to make their initial declared values easy to change. I usually add many variables to use as constants as well. For instance I would declare a variable for each servo and use that variable throughout the script as opposed to directly using the servo port number. That way if I change the port for a particular servo all I have to do is change that value in one place.
ALWAYS THE HARD WAY!
Next, I will try Bob Houston's and Aerius's and Richard R and Dj's advise with Auto Position control. I also have to figure out how to tighten the braided fishing line as my fingers are not tight enough. I'm sure there is an art to it.
Thanks guys!
BobJ
Perhaps hard to you, the familiar (and correct) way to me.
Thanks. I wondered about that. That was going to be the next thing I looked at to see how all that was usually done. I'll start with your example. Does seem like a good way to isolate program sections for reuse. Also perhaps a way to introduce "scope" into the whole thing.
What a GREAT idea! Can you point me to a source as to where someone can find screws like that? I don't even know what to call them but that would solve that problem pretty well.
BobJ
LOL!
You had me thinking that there was a small screw with a hole through it like tuning peg available someplace!
However, thanks for describing what you mean...it will do the same thing!
BobJ