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

Elegant avoiding of obstacle Young Joon Kim MSRDS First Beginner Course – STEP5

Embed Size (px)

Citation preview

Elegant avoiding of obstacle

Young Joon Kimhttp://www.helloapps.com

MSRDS First Beginner Course – STEP5

2

Topics

• Preparing basic environment

• Detecting distance by using laser distance sensor

• Stopping robot driving

• Avoiding obstacles

3

Preparing basic environment

4

Preparing basic environment

• Add a “Data” activity and “SPL Engine”

• Type “Script/BasicEnv4.txt” in the “Data” activity

5

Preparing basic environment

• Execution result

6

Detecting distance

by using laser distance sensor

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

8

• Add “SPL Sensors” service by dragging

Detecting distance by using laser sensor

9

Detecting distance by using laser sensor

• Add “Calculate” activity

10

Detecting distance by using laser sensor

• Connect the notification point of “SPL Sensors” to the input

point of “Calculate” activity

11

Detecting distance by using laser sensor

• Select “LRFNotify” item from the left list

12

Detecting distance by using laser sensor

• Type ““Distance is “ +” in the Calculate

• Select “SensorData” from the list

13

Detecting distance by using laser sensor

• Add “.”

• Select “DistanceMeasurements” item from the list

14

Detecting distance by using laser sensor

• Add “[180]”

– “Distance is “ + SensorData.DistanceMeasurements[180]

15

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

16

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]

17

Detecting distance by using laser sensor

• Add “HelloApps Console” service

18

Detecting distance by using laser sensor

• Connect the output point of “Calculate” activity to the input

point of “Console” service

19

Detecting distance by using laser sensor

• Select “WriteLine” item from the right list

20

Detecting distance by using laser sensor

• Select “value” item from the left list

21

Detecting distance by using laser sensor

• Save and run diagram

22

Detecting distance by using laser sensor

• Execution results

23

Stopping robot driving

24

Stopping robot driving

• If the distance from obstacle is below 1m(1000millimeter),

make a robot stop

– If (SensorData.DistanceMeasurements[180] < 1000)

• myrobot.Stop()

25

Stopping robot driving

• Remove “Calculate” activity and “Console” service

26

• Add a “If” activity

Stopping robot driving

27

• Connect the notification point of “SPL Sensors” to the input

point of “If” activity

Stopping robot driving

28

Stopping robot driving

• Select “LRFNotify” item from the list

29

Stopping robot driving

• Click textbox in the “If” activity

• Select “SensorData” item from the list

30

Stopping robot driving

• Type “.”

• Select “DistanceMeasurements” item from the list

31

Stopping robot driving

• Type “[180] < 1000”

32

• Add “Stop driving” diagram

Stopping robot driving

Add diagram

33

• Connect the output point of “If” condition to the input point

of “Data” activity

Stopping robot driving

34

Stopping robot driving

• Save and run diagram

35

Stopping robot driving

• Execution result

Stop

36

Avoiding obstacles

37

• Modify “Stop driving” diagram into “Turn 90 degrees”

– Turn(90, 0.2)

Avoiding obstacles

38

• Add “Go forwards” diagram and connect them

– Go(0.2)

Avoiding obstacles

39

Avoiding obstacles

• Save and run diagram

40

Avoiding obstacles

• Execution result