MicroFOBO/Spring/2020

Spring 2020: MicroFOBO Gen 4 Software

Author: Hien Nguyen (System/ Software Engineer)
Approval: Dakarai Scott (Project Manager)

Table of Contents

Introduction

Initially, we picked up over what was left of MicroFOBO gen 3. However, we encountered various hardware and software problems with little documentations on troubleshooting from previous generation. As such, we decided to start the software from scratch. MicroFOBO is based on Project Biped’s FOBO so you can go to their website here for reference.

MicroFOBO can be first setup with an Arduino UNO to make calibrations, adjustments and actions. After these initial setups, MicroFOBO can be implemented using a 3DoT board using a different “ServoShield.h” which is a modified version of the original .h file found on the Project Biped website. All of these materials can be found on the Project Biped website and our Google Drive folder. If you run to any problems during any of the steps, you can refer to the troubleshooting and known problems section at the end to find some potential fixes.

Initial software setup with Arduino UNO:

Before assembly, it is highly recommended that a code call “Servo_Centering” from the Project Biped website should be uploaded to the Arduino UNO. You will also be required to install the original ServoShield.h from this website for this code to work. This code will bring all servos to their respective 60-degree angles which will give them the most degree of freedom to move around as MicroFOBO execute an action. In addition, you can also use this code to test all 8 servos if the circuit is setup right. The angles might be a little off but as long as MicroFOBO is standing, it’s okay. These angles will be rectified again using software.

After making sure that all the servos are working and in the right places, you can begin to put MicroFOBO together. Project Biped has an awesome guide to set this up here [LINK]. You can repeat this step to make sure that MicroFOBO is standing up straight after the “Servo_Centering” code is uploaded.

This code can also be uploaded to the 3dot so when setting up MicroFOBO with the 3dot board, you can do this step again.

Setting up FOBO Poser Program:

This step can ONLY be done with an Arduino UNO board! This is because the way FOBOPoser is written by Johnathan Dowdall from the Project Biped website such that it can be only connected to an Arduino UNO board.

From the Project Biped website, you can find another piece of code called “Remote_Control”. When uploaded to the Arduino UNO, this code will allow MicroFOBO to receive serial data from the FOBOPoser program. After the code is uploaded, make sure that the serial monitor on Arduino IDE is off and open up FOBOPoser to connect it to the Arduino board.

Refer to “Help” and “About” tabs on the top left of the program to get additional instructions to use this program.

Figure 1. Connecting MicroFOBO to FOBOPoser

As seen in the figure above, press the RED box to connect MicroFOBO to the program. On the right, you should be able to select the right port that the Arduino is connected to. You can also check Arduino IDE to the port that is it connected to. The button will

Using FOBO Poser Program:

There are a number of operations this program is capable of: setting up calibration file, creating new actions, using preexisting actions, exporting action files into Arduino code.

  1. Setting up calibration file:

As mentioned above, calibrating MicroFOBO manually will never give the most degree of precision. This is why FOBO Poser program comes into the picture which accuracy up to 0.1 degrees. After MicroFOBO is connected to Poser, press the “Move Servos to Home Positions” button.

Figure 2. Home positions.

This will move all servos to their respective home position at 60 degrees. However, because MicroFOBO is not perfectly calibrated, the angles will seem a little off. Select “Add Action” and name this new action “Calibration”. Then, move each servo using the right and left leg servos control panel as seen in the green boxes such that MicroFOBO is perfectly calibrated. Note that these angles might be vary for different setups of MicroFOBO. Select “Add Frame” and “Save Action” as a calibration file.

Figure 3. Setting up calibration file.

Finally, select “Set Calibration File” on the top right of the program to get MicroFOBO calibrated. These offset angles will be automatically applied to the controls and “Home Position” will always set MicroFOBO stand up straight.

2. Creating new actions:

New actions can be created by selecting “Add Action” button. The servos can then be moved around as seen in the green boxes and added as “frames” at the bottom controls. “Move to Frames” can be used to better visualize the actions on MicroFOBO and make any necessary adjustments to the angles of each frame for each individual servo. After creating the action, the action can then be saved as an ACTION file by selecting “Save Action” at the bottom left of the program. Note that you can change the frame delay to better fit your custom action.

Figure 4. Creating new actions.

3. Loading preexisting actions:

To load custom created actions or preexisting actions from the Project Biped website, simply click on “Load Action” at the bottom left of the program and locate the desired ACTION files.

Figure 5. Using saved or downloaded actions.

4. Exporting actions files into Arduino code:

After ACTIONS files are loaded into the program, pressing the “Export Action to Arduino” will generate a simple action code in Arduino IDE. This code can be uploaded directly onto the Arduino UNO and MicroFOBO will execute the according action in loops.

Figure 6. An example of the action frames in Arduino code.

Above is an example of a walk action sequence in a 10×8 matrix. There are 10 frames in this action and 8 values for each servo. The calibration[8] matrix is the calibration offsets set after selecting “Set Calibration File” in the FOBOPoser program.

Figure 7. Declaring action class in Arduino code.

The above figure shows how an action is defined with “myAction([number of key frames],[ total executed frames], [frame delay], [name of action matrix])”.

Integration into the 3dot board

To integrate project biped work into MicroFOBO gen 4, we used a modified version of the “Servo_Shield.h” from previous generations. This is because the original “Servo_Shield.h” is designed to work with an Arduino UNO which uses a Microchip ATmega328P. However, MicroFOBO is set to use the 3dot board which is similar to a Arduino Leonardo with an ATmega32u4. As such, there has to be some modifications with the “Servo_Shield.h” which is written in C#. This modified version of “Servo_Shield.h” can be found in our Google Drive and previous generations of MicroFOBO as well. 

The most important function for the 3dot implementation is the “UpdateAction()” from Project Biped. This function is responsible for the logic behind MicroFOBO’s operation. Below is an example of a remote control “UpdateAction()” we used for our V2 demo:

Fig 7. An example of UpdateAction()

Fig 8. An example of moveHandler() 

As seen in the figure above, “UpdateAction()” will determine the currentAction for MicroFOBO according to the values of “stateActive” variable. The value of this variable is determined through another function call “moveHandler()” from the ArxRobot library in fig 8. which decodes the values of param[0] and param[2] sent from the Arxrobot Bluetooth App. You can find very useful examples of Bluetooth RC for the App with this link.

It is highly recommended that you should use as many Serial.println() as possible to test out what is being sent to MicroFOBO.

Troubleshooting/ known issues:

– The project biped code for remote control, it gives an error at “Serial.print(128, BYTE); “ –> just delete BYTE or change it to DEC. The reason for this is that this data type is no longer supported by arduino.

– There is an error in the library for “WProgram.h” when trying compile the codes from Project Biped —> go to the servoshield library and change “WProgram.h” line into “Arduino.h”

in the cpp and h file of the library.

– Read the instruction about the Poser app very carefully.

– On first open, Poser will not show up until the USB port is disconnected from the pc BUT it still occupies the same COM port which prevents MicroFOBO from sending any data to PC. Any subsequent opening of FOBOPoser will also not work due to this. —> just open Poser once. when it does not show up, disconnect usb and reconnect it. The actual Poser will show up. Then, follow the instruction on project biped to establish connection.

– We ran into a problem with the 3dot not compiling with “Board 3DoT-legacy (platform avr, package 3DoT) is unknown” error message. This happened because there was an error with installing the 3dot. To fix this, we had to reinstall the 3dot clean by locating a folder called “Arduino15” located in the %appdata% folder and delete it. Then, we followed the instruction to install the 3dot again on the Arxterra website.

– We also identified a problem with the power supply for the CD4017. In the original design of the servo shield, the CD4017 shares the same power line with 8 servos. For the CD4017 to work properly, constant voltage is required, which means the original set up requires a very good power supply. If small batteries with no capacitors, the overall voltage will fluctuate as all 8 servos draw large current from the batteries at the same time. As a result, the CD4017 will not work as intended and all 8 servos will receive signals with A LOT of noise. When this happens MicroFOBO will be have a series of spasm and will not response correctly to any action matrix or FOBOPoser. As such, I made a suggestion to Jeffrey, our Electrical Engineer, to improve the servo shield design by having the CD4017 taking power directly from the 3Dot board and all 8 servos taking power from a different power source. This will be explained in detail in his shield design blogpost.

Conclusion

Overall, the software of MicroFOBO for this generation is quite successful. Further details about V2 and V3 code can be found in our final blogpost. Due to the COVID-19 situation, we were not able to test some of our new hardware implementations like the Lidar Scan module. There can always be room for improvements for future iterations of MicroFOBO. For example, an new function can be implemented to smoothen the transition between the actions or more/ better logic can be applied to get MicroFOBO complete the current action, which ever is more applicable to future implementations.

References/Resources