Blink Speed

Hello, Does anyone know how to control the blink speed when the Inmovv robot is sitting still. It looks like the robot is passed random eye blinks but I notice there is random veocity numbers. I would like to hold it at max speed "-1". Is there a defualt I can modify or a script ?  Can someone help point me to the correct file ?  thanks ;)

hairygael's picture

Hello, the blinking velocity

Hello,

the blinking velocity for the eyelids seems to have been hardcoded by Anthony, who created the service in MRL.

https://github.com/MyRobotLab/myrobotlab/blob/3125c6d3f320d7e4b55a95af4b65c2e42f4350cc/src/main/java/org/myrobotlab/service/InMoovEyelids.java#L38

it would have been better to give the possibility to change it simply with python.

You could create a code into your custom.py to modify that.

theDVSguy's picture

thanks

Thanks for the feedback....Ii guess you wouldnt have an example I can start with in the custom.py ?

hairygael's picture

Hello,Here is how to do it,

Hello,

Here is how to do it, this is not using the Custom script because we set more configs.

  1. Edit InMoov/skeleton/eyeLids.py
  2. Comment with "#" or remove the line eyelids.autoBlink(True)
  3. Add "MoveEyeLidsRandomize.py" script into InMoov/Life
  4. Edit InMoov/config/InMoovLife.config
  5. Add ;ramdom move the eyeLids
            [MOVEEYELIDSRANDOM]
            RobotCanMoveEyeLids=True
  6. Edit InMoov/Life/0_inmoovLife.py
  7. Add RobotCanMoveEyeLids=inmoovLifeConfig.getboolean('MOVEEYELIDSRANDOM', 'RobotCanMoveEyeLids')
  8. You should now be able to run your robot and modify the velocity and random timers for the eye lids.
  9. Note that if you update the InMoov folder with a new version, these modifications will be lost.
  10. I recommend to save these modifications also in another safe place.

 

MoveEyeLidsRandomize.py:

# ##############################################################################
#            *** ROBOT MOVE THE EYELIDS RANDOMLY ***
# ##############################################################################

if isEyeLidsActivated:
  MoveEyeLidsTimer = Runtime.start("MoveEyeLidsTimer","Clock")

  def MoveEyeLids(timedata):
    #redefine next loop
    MoveEyeLidsTimer.setInterval(random.randint(100,10000))
    if not i01.RobotIsSleeping and not i01.RobotIsTrackingSomething():
      
      if isEyeLidsActivated:
        i01.eyelids.setVelocity(-1,-1)
        #i01.setEyeLidsVelocity(random.randint(45,-1),random.randint(45,-1),random.randint(45,-1))
        #move the servo randomly
        i01.eyelids.moveToBlocking(random.uniform(0,180),random.uniform(0,180))
        sleep(0.2)
        i01.eyelids.moveTo(0,0)
      else:
        MoveEyeLidsTimer.stopClock()
    
  #initial function
  def MoveEyeLidsStart():
    if isEyeLidsActivated:
      print "moveEyeLidsStart"
      if not i01.RobotIsSleeping and not i01.RobotIsTrackingSomething():
        MoveEyeLidsTimer.startClock()
      else:MoveEyeLidsTimer.stopClock()
      
  def MoveEyeLidsStop():
    
    if not i01.RobotIsSleeping and not i01.RobotIsTrackingSomething():
      if isEyeLidsActivated:
        MoveEyeLidsTimer.stopClock()
        i01.eyelids.setVelocity(-1,-1)
        i01.eyelids.rest()

  if RobotCanMoveEyeLids==1:
    MoveEyeLidsStart()
      
  MoveEyeLidsTimer.addListener("pulse", python.name, "MoveEyeLids")
  MoveEyeLidsTimer.addListener("clockStarted", python.name, "MoveEyeLidsStart")
  MoveEyeLidsTimer.addListener("clockStopped", python.name, "MoveEyeLidsStop")

 

theDVSguy's picture

Thanks

Thanks Gael its working....its claiming I have an error in my eyelids config file which I cant seem to identify.

Looks all good to me...could the tweak could have caused an issue ?  I am attaching my config just incase.

Also notice that it can random blink 1 eye ?  Can I force it to do both ?

 

;----------------------------- EYELID CONFIGURATION ----------------------------------------
[MAIN]
isEyeLidsActivated=True
EyeLidsConnectedToArduino=right
;chose left or right existing and connected arduino

EyeLidsLeftActivated=True
EyeLidsRightActivated=True
;EyeLidsLeftActivated : 1 servo control 2 eyelids
;EyeLidsRightActivated+EyeLidsLeftActivated : 1 servo control 1 eyelid

[SERVO_MINIMUM_MAP_OUTPUT]
;your servo minimal limits
eyelidleft=35
eyelidright=50

[SERVO_MAXIMUM_MAP_OUTPUT]
;your servo maximal limits
eyelidleft=110
eyelidright=140

[SERVO_REST_POSITION]
eyelidleft=0
eyelidright=0

;----------------------------------- ADVANCED CONFIGURATION --------------------------------------------------

[SERVO_INVERTED]
eyelidleft=True
eyelidright=False

[MAX_VELOCITY]
eyelidleft=-1
eyelidright=-1

[MINIMUM_MAP_INPUT]
eyelidleft=0
eyelidright=0

[MAXIMUM_MAP_INPUT]
eyelidleft=180
eyelidright=180

[SERVO_PIN]
eyelidleft=22
eyelidright=24

[SERVO_AUTO_DISABLE]
eyelidleft=True
eyelidright=True

;----------------------------------- END --------------------------------------------------

 

hairygael's picture

Hello,Glad you can use it.I

Hello,

Glad you can use it.

I see, in your config, that you are using it with two servo motors, one for each eyelid, this is the reason only one eyelid is blinking. I have done the code to be used with only one servo controlling both eyelids.

I will see if I get a moment to review the code to make the modification and let you know.

In the meantime, if you know how to code python, you can do it yourself of course.

 

UPDATE: I modified the code and it should now work for both eyeLid.

Here is the new code:

# ##############################################################################
#            *** ROBOT MOVE THE EYELIDS RANDOMLY ***
# ##############################################################################

if isEyeLidsActivated:
  MoveEyeLidsTimer = Runtime.start("MoveEyeLidsTimer","Clock")

  def MoveEyeLids(timedata):
    #redefine next loop
    MoveEyeLidsTimer.setInterval(random.randint(100,10000))
    if not i01.RobotIsSleeping and not i01.RobotIsTrackingSomething():
     
      if isEyeLidsActivated:
        if EyeLidsLeftActivated and EyeLidsRightActivated:
          i01.eyelids.setVelocity(-1,-1)
          i01.eyelids.moveToBlocking(180,180)
          sleep(0.2)
          i01.eyelids.moveTo(0,0)
          sleep(0.1)
          i01.eyelids.disable()
        elif EyeLidsLeftActivated and not EyeLidsRightActivated:
          i01.eyelids.eyelidleft.setVelocity(-1)
          i01.eyelids.eyelidleft.moveToBlocking(180)
          sleep(0.2)
          i01.eyelids.eyelidleft.moveTo(0)
          sleep(0.1)
          i01.eyelids.eyelidleft.disable()
      else:
        MoveEyeLidsTimer.stopClock()
   
  #initial function
  def MoveEyeLidsStart():
    if isEyeLidsActivated:
      print "moveEyeLidsStart"
      if not i01.RobotIsSleeping and not i01.RobotIsTrackingSomething():
        MoveEyeLidsTimer.startClock()
      else:MoveEyeLidsTimer.stopClock()
     
  def MoveEyeLidsStop():
   
    if not i01.RobotIsSleeping and not i01.RobotIsTrackingSomething():
      if isEyeLidsActivated:
        if EyeLidsLeftActivated and EyeLidsRightActivated:
          MoveEyeLidsTimer.stopClock()
          i01.eyelids.setVelocity(-1,-1)
          i01.eyelids.rest()
        elif EyeLidsLeftActivated and not EyeLidsRightActivated:
          MoveEyeLidsTimer.stopClock()
          i01.eyelids.eyelidleft.setVelocity(-1)
          i01.eyelids.eyelidleft.rest()

  if RobotCanMoveEyeLids==1:
    MoveEyeLidsStart()
     
  MoveEyeLidsTimer.addListener("pulse", python.name, "MoveEyeLids")
  MoveEyeLidsTimer.addListener("clockStarted", python.name, "MoveEyeLidsStart")
  MoveEyeLidsTimer.addListener("clockStopped", python.name, "MoveEyeLidsStop")

theDVSguy's picture

thanks. I will give this a go

thanks. I will give this a go ;)

theDVSguy's picture

I cant see

I cant see why at startup it states I have an error in my eyelids config. It started when I made ur adjustements for the blink

 

;----------------------------- EYELID CONFIGURATION ----------------------------------------
[MAIN]
isEyeLidsActivated=True
EyeLidsConnectedToArduino=right
;chose left or right existing and connected arduino

EyeLidsLeftActivated=True
EyeLidsRightActivated=True
;EyeLidsLeftActivated : 1 servo control 2 eyelids
;EyeLidsRightActivated+EyeLidsLeftActivated : 1 servo control 1 eyelid

[SERVO_MINIMUM_MAP_OUTPUT]
;your servo minimal limits
eyelidleft=35
eyelidright=50

[SERVO_MAXIMUM_MAP_OUTPUT]
;your servo maximal limits
eyelidleft=110
eyelidright=140

[SERVO_REST_POSITION]
eyelidleft=0
eyelidright=0

;----------------------------------- ADVANCED CONFIGURATION --------------------------------------------------

[SERVO_INVERTED]
eyelidleft=True
eyelidright=False

[MAX_VELOCITY]
eyelidleft=-1
eyelidright=-1

[MINIMUM_MAP_INPUT]
eyelidleft=0
eyelidright=0

[MAXIMUM_MAP_INPUT]
eyelidleft=180
eyelidright=180

[SERVO_PIN]
eyelidleft=22
eyelidright=24

[SERVO_AUTO_DISABLE]
eyelidleft=True
eyelidright=True

;----------------------------------- END --------------------------------------------------

 

hairygael's picture

This might come because you

This might come because you are running only the eyelids on the right Arduino and no Arduino on the left side.

I haven't really figured why it's behaving to give the error.

But it seems you could remedy that with modifying the line 41 in InMoov/skeleton/eyeLids.py

if LeftPortIsConnected or RightPortIsConnected:

to:

if RightPortIsConnected or LeftPortIsConnected:

theDVSguy's picture

thanks

Illl give that a try thanks