BPB Online LLP
Practical Robotics in C++
Lloyd Brombach
Practical Robotics in C++
US$ 19.95
The publisher has enabled DRM protection, which means that you need to use the BookFusion iOS, Android or Web app to read this eBook. This eBook cannot be used outside of the BookFusion platform.
Description
Contents
Reviews

Learn how to build and program real autonomous robots

Key Features
Simplified coverage on fundamentals of building a robot platform.
Learn to program Raspberry Pi for interacting with hardware.
Cutting-edge coverage on autonomous motion, mapping, and path planning algorithms for advanced robotics.

Description
Practical Robotics in C++ teaches the complete spectrum of Robotics, right from the setting up a computer for a robot controller to putting power to the wheel motors. The book brings you the workshop knowledge of the electronics, hardware, and software for building a mobile robot platform.

You will learn how to use sensors to detect obstacles, how to train your robot to build itself a map and plan an obstacle-avoiding path, and how to structure your code for modularity and interchangeability with other robot projects. Throughout the book, you can experience the demonstrations of complete coding of robotics with the use of simple and clear C++ programming.

In addition, you will explore how to leverage the Raspberry Pi GPIO hardware interface pins and existing libraries to make an incredibly capable machine on the most affordable computer platform ever.

What You Will Learn
Write code for the motor drive controller.
Build a Map from Lidar Data.
Write and implement your own autonomous path-planning algorithm.
Write code to send path waypoints to the motor drive controller autonomously.
Get to know more about robot mapping and navigation.

Who this book is for
This book is most suitable for C++ programmers who have keen interest in robotics and hardware programming. All you need is just a good understanding of C++ programming to get the most out of this book.

Table of Contents
1. Choose and Set Up a Robot Computer
2. GPIO Hardware Interface Pins Overview and Use
3. The Robot Platform
4. Types of Robot Motors and Motor Control
5. Communication with Sensors and other Devices
6. Additional Helpful Hardware
7. Adding the Computer to Control your Robot
8. Robot Control Strategy
9. Coordinating the Parts
10. Maps for Robot Navigation
11. Robot Tracking and Localization
12. Autonomous Motion
13. Autonomous Path Planning
14. Wheel Encoders for Odometry
15. Ultrasonic Range Detectors
16. IMUs: Accelerometers, Gyroscopes, and Magnetometers
17. GPS and External Beacon Systems
18. LIDAR Devices and Data
19. Real Vision with Cameras
20. Sensor Fusion
21. Building and Programming an Autonomous Robot

About the Author
Lloyd Brombach is a controls engineer, programmer, and long-time electronics and robotics enthusiast. He has competed at robotics events such as the NASA-funded 2007 Lunar Regolith Excavation Challenge and recently the 27th Intelligent Ground Vehicle Challenge. He is committed to making contributions to the robotics field that future roboticists and robot-owners will benefit from for years to come.

Facebook Profile: www.facebook.com/practicalrobotics
Youtube: www.youtube.com/practicalrobotics
LinkedIn Profile: https://www.linkedin.com/in/lbrombach

Language
English
ISBN
9789389423464
Cover Page
Title Page
Copyright Page
Dedication Page
About the Author
Acknowledgements
Preface
Foreword
Errata
Table of Contents
Introduction
1. Choose and Set Up a Robot Computer
What is a Raspberry Pi?
What’s the difference then?
So the Raspberry Pi is the only choice for a robot controller?
Isn’t the Raspberry Pi for schools, hobbyists, and toys? I wanted to learn about real robotics.
Raspberry Pi models and why not all are suitable for our purposes
Raspberry Pi Zero and Raspberry Pi ZeroW
The Raspberry Pi 2B
The Raspberry Pi 3B - Best choice!!
The Raspberry Pi 3B+
The new Raspberry Pi 4
Operating system choices
Raspbian
Ubuntu
Operating system installation and setup
Full Ubuntu desktop on laptop or desktop PC
Lubuntu on your Raspberry Pi
Programming environment (IDE) installation and setup
Visual studio code for the laptop or desktop PC
Code blocks for the Raspberry Pi
Conclusion
Questions
2. GPIO Hardware Interface Pins Overview and Use
Introduction
What are GPIO pins
So what exactly does the GPIO do?
Electronics for programmers 101
Types of output data
Types of input data
Some common electronics hardware
Breadboards
GPIO pins as outputs
Two pin numbering systems
GPIO pins as inputs
Accessing the Raspberry Pi GPIO with C++ programs
Installing PIGPIO
Installing and setting up the PIGPIO library
Making sure Code::Blocks can link to PIGPIO
Running PIGPIO programs
Our first GPIO project – hello_blink
Digital input to control a digital output – hello_button
GPIO event callback functions
Conclusion
3. The Robot Platform
Introduction
Objective
Considering the size and operating environment
Differential drive versus Ackerman (car-like) steering
Differential drive
Ackerman steering
Ready-made robot platforms
Large pre-built robots
Small pre-built robots
Tips for building your own robot
Building materials
Batteries
Drive trains
Robot parts sources
Re-purposing robot vacuums or remote-controlled cars
Robot vacuums with the interface
Interfacing with a Roomba
Un-freezing your Roomba
Robot vacuums without an Interface
Hacking remote-controlled cars and trucks
Conclusion
Questions
4. Types of Robot Motors and Motor Control
Introduction
Objectives
Motor types
Alternating current (AC) versus direct current (DC) motors
Brush-type DC motors
Servos
Stepper motors
Brushless DC motors (also known as BLDC)
Introduction to the transistor and motor drivers
The most basic control: On/Off
Transistors
Pulse width modulation (PWM)
PWM to create analog voltages
PWM as a control signal
Motor drivers and motor controllers
Motor drivers
Controlling motors with an L298N dual H-Bridge motor driver
Motor controllers
Conclusion
Questions
Bonus challenge
5. Communication with Sensors and other Devices
Introduction
Objective
Binary (logical) signals
Debouncing switches
Wheel encoders
Binary signals from analog sensors
Binary communication summary
Serial communication primer
UART serial
Set up a Raspberry Pi and test UART serial communication
Fixing error opening serial port
I2C communication primer
To set up and use an I2C device with the Raspberry Pi:
Example and test program: hello_i2c_lsm303
Conclusion
Questions
6. Additional Helpful Hardware
Introduction
Objective:
Power supplies
5 volt supplies
Adjustable power supplies
Relay modules
Logic level converters
FTDIs
Arduinos
Digisparks
Conclusion
Questions
7. Adding the Computer to Control your Robot
Introduction
Structure
Objective
The steps
Step 1 - Mount and run power to the computer:
Interface (wire) the computer to the rest of the Robot:
Conclusion
Questions
8. Robot Control Strategy
Introduction
Structure
Objectives
Robot control: The big picture versus the small picture
The fundamental control loop
Observe and compare
React
Affect
Open-loop and closed-loop controllers:
Designing a big picture (also known as the master) controllers:
Designing a small picture (also known as a process) controllers:
Bang bang controllers (also known as On/Off controllers)
Proportional controllers
Designing controllers to accept some error
Setting a minimum output
Beyond proportional controllers
Conclusion
Questions
9. Coordinating the Parts
Introduction:
Structure:
Objective
What is the robot operating system?
ROS versus writing your robot control software
ROS and the commercial robotics industry
ROS setup
ROS melodic installation on your laptop or desktop
ROS kinetic installation on your Raspberry Pi 3B
ROS overview and crash-course
Packages, nodes, publishers, subscribers, topics, and messages
A handful of helpful tips
Creating and writing ROS packages and nodes
The ROS file system
Creating ROS packages
Writing ROS programs (Nodes)
Downloading, reviewing, and running the chapter download programs
Making life easier with roslaunch and .launch files
Conclusion
Questions
10. Maps for Robot Navigation
Introduction
Objectives
Angle, heading, and distance conventions
Receiving sensor data
Occupancy grid maps
Building occupancy grid maps (OGMs) with sensor data
Marking the occupied cells
Marking the free cells
Completing the map
Publishing the map as a ROS Message
Transforms in ROS
Understanding transforms
How transforms are used in ROS
Publishing transforms with the static transform publisher
Publishing transforms from nodes with a transform broadcaster
Getting transform data in your nodes
Viewing transform data from the command line
Mapping made easy with Gmapping
Gmapping 101
Getting Gmapping
Running Gmapping and parameters in launch files
Steps to create a map
Visualizing a live map
Saving a Map and using it later
Saving maps
Load previously saved map
Conclusion
Questions
11. Robot Tracking and Localization
Introduction
Objectives
The robot pose
Converting Euler angles to quaternions
Converting quaternions to Euler angles
Odometry and dead reckoning
Wheel odometry
Calculate the distance traveled for each wheel
Calculate the total distance the robot has traveled
Calculate the change in heading angle theta
Add the change in heading to old heading theta
Calculate the distance moved in the x direction and the y directions (also known as translation)
Add the distances calculated to the previous pose estimate
Dead reckoning
Publishing odometry data in ROS
Odometry transform publisher
Further tracking and localization
Manual pose updater
Fiducials
Laser scanner based localization
GPS and GNSS
Beacon-based localization systems
Conclusion
Questions
12. Autonomous Motion
Introduction
Objective
ROS robot motion overview
The motor controller - simple_diff_drive.cpp
The simple_diff_drive motor controller code steps
The differential drive motor controller code outline
The differential drive motor controller code
The drive controller: simple_drive_controller.cpp
Drive controller steps
Conclusion
Questions
13. Autonomous Path Planning
Introduction
Objectives
Path planning methods and challenges
Challenges
Path planning methods
Obstacle inflation
Costmaps
A* path planning
How it works
The A* algorithm by the steps
Walking through an A* routine
Writing the A* program as a ROS node
The standard stuff, helper functions, and main()
The heart of your A* Node: find_path()
Conclusion
Questions
14. Wheel Encoders for Odometry
Introduction
Objective
Wheel encoders 101
Optical encoders
Hall effect encoders
Wiring encoders
The Encoder tick publisher - tick_publisher.cpp
Encoder tick publisher code
Conclusion
Questions
15. Ultrasonic Range Detectors
Introduction
Objective
HC-SR04 ultrasonic range sensor basics
Reading HC-SR04 by the steps
Wiring the HC-SR04
Ultrasonic range data publisher: ultrasonic_publisher.cpp
Ultrasonic range publisher by the steps
Ultrasonic range publisher code
Ultrasonic range data for object detection
Conclusion
Questions
16. IMUs - Accelerometers, Gyroscopes and Magnetometers
Introduction
Objectives
Accelerometers
Accelerometer shortcomings
Publishing IMU Data in ROS
The ROS sensor_msgs::Imu data type
The IMU message publisher code
Gyroscopes
Gyroscope shortcomings
Adding gyroscope data to the IMU node
Magnetometers
Magnetometer shortcomings
Adding magnetometer data
Mounting the IMU
Conclusion
Questions
17. GPS and External Beacon Systems
Introduction
Objectives
How beacon systems work
GPS and GNSS basics
GPS/GNSS accuracy
GPS/GNSS-RTK for 2cm accuracy
GPS/GNSS limitations
GPS/GNSS data
NMEA data strings
Some key lat/long data representations
Publishing GPS/GNSS data in ROS
The ROS package: nmea_navsat_driver
Installing the nmea_navsat_driver package
Reading ROS package documentation
Running the nmea_serial_driver node with parameters
Conclusion
Questions
18. LIDAR Devices and Data
Introduction
Objective
LIDAR basics
LIDAR limitations
LIDAR types
Unidirectional (single point) LIDAR
2D LIDAR
3D LIDAR
Salvaged robot vacuum LIDAR
LIDAR selection considerations
LIDAR data: The sensor_msgs::LaserScan message
LIDAR mounting considerations
Setting up, running, and testing a common LIDAR unit
Setting up an RPLIDAR by following these steps:
Visualizing the LaserScan message
Conclusion
Questions
19. Real Vision with Cameras
Introduction
Objectives
What is an image?
Image attributes
Pixel coordinates
Checking or installing the required software
ROS Kinetic
ROS Melodic
Testing OpenCV in ROS
Image processing software (OpenCV) and ROS:
Step 1: Publishing images in ROS
Installing the usb_cam_node
Running the usb_cam_node
Test the camera output
Step 2: Subscribe to image in a different node
Create your ROS vision package
Coding the image message subscriber
Step 3: Use cv-bridge to convert the RGB image ROS uses to a BGR image OpenCV can work with
Step 4: Perform desired operations on the image
Step 5: Publish any non-image data as their own ROS message.
Step 6: Convert modified image back to RGB
Step 7: Publish result image under its own topic
More image processing basics
Kernels, apertures and blocks
The importance of working on copies instead of original images
A word about lighting
Step 4 revisited - more possible OpenCV operations
Converting color format: cvtColor()
Blurring images: blur(), medianBlur(), GaussianBlur()
Edge detection: Canny()
Edges on image to numerical lines: HoughLinesP()
Image masking: bitwise_and()
Filtering by Color: cvtColor() and inRange()
Miscellaneous helpful ROS tool
Advanced OpenCV and beyond
Cloud-based image recognition
Conclusion
Questions
20. Sensor Fusion
Introduction
Objective
Sensor fusion made easy
The Bosch BN0055 absolute orientation sensor
Provided data
Improved odometry
Integrating the BN0055 – The hardware and ROS publisher
Integrating the BN0055 – The odometry node
Step 1: Subscribe to the IMU message
Step 2: Verify orientation is not marked Do Not Use
Step 3: Convert quaternions to Euler angles
Step 4: Save Offset information IF this is first IMU message
Step 5.1: If NOT the first IMU message – Save the IMU heading
Step 5.2: Apply the new heading in the odometry calculation function
Sensor fusion 2 – A more comprehensive approach
The Kalman filter
The covariance matrix
Covariance matrices in ROS messages
The robot_pose_ekf node
Installing robot_pose_ekf
Running the robot_pose_ekf
A final note on transforms and roslaunch
Conclusion
Questions
21. Building and Programming an Autonomous Robot
Introduction
Objective
Part 1 - Building the physical robot platform
The robot platform – General overview and parts list
Wheel/motor modules
Motor driver(s)
Caster wheel
Battery and charger
Chassis/base
Computers
LIDAR or another ranging sensor
Wheel encoders
IMU
Voltage converter for computer
GPIO header breakout board
Camera
Voltmeter
Miscellaneous materials
Assembling the robot platform
Mount the wheel modules and caster
Mount the motor driver, terminal strips, and computer power supply
Prepare the GPIO breakout board
Mount the computer, GPIO breakout board, and IMU
Complete wiring and mount battery
Mount LIDAR and camera
Part 1 - Conclusion
Part 2 - Programming your robot
Programming – General overview
Programming your robot – Detailed steps
Run your autonomous robot!
Some troubleshooting tips
What next?
Dynamic obstacle avoidance
PID controllers
A master controller that manages various routines or tasks
Implementing the map to odom transform (full localization)
Keep an eye on facebook.com/practicalrobotics and youtube.com/practicalrobotics
Conclusion
Index
The book hasn't received reviews yet.
You May Also Like
Artificial Intelligence and Deep Learning for Decision Makers
$19.95
Dr. Jagreet Kaur, Navdeep Singh Gill
Artificial Intelligence and Deep Learning for Decision Makers
Internet of Things (IoT)
$19.95
Dr Kamlesh Lakhwani, Dr Hemant Kumar Gianey, Joseph Kofi Wireko, Kamal Kant Hiran
Internet of Things (IoT)