To be able to detect its orientation at all times, there is an accelerometer mounted to the robot’s body. It is mounted with its y-axis in line with gravity when the robot is facing up. As such, when the y-axis of the accelerometer reads 9.8 m/s2, the robot must be facing upright, and every other orientation angle is also directly related to an accelerometer reading by the equation:
Angle = arcsin(yaccel/9.8)*(-180/pi)
With the ability to detect its own orientation, the robot can correct its walk towards whatever heading the user desires. This means the robot can always walk straight in any direction with a control loop, even if the hardware or calibration isn’t perfect.
One of our goals was to have a completely untethered robot. This meant that it had to supply its own power. We were able to accomplish this with a 12V LiPo battery strapped to the belly of the robot. An Arduino Mega runs off of 7 - 12V, while the servos run off 5 - 6.8V. We could safely connect the Arduino to the battery, but 12V directly from the battery would have fried the servos, so we also integrated a power converter between them and the battery. The transformer has variable output voltage, which allowed us to experiment with optimizing the servos’ torque output without putting them in danger of over current.
A switch between the converter and the servos allows for the user to easily pause the robot’s movement.
One more problem we had to solve was that when the battery was disconnected but the Arduino was powered, back-current caused the Arduino to power the servos. To fix this, there is a diode between the converter and the Arduino.
To control our robot remotely we used two DSD Tech HM10 Bluetooth modules. One was wired to secondary sending and receiving serial pins on the Arduino Mega while the other used a micro USB port to connect to a laptop. The two modules were linked when we got them, so when we plugged them in, they connected easily.
Navigating the second serial port was a little more difficult. We could upload code to the Arduino via the primary corded serial port but not over Bluetooth. However, the other serial ports don’t have a convenient serial monitor, so debugging and testing was difficult without anywhere to print values to. Eventually, we linked the two ports in a test program so we could send and receive printed data in the serial monitor while actually using the other Bluetooth serial port to communicate with our robot.