microsoft visual programming language advanced example
TRANSCRIPT
MicrosoftMicrosoftVisual Programming LanguageVisual Programming LanguageAdvanced ExampleAdvanced Example
Microsoft Visual Microsoft Visual Programming Language Programming Language 22Andreas UlbrichAndreas UlbrichSoftware Development EngineerSoftware Development EngineerMicrosoft CorporationMicrosoft Corporation
OverviewOverview
Autonomous behaviorAutonomous behavior
Factoring of activitiesFactoring of activities
Working with data collectionsWorking with data collections
Configuring programs for simulation Configuring programs for simulation and realityand reality
ScenarioScenario
RobotRobotLaser range finder for obstacle detectionLaser range finder for obstacle detection
Two-wheel differential driveTwo-wheel differential drive
Autonomous wandering behaviorAutonomous wandering behaviorRobot roams around and ideally does not Robot roams around and ideally does not bump into obstaclesbump into obstacles
Run in simulation and realityRun in simulation and reality
PrerequisitesPrerequisites
You should be familiar with the basics You should be familiar with the basics of the Microsoft Visual Programming of the Microsoft Visual Programming Language.Language.
HardwareHardware
MobileRobots Pioneer P3DX withMobileRobots Pioneer P3DX with
Sick Laser Range Finder LM200Sick Laser Range Finder LM200
Can easily be adapted to other Can easily be adapted to other hardwarehardware
Laser Range Finder
Two-wheel differential drive
Two-wheel Differential Two-wheel Differential DriveDrive
Very simple drive systemVery simple drive systemControlled by applying different power to Controlled by applying different power to left and right motorleft and right motor
Generic Differential Drive ServiceGeneric Differential Drive ServiceSetDrivePowerSetDrivePower action action
Laser Range FinderLaser Range Finder
Distance measurement deviceDistance measurement device
SICK Laser Range Finder ServiceSICK Laser Range Finder ServiceMeasurementMeasurement notification notification
180° sweep, 0.5° resolution, ca. 8m 180° sweep, 0.5° resolution, ca. 8m rangerange
0°180°
Distancemeasurement
Basic IdeaBasic Idea
Convert laser scan into three sectorsConvert laser scan into three sectorsLeft, right, centerLeft, right, center
For each sector find nearest For each sector find nearest measurementmeasurement
If center measurement is above If center measurement is above thresholdthreshold
Go straight (1)Go straight (1)
Else if left is larger than rightElse if left is larger than rightTurn left (2)Turn left (2)
ElseElseTurn right (3)Turn right (3)
1 2 3
Three SectorsThree Sectors
Right(3/8)
Left(3/8)
Center(2/8 = 45°)
Nearest measurement in sector
(not to scale)
Factoring: Who does Factoring: Who does What?What?
Create new activities when possible!Create new activities when possible!Diagrams smaller and easier to readDiagrams smaller and easier to read
Easier to change and to reuseEasier to change and to reuse
LaserRangeFinderLaserRangeFinder activity activityHandles laser notifications and finds nearest Handles laser notifications and finds nearest measurements in sectorsmeasurements in sectors
AutoDriveAutoDrive activity activityBased on nearest left, right, and center Based on nearest left, right, and center measurement select the best direction and turnmeasurement select the best direction and turn
Main diagramMain diagramCoordinate Coordinate LaserRangeFinderLaserRangeFinder and and AutoDriveAutoDrive
LaserRangeFinderLaserRangeFinder
Laser data is list of intLaser data is list of intSplit into sectorsSplit into sectors
Start indexStart index
Limit indexLimit index
Find nearestFind nearestNeeds to be done for each sector Needs to be done for each sector Create an action Create an action FindNearestFindNearest
When done send notification When done send notification FoundNearestFoundNearest
LaserRangeFinderLaserRangeFinderFindNearest ActionFindNearest Action
List of measurments List of measurments DataData
NearestNearest measurement measurement start value is maximum rangestart value is maximum range
Current index Current index iiStart value is start index of sectorStart value is start index of sector
FindNearest:FindNearest:If If DataData[ [ ii ] < ] < NearestNearest then then NearestNearest = = DataData[ [ ii ] ]
Repeat with Repeat with ii = = ii + + IncrementIncrement (Recursion)(Recursion)
Stop if outside the sector Stop if outside the sector LimitLimit and send and send the notificationthe notification
LaserRangeFinderLaserRangeFinderFindNearest ActionFindNearest Action
Input valuesInput valuesii – index at which to start searching (int) – index at which to start searching (int)
IncrementIncrement – index step size (int) – index step size (int)
LimitLimit – index at which to stop searching – index at which to stop searching (int)(int)
DataData – laser data (List of int) – laser data (List of int)
NearestNearest – nearest found so far (int) – nearest found so far (int)
LabelLabel – sector (string: “Left”, “Right”, – sector (string: “Left”, “Right”, “Center”)“Center”)
Sends Sends FoundNearestFoundNearest notification notificationNearestNearest – nearest measurement in – nearest measurement in sector (int)sector (int)
LabelLabel – sector (string: “Left”, “Right”, – sector (string: “Left”, “Right”, “Center”)“Center”)
AutoDriveAutoDriveUpdateDrive ActionUpdateDrive Action
Simple state machineSimple state machineVariable Variable State State (“Forward”, “Turn”)(“Forward”, “Turn”)
Input values Input values LeftLeft, , RightRight, , Center Center (int)(int)
If currently in “Forward” modeIf currently in “Forward” modeIf If CenterCenter > 1500 > 1500
Stop driving, go to “Turn” modeStop driving, go to “Turn” mode
If currently in “Turn” modeIf currently in “Turn” modeIf If CenterCenter > 2000 > 2000
Go to “Forward” mode, drive forwardGo to “Forward” mode, drive forward
Else turn left or rightElse turn left or right
Main DiagramMain Diagram
Notifications from Notifications from LaserRangeFinderLaserRangeFinderLeft and Right stored in variablesLeft and Right stored in variables
On Center get all variable values and On Center get all variable values and send to send to UpdateDriveUpdateDrive action of action of AutoDriveAutoDrive
Simple VPL ExplorerSimple VPL Explorer
SummarySummary
Autonomous behaviorAutonomous behaviorConstantly update actuators based on Constantly update actuators based on sensors and statesensors and state
Factoring of activitiesFactoring of activities
Data collections and recursion Data collections and recursion
Simulation and realitySimulation and reality
See alsoSee also
Robotics Tutorial 5Robotics Tutorial 5C#C#
Path planning for smooth obstacle Path planning for smooth obstacle avoidanceavoidance
VplExplorer (Channel 9 Sandbox)VplExplorer (Channel 9 Sandbox)Enhanced version of this tutorialEnhanced version of this tutorial
Combines wandering with joystick driveCombines wandering with joystick drive
© 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions,
it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.