Pingdar

javadoc

The pingdar service is a basic system which allows simple range collection from an UltrasonicSensor and Servo.  The UltrasonicSensor is swung back and forth and the range data is available to to consume by other services.  The GUI shows a basic "radar" map of what is found.

TODO

Here looks to be an excellent implementation of this common use case in Processing :

Processing Pingdar - http://www.tuelectronica.es/tutoriales/processing/radar-con-processing.html#

Examples:


#file : service/Pingdar.py edit raw
#########################################
# Pingdar.py
# more info @: http://myrobotlab.org/service/Pingdar
#########################################
# virtual = True

port = "COM3"
trigPin = 7
echoPin = 8
servoPin = 4

gui = Runtime.start("gui","SwingGui")

# start controler
arduino = Runtime.start("arduino","Arduino")
# start UltrasonicSensor
sr04 = Runtime.start("sr04", "UltrasonicSensor")
# start a pingdar
pingdar = Runtime.start("pingdar","Pingdar")
# start servo
servo = Runtime.start("servo","Servo")

if ('virtual' in globals() and virtual):
    virtualArduino = Runtime.start("virtualArduino", "VirtualArduino")
    virtualArduino.connect(port)
    
# attach all the parts
arduino.connect(port);
sr04.attach(arduino, trigPin, echoPin)
servo.attach(arduino, servoPin);
gui.fullscreen(True);
gui.undockTab("pingdar")

# start pingdar
pingdar.attach(sr04, servo)

# sweep from servo position 10 to 170 step by 1
pingdar.sweep(10, 170)

# continue to sweep 
# for 10 seconds
sleep(10)

# stop
pingdar.stop()
gui.dockTab("pingdar")
gui.fullscreen(False);