Reader small image

You're reading from  Learn Robotics Programming - Second Edition

Product typeBook
Published inFeb 2021
PublisherPackt
ISBN-139781839218804
Edition2nd Edition
Concepts
Right arrow
Author (1)
Danny Staple
Danny Staple
author image
Danny Staple

Danny Staple builds robots and gadgets as a hobbyist, makes videos about his work with robots, and attends community events such as PiWars and Arduino Day. He has been a professional Python programmer, later moving into DevOps, since 2009, and a software engineer since 2000. He has worked with embedded systems, including embedded Linux systems, throughout the majority of his career. He has been a mentor at a local CoderDojo, where he taught how to code with Python. He has run Lego Robotics clubs with Mindstorms. He has also developed Bounce!, a visual programming language targeted at teaching code using the NodeMCU IoT platform. The robots he has built with his children include TankBot, SkittleBot (now the Pi Wars robot), ArmBot, and SpiderBot.
Read more about Danny Staple

Right arrow

Chapter 19: Planning Your Next Robot Project – Putting It All Together

Throughout this book, you've now seen how to plan, design, build, and program a robot. We've covered many of the starting topics with some hands-on experience of them, an example demonstrating the basics, and some ideas of how you could improve them. In this chapter, we will think about your next robot. We'll answer questions such as the following: How would you plan and design it? Which skills might you need to research and experiment with? What would you build?

We will cover the following topics in this chapter:

  • Visualizing your next robot—how will it look?
  • Making a block diagram—identify the inputs/outputs and parts it would need
  • Choosing the parts—which tradeoffs will you think about when selecting components for the robot?
  • Planning the code for the robot—which software layers and components might this robot need, and which behaviors would...

Technical requirements

For this chapter, I recommend having some diagramming tools such as the following:

  • Pen/pencils
  • Paper—a sketchbook (or perhaps graph paper) is great, but the back of an envelope will do
  • A computer with internet and access to https://app.diagrams.net/

Visualizing your next robot

When we started this book, in Chapter 2, Exploring Robot Building Blocks – Code and Electronics, we first learned how to look at robots as a sketch. I suggested that you make quick drawings, and not worry if they are rough and sketchy—this is perfect at an early planning stage. Use a pencil or pen, and then move on to the more formal block and layout diagrams later.

Every robot starts with a bit of inspiration. Perhaps there is a competition you want to try; maybe you've seen something such as another robot or an animal you want to mimic (crabs are fascinating!). Other inspirations may come from seeing a unique new part or wanting to learn/play with a new skill. You may even have made a list of amazing robots you want to try to build.

Before building a robot, make a short bullet-point list of what it will do, which sensors/outputs it will have, and what it might have to deal with. This list lets you focus your efforts. Here is an...

Making a block diagram

Recall how in Chapter 2, Exploring Robot Building Blocks – Code and Electronics, and throughout the book, we've created block diagrams showing the robot we built there. You can represent any robot in this way. This diagram is where you would have a block for each input and output and then create controller and interface blocks to connect with them. Don't worry about the diagram being perfect; the main point is that the picture conveys which parts you'll connect to others. It's also quite likely that the initial diagram will need some change as you build a robot and come across constraints you were not aware of.

Here are two stages of a block diagram for SpiderBot:

Figure 19.2 – SpiderBot block diagram stages

In Figure 19.2, I initially knew going in that each leg had three motors, but not a lot else. So, I drew those blocks in, along with the distance sensor I want it to have and a Wi-Fi connection...

Choosing the parts

Throughout this book, we have looked at the tradeoffs between different kinds of sensors, different chassis kits, controllers, and so on. These are tradeoffs on weight, complexity, availability (you don't want an irreplaceable part), and cost, covered in detail in Chapter 6, Building Robot Basics – Wheels, Power, and Wiring.

If a particular kit inspired the robot—for example, SpiderBot was inspired by a hexapod kit; yours could be a robot arm or caterpillar track kit—this will likely constrain the other part choices you need to make. I'd need to support 18 servo motors; however, I had a 16-motor controller available, so I elected to use two input/output (I/O) pins of the central controller for the remaining two servos. This added software complexity, though.

Another tradeoff was the main controller. I knew that I'd want SpiderBot to be Wi-Fi-enabled, but it wasn't going to be doing visual processing, so a small, cheap...

Planning the code for the robot

We started planning code in layers in Chapter 2, Exploring Robot Building Blocks – Code and Electronics, and then explored this further in Chapter 7, Drive and Turn – Moving Motors with Python under the Robot Object section.

Let's recall how we planned our code structure with layers.

System layers

The general idea is to create layers of code in the system, as shown in the following diagram:

Figure 19.3 – Robot software layers

As Figure 19.3 shows, there are some suggested layers, as follows:

  • At the bottom of the stack, Vendor Libraries. These, as the name implies, usually come from the hardware supplier, third parties, or a community. These are things such as the gpiozero library we have been using or the various Arduino libraries for that ecosystem. This layer may include I/O control, bus layers, and network stacks.
  • The next layer is Libraries and Middleware. This software...

Letting the world know

You are bound to have questions about how to proceed and problems to be solved—perhaps you've already encountered them before building. When you have questions or have made some minor progress, it is the right time to get online and link with the robotics communities, as shown in the Online robot building communities section of Chapter 18, Taking Your Robot Programming Skills Further.

Use Twitter and Stack Overflow to ask questions or even answer questions from other robot builders. Use YouTube to share your creation or the story of your build and see other people's builds. You do not need to wait until you have a perfectly polished product. Share the steps you've taken, the frustrations you have encountered, and even the failures you've learned from. Failure situations make for some of the best stories. These stories can be just the right motivation for someone else to keep on persisting with complicated builds.

Use a combination...

Summary

You've now seen throughout this book how to build and program your first robot. You've seen where to find out more and how to extend your knowledge. In this final chapter, we've summarized what you've learned and suggested how to use this to plan, build, and program your next robot, as well as taking it on tour and being a member of the robotics community.

You've seen how to design and plan a robot and how to build, program, and test a robot. You've learned hardware skills such as soldering, simple software such as moving a robot, and have touched lightly on complex areas such as computer vision and inertial measurements. You've shaken out bugs, made tradeoffs, finely tuned systems, and learned how to keep backups. You've made user interfaces, smart behaviors, and taken control of a robot with a smartphone.

You have reached the end of this book, but I hope this is just the start of your robotics journey.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Learn Robotics Programming - Second Edition
Published in: Feb 2021Publisher: PacktISBN-13: 9781839218804
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.
undefined
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 ₹800/month. Cancel anytime

Author (1)

author image
Danny Staple

Danny Staple builds robots and gadgets as a hobbyist, makes videos about his work with robots, and attends community events such as PiWars and Arduino Day. He has been a professional Python programmer, later moving into DevOps, since 2009, and a software engineer since 2000. He has worked with embedded systems, including embedded Linux systems, throughout the majority of his career. He has been a mentor at a local CoderDojo, where he taught how to code with Python. He has run Lego Robotics clubs with Mindstorms. He has also developed Bounce!, a visual programming language targeted at teaching code using the NodeMCU IoT platform. The robots he has built with his children include TankBot, SkittleBot (now the Pi Wars robot), ArmBot, and SpiderBot.
Read more about Danny Staple