In this section, we will show how to run the GoPiGo3 BalanceBot, and how to adjust the various constants in the python program that control the balancing algorithm. The GoPiGo3 can be transformed from a car, into a Balancing Raspberry Pi Robot. In this tutorial we walk you through how to setup and run you balancing Raspberry Pi robot.
Before you Begin
You should already have assembled the GoPiGo3 BalanceBot robot; if not, see our directions here.
Running the BalanceBot Program
We will go over running the BalanceBot for the first time.
- Assemble the BalanceBot. Pay special attention to how the sensors are attached: if they are backwards, the BalanceBot will not balance.
- Power up the robot. We recommend using an 8xAA battery pack. If you are using a different power source, you may need to adjust the constants in the program to balance your robot.
- Login to the GoPiGo3 Robot. In this example, we use Raspbian for Robots. Since you will want your BalanceBot to roam free, we recommend connecting your robot to your local WiFi network.
- Find the file. The file is located in
~/Dexter/GoPiGo3/Projects/BalanceBotdirectory. If you can’t find it, do a Git update on the directory:
cd ~/Dexter/GoPiGo3 && sudo git fetch --all
- Run the program:
sudo python BalanceBot.py
- Stand the GoPiGo3 BalanceBot upright. With the program running, the robot should almost balance on its own.
- Press the OK button. You will be Prompted to press the OK button on your IR remote. Once you press the button you should feel the robot begin to balance on its own.
- Drive Around! You can now use the Up, Down, Left, and Right buttons on the IR Remote to move the robot around.
- It fell! No problem. You should be able to stand it back up, bring it to balanced, and press the OK button again. You robot will keep going!
Understanding the K-Constants
A balanced robot relies on the constants in the PID control algorithm. These constants work for a certain environment: the size of the wheels, the weight of the battery pack, the surface that your BalanceBot is working on. If you scroll through the BalanceBot.py program, stop at lines 50-70.
The balance behavior of the balancing Raspberry Pi Robot will be most significantly affected by KGYROANGLE and KGYROSPEED. If you feel you need to change the constants because your robot is not balancing or having trouble, start with these constants and adjust.
Most Important PID Constants:
Other PID Constants:
KSPEED – How much the current motor speed effects the motor power.