UltraSonic sensor is a device that measure distances. Use a SR04 or a SR05.
A value is sent to arduino when requested.
Useful to measure if someone is close from  the robot to shake hands. Or what ever you want.

Summary :

  • ELECTRONIC
  • SETUP
  • UTILISATION

ELECTRONIC



SETUP


Open InMoov/config/service_I_UltraSonicSensor.config and setup like below.

If you have two UltraSonic sensors, you will set one on each Arduino (left and right)

[MAIN]

ultraSonicRightActivated=True
ultraSonicRightArduino=right
trigRightPin=64
echoRightPin=63

ultraSonicLeftActivated=False
ultraSonicLeftArduino=left
trigLeftPin=64
echoLeftPin=63

To check if the UltraSonic is worky, you can type in the python window and execute:

print "ultrasonicRight test is: ", i01.getUltrasonicSensorDistance()

And see the result in the python tab.


UTILISATION


By default the ultrasonic is not triggered, you need to tell it to start to get echo.

How to use it with Right UltraSonic:

if ultraSonicRightActivated:

distanceRight=200
while (not distanceRight or distanceRight > 100):
  distanceRight=i01.getUltrasonicSensorDistance()
  print "==Ultrasonic=distanceRight=Distance:", distanceRight

How to use it with Left UltraSonic:

if ultraSonicLeftActivated:

distanceLeft=200
while (not distanceLefht or distanceLeft > 100):
  distanceLeft=i01.getUltrasonicSensorDistance()
  print "==Ultrasonic=distanceLeft=Distance:", distanceLeft

File exemple InMoov/gestures/shakehand.py