Build Your Own Robot

Book description

A DIY guide to bringing your first robot to life with cheap and basic components.

Build Your Own Robot introduces you to the exciting world of robotics in a way that’s fun and affordable! You’ll build your own real robot with easy-to-find hardware and free open source software. Plus, all the components you need can be assembled with simple tools like a screwdriver.

In Build Your Own Robot you’ll learn how to:

  • Use cameras to capture photos and let your robot see
  • Add cameras and basic computer vision
  • Coordinate DC motors to move your robot
  • Write a web app to control your robot
  • Set up controls for joysticks
  • Read QR codes to find and identify objects

This book shows you how anyone can start building their own robot—no special soldering or electronic skills required. All you need is some basic Python know-how to get started. From scratch, you’ll go hands-on with DC motors, touch sensors, custom shell scripting, joystick controls, and even face detection for your robot friend.

About the Technology
You can build your own robot! With this book, you’ll use readily-available hardware and author Marwan Alsabbagh’s clear step-by-step instructions to create a robot that moves, manipulates objects, and responds to its environment. Along the way, you’ll learn some serious skills like computer vision, networking, and the basics of robotics programming.

About the Book
Build Your Own Robot is a project-based guide that takes you from spinning your first DC motor to programming a mobile robot that you can control from your phone or computer. You’ll write simple Python code to help your new friend spin, move, and find its way. You’ll even teach it to track faces and fetch snacks. Plus, a helpful hardware purchasing guide makes it easy to find exactly what you need to get started!

What's Inside
  • Coordinate DC motors to move your robot
  • Write a web app to control your robot
  • Adding cameras and basic computer vision
  • Read QR codes to find and identify objects


About the Reader
Examples use simple Python code. No special skills or expensive tools required.

About the Author
Marwan Alsabbagh is a seasoned software developer, who has studied mathematics and computer science at McGill University.

The technical editor on this book was Alexander Ryker.

Quotes
There’s a lot to learn! Follow the step-by-step instructions and tons of code examples; you’ll be making your next mechatronic friend all in a single weekend.
- Limor “Ladyada” Fried, Founder & Engineer, Adafruit

This easy-to-follow guide takes you from simple experiments to using the OpenCV library for image recognition. You’ll soon have your own tiny robot that can follow faces and read QR codes!
- Bill Jamshedji, DroneBot Workshop

Every step of the way, you create something worth being excited about!
- Jonathan Choate, Takeoff Technologies, Inc.

This approach really makes robotics accessible.
- James Matlock, Wake Technical Community College

Table of contents

  1. inside front cover
  2. Build Your Own Robot
  3. Copyright
  4. dedication
  5. contents
  6. front matter
    1. preface
    2. acknowledgments
    3. about this book
      1. Who should read this book?
      2. How this book is organized: A roadmap
      3. About the code
      4. liveBook discussion forum
      5. Software/Hardware requirements
    4. about the author
    5. about the cover illustration
  7. 1 What is a robot?
    1. 1.1 Why robots are amazing
    2. 1.2 Our approach to making robots
      1. 1.2.1 Learning from failures
      2. 1.2.2 What will you gain?
      3. 1.2.3 Prototyping
      4. 1.2.4 Teaching
      5. 1.2.5 Production ready
      6. 1.2.6 Limitations
    3. 1.3 What are robots made of?
      1. 1.3.1 The robot building blocks
      2. 1.3.2 Servos and DC motors on a Raspberry Pi
      3. 1.3.3 Hardware stack
      4. 1.3.4 Python and Linux
      5. 1.3.5 Software stack
    4. Summary
  8. 2 Getting started
    1. 2.1 Introducing our robotic hardware
      1. 2.1.1 Raspberry Pi
      2. 2.1.2 Adafruit CRICKIT HAT
    2. 2.2 Configuring the software for our robots
    3. 2.3 Changing Neopixel colors
    4. 2.4 Checking the touch sensor state
    5. 2.5 Controlling DC motors
    6. 2.6 Controlling motors with the touch sensor
    7. Summary
  9. 3 Driving the robot
    1. 3.1 What’s a robot chassis kit?
    2. 3.2 Hardware stack
    3. 3.3 Software stack
    4. 3.4 Writing a move forward function
    5. 3.5 Using environment variables for configuration
    6. 3.6 Controlling the speed and duration of movements
    7. 3.7 Moving backward
    8. 3.8 Turning right
    9. 3.9 Moving left and spinning in either direction
    10. 3.10 Refactoring by finding common logic
    11. 3.11 Refactoring by using functools
    12. Summary
  10. 4 Creating a robot shell
    1. 4.1 What’s a REPL or shell?
    2. 4.2 Benefits of a REPL
    3. 4.3 Hardware stack
    4. 4.4 Software stack
    5. 4.5 Creating the robot shell
    6. 4.6 Handling command arguments
    7. 4.7 Adding a speed argument
    8. 4.8 Running robot shell scripts
    9. Summary
  11. 5 Controlling robots remotely
    1. 5.1 Hardware stack
    2. 5.2 Software stack
    3. 5.3 Robot testing tips
    4. 5.4 Controlling robots over SSH
      1. 5.4.1 Creating the server-side script
      2. 5.4.2 Running the script remotely
      3. 5.4.3 Creating the client-side script
    5. 5.5 Creating web services for robots
      1. 5.5.1 Creating our first web service
      2. 5.5.2 Creating web services to perform robot movements
    6. 5.6 Calling web services from Python
      1. 5.6.1 Using the read–evaluate–print loop to call web services
      2. 5.6.2 Creating a basic web service client
      3. 5.6.3 Creating a web service client with persistent connections
      4. 5.6.4 Measuring client performance
    7. Summary
  12. 6 Creating robot web apps
    1. 6.1 Hardware stack
    2. 6.2 Software stack
    3. 6.3 Moving robots forward and backward over the web
      1. 6.3.1 Creating a basic web application
      2. 6.3.2 Detecting failed requests
      3. 6.3.3 Moving robots forward with web apps
    4. 6.4. Creating a full-movement web app
      1. 6.4.1 Creating the full-movement application
      2. 6.4.2 Web interface design
      3. 6.4.3 Measuring application performance in the browser
      4. 6.4.4 Web hardware devices
    5. Summary
  13. 7 Joystick-controlled robots
    1. 7.1 Hardware stack
    2. 7.2 Software stack
    3. 7.3 Joystick events
    4. 7.4 Reading joystick events using Pygame
      1. 7.4.1 Detecting events in Pygame
      2. 7.4.2 Detecting joystick events
    5. 7.5 Reading Linux joystick events
      1. 7.5.1 Exploring the Linux input subsystem
      2. 7.5.2 Unpacking joystick events
      3. 7.5.3 Mapping joystick events
      4. 7.5.4 Working with axis events
    6. 7.6 Measuring the rate of joystick events
      1. 7.6.1 Calculating the event rate
      2. 7.6.2 Calculating the level rate
    7. 7.7 Moving robots with joysticks
      1. 7.7.1 Creating the joystick client
    8. Summary
  14. 8 Keyboard-controlled camera
    1. 8.1 Hardware stack
    2. 8.2 Software stack
    3. 8.3 Capturing images using OpenCV
      1. 8.3.1 Exploring the OpenCV library
      2. 8.3.2 Drawing shapes and displaying text with OpenCV
      3. 8.3.3 Taking snapshots with OpenCV
    4. 8.4 Moving a camera with servos
      1. 8.4.1 Exploring the servo motors with the CRICKIT library
      2. 8.4.2 Performing a pan-and-tilt sweep
      3. 8.4.3 Controlling servos and the camera together
    5. Summary
  15. 9 Face-following camera
    1. 9.1 Hardware stack
    2. 9.2 Software stack
    3. 9.3 Detecting faces in an image
      1. 9.3.1 Exploring face detection
      2. 9.3.2 Marking detected faces
    4. 9.4 Detecting faces in live video
      1. 9.4.1 Measuring face detection performance
      2. 9.4.2 Reducing the number of pixels to process
      3. 9.4.3 Optimizing face detection performance
      4. 9.4.4 Showing detected faces in live video
    5. 9.5 Creating a face-following robot
      1. 9.5.1 Zoning the face detection
      2. 9.5.2 Moving motors to follow faces
    6. Summary
  16. 10 Robotic QR code finder
    1. 10.1 Hardware stack
    2. 10.2 Software stack
    3. 10.3 Detecting QR codes in an image
      1. 10.3.1 Exploring QR codes
      2. 10.3.2 Marking detected QR codes
    4. 10.4 Streaming live video to multiple applications
      1. 10.4.1 Saving the video stream to a ramdisk
      2. 10.4.2 Watching the filesystem for changes
      3. 10.4.3 Streaming to a graphical application
      4. 10.4.4 Detecting QR codes in a video stream
      5. 10.4.5 Streaming to a web browser
    5. 10.5 Moving the robot to a target QR code
      1. 10.5.1 Find the QR code
    6. Summary
  17. 11 Building a snack-pushing robot
    1. 11.1 Hardware stack
    2. 11.2 Software stack
    3. 11.3 Finding and pushing snacks
      1. 11.3.1 Reading the list of snacks
      2. 11.3.2 Pushing snacks
    4. 11.4 Creating the snack-pushing application
      1. 11.4.1 Selecting snacks with the application
      2. 11.4.2 Styling the web application
      3. 11.4.3 Adding the live video stream to the application
    5. Summary
  18. Appendix A. Hardware purchasing guide
    1. A.1 Raspberry Pi components
    2. A.2 Motors, chassis kits, and joystick controllers
    3. A.3 Power and cabling
    4. A.4 Optional purchases
  19. Appendix B. Configuring the Raspberry Pi
    1. B.1 Setting up the Raspberry Pi
    2. B.2 Setting up the Adafruit CRICKIT HAT
    3. B.3 Activating the Python virtual environment
  20. Appendix C. Robot assembly guide
    1. C.1 Building a mobile robot
    2. C.2 Building a servo camera robot
    3. C.3 Building a pusher robot
    4. C.4 Creating a track for the pusher robot
  21. Appendix D. Mocking the CRICKIT library
    1. D.1 Installing the mock CRICKIT library
  22. index
  23. inside back cover

Product information

  • Title: Build Your Own Robot
  • Author(s): Marwan Al-Sabbagh
  • Release date: February 2024
  • Publisher(s): Manning Publications
  • ISBN: 9781633438453