Want to develop novel robot applications, but don't know how to write a mapping or object-recognition system? You're not alone, but you're certainly not without help. By combining real-world examples with valuable knowledge from the Robot Operating System (ROS) community, this practical book provides a set of motivating recipes for solving specific robotics use cases.Ideal for enthusiasts, from students in robotics clubs to professional robotics scientists and engineers, each recipe describes a complete solution using ROS open source libraries and tools. You'll learn how to complete tasks described in the recipes, as well as how to configure and recombine components for other tasks. If you're familiar with Python, you're ready to go.• Learn fundamentals, including key ROS concepts, tools, and patterns• Program robots that perform an increasingly complex set of behaviors, using the powerful packages in ROS• See how to easily add perception and navigation abilities to your robots• Integrate your own sensors, actuators, software libraries, and even a whole robot into the ROS ecosystem• Learn tips and tricks for using ROS tools and community resources, debugging robot behavior, and using C++ in ROS Cover -1 Copyright 4 Table of Contents 5 Preface 13 Who Should Read This Book? 14 Who Should Not Read This Book? 15 What You’ll Learn 15 Prerequisites 16 Conventions Used in This Book 16 Using Code Examples 17 Safari® Books Online 17 How to Contact Us 18 Acknowledgments 18 Part I. Fundamentals 21 Chapter 1. Introduction 23 Brief History 24 Philosophy 24 Installation 26 Summary 27 Chapter 2. Preliminaries 29 The ROS Graph 29 roscore 31 catkin, Workspaces, and ROS Packages 33 catkin 33 Workspaces 33 ROS Packages 34 rosrun 37 Names, Namespaces, and Remapping 42 roslaunch 43 The Tab Key 45 tf: Coordinate Transforms 45 Poses, Positions, and Orientations 46 tf 47 Summary 49 Chapter 3. Topics 51 Publishing to a Topic 52 Checking That Everything Works as Expected 54 Subscribing to a Topic 56 Checking That Everything Works as Expected 57 Latched Topics 58 Defining Your Own Message Types 59 Defining a New Message 61 Using Your New Message 65 When Should You Make a New Message Type? 67 Mixing Publishers and Subscribers 67 Summary 68 Chapter 4. Services 71 Defining a Service 71 Implementing a Service 75 Checking That Everything Works as Expected 76 Other Ways of Returning Values from a Service 76 Using a Service 77 Checking That Everything Works as Expected 78 Other Ways to Call Services 78 Summary 79 Chapter 5. Actions 81 Defining an Action 82 Implementing a Basic Action Server 84 Checking That Everything Works as Expected 86 Using an Action 87 Checking That Everything Works as Expected 88 Implementing a More Sophisticated Action Server 88 Using the More Sophisticated Action 91 Checking That Everything Works as Expected 92 Summary 94 Chapter 6. Robots and Simulators 97 Subsystems 97 Actuation: Mobile Platform 97 Actuation: Manipulator Arm 100 Sensors 101 Computation 107 Complete Robots 108 PR2 108 Fetch 109 Robonaut 2 110 TurtleBot 111 Simulators 112 Stage 113 Gazebo 115 Other Simulators 116 Summary 117 Chapter 7. Wander-bot 119 Creating a Package 119 Reading Sensor Data 123 Sensing and Actuation: Wander-bot! 126 Summary 128 Part II. Moving Around Using ROS 129 Chapter 8. Teleop-bot 131 Development Pattern 132 Keyboard Driver 132 Motion Generator 134 Parameter Server 139 Velocity Ramps 142 Let’s Drive! 145 rviz 146 Summary 154 Chapter 9. Building Maps of the World 155 Maps in ROS 155 Recording Data with rosbag 158 Building Maps 160 Starting a Map Server and Looking at a Map 167 Summary 170 Chapter 10. Navigating About the World 171 Localizing the Robot in a Map 171 Getting a Good Initial Localization 174 What’s Going on Behind the Scenes 175 Tips for Setting a Better Initial Pose 176 Using the ROS Navigation Stack 176 The ROS Navigation Stack 177 Navigating in rviz 177 Seeing What’s Going On 178 Navigating in Code 181 Summary 183 Chapter 11. Chess-bot 185 Joints, Links, and Kinematic Chains 186 Joint Space 187 Inverse Kinematics 189 The Key to Success 190 Installing and Running a Simulated R2 192 Moving R2 from the Command Line 195 Moving R2 Around a Chessboard 197 Operating the Hand 199 Modeling a Chessboard 202 Playing Back a Famous Chess Game 205 Summary 208 Part III. Perception and Behavior 211 Chapter 12. Follow-bot 213 Acquiring Images 213 Detecting the Line 220 Following the Line 226 Summary 228 Chapter 13. On Patrol 229 Simple Patrolling 229 State Machines 231 State Machines in ROS 232 Defining State Machines with smach 233 A Slightly More Relevant Example 236 Defining State Machines Procedurally 239 Patrolling with State Machines 241 A Better Way to Patrol 242 Summary 244 Chapter 14. Stockroom-bot 245 Stockroom Simulation 245 Driving to Bins 258 Picking Up the Item 262 Summary 276 Part IV. Bringing Your Own Stuff into ROS 277 Chapter 15. Your Own Sensors and Actuators 279 Adding Your Own Sensors 279 A (Fake) Sensor 279 Designing the ROS Wrapper 280 Design 1: Periodic Measurements over a Topic 281 Design 2: Streaming Measurements over a Topic 283 Design 3: Streaming Measurements Published at a Fixed Rate 284 Design 4: Sensor Measurements on Demand 286 Adding Your Own Actuators 287 A (Fake) Actuator 287 Designing the ROS Wrapper 288 Design 1: Continuous Actuation 290 Design 2: Infrequent, Instantaneous Actuation 291 Design 3: Infrequent, Extended Actuation 292 Summary 294 Chapter 16. Your Own Mobile Robot 295 TortoiseBot 295 ROS Message Interface 297 Hardware Driver 300 Modeling the Robot: URDF 301 Simulation in Gazebo 309 Summary 317 Chapter 17. Your Own Mobile Robot: Part 2 319 Verifying Transforms 319 Adding a Laser Sensor 324 Configuring the Navigation Stack 328 Using rviz to Localize and Command a Navigating Robot 333 Summary 337 Chapter 18. Your Own Robot Arm 339 CougarBot 339 ROS Message Interface 341 Hardware Driver 342 Modeling the Robot: URDF 343 Simulation in Gazebo 347 Verifying Transforms 355 Configuring MoveIt 359 Using rviz to Send Goals 363 Summary 365 Chapter 19. Adding a Software Library 367 Make Your Robot Talk: pyttsx 368 Action Interface 369 Parameters 370 Event Loops 371 The Speech Server 371 The Speech Client 374 Checking That Everything Works as Expected 374 Summary 375 Part V. Tips and Tricks 377 Chapter 20. Tools 379 The Master and Friends: roscore 379 Parameters: rosparam 381 Navigating the Filesystem: roscd 382 Starting a Node: rosrun 382 Starting Many Nodes: roslaunch 383 Testing a Many-Node System: rostest 386 Introspection: rosnode, rostopic, rosmsg, rosservice, and rossrv 389 Summary 393 Chapter 21. Debugging Robot Behavior 395 Log Messages: /rosout and rqt_console 395 Generating Log Messages: /rosout 396 Logger Levels 398 Reading Log Messages: rqt_console 400 /rosout Versus /rosout_agg 402 Nodes, Topics, and Connections: rqt_graph and rosnode 403 Visualizing the Graph: rqt_graph 403 Problem: Mismatched Topic Names 405 Problem: Mismatched Topic Types and/or Checksums 406 Problem: Incorrect Network Settings 409 Sensor Fusion: rviz 411 Plotting Data: rqt_plot 412 Data Logging and Analysis: rosbag and rqt_bag 414 Logging and Playing Back Data: rosbag 414 Visualizing Bags: rqt_bag 417 Analyzing ROS Bags with Other Tools: rostopic echo -b 417 Summary 418 Chapter 22. The ROS Community: Online Resources 419 Etiquette 419 The ROS Wiki 420 ROS Answers 421 Trackers (Bugs and Feature Requests) 423 Mailing Lists and Special Interest Groups 423 Finding and Sharing Code 424 Summary 424 Chapter 23. Using C++ in ROS 425 When Should You Use C (or Some Other Language)? 426 Building C++ with catkin 426 package.xml 427 CMakeLists.txt 427 catkin_make 428 Translating from Python to C++ (and Back Again) 428 A Simple Node 429 Topics 430 Services 432 Summary 434 Index 437 About the Authors 446 www.it-ebooks.info Want to develop novel robot applications, but dont know how to write a mapping or object recognition system? Youre certainly not alone, but youre not without help. By combining real-world examples with valuable knowledge from the Robot Operating System (ROS) community, this practical book provides a set of motivating recipes for solving specific robotics use cases. Ideal for wide range of robot enthusiasts, from students in robotics clubs to professional robotics scientists and engineers, each recipe describes a complete solution using ROS open source libraries and tools. Youll not only learn how to complete the task described in the recipe, but also how to configure and recombine the components for other tasks. All recipes include Python code. No robot hardware is required to get started, just experience with Python and Linux. This book is appropriate for undergraduate and graduate students in introductory robotics courses. "Want to develop novel robot applications, but don't know how to write a mapping or object-recognition system? You're not alone, but you're certainly not without help. By combining real-world examples with valuable knowledge from the Robot Operating System (ROS) community, this practical book provides a set of motivating recipes for solving specific robotics use cases. Ideal for enthusiasts, from students in robotics clubs to professional robotics scientists and engineers, each recipe describes a complete solution using ROS open source libraries and tools. You'll learn how to complete tasks described in the recipes, as well as how to configure and recombine components for other tasks. If you're familiar with Python, you're ready to go."--Www.amazon.com.