Avoiding Obstacles

Microsoft Robotics

Glossary Item Box

Microsoft Robotics Developer StudioSend 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:

Bb870561.ExpandBasicActivities(en-us,MSDN.10).png

You can also close the Properties window:

Bb870561.CloseProperties(en-us,MSDN.10).png

From the Basic Activities window, drag an, If, block on to your diagram. 

Bb870561.AddIfStatement(en-us,MSDN.10).png

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.

Bb870561.StartNotification(en-us,MSDN.10).png

This will open the Connections dialog. Select From the SonarSensorUpdate notification and click OK.

Bb870561.Connections-SonarSensorUpdate(en-us,MSDN.10).png

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.

Bb870561.IfDistance(en-us,MSDN.10).png

Drag from the pin to the right of the expression over to the NxtDrive activity.

Bb870561.IfDistance1(en-us,MSDN.10).png

This will open the Connections dialog.  Select From TrueChoice and To the RotateDegrees. Click OK.

Bb870561.IfDistance1RotateDegrees(en-us,MSDN.10).png

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.

Bb870561.RotateDegreesDataConnectionEnterValues(en-us,MSDN.10).png

 

 

© 2012 Microsoft Corporation. All Rights Reserved.

Show: