hello guys i use the roll neck with servos not hacked, 

in 1412 i used this script with sucess

def neckMoveTo(restPos,delta):
      leftneckServo.moveTo(restPos + delta)
      rightneckServo.moveTo(restPos - delta)
 
leftneckServo = Runtime.start("leftNeck","Servo")
rightneckServo = Runtime.start("rightNeck","Servo") 
right = Runtime.start("i01.right", "Arduino")
#right.connect(rightPort)
 
 
leftneckServo.attach(right, 13)
rightneckServo.attach(right, 12)
 
restPos = 90
delta = 20
neckMoveTo(restPos,delta)
 
but now is failing at neckMoveTo :(
 
can somene help pls

Mats

7 years 6 months ago

Hi Pedro

With a quick look if find two problems, if this is the complete script.

1. You have commented out the connect. That's OK if you connect manually thru the GUI or you do it in some other part of the script. I.e this line:

#right.connect(rightPort)

should be

right.connect(rightPort)

2, If you uncomment the connect, you also need to define a variable so that the script knows what port to connect to. Something like this:

rightPort = 'COM3'

If it's not the complete script, then please send a no-worky

/Mats

 

 

pedro

7 years 6 months ago

In reply to by Mats

mats thanks alot for the help, but is not that is uncommented and the rightPort was defined before :( but it doesnt mather i burn one ot them for some reason wasnt even atached and burned!!! 

 

so now im using only one and the other as a dummy, so also im not using that script anyway!!

 

this script used to work, well thanks anyway :)

Hi Pedro

In the latest release of MyRobotLab you can use the publish subscribe pattern to syncronize servos.

Like this:

# Remap the leftneckServo since it is reversed and 20 degrees offset to the right
# Depending on the direction of the offset you need to remap different
leftneckServo.map(0,180,200,20)

# Alternative, in case it the offset is in the opposite direction

# leftneckServo.map(0,180,160,-20)

# Make the left neck servo sync with the right hand servo
rightneckServo.addServoEventListener(leftneckServo)
rightneckServo.eventsEnabled(True)

Now you only need to send commands to the rightneckServo. The leftneckServo will follow.
/Mats