Planning components and code structure
Before you build a robot, consider what you’d like it to do. What code and software would you run? In this section, we’ll make a block diagram of the software we want, and what hardware it may need to connect to. This will help drive other plans.We will also consider how the code is structured. Code is easier to reason about when taken as logical blocks instead of one large lump. Arranging code in layers and blocks will help you navigate your way around as it becomes more complicated.Let’s start with a specific use case, tracking an object. From this use case, we are going to want to handle a camera and drive wheels, which would lead to this logical hardware plan:
We’d need the hardware in Figure 2.1 (a sensor and two outputs – a left and right motor) for the capability described. This helps us to think about what our code would need to handle. Each component (camera...