|
| 1 | +--- |
| 2 | +layout: page |
| 3 | +title: Robots 101 - The Code |
| 4 | +--- |
| 5 | + |
| 6 | +Welcome to another blog post in our 101 series! Today, we're going to delve into |
| 7 | +the brains of your robot - its code. |
| 8 | + |
| 9 | +## Teamwork Makes The Code Work |
| 10 | + |
| 11 | +First and foremost, your robot's code should never be a one-person show. Make |
| 12 | +sure more than one person has access to the codebase and understands it. This is |
| 13 | +crucial for two reasons: First, if the primary coder is unavailable for any |
| 14 | +reason, others can step in and keep things moving. Second, multiple perspectives |
| 15 | +can identify potential issues and generate creative solutions that a single mind |
| 16 | +might overlook. Think of it as having a built-in code review process! |
| 17 | + |
| 18 | +## The Pulse of Your Robot - The Control Loop |
| 19 | + |
| 20 | +Your robot interacts with the environment in a continuous cycle of sensing and |
| 21 | +acting. It's essential to have a solid control loop in your code where your |
| 22 | +robot senses its environment and then decides what to do next based on that |
| 23 | +information. This loop should be at the core of your robot's operation, allowing |
| 24 | +it to adapt and react to its surroundings. |
| 25 | + |
| 26 | +## Backup Your Code: The Magic of Version Control Systems |
| 27 | + |
| 28 | +Mistakes and accidents happen, files get lost, and computers crash. To protect |
| 29 | +your work from these unpredictable events, ensure you regularly back up your |
| 30 | +code. Better yet, use a Version Control System (VCS) like Git with GitHub. A VCS not only |
| 31 | +provides a backup of your code but also tracks changes, making it easy to |
| 32 | +identify when and where things might have gone wrong or right! |
| 33 | + |
| 34 | +## The Six T's: Test, Test, Test, Test, Test, Test! |
| 35 | + |
| 36 | +If there's one golden rule in the world of coding, it's this: test your code. |
| 37 | +Then, test it again, and keep testing! You can utilise our web interface to help |
| 38 | +you quickly iterate on your robot, by live streaming the logs and viewing |
| 39 | +the last captured image. You can also use the web interface to stop and |
| 40 | +restart the execution of your code. The more robust your testing, the |
| 41 | +more reliable your robot will be when it counts! |
| 42 | + |
| 43 | +## The Benefits of Friendly Competition |
| 44 | + |
| 45 | +If you have a large enough team, consider developing competing implementations |
| 46 | +of certain features or systems. This can be an effective way to explore |
| 47 | +different solutions and spark innovation. You can then choose the best elements |
| 48 | +from each, or select the most efficient solution overall. |
| 49 | + |
| 50 | +## Embrace Imperfections: Sensor Noise |
| 51 | + |
| 52 | +It's crucial to remember that real-world data is often noisy and imperfect. |
| 53 | +Your sensors may pick up interference, or there could be slight variations in |
| 54 | +readings. Your code should be robust enough to handle this noise and still make |
| 55 | +effective decisions. Techniques such as sensor fusion or filtering (like |
| 56 | +taking an average of multiple readings) can be highly beneficial here. |
| 57 | + |
| 58 | +## The Power of Documentation |
| 59 | + |
| 60 | +Our [Docs](https://studentrobotics.org/docs) are a goldmine of knowledge and |
| 61 | +should be your first port of call whenever you're unsure about something. Much |
| 62 | +like a good textbook or reference guide, our Docs are designed to support you in |
| 63 | +understanding your robot better. From getting started with your robot kit, to |
| 64 | +understanding the APIs, to troubleshooting common issues; the Docs cover a broad |
| 65 | +spectrum of topics you may encounter. |
| 66 | + |
| 67 | +<br/> |
| 68 | + |
| 69 | +Coding your robot can be a challenging yet rewarding experience. It's where the |
| 70 | +magic happens, where the inert pieces of metal, wood, and circuitry come to life |
| 71 | +and engage with the world. We hope these tips and strategies will help you avoid |
| 72 | +common pitfalls and pave the way for your success in the Student Robotics |
| 73 | +competition. Remember, every stumble is an opportunity to learn and improve. |
| 74 | +Keep coding, keep testing, and most importantly, have fun! |
0 commit comments