I was trying to test the right arm in myrobotlab. So I added several lines for the right arm in InMoov2.minimal.py so it looks like this:

 
i01.startRightHand(rightPort)
# tweaking defaults settings of right hand
i01.rightHand.thumb.setMinMax(35,145)
i01.rightHand.index.setMinMax(35,148)
i01.rightHand.majeure.setMinMax(35,149)
i01.rightHand.ringFinger.setMinMax(36,149)
i01.rightHand.pinky.setMinMax(37,149)
i01.rightHand.thumb.map(0,180,35,145)
i01.rightHand.index.map(0,180,35,148)
i01.rightHand.majeure.map(0,180,35,149)
i01.rightHand.ringFinger.map(0,180,36,149)
i01.rightHand.pinky.map(0,180,37,149)
#################
i01.startRightArm(rightPort)
# tweak default RightArm
i01.rightArm.bicep.setMinMax(46,120)
 
However, when I execute the code, the bicep was trying to go to 0, and it completely ignored the limit I set (46,120).  I was told the servo will go to Gael's default rest angle (0) before the setMinMax() takes effect. Is there a function to override this? Thanks for any help!

 

GroG

8 years 6 months ago

Hello Dr Robot and Welcome !

You can "create"  & "adjust" before you "start"

In your script your starting before adjusting ...

More like this :

rightHand = Runtime.create("i01.rightHand","InMoovHand")
 
# tweaking defaults settings of right hand
rightHand.thumb.setMinMax(35,145)
rightHand.index.setMinMax(35,148)
rightHand.majeure.setMinMax(35,149)
rightHand.ringFinger.setMinMax(36,149)
rightHand.pinky.setMinMax(37,149)
rightHand.thumb.map(0,180,35,145)
rightHand.index.map(0,180,35,148)
rightHand.majeure.map(0,180,35,149)
rightHand.ringFinger.map(0,180,36,149)
rightHand.pinky.map(0,180,37,149)
 
rightArm = Runtime.create("i01.rightArm","InMoovArm")
rightArm.bicep.setMinMax(46,120)
 
i01 = Runtime.start("i01","InMoov")
i01.startRightHand(rightPort)
i01.startRightArm(rightPort)
 
 
You can also set a rest value of a Servo with :
someServo.setRest(75)
 
And there is a big difference between "map" and setting min/max limits, although the results can be similar.  Mapping is mapping a range onto another range.   Min / max are hard limits.
An analogy would be mapping is like adjusting volume, while min/max clip the output..
 
Hope this helps !
(ps - you don't look like a Mr Robot, perhaps a change of avatar is in order ;)

Thanks GroG! I was using 

i01 = Runtime.createAndStart("i01", "InMoov")

at the very beginning of the script, so now should I change it to

i01 = Runtime.create("i01", "InMoov")?

It seems to me that setMinMax and map are redundant with each other, should I just use one or the other (map seems better)?  Also, someServo.setRest(75), is the input 75 a value before or after mapping?

PS, I'll change my avatar soon, that one is set by default:)

i01 = Runtime.createAndStart("i01", "InMoov")

this returns the "InMoov" service ... its can create to other Servo services... so it does not return a servo..

It does not directly own or control Servos...

This

rightHand = Runtime.create("i01.rightHand","InMoovHand")

is an InMoovHand (see the second parameter)  ... it has all the finger servos

When you create a hand - it creats all the finger servos.. so I'd recommend you look closely at the example I previously provided.

the reason the "InMoov" service does not directly create "everything" as soon as it starts, its because many people don't have all the parts ...

Try experimenting with the right hand statement and sample I posted

MinMax is clipping output
Map is mapping input & output ranges ... they in some ways can produce similar results - but they control different things.

It will take a while to get familiar.. don't hesitate asking questions... pleanty of friendly elves here...

Dr Robot

8 years 6 months ago

In reply to by GroG

Thanks a lot! I just tested the script after I made the changes you suggested, it worked great except a minor issue with the voice.  Here is the full script I have now:

rightPort = "COM7"
 
i01 = Runtime.create("i01", "InMoov") 
# starting parts
i01.startEar()
i01.startMouth()
#to tweak the default voice
##############
rightHand = Runtime.create("i01.rightHand","InMoovHand")
# tweaking defaults settings of right hand
rightHand.thumb.setMinMax(35,145)
rightHand.index.setMinMax(35,148)
rightHand.majeure.setMinMax(35,149)
rightHand.ringFinger.setMinMax(36,149)
rightHand.pinky.setMinMax(37,149)
rightHand.thumb.map(0,180,35,145)
rightHand.index.map(0,180,35,148)
rightHand.majeure.map(0,180,35,149)
rightHand.ringFinger.map(0,180,36,149)
rightHand.pinky.map(0,180,37,149)
#################
rightArm = Runtime.create("i01.rightArm","InMoovArm")
# tweak default RightArm
rightArm.bicep.setMinMax(0,80)
rightArm.bicep.map(0,180,0,80)
rightArm.bicep.setRest(10)
rightArm.rotate.setMinMax(40,160)
rightArm.rotate.map(0,180,40,160)
rightArm.rotate.setRest(90)
rightArm.shoulder.setMinMax(30,120)
rightArm.shoulder.map(0,180,30,120)
rightArm.shoulder.setRest(30)
rightArm.omoplate.setMinMax(10,70)
rightArm.omoplate.map(0,180,10,70)
rightArm.omoplate.setRest(15)
################
i01 = Runtime.start("i01","InMoov")
i01.startRightHand(rightPort)
i01.startRightArm(rightPort)
#################
 
# verbal commands
ear = i01.ear
 
ear.addCommand("attach right hand", "i01.rightHand", "attach")
ear.addCommand("disconnect right hand", "i01.rightHand", "detach")
ear.addCommand("rest", i01.getName(), "rest")
ear.addCommand("open hand", "python", "handopen")
ear.addCommand("close hand", "python", "handclose")
ear.addCommand("move arm", "python", "movearm")
ear.addCommand("manual", ear.getName(), "lockOutAllGrammarExcept", "voice control")
ear.addCommand("voice control", ear.getName(), "clearLock")
  
ear.addComfirmations("yes","correct","yeah","ya")
ear.addNegations("no","wrong","nope","nah")
 
ear.startListening()
 
def handopen():
  i01.moveHand("right",0,0,0,10,10)
 
def handclose():
  i01.moveHand("right",180,180,180,180,180)
 
def movearm():
  i01.setArmSpeed("right", 0.5, 0.5, 0.5, 0.5)
  i01.moveArm("right",90,90,90,90)
 
I have to add the highlighted line i01 = Runtime.create("i01", "InMoov") at the beginning since i01 is used to start ear and mouth.  Other than that, I created a new gesture movearm().  When I spoke "move arm", in the log file, I saw the robot did recognize the phrase "move arm" and it printed out "did you say move arm?", but the robot didn't speak it out. The robot did speak out "did you say open hand" and "close hand" with Gael's example code. Did I miss anything here? Thanks!
 

Never mind. I was using 1.0.119, which is the latest version I found under the download link. Later I found out I can download the latest build above the shout box:) I am running 1.0.1349 now and the voice works fine.