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#
Example code (from branch develop):
#########################################
# 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);
Example configuration (from branch develop):
!!org.myrobotlab.service.config.PingdarConfig
listeners: null
peers:
controller:
autoStart: true
name: pingdar.controller
type: Arduino
servo:
autoStart: true
name: pingdar.servo
type: Servo
ultrasonic:
autoStart: true
name: pingdar.ultrasonic
type: UltrasonicSensor
type: Pingdar