Download - Elegant avoiding of obstacle
HelloApps.com
Elegant avoiding of obstacle
Young Joon Kimhttp://www.helloapps.com
MSRDS First Beginner Course – STEP5
HelloApps.com 2
Topics
• Preparing basic environment
• Detecting distance by using laser distance sensor
• Stopping robot driving
• Avoiding obstacles
HelloApps.com 3
Preparing basic environment
HelloApps.com 4
Preparing basic environment
• Add a “Data” activity and “SPL Engine”
• Type “Script/BasicEnv4.txt” in the “Data” activity
HelloApps.com 5
Preparing basic environment
• Execution result
HelloApps.com 6
Detecting distance
by using laser distance sensor
HelloApps.com 7
• Laser distance sensor
– Detect distance against target
– Notify distance with millimeter unit
– Max distance is 8000 millimeter
• SPL Engine provides notification data for laser sensor
– LRFNotify
• EntityName
• SensorData
– DistanceMeasurements
Detecting distance by using laser sensor
HelloApps.com 8
• Copy and paste “SPL Engine” service
Detecting distance by using laser sensor
1
2
Copy by pressingCtrl+C
Paste by pressingCtrl+V
HelloApps.com 9
• Add a “HelloApps Console” service
Detecting distance by using laser sensor
HelloApps.com 10
• Add a “Calculate” activity
Detecting distance by using laser sensor
HelloApps.com 11
• Connect the notification point of “SPL Engine” to the input
point of “Calculate” activity
Detecting distance by using laser sensor
HelloApps.com 12
Detecting distance by using laser sensor
• Select “LRFNotify” item from the left list
HelloApps.com 13
Detecting distance by using laser sensor
• Type ““Distance is “ +” in the Calculate
• Select “SensorData” from the list
HelloApps.com 14
Detecting distance by using laser sensor
• Add “.”
• Select “DistanceMeasurements” item from the list
HelloApps.com 15
Detecting distance by using laser sensor
• Add “[180]”
– “Distance is “ + SensorData.DistanceMeasurements[180]
HelloApps.com 16
Laser Sensor Data
• DistanceMeasurements
– Array of 361 distances
For 180 angles,Detect distances by 0.5 degrees
0th index360th
180th
Millimeter unit, max distance is 8m(8000 millimeter)
90th270th
HelloApps.com 17
Laser Sensor Data
• Distance for the front direction
– SensorData.DistanceMeasurements[180]
• Distance for the right 45 degrees direction
– SensorData.DistanceMeasurements[90]
• Distance for the left 45 degrees direction
– SensorData.DistanceMeasurements[270]
• Distance for the right direction
– SensorData.DistanceMeasurements[0]
• Distance for the left direction
– SensorData.DistanceMeasurements[360]
HelloApps.com 18
Detecting distance by using laser sensor
• Connect the output point of “Calculate” activity to the input
point of “Console” service
HelloApps.com 19
Detecting distance by using laser sensor
• Select “WriteLine” item from the right list
HelloApps.com 20
Detecting distance by using laser sensor
• Select “value” item from the left list
HelloApps.com 21
Detecting distance by using laser sensor
• Save and run diagram
HelloApps.com 22
Detecting distance by using laser sensor
• Execution results
HelloApps.com 23
Stopping robot driving
HelloApps.com 24
Stopping robot driving
• If the distance from obstacle is below 1m(1000millimeter),
make a robot stop
– If (SensorData.DistanceMeasurements[180] < 1000)
• myrobot.Stop()
HelloApps.com 25
Stopping robot driving
• Remove “Calculate” activity and “Console” service
HelloApps.com 26
Stopping robot driving
• Add a “If” activity
HelloApps.com 27
Stopping robot driving
• Connect the notification point of “SPL Engine” to the input
point of “If” activity
HelloApps.com 28
Stopping robot driving
• Select “LRFNotify” item from the list
HelloApps.com 29
Stopping robot driving
• Click textbox in the “If” activity
• Select “SensorData” item from the list
HelloApps.com 30
Stopping robot driving
• Type “.”
• Select “DistanceMeasurements” item from the list
HelloApps.com 31
Stopping robot driving
• Type “[180] < 1000”
HelloApps.com 32
Stopping robot driving
• Add “Stop driving” diagram
Add diagram
HelloApps.com 33
Stopping robot driving
• Connect the output point of “If” condition to the input point
of “Data” activity
HelloApps.com 34
Stopping robot driving
• Save and run diagram
HelloApps.com 35
Stopping robot driving
• Execution result
Stop
HelloApps.com 36
Avoiding obstacles
HelloApps.com 37
• Modify “Stop driving” diagram into “Turn 45 degrees”
– Turn(45, 0.2)
Avoiding obstacles
HelloApps.com 38
• Add “Go forwards” diagram and connect them
– Go(0.2)
Avoiding obstacles
HelloApps.com 39
Avoiding obstacles
• Save and run diagram
HelloApps.com 40
Avoiding obstacles
• Execution result