Задани на лабораторные работы. ПРК / Professional Microsoft Robotics Developer Studio
.pdf
Executive Editor
Chris Webb
Development Editor
Maureen Spears
Technical Editors
David E. Buckley
Steve Tudor
Production Editor
William A. Barton
Copy Editor
Luann Rouff
Editorial Manager
Mary Beth Wakefield
Production Manager
Tim Tate
www.it-ebooks.info
Credits
Vice President and Executive Group Publisher
Richard Swadley
Vice President and Executive Publisher
Joseph B. Wikert
Project Coordinator, Cover
Lynsey Stanford
Proofreaders
Jeremy Bagai,
David Fine,
Paul Sagan,
Word One
Indexer
Robert Swanson
www.it-ebooks.info
www.it-ebooks.info
Acknowledgments
Various organizations have assisted with the production of this book by making software services for their robots available for inclusion in the book examples and/or providing images for use in the figures. The authors wish to acknowledge their support. These organizations include (in alphabetical order) the following:
CoroWare, Inc.: www.coroware.com
Institute for Personal Robots in Education (IPRE): www.ipre.org
LEGO: www.lego.com
Lynxmotion, Inc.: www.lynxmotion.com
Parallax, Inc.: www.parallax.com
Picblok Corporation Pty Ltd: www.picblokcorporation.com
RoboticsConnection (Summerour Robotics Corporation): www.roboticsconnection.com
Surveyor Corporation: www.surveyor.com
Throughout the preparation of the book, the Microsoft Robotics Developer Studio Team have been most helpful in resolving problems and answering questions. To them we extend a big “thank-you.”
www.it-ebooks.info
www.it-ebooks.info
Contents
Foreword |
xxv |
Introduction |
xxix |
Part I: Robotics Developer Studio Fundamentals |
1 |
Chapter 1: Exploring Microsoft Robotics Developer Studio |
3 |
Microsoft Does Robots? |
4 |
Microsoft Robotics Developer Studio Components |
5 |
Concurrency and Coordination Runtime (CCR) |
5 |
Decentralized Software Services (DSS) |
6 |
Visual Simulation Environment |
6 |
Visual Programming Language (VPL) |
7 |
Robotics Samples |
8 |
Packages |
9 |
Support for MRDS |
12 |
The SubjuGator |
12 |
Prospect 12 |
13 |
The uBot-5 |
13 |
KUKA Educational Framework |
14 |
Setting Up Your System |
15 |
System Requirements |
15 |
Prerequisites |
16 |
Installing MRDS 1.5 |
16 |
Robotics Studio 1.5 Directory Structure |
19 |
Installing the Packages |
20 |
Installing the Sample Code for This Book |
21 |
Verifying the Installation |
21 |
Additional Resources and Support |
27 |
www.Microsoft.Com/Robotics |
27 |
Tutorials and User Guides |
27 |
Online Forums |
27 |
Channel 9 |
28 |
Summary |
28 |
|
www.it-ebooks.info |
|
Contents |
|
|
Chapter 2: Concurrency and Coordination Runtime (CCR) |
29 |
|
Overview of the MRDS Framework |
30 |
|
The Need for Concurrency |
30 |
|
Services — The Basic Building Blocks |
31 |
|
Orchestration — Putting Services Together |
31 |
|
Setting Up for This Chapter |
32 |
|
Using the CCRExamples Project |
33 |
|
Entering the Code Manually |
34 |
|
Tips for Coding with MRDS |
37 |
|
Coordination and Concurrency Runtime |
38 |
|
Concurrent Execution |
39 |
|
Ports and Messages |
50 |
|
Receivers and Arbiters |
55 |
|
Dispatchers and Dispatcher Queues |
65 |
|
Implementing Common Control Structures |
68 |
|
Sequential Processing |
68 |
|
Scatter/Gather |
69 |
|
State Machines |
70 |
|
Last Message |
70 |
|
Time Delays |
71 |
|
Periodic Events |
73 |
|
Setting Limits with Timeouts |
75 |
|
Asynchronous I/O |
75 |
|
Blocking I/O |
76 |
|
Throttling |
76 |
|
Error Handling |
77 |
|
Causalities |
77 |
|
Success/Failure Ports |
79 |
|
Interoperation with Legacy Code |
81 |
|
Traps for New Players |
81 |
|
Summary |
82 |
|
Chapter 3: Decentralized Software Services (DSS) |
83 |
|
Overview of DSS |
84 |
|
Contracts |
86 |
|
State |
87 |
|
Behavior |
91 |
|
Execution Context |
93 |
|
DSSP Service Operations |
94 |
|
Generic Contracts |
98 |
|
xiv
|
www.it-ebooks.info |
|
|
Contents |
|
Running a DSS Node |
98 |
|
Directory Structure of a DSS Node |
99 |
|
Starting DssHost |
100 |
|
Exploring the DSS Web Pages |
101 |
|
Running a Robot Service |
109 |
|
Creating a New Service |
112 |
|
Building a Service from Scratch |
112 |
|
Examining the Service Source Files |
116 |
|
Compiling and Running Services |
121 |
|
Compiling a Service |
121 |
|
Setting Up References |
122 |
|
Proxy Assemblies |
123 |
|
Running Services |
123 |
|
Using the Debugger |
125 |
|
Defining Service State |
127 |
|
Persisting Service State |
129 |
|
Loading State from a Configuration File |
129 |
|
Saving the State to a Config File |
131 |
|
Modifying Service State |
132 |
|
Replace |
132 |
|
Update |
133 |
|
Service Initialization |
136 |
|
Composing and Coordinating Services |
137 |
|
Starting and Stopping Services Programmatically |
137 |
|
Using the Partner Attribute to Start Services |
144 |
|
Modifying Manifests Manually |
146 |
|
DSS Tools |
149 |
|
Modifying Manifests Using the DSS Manifest Editor |
149 |
|
DssInfo: Examining Contract Information |
150 |
|
DssProjectMigration: Migrating Services |
151 |
|
Deploying Services |
151 |
|
Sharing Source Code |
152 |
|
Distributing Executables |
154 |
|
Viewing the Contents of a Package |
155 |
|
Summary |
155 |
|
Chapter 4: Advanced Service Concepts |
157 |
|
Setting Up for This Chapter |
157 |
|
Hardware Setup |
159 |
|
Creating the Service |
160 |
|
xv
|
www.it-ebooks.info |
|
Contents |
|
|
Subscribing and Notifying |
163 |
|
Subscribing to State Changes |
164 |
|
Unsubscribing from State Change Notifications |
167 |
|
Building in Support for Subscriptions and Notifications |
167 |
|
User Interfaces |
170 |
|
Using Windows Forms |
171 |
|
Using Web Forms |
185 |
|
Using a Camera |
205 |
|
Adding a Camera to a Service |
206 |
|
Setting Up a WinForm for the Video Feed |
207 |
|
Processing Video Frames |
212 |
|
Inheriting from Abstract Services |
215 |
|
Implementing a Generic Service |
215 |
|
Building Virtual Services |
217 |
|
More on Debugging |
219 |
|
Read the Documentation First |
219 |
|
Use the Visual Studio Debugger |
219 |
|
Examine the State of a Node and Services |
220 |
|
Traditional Debugging Techniques |
220 |
|
Using Trace Level and Logging |
220 |
|
Where to Go from Here |
221 |
|
Summary |
222 |
|
Part II: Simulations |
223 |
Chapter 5: The MRDS Visual Simulation Environment |
225 |
The Advantages of Simulation |
226 |
The Difficulties with Simulation |
226 |
Prerequisites |
227 |
Hardware Requirements |
227 |
Software Requirements |
228 |
Starting the Simulator |
230 |
Using the Simulator |
231 |
Navigating the Simulation Environment |
232 |
The Status Bar |
234 |
The Help Menu |
235 |
The Camera Menu |
235 |
The Rendering Menu |
236 |
Graphics Settings |
240 |
The Physics Menu |
241 |
Saving and Loading Scenes |
243 |
xvi
www.it-ebooks.info |
||
Contents |
||
Saving and Loading Manifests |
243 |
|
Other File Menu Items |
243 |
|
The Simulation Editor |
244 |
|
Selecting Entities |
245 |
|
Manipulating Selected Entities |
246 |
|
The Entities Menu |
247 |
|
Modifying Entity State |
248 |
|
Other Common Entity Properties |
250 |
|
Built-in Simulation Entities |
252 |
|
Sky and Ground Entities |
253 |
|
Lights and Shadows |
257 |
|
General-Purpose Entities |
259 |
|
Robot Entities |
263 |
|
Summary |
267 |
|
Chapter 6: Extending the MRDS Visual Simulation Environment |
269 |
|
Simulation DLLs and Types |
270 |
|
RoboticsCommon.DLL |
270 |
|
SimulationCommon.DLL |
271 |
|
SimulationEngine.DLL |
272 |
|
SimulationEngine.Proxy.DLL |
274 |
|
PhysicsEngine.DLL |
274 |
|
Microsoft.Xna.Framework.DLL |
274 |
|
Using Statements and DLL References |
275 |
|
Building Your Own SRS-Robo-Magellan Simulation |
276 |
|
Simulation Services |
276 |
|
Creating a Simulation Service |
277 |
|
Defining a Custom Robot Entity |
281 |
|
The Drive Methods |
293 |
|
The SimulatedQuadDifferentialDrive Service |
296 |
|
Tuning the Corobot Entity |
313 |
|
Adding a Camera |
322 |
|
Adding Infrared Distance Sensors |
323 |
|
Summary |
336 |
|
Chapter 7: Using Orchestration Services to Build a Simulation Scenario |
337 |
|
The Robo-Magellan Referee Service |
338 |
|
Customizing the SimulationTutorial1 Service |
339 |
|
Starting a Service from the Browser |
339 |
|
Building the World and Adding Cameras |
340 |
|
Adding a Sky, Sun, and Ground |
340 |
|
xvii
|
www.it-ebooks.info |
|
Contents |
|
|
Adding Barriers |
341 |
|
Building a Better Traffic Cone |
343 |
|
The Robo-Magellan Orchestration Service |
347 |
|
Generating the SimMagellan Service |
347 |
|
Creating a Manifest with the Manifest Editor |
349 |
|
Adding a Windows Forms User Interface |
351 |
|
Creating the Form |
351 |
|
Connecting the Service to the Form |
352 |
|
How to Make a Robot Behave |
354 |
|
Defining Behavior States |
355 |
|
Implementing the Behavior for Each State |
356 |
|
Processing Camera Frames |
362 |
|
The Wander Behavior |
367 |
|
The Approach State |
369 |
|
The Final Approach State |
371 |
|
The Back Away State |
372 |
|
The Finished State |
373 |
|
The Avoid Collision State |
373 |
|
Using the SimMagellan Service |
374 |
|
Future Directions |
374 |
|
Summary |
375 |
|
Chapter 8: Simulating Articulated Entities |
377 |
|
The Joint Class |
377 |
|
The Joint Frame |
378 |
|
Joint Properties |
378 |
|
A Joint TestBench |
382 |
|
Building a Simulated Robotic Arm |
394 |
|
The Physical Model of the Arm Entity |
394 |
|
Running the Arm Service |
405 |
|
Moving the Arm |
405 |
|
A Fly in the Ointment |
407 |
|
Inverse Kinematics |
410 |
|
Using the Arm User Interface |
412 |
|
Summary |
418 |
|
Chapter 9: Adventures in Simulation |
419 |
|
Simulating a Sumo Competition |
419 |
|
SimulatedSumo |
420 |
|
The Simulated Sumo Referee |
421 |
|
Communicating with the Sumo Referee Service |
423 |
|
xviii
