Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Vision and Behavior for Self-Driving Cars

You're reading from   Hands-On Vision and Behavior for Self-Driving Cars Explore visual perception, lane detection, and object classification with Python 3 and OpenCV 4

Arrow left icon
Product type Paperback
Published in Oct 2020
Publisher Packt
ISBN-13 9781800203587
Length 374 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Krishtof Korda Krishtof Korda
Author Profile Icon Krishtof Korda
Krishtof Korda
Luca Venturi Luca Venturi
Author Profile Icon Luca Venturi
Luca Venturi
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Section 1: OpenCV and Sensors and Signals
2. Chapter 1: OpenCV Basics and Camera Calibration FREE CHAPTER 3. Chapter 2: Understanding and Working with Signals 4. Chapter 3: Lane Detection 5. Section 2: Improving How the Self-Driving Car Works with Deep Learning and Neural Networks
6. Chapter 4: Deep Learning with Neural Networks 7. Chapter 5: Deep Learning Workflow 8. Chapter 6: Improving Your Neural Network 9. Chapter 7: Detecting Pedestrians and Traffic Lights 10. Chapter 8: Behavioral Cloning 11. Chapter 9: Semantic Segmentation 12. Section 3: Mapping and Controls
13. Chapter 10: Steering, Throttle, and Brake Control 14. Chapter 11: Mapping Our Environments 15. Assessments 16. Other Books You May Enjoy

An example MPC in C++

A full implementation of MPC is beyond the scope of this chapter but you can review this example implementation written in C++ at https://github.com/Krishtof-Korda/CarND-MPC-Project-Submission/blob/master/src/MPC.cpp.

The following example will walk you through the implementation of an MPC module that you can use in place of a PID controller for both lateral and longitudinal control. Recall that MPC is a MIMO system, meaning you can control multiple outputs.

The following example shows all the basic components and code you'll need to build an MPC controller:

  1. First, use the following code to fit a polynomial to your prediction horizon waypoints:
    Main.cpp --> polyfit()

    Use the following code to calculate cross-tracking errors:

    Main.cpp --> polyeval()
    double cte = polyeval(coeffs, px) - py;

    Use the following code to calculate orientation errors:

    double epsi = psi - atan(coeffs[1] + 2*coeffs[2]*px + 3*coeffs[3]*px*px) ;
  2. Now, we use MPC.cpp...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image