20
Microsoft Microsoft Visual Programming Language Visual Programming Language Advanced Example Advanced Example

Microsoft Visual Programming Language Advanced Example

Embed Size (px)

Citation preview

Page 1: Microsoft Visual Programming Language Advanced Example

MicrosoftMicrosoftVisual Programming LanguageVisual Programming LanguageAdvanced ExampleAdvanced Example

Page 2: Microsoft Visual Programming Language Advanced Example

Microsoft Visual Microsoft Visual Programming Language Programming Language 22Andreas UlbrichAndreas UlbrichSoftware Development EngineerSoftware Development EngineerMicrosoft CorporationMicrosoft Corporation

Page 3: Microsoft Visual Programming Language Advanced Example

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

Page 4: Microsoft Visual Programming Language Advanced Example

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

Page 5: Microsoft Visual Programming Language Advanced Example

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.

Page 6: Microsoft Visual Programming Language Advanced Example

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

Page 7: Microsoft Visual Programming Language Advanced Example

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

Page 8: Microsoft Visual Programming Language Advanced Example

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

Page 9: Microsoft Visual Programming Language Advanced Example

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

Page 10: Microsoft Visual Programming Language Advanced Example

Three SectorsThree Sectors

Right(3/8)

Left(3/8)

Center(2/8 = 45°)

Nearest measurement in sector

(not to scale)

Page 11: Microsoft Visual Programming Language Advanced Example

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

Page 12: Microsoft Visual Programming Language Advanced Example

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

Page 13: Microsoft Visual Programming Language Advanced Example

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

Page 14: Microsoft Visual Programming Language Advanced Example

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”)

Page 15: Microsoft Visual Programming Language Advanced Example

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

Page 16: Microsoft Visual Programming Language Advanced Example

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

Page 17: Microsoft Visual Programming Language Advanced Example

Simple VPL ExplorerSimple VPL Explorer

Page 18: Microsoft Visual Programming Language Advanced Example

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

Page 19: Microsoft Visual Programming Language Advanced Example

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

Page 20: Microsoft Visual Programming Language Advanced Example

© 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.