Elegant avoiding of obstacle MSRDS First Beginner Course – STEP5 Young Joon Kim http://www.helloapps.com.

Download Report

Transcript Elegant avoiding of obstacle MSRDS First Beginner Course – STEP5 Young Joon Kim http://www.helloapps.com.

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