User Tools

Site Tools


new_podo_al

This is an old revision of the document!


Create a New AL

Author: Yu Hang He
Email: hey6@unlv.nevada.edu
Date: Last modified on <09/14/18>
Keywords: Hubo 2, PODO 3, Ubuntu, AL, QT GUI

Motivation and Audience

The tutorial serves as a guide for creating a new AL in PODO system. The tutorial will cover how to create a new GUI in QT program, creating a new AL in PODO, and modifying AL DB file. Contact the author for necessary files. The steps for creating a new AL is as follows:

  • Creating a main GUI
  • Creating AL program
  • Create basic program structure
  • Add communication functions
  • Implement GUI communication function
  • Adding AL program to Daemon
  • DB file modification

Author of this tutorial assumes the reader has the following background and interests:

* Familiar with programming process
* Interested in creating GUI with QT IDE
* Interested in working with Jaemi-Hubo and other Hubo robots


The rest of this tutorial is presented as follows:

Create GUI in QT

This section will demonstrate how to create a GUI file for PODOGUI in QT Creator.

  • Open the PODOGUI and ALPrograms project in QT Creator. Both are located under src/ folder of repository.
  • Right click on PODOGUI project → Add new → QT → Click Qt Designer Form Class.

  • Choose a Form Template → Dialog without Buttons. Set the class name to be related to the AL to be created.

  • Create one test button by dragging the Push Button on the left panel onto GUI.

  • Change text on the button by double clicking.
  • Right click on button → go to slot → clicked().

  • This will create a function that is called every time the button is pressed.
  • Add header files at the top of GUI dialog.cpp file
    • #include “CommonHeader.h”
    • #include “BasicFiles/PODOALDialog.h”
  • Editing the GUI dialog.h file. Found under project PODOGUI/Headers.
    • #include “CommonHeader.h”
  • Declaring private objects in the GUI dialog.h file, basic variables for communicating with Al
    • private:
    • LANDialog * lanData; Communication with Daemon
    • int AlnumXXXX; Choose the name of AL you want to use or create
    • int AlnumOmniWheel; For example *int AlnumWalkReady; or this

Create New AL

This section will demonstrate how to create a new AL for PODO.

  • Within QT Creator, right click on ALPrograms → project → New Subproject.
  • In New Project window → Application → Select Qt Console Application.

  • Name the project similar to the GUI project name you created earlier.
  • Using Files Navigator, go to the file PODO/DRC_HUBO/PODO_DRC/src/ALPrograms/ALTutorial and Copy the BasicFiles folder into the folder of new AL that was created.
  • Open the ALTutorial/main.cpp and copy the content of Line 1::80 into main.cpp of the new AL. Overwrite the Existing content.
  • Right click on the new AL project created in QT → Add Existing Directory. In the new window click → Browse → Click on BasicFIles folder that was copied into the new AL project folder.

  • Trying building the project. Ignore the error for now.
  • Next, modify the project management file. QT's project management is implemented with an extension file called [project name].pro.
  • Copy the content of the ALTutorial.pro file in ALTutorial project folder and overwrite the contents of [new AL name].pro.
  • Modify the .pro file by insert the following codes between CONFIG setting and QMAKE setting.
    • CONFIG (debug, debug | release) {
    • DESTDIR = ../PODO_PROC_Build
    • } else {
    • DESTDIR = ../PODO_PROC_Build
    • }
  • Return to new AL/main.cpp and delete or comment out the FingerControl function on line 25.
  • Important!Modify line 38 with name of new AL. The name must be unique and matches the name that will be add to the DB file later.
    • sprintf(__AL_NAME, “ALTutorial”);
  • From line 64::70 delete or comment out the switch case TUTORIAL_FINGER_CONTROL.
  • Finally, imported the RBTaskThread and RBFlagThread functions from ALTutorial/main.cpp by copy and paste.
  • Before Rebuilding, open Projects tab and configure the build directory.
  • Right click on project → Run qmake.
  • Right click on project again → Rebuild.
  • Change enum TUTORIAL_COMMAND at the top of Main.cpp
  • Note: Always set NO_ACT at the beginning and set the initial value to 100.
  • The naming convention is to use AL name_COMMAND for command and AL name_function for function.

  • Change the enum name used in the switch-case statement in the main statement, just as you did in Enum.
  • It is more convenient and clear to use an enum than to declare a number like 999.

Edit GUI Code

  • Copy the [AL]_COMMAND enum created in AL to the top of [GUI]dialog.cpp.
  • Assigning the value of AlnumXXXX (AL used or new AL created):
    • Inside the [AL]dialog.cpp UI constructor, after ui→setupUi(this);
    • AlnumXXXX = PODOALDialog :: GetALNumFromFileName (“ALFILENAME”);Write the correct AL file name
    • For the new AL created, input the AL name you picked.

  • Use Qtimer if you want to display variables in the GUI.
  • Declare a Qtimer variable in [new AL]dialog.h:
    • under private:
    • QTimer *displayTimer;
  • Inside the UI constructor:
    • displayTimer = new QTimer(this);
    • connect(displayTimer, SIGNAL(timeout()), this, SLOT(DisplayUpdate())); function inside SLOT() will be updated according to the interval set
    • displayTimer→start(50); set the time interval (50 ms) for the function inside SLOT() to be updated Create a DisplayUpdate() function to update the variables on GUI.

  • Add the following code inside the event function that occurs when the button is clicked:
    • USER_COMMAND cmd;
    • cmd.COMMAND_DATA.USER_COMMAND = (Enter one of the variables declared in the enum);
    • cmd.COMMAND_TARGET = (variable with name of AL to use ex) AlnumManualMove);
    • pLAN→ SendCommand (cmd);
  • Edit GUIMainWindow.h
    • #include “your own gui header file”
    • Declare a Gui object
    • ex) TestDialog *dialogTest;

  • Modify GUIMainWindow.cpp
    • Declare [new AL]dialog object = new Classname(this);
    • ui→ MAIN_TAB→ addTab ((Qwidget *) declared dialog, “TABNAME”);

  • Rebuild.

Modify DB File

  • Download SQLiteStudio from its official download site.
  • Extract the compressed file and open sqlitestudio executable inside the folder.
  • The Core_config.db file we will modify is in the /exe folder within the PODO path
  • In SQLiteStudio, click on Database in upper left corner → Add a Database.
  • Navigate to Core_config.db file and open the database.

  • Under Core_Config → Tables → double click AL.

  • Go to Data tab, click green plus button to create a new entry and enter new ALName, FileName, and PathName.
  • click green check button to commit the new changes.

  • Double click on General table → Data tab → change the No. of PODO AL'.

  • Open PODO_DRC/share/Headers/RBSharedMemory.h and fix MAX_AL if necessary.

Final Words

For questions and comments, email hey6@unlv.nevada.edu

new_podo_al.1540506775.txt.gz · Last modified: 2018/10/25 15:32 by yuhanghe