400 likes | 492 Views
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. Preparing basic environment.
E N D
Elegantavoiding 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
Preparing basic environment • Add a “Data” activity and “SPL Engine” • Type “Script/BasicEnv4.txt” in the “Data” activity
Preparing basic environment • Execution result
Detecting distance by using laser distance sensor
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
Detecting distance by using laser sensor • Add “SPL Sensors” service by dragging
Detecting distance by using laser sensor • Add “Calculate” activity
Detecting distance by using laser sensor • Connect the notification point of “SPL Sensors” to the input point of “Calculate” activity
Detecting distance by using laser sensor • Select “LRFNotify” item from the left list
Detecting distance by using laser sensor • Type ““Distance is “ +” in the Calculate • Select “SensorData” from the list
Detecting distance by using laser sensor • Add “.” • Select “DistanceMeasurements” item from the list
Detecting distance by using laser sensor • Add “[180]” • “Distance is “ + SensorData.DistanceMeasurements[180]
Laser Sensor Data • DistanceMeasurements • Array of 361 distances For 180 angles, Detect distances by 0.5 degrees 180th 90th 270th 0thindex 360th Millimeter unit,max distance is8m(8000 millimeter)
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]
Detecting distance by using laser sensor • Add “HelloApps Console” service
Detecting distance by using laser sensor • Connect the output point of “Calculate” activity to the input point of “Console” service
Detecting distance by using laser sensor • Select “WriteLine” item from the right list
Detecting distance by using laser sensor • Select “value” item from the left list
Detecting distance by using laser sensor • Save and run diagram
Detecting distance by using laser sensor • Execution results
Stopping robot driving • If the distance from obstacle is below 1m(1000millimeter), make a robot stop • If(SensorData.DistanceMeasurements[180] < 1000) • myrobot.Stop()
Stopping robot driving • Remove “Calculate” activity and “Console” service
Stopping robot driving • Add a “If” activity
Stopping robot driving • Connect the notification point of “SPL Sensors” to the input point of “If” activity
Stopping robot driving • Select “LRFNotify” item from the list
Stopping robot driving • Click textbox in the “If” activity • Select “SensorData” item from the list
Stopping robot driving • Type “.” • Select “DistanceMeasurements” item from the list
Stopping robot driving • Type “[180] < 1000”
Stopping robot driving • Add “Stop driving” diagram Add diagram
Stopping robot driving • Connect the output point of “If” condition to the input point of “Data” activity
Stopping robot driving • Save and run diagram
Stopping robot driving • Execution result Stop
Avoiding obstacles • Modify “Stop driving” diagram into “Turn 90 degrees” • Turn(90, 0.2)
Avoiding obstacles • Add “Go forwards” diagram and connect them • Go(0.2)
Avoiding obstacles • Save and run diagram
Avoiding obstacles • Execution result