You are previewing ROS Robotics By Example.
O'Reilly logo
ROS Robotics By Example

Book Description

Bring life to your robot using ROS robotic applications

About This Book

  • This book will help you boost your knowledge of ROS and give you advanced practical experience you can apply to your ROS robot platforms

  • This is the only book that offers you step-by-step instructions to solidify your ROS understanding and gain experience using ROS tools

  • From eminent authors, this book offers you a plethora of fun-filled examples to make your own quadcopter, turtlebot, and two-armed robots

  • Who This Book Is For

    If you are a robotics developer, whether a hobbyist, researchers or professional, and are interested in learning about ROS through a hands-on approach, then this book is for you. You are encouraged to have a working knowledge of GNU/Linux systems and Python.

    What You Will Learn

  • Get to know the fundamentals of ROS and apply its concepts to real robot examples

  • Control a mobile robot to navigate autonomously in an environment

  • Model your robot designs using URDF and Xacro, and operate them in a ROS Gazebo simulation

  • Control a 7 degree-of-freedom robot arm for visual servoing

  • Fly a quadcopter to autonomous waypoints

  • Gain working knowledge of ROS tools such as Gazebo, rviz, rqt, and Move-It

  • Control robots with mobile devices and controller boards

  • In Detail

    The visionaries who created ROS developed a framework for robotics centered on the commonality of robotic systems and exploited this commonality in ROS to expedite the development of future robotic systems.

    From the fundamental concepts to advanced practical experience, this book will provide you with an incremental knowledge of the ROS framework, the backbone of the robotics evolution. ROS standardizes many layers of robotics functionality from low-level device drivers to process control to message passing to software package management. This book provides step-by-step examples of mobile, armed, and flying robots, describing the ROS implementation as the basic model for other robots of these types. By controlling these robots, whether in simulation or in reality, you will use ROS to drive, move, and fly robots using ROS control.

    Style and approach

    This is an easy-to-follow guide with hands-on examples of ROS robots, both real and in simulation.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the code file.

    Table of Contents

    1. ROS Robotics By Example
      1. Table of Contents
      2. ROS Robotics By Example
      3. Credits
      4. About the Authors
      5. About the Reviewer
        1. eBooks, discount offers, and more
          1. Why subscribe?
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Getting Started with ROS
        1. What does ROS do and what are the benefits of learning ROS?
          1. Who controls ROS?
        2. Which robots are using ROS?
        3. Installing and launching ROS
          1. Configuring your Ubuntu repositories
          2. Setting up your sources.list
          3. Setting up your keys
          4. Installing ROS Indigo
          5. Initialize rosdep
          6. Environment setup
          7. Getting rosinstall
          8. Troubleshooting – examining your ROS environment
        4. Creating a catkin workspace
        5. ROS packages and manifest
          1. ROS manifest
          2. Exploring the ROS packages
            1. rospack find packages
            2. rospack list
        6. ROS nodes and ROS Master
          1. ROS nodes
            1. Nodes can publish and nodes can subscribe
          2. ROS Master
            1. Invoking the ROS Master using roscore
              1. Parameter Server
          3. ROS commands to determine the nodes and topics
        7. Turtlesim, the first ROS robot simulation
          1. Starting turtlesim nodes
            1. rosrun command
          2. Turtlesim nodes
          3. Turtlesim topics and messages
            1. rostopic list
            2. rostopic type
            3. rosmsg list
            4. rosmsg show
            5. rostopic echo
          4. Parameter Server of turtlesim
            1. rosparam help
            2. rosparam list for /turtlesim node
            3. Change parameters for the color of the turtle's background
              1. rosparam get
              2. rosparam set
          5. ROS services to move turtle
            1. rosservice call
        8. ROS commands summary
        9. Summary
      9. 2. Creating Your First Two-Wheeled ROS Robot (in Simulation)
        1. Rviz
          1. Installing and launching rviz
          2. Using rviz
            1. Displays panel
            2. Views and Time panels
              1. Mouse control
            3. Toolbar
            4. Main window menu bar
        2. Creating and building a ROS package
        3. Building a differential drive robot URDF
          1. Creating a robot chassis
          2. Using roslaunch
          3. Adding wheels
          4. Adding a caster
          5. Adding color
          6. Adding collisions
          7. Moving the wheels
          8. A word about tf and robot_state_publisher
          9. Adding physical properties
          10. Trying URDF tools
            1. check_urdf
            2. urdf_to_graphiz
        4. Gazebo
          1. Installing and launching Gazebo
          2. Using roslaunch with Gazebo
          3. Using Gazebo
            1. Environment toolbar
            2. World and Insert panels
            3. Joints panel
            4. Main window menu bar
            5. Simulation panel
          4. Modifications to the robot URDF
            1. Adding the Gazebo tag
            2. Specifying color in Gazebo
            3. A word about <visual> and <collision> elements in Gazebo
          5. Verifying a Gazebo model
          6. Viewing the URDF in Gazebo
          7. Tweaking your model
          8. Moving your model around
          9. Other ROS simulation environments
        5. Summary
      10. 3. Driving Around with TurtleBot
        1. Introducing TurtleBot
        2. Loading TurtleBot simulator software
        3. Launching TurtleBot simulator in Gazebo
          1. Problems and troubleshooting
          2. ROS commands and Gazebo
          3. Keyboard teleoperation of TurtleBot in simulation
        4. Setting up to control a real TurtleBot
          1. TurtleBot standalone test
        5. Networking the netbook and remote computer
          1. Types of networks
          2. Network addresses
          3. Remote computer network setup
          4. Netbook network setup
          5. Secure Shell (SSH) connection
          6. Summary of network setup
          7. Troubleshooting your network connection
          8. Testing the TurtleBot system
        6. TurtleBot hardware specifications
          1. TurtleBot dashboard
        7. Move the real TurtleBot
          1. Using keyboard teleoperation to move TurtleBot
          2. Using ROS commands to move TurtleBot around
          3. Writing your first Python script to control TurtleBot
        8. Introducing rqt tools
          1. rqt_graph
          2. rqt message publisher and topic monitor
        9. TurtleBot's odometry
          1. Odom for the simulated TurtleBot
          2. Real TurtleBot's odometry display in rviz
        10. TurtleBot automatic docking
        11. Summary
      11. 4. Navigating the World with TurtleBot
        1. 3D vision systems for TurtleBot
          1. How these 3D vision sensors work
          2. Comparison of 3D sensors
            1. Microsoft Kinect
            2. ASUS
            3. Obstacle avoidance drawbacks
        2. Configuring TurtleBot and installing the 3D sensor software
          1. Kinect
          2. ASUS and PrimeSense
          3. Camera software structure
          4. Defining terms
        3. Testing the 3D sensor in standalone mode
        4. Running ROS nodes for visualization
          1. Visual data using Image Viewer
          2. Visual data using rviz
        5. Navigating with TurtleBot
          1. Mapping a room with TurtleBot
            1. Defining terms
            2. Building a map
            3. How does TurtleBot accomplish this mapping task?
          2. Autonomous navigation with TurtleBot
            1. Defining terms
            2. Driving without steering TurtleBot
            3. rviz control
            4. How does TurtleBot accomplish this navigation task?
          3. rqt_reconfigure
          4. Exploring ROS navigation further
        6. Summary
      12. 5. Creating Your First Robot Arm (in Simulation)
        1. Features of Xacro
          1. Expanding Xacro
        2. Building an articulated robot arm URDF using Xacro
          1. Using the Xacro property tag
            1. Using roslaunch for rrbot
          2. Using Xacro include and macro tags
          3. Adding mesh to the robot arm
        3. Controlling an articulated robot arm in Gazebo
          1. Adding Gazebo-specific elements
          2. Fixing the robot arm to the world
          3. Viewing the robot arm in Gazebo
          4. Adding controls to the Xacro
            1. Defining transmission elements for joints
            2. Adding a Gazebo ROS control plugin
            3. Creating a YAML configuration file
            4. Creating a control launch file
          5. Controlling your robot arm with the ROS command line
          6. Controlling your robot arm with rqt
            1. Trying more things in rqt
        4. Summary
      13. 6. Wobbling Robot Arms Using Joint Control
        1. Introducing Baxter
          1. Baxter, the research robot
          2. Baxter Simulator
        2. Baxter's arms
          1. Baxter's pitch joints
          2. Baxter's roll joints
          3. Baxter's coordinate frame
          4. Control modes for Baxter's arms
          5. Baxter's grippers
          6. Baxter's arm sensors
        3. Loading the Baxter software
          1. Installing Baxter SDK software
          2. Installing Baxter Simulator
          3. Configuring the Baxter shell
          4. Installing MoveIt
        4. Launching Baxter Simulator in Gazebo
          1. Bringing Baxter Simulator to life
          2. Warm-up exercises
          3. Flexing Baxter's arms
            1. Tucking and untucking
            2. Wobbling arms
            3. Controlling arms and grippers with a keyboard
            4. Controlling arms and grippers with a joystick
            5. Controlling arms with a Python script
            6. Recording and replaying arm movements
          4. Tuning Baxter's arm controllers
        5. Baxter's arms and forward kinematics
          1. Joints and joint state publisher
          2. Understanding tf
            1. A program to move Baxter's arms to a zero angle position
          3. Rviz tf frames
          4. Viewing a tf tree of robot elements
        6. Introducing MoveIt
          1. Planning a move of Baxter's arms with MoveIt
          2. Adding objects to a scene
            1. Position of objects
          3. Planning a move to avoid obstacles with MoveIt
        7. Configuring a real Baxter setup
        8. Controlling a real Baxter
          1. Commanding joint position waypoints
          2. Commanding joint torque springs
          3. Demonstrating joint velocity
          4. Additional examples
          5. Visual servoing and grasping
        9. Inverse kinematics
        10. Summary
      14. 7. Making a Robot Fly
        1. Introducing quadrotors
          1. Why are quadrotors so popular?
          2. Defining roll, pitch, and yaw
          3. How do quadrotors fly?
          4. Components of a quadrotor
          5. Adding sensors
          6. Quadrotor communications
        2. Understanding quadrotor sensors
          1. Inertial measurement unit
          2. Quadrotor condition sensors
        3. Preparing to fly your quadrotor
          1. Testing your quadrotor
          2. Pre-flight checklist
          3. Precautions when flying your quadrotor
          4. Following the rules and regulations
        4. Using ROS with UAVs
        5. Introducing Hector Quadrotor
          1. Loading Hector Quadrotor
          2. Launching Hector Quadrotor in Gazebo
            1. Flying Hector outdoors
            2. Flying Hector indoors
        6. Introducing Crazyflie 2.0
          1. Controlling Crazyflie without ROS
          2. Communicating using Crazyradio PA
          3. Loading Crazyflie ROS software
            1. Setting up udev rules for Crazyradio
          4. Pre-flight check
          5. Flying Crazyflie with teleop
            1. Details of teleop_xbox360.launch
          6. Flying with a motion capture system
          7. Flying multiple Crazyflies
        7. Introducing Bebop
          1. Loading bebop_autonomy software
          2. Preparing to fly Bebop
            1. Testing Bebop communications
          3. Flying Bebop using commands
            1. Take off
            2. Landing
        8. Summary
      15. 8. Controlling Your Robots with External Devices
        1. Creating a custom ROS game controller interface
          1. Testing a game controller
            1. Alternative test of a game controller
          2. Using the joy ROS package
          3. Controlling Turtlesim with a custom game controller interface
        2. Creating a custom ROS Android device interface
          1. Playing with Turtlebot Remocon
            1. Troubleshooting TurtleBot Remocon
          2. Custom control of ROS robot using an Android device
            1. Installing Android Studio and Tools
            2. Installing an ROS-Android development environment
            3. Defining terms
            4. Introducing ROS-Android development
        3. Creating ROS nodes on Arduino or Raspberry Pi
          1. Using Arduino
            1. Installing the Arduino IDE software
            2. Installing the ROS Arduino software
            3. Ultrasonic sensor control using ROS and Arduino
              1. Connecting the Arduino to the HC-SR04 ultrasonic sensor
              2. Programming the Arduino to sense distance
              3. Executing the ultrasonic sensor program
            4. Other applications using ROS and Arduino
          2. Using Raspberry Pi
            1. Installing ROS on the Raspberry Pi
        4. Summary
      16. 9. Flying a Mission with Crazyflie
        1. Mission components
          1. Kinect for Windows v2
          2. Crazyflie operation
          3. Mission software structure
          4. OpenCV and ROS
        2. Loading software for the mission
          1. Installing libfreenect2
          2. Installing iai_kinect2
          3. Using the iai_kinect2 metapackage
            1. kinect2_bridge and kinect2_viewer
            2. kinect2_calibration
              1. Calibrating your Kinect
        3. Setting up the mission
          1. Detecting Crazyflie and a target
            1. Identifying markers in a color image
              1. Problems with target detection
            2. Detecting and viewing markers with OpenCV
          2. Using Kinect and OpenCV
          3. How to track Crazyflie
        4. How to control Crazyflie
          1. Crazyflie control states
            1. Using ROS services to control takeoff and land
              1. Activating takeoff and land
              2. What makes takeoff and land work?
            2. Using PID control for hover and flight
            3. Using an observer node
        5. Flying Crazyflie
          1. Hovering in place
            1. What makes hover work?
          2. Flying to a stationary target
            1. What makes target detection work?
          3. Learned lessons
            1. Logging messages with rosout and rospy
        6. Summary
      17. 10. Extending Your ROS Abilities
        1. Controlling a robot with your voice
          1. Sphinx
          2. rospeex
        2. Enabling a robot to speak
        3. Enabling a robot to recognize faces
          1. Face detection with a cascade classifier
            1. Using ROS package face_detector
          2. Face recognition with OpenCV
            1. Using ROS package cob_people_detection
            2. Using ROS package face_recognition
        4. Summary
      18. Index