Award
Congratulations DJ Sures, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

Virtual Servos On Second Or Third Ezb?

Assistance Requested

Help Dave Schulpius with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

Dave Schulpius claims to have checked these sources:
 
#1

Can we have virtual servos assigned to more then one EZB in a project? I'm trying to run a script pointing to watch a virtual assigned to a second EZB in my project. I get the following error:

Code:


Start
1: :start
2: WaitForServoMove(1.V1)
> Error on line 2: Missing String Quotes or Invalid Expression at index 1: .V
Done (00:00:00.0468763)



Here's my script:

Code:


:start
WaitForServoMove(1.V1)
$ElbowPos = GetServo(1.V1)
#Commands for moving motor to position and
#speed based on the variable contents. I'll
#emulate with print commands.
print("The Elbow position is " + $elbowpos)
sleep(150)
goto(start)

I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.


Also, consider reviewing the Learn section for informative lessons and activities. Check it out!


#2

Since they are virtual, I don't think assigning them to a specific EZB makes sense. I am away from my computer, so can't check, but I think there are over 100 virtual servos so you shouldn't run out.

#3

OK, here's what I'm doing and finding out:

I want to trigger a DC motor that has feedback from a pot to move to a certain position through the Auto Position control. This motor is controlled with serial commands through a Uart port (through a Kangaroo X2) on EZB board 2 connection in EZ Builder.This motor is part of several servos in my robot arm. All these servos and the DC motor is connected to the third EZB (board connection 2) in my robot. I'm trying to control all the servos and the DC motor with a AutoPosition control.

I've got a Virtual servo set up (V1) for the DC motor in the AP control along with the other 3 actual servos built into this arm. This AP Control is pointing to #2 EZB board connection because all the servos in that arm are connected to the third EZB.

I've also got a regular Vertical Servo Control set up in the project pointing to this V1 virtual servo on board 2.

When I move the frame in this AP control I can see the other regular Vertical Servo control assigned to the board 2, V1's value change so I know it's working.

However when I try to write a script pointing to the V1 servo (2.V1) on board 2 I get the error you see in my first post.

If I just write the script pointing to V1 (with no board designation) I get no errors. However the script does not see the position change on the board 2, V1 in the AP control when I run the frame.

Could it be that scripts being able to see virtual servos in AP controls running boards other then 0 is not supported? *tired*

#4

Dave, if you re-read the post with my example, I point out that you can insert scripts directly into frames, so rather than using my script example that listens for the virtual servo position, just put the script statement right in the frame itself. (I would still use the virtual servo in the frame just to remind myself what I am having the script do, but it isn't actually required).

Let me know if this doesn't make sense and I will throw together another example.

Alan

#5

Dave,

1)
Virtual Servos are associated to an EZB board.

When the code below is executed:

Code:


Servo(V1, 90)


the V1's position is stored in EZB[0].

2) if your virtual servo is in EZB board 1, you need to address using the board prefix:

Code:


Servo(1.V1, 90)



3) your code is correct:

Code:


WaitForServoMove(1.V1)



it seems an EZ-Script Regular Expressions Parser Error/Bug.

@DJ:
I think the regular expression is doing a partial group capture
Please confirm if my assumption is correct.

#6

I'll take a look

#7

Thanks guys!

@PTP, It's good to know the script is correct. It's Alan's script that he had shared with me so I was pretty sure it was OK. I just added the designation of the second EZB board. I got the error after I changed the board designation. Thanks for the confirmation. It's good to know a pro has my back. Winky

@DJ, Thanks for being open to having a look at this. I know you have a billion things going on. This may seem like a little thing but it will be good to both have things work in EZ Script as expected and also to have my selfish needs satisfied. LOL Grin

@Alan, your continued help and advice is very welcomed and appreciated. Your nickname "thetechguru" is well deserved. Your explanation make perfect sense. Once I started writing/copying your scripts and setting up the AP control a light went on in my head and it was clear what you were trying to show me. Thanks again. I don't think there is any need for you to go to the trouble to make another example for me. Feel free though if you think it will help others.

I can see several ways to get this DC motor to work. Up until now to get my DC motor to move along with the other three servos in the AP control moving the arm I've placed it in a EZ script and created an Action from the frames found in the AP. A EZ Script for a movment would look like this:

Code:


#################################################################################
#Pair AutoPosition frame(s) along with Command
#to start Move_Rt_Elbow Script below. State any Position & Speed values to set
#Variables with each Move_Rt_Elbow CC so that script knows position & Speeds.
#Pick any value between hi and low. Each pair makes an action.
#
#Elbow Kangaroo Values:
#Position Varable is - $Rt_Elbow_Position -> p3000 -Full up, p2468 -Center, p1885 -Full Down
#Speed Variable is - $Rt_Elbow_Speed -> s2000 -Full Speed, s0 -Dead Stop
###################################################################################
#---------------------------------------

##Start Auto Frame arm movements

$Rt_Elbow_Position = 3000
$Rt_Elbow_Speed = 800
Sleep(50)
ControlCommand("Amanation Arms", ScriptStart, "Move_Rt_Elbow")
Sleep(500)
ControlCommand("Auto Right Arm", AutoPositionFrame, "Attack, Claw Open", 25, 4, 0)

Sleep(4393)

#---------

$Rt_Elbow_Position = 1800
$Rt_Elbow_Speed = 2000
Sleep(50)
ControlCommand("Amanation Arms", ScriptStart, "Move_Rt_Elbow")
Sleep(300)
ControlCommand("Auto Right Arm", AutoPositionFrame, "Center", 25, 20, 0)

Sleep(1099)
#---------
$Rt_Elbow_Position = 2850
$Rt_Elbow_Speed = 2000
Sleep(50)
ControlCommand("Amanation Arms", ScriptStart, "Move_Rt_Elbow")
Sleep(300)
ControlCommand("Auto Right Arm", AutoPositionFrame, "Reach to Collar, Claw Open", , 25, 3, 0)

#--------------

$Rt_Elbow_Position = 2000
$Rt_Elbow_Speed = 800
Sleep(50)
ControlCommand("Amanation Arms", ScriptStart, "Move_Rt_Elbow")
Sleep(50)
ControlCommand("Auto Right Arm", AutoPositionFrame, "Attack, Claw Open", 25, 40, 0)



And so on.... Kinda clunky and I had to manually time the movements with sleep commands between frames. I had hoped by using Virtual servos and the Action feature of the AutoPosition control I could do away with the timing sleep() commands and let the AP do all that.

Now what I suspect I'll do if I don't use virtual servos in the AP Frame for the DC motor is just place the ControlCommand to start the script to move the elbow motor ("Move_Rt_Elbow", located in an outside script from the AP for threading purposes) in the AP frame script. This script sends the serial command for elbow position and speed to the Kangaroo X2 and Sabertooth to move the Elbow's DC motor.

I still need to decide if I want to use the Action feature of the AutoPostion control for stitching together multiple frames or script them in outside scripts like I posted just above. I'd love to just use the AP and EZ Script actions.

Looking over my EZB's I do see I have six Digital ports open on EZB - 0, If DJ can't get to this issue anytime soon, I could just move the six arm servos attached to EZB - 2 over to EZB - 0. That would solve not being able to have a EZ Script see a virtual servo running on a second or third EZB. However I really did want to keep my arms running off their own EZB because EZB - 0 is almost full. The second EZB the arm servos are connected to gives me the extra ADC and Uart ports I needed. I don't really know if there is any other benefit or penalty running the arms off a separate EZB Ver4/2 other than that.

Thoughts or suggestions? Smile

Thanks again everyone! Smile

#8

It'll be in the new year, next week.

#9

Thanks Sir!

#10

Happy Winter Solstice... We are officially on winter.

@DJ,

Thanks for the fix. I'm working in a project and i will use the Virtual Servos.
i'll do an open source custom plugin similar to the Dynamixel, i hope can help demo the SDK api methods.

@Dave,

Thanks for the kind words, although i don't feel like a pro, i'm not working for the Google Brain project Smile

Alan is the man... When i grow up i would like to be like him Smile patient and one thing at a time... I do multitasking and sometimes i miss simple things, going then for the big issues.

Thanks Alan