Skip to Content
Hands-On Robotics Programming with C++
book

Hands-On Robotics Programming with C++

by Dinesh Tavasalkar
March 2019
Intermediate to advanced
312 pages
7h 37m
English
Packt Publishing
Content preview from Hands-On Robotics Programming with C++

Object-following robot program

The object-following robot program is basically a combination of the obstacle-avoiding program from Chapter 4, Building an Obstacle-Avoiding Robot, and the preceding ball-tracing program. The program is called ObjectFollowingRobot.cpp and you can download it from the Chapter07 folder of the GitHub repository:

int main() { ... float distance = (totalTime * 0.034)/2; if(distance < 15) { cout<<"Object close to Robot"<< " " << Mat(p)<< " " <<distance << " cm" << endl; stop(); } else{       if(x<20 && y< 20)      {      cout<<"Object not found"<< " " << Mat(p)<< " " <<distance << " cm" << endl;      stop();      }      if(x > 20 && x < 170 && y > 20 )      {      cout<<"LEFT TURN"<< " " << Mat(p)<< " " <<distance << " cm" << endl;      left();      } if(x > 170 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn Robotics Programming

Learn Robotics Programming

Danny Staple
C++ Reactive Programming

C++ Reactive Programming

Praseed Pai, Peter Abraham

Publisher Resources

ISBN: 9781789139006Supplemental Content