Avoiding Obstacles
Glossary Item Box
Microsoft Robotics Developer Studio | Send feedback on this topic |
Avoiding Obstacles
Adding logic to the diagram is straight forward but you may need to make more room for the diagram. To do this, expand the Basic Activities window:
You can also close the Properties window:
From the Basic Activities window, drag an, If, block on to your diagram.
Next you will capture notifications from the NxtUltrasonicSensor every time a Distance reading is received. You will use this value to determine how to drive the motors.
Select the Round Notification pin on the NxtUltrasonicSensor and drag it on to the, If, block. This indicates that you will capture notifications from the Touch Sensor and evaluate them.
This will open the Connections dialog. Select From the SonarSensorUpdate notification and click OK.
In the If expression box, type a space. Notice that a drop-down dialog opens, indicating the values which are available from the sensor. Select or type, Distance < 50. This means, when the distance is less than 50 cm.
Drag from the pin to the right of the expression over to the NxtDrive activity.
This will open the Connections dialog. Select From TrueChoice and To the RotateDegrees. Click OK.
This will open the Data Connections for Rotate Degrees. Select, [x] Edit values directly, then type in, 45 Degrees and .50 Power. Click OK. Assuming no further drive commands are issued, this will turn the Tribot 45 degrees to the left, or counter-clockwise.
© 2012 Microsoft Corporation. All Rights Reserved.