FRC Robot Programming

Introduction

With the help of this book, you will learn to do awesome things with simple code. Who says that building, designing and programming your own robot is not fun? For the newcomers, it’s a heck of fun. It will not be easy. You may even forget the concept of sleeping, but you will see what a real team is and what “the hardest fun you’ll ever have” means.

This book will teach you to program a FRC robot. Some previous programming experience is recommended, but not required.

If you are not familiar with a term on this book, you can always Google it or you can check the Glossary section of this book.

➠ How to use this book

This book will try to explain everything in the simplest terms. If you have a question, you can always use Google before complaining. If that still does not help you, e-mail me or ask your mentors about it.

Do not copy-and-paste

In this book, you will see many exercises containing code. If you really want to learn to code, do not copy-and-paste. Type the code by yourself, manually. If you copy-and-paste these exercises, you will learn nothing from them. The point of these exercises is to train your hands and brain to code.

Pay attention to details

The one skill that separates bad programmers from good programmers is attention to detail. In fact, it's what separates the good from the bad in any profession. You must pay attention to the tiniest details of your work or you will miss important elements of what you create. In programming, this is how you end up with bugs and difficult-to-use systems.

By going through this book, and copying each example exactly. You will be training your brain to focus on the details of what you are doing, as you are doing it. (Shaw)

➠ Safety warnings and some advice

This book is distributed in the hope that it will be useful, but without any warranty. If your robot explodes or becomes the boot loader of Skynet, its not my fault, its yours and yours only.

Terminator

You are responsible if your robot ends like this

While the probability of exploding your robot or creating the next Terminator is highly unlikely. Be very careful when writing and testing your code. You never know when something will fail or when your robot will start acting “crazy” due to a bad circuit or a bug in the code.

Use common sense; do not enable the robot when somebody is working with it. Warn your team when you enable it and disable as soon as you finished using it. If something goes wrong, immediately press the <SPACE> key in your keyboard to stop the robot.

A quick list of tips may help you:

  • Always DOUBLE CHECK YOUR CODE when you are writing a new feature
  • Document your code properly. The art of programming is not writing code that computers understand. Its writing code that humans can read and understand
  • When testing a new feature or removing code, test your code for every change you perform. This will avoid bugs and will help you understand where and why you did something wrong. Fixing a single error is easier than fixing ten errors that are related to each other.
  • DO NOT ENABLE THE ROBOT SOMEBODY IS NEAR ITS OPERATIONAL ZONE.
  • Always have someone near the computer you drive the robot with. He or she must be able to stop the robot as soon as something is about to go wrong. We broke a couple of windows in our school by not doing this.
  • Write your code as simple as possible, this will reduce the chances of unexpected robot errors.
  • Follow the KISS principle (Keep It Simple Stupid). You will thank me for that later.