User Tools

Site Tools


new_podo_al

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
new_podo_al [2018/09/14 14:44]
yuhanghe
new_podo_al [2018/10/25 15:33] (current)
yuhanghe [Create a New AL]
Line 5: Line 5:
 **Email:** <​[email protected]> ​ **Email:** <​[email protected]> ​
 \\ \\
-**Date:** Last modified on <09/14/18>+**Date:** Last modified on <10/25/18>
 \\ \\
 **Keywords:​** Hubo 2, PODO 3, Ubuntu, AL, QT GUI **Keywords:​** Hubo 2, PODO 3, Ubuntu, AL, QT GUI
Line 51: Line 51:
   *This will create a function that is called every time the button is pressed.   *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   *Add header files at the top of GUI dialog.cpp file
- +    ​*''#​include "​CommonHeader.h"''​ 
-  ​*''#​include "​CommonHeader.h"''​ +    *''#​include "​BasicFiles/​PODOALDialog.h"''​
-  *''#​include "​BasicFiles/​PODOALDialog.h"''​+
  
   *Editing the GUI dialog.h file. Found under project PODOGUI/​Headers.   *Editing the GUI dialog.h file. Found under project PODOGUI/​Headers.
- +    ​*''#​include "​CommonHeader.h"''​
-  ​*''#​include "​CommonHeader.h"''​+
  
   *Declaring private objects in the GUI dialog.h file, basic variables for communicating with Al   *Declaring private objects in the GUI dialog.h file, basic variables for communicating with Al
- +    ​*''​private:''​ 
-  ​*''​private:''​ +    *''​LANDialog * lanData; ////​Communication with Daemon''​\\ 
-  *''​LANDialog * lanData; ////​Communication with Daemon''​\\ +    *''​int AlnumXXXX; //// Choose the name of AL you want to use or create''​\\ 
-  *''​int AlnumXXXX; //// Choose the name of AL you want to use or create''​\\ +    *''​int AlnumOmniWheel;​ //For example''​ 
-  *''​int AlnumOmniWheel;​ //For example''​ +    *''​int AlnumWalkReady;​ //or this''​
-  *''​int AlnumWalkReady;​ //or this''​+
  
 ===== Create New AL ===== ===== 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.''​
 +{{ :​yuhang:​hubo2:​screenshot_from_2018-06-29_13-55-42.png |}}
 +  *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.
 +{{ :​yuhang:​hubo2:​screenshot_from_2018-06-29_14-15-46.png |}}
 +  *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.
 +{{ :​yuhang:​hubo2:​screenshot_from_2018-07-02_13-38-00.png |}}
 +  *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.
 +{{ :​yuhang:​hubo2:​screenshot_from_2018-07-02_13-37-48.png |}}
   ​   ​
 ===== Edit GUI Code ===== ===== 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.
 +{{ :​yuhang:​hubo2:​screenshot_from_2018-07-02_14-29-08.png |}}
 +  *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.''​
 +{{ :​yuhang:​hubo2:​screenshot_from_2018-07-02_14-47-27.png |}}
 +
 +  *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;​
 +{{ :​yuhang:​hubo2:​screenshot_from_2018-07-02_15-06-19.png |}}
 +  *Modify GUIMainWindow.cpp
 +    *''​Declare [new AL]dialog object = new Classname(this);''​
 +    *''​ui->​ MAIN_TAB->​ addTab ((Qwidget *) declared dialog, "​TABNAME"​);''​
 +{{ :​yuhang:​hubo2:​screenshot_from_2018-07-02_15-09-41.png |}}
 +  *Rebuild.
  
 ===== Modify DB File ===== ===== 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. 
 +{{ :​yuhang:​hubo2:​screenshot_from_2018-07-02_15-45-15.png |}} 
 +  *Under Core_Config -> Tables -> double click AL. 
 +{{ :​yuhang:​hubo2:​screenshot_from_2018-07-02_15-45-46.png |}} 
 +  *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. 
 +{{ :​yuhang:​hubo2:​screenshot_from_2018-07-02_15-46-11.png |}} 
 +  *Double click on General table -> Data tab -> change the No. of PODO AL'. 
 +{{ :​yuhang:​hubo2:​screenshot_from_2018-07-02_15-57-07.png |}} 
 +  *Open PODO_DRC/​share/​Headers/​RBSharedMemory.h and fix MAX_AL if necessary.
  
 ===== Final Words ===== ===== Final Words =====
  
-The purpose of this tutorial was to guide reader through the process of installing Ubuntu and set up Xenomai environment in preparation for working with Hubo 2. 
-\\ \\  
 For questions and comments, email <​[email protected]>​ For questions and comments, email <​[email protected]>​
  
  
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
-Creating a new AL 
-The necessary files for this tutorial can be found in the Github repository. There are three components for creating a new AL in PODO. 
- 
-UI Creation 
-AL Program Creation 
-DB File Modification 
-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 
-Creating a 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. 
-Screenshot from 2018-06-29 13-39-20.png 
-Choose a Form Template -> Dialog without Buttons. Set the class name to be related to the AL to be created. 
-Screenshot from 2018-06-29 13-42-06.png 
-Create one test button by dragging the Push Button on the left panel onto GUI. 
-Screenshot from 2018-06-29 13-43-08.png 
-. Change text on the button by double clicking. 
-Right click on button -> go to slot -> clicked(). 
-Screenshot from 2018-06-29 13-43-47.png 
-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 
-Creating New AL 
-Right click on ALPrograms project -> New Subproject. 
-In New Subproject -> Application -> Select Qt Console Application. 
-Screenshot from 2018-06-29 13-55-42.png 
-Name the project similar to the GUI project name you created earlier. 
-Using Files Navigator, go to the file downloaded through GitHub, 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. 
-Screenshot from 2018-06-29 14-15-46.png 
-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. 
-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. 
-Screenshot from 2018-07-02 13-38-00.png 
-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. 
-Screenshot from 2018-07-02 13-37-48.png 
-Editing 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. 
-Screenshot from 2018-07-02 14-29-08.png 
-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. 
-Screenshot from 2018-07-02 14-47-27.png 
-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;​ 
-Screenshot from 2018-07-02 15-06-19.png 
-Modify GUIMainWindow.cpp 
-Declare [new AL]dialog object = new Classname(this);​ 
-ui-> MAIN_TAB->​ addTab ((Qwidget *) declared dialog, "​TABNAME"​);​ 
-Screenshot from 2018-07-02 15-09-41.png 
-Rebuild. 
-Modifying the 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 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. 
-Screenshot from 2018-07-02 15-45-15.png 
-Under Core_Config -> Tables -> double click AL. 
-Screenshot from 2018-07-02 15-45-46.png 
-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. 
-Screenshot from 2018-07-02 15-46-11.png 
-Double click on General table -> Data tab -> change the No. of PODO AL'. 
-Screenshot from 2018-07-02 15-57-07.png 
-Open PODO_DRC/​share/​Headers/​RBSharedMemory.h and fix MAX_AL if necessary. 
new_podo_al.1536961445.txt.gz · Last modified: 2018/09/14 14:44 by yuhanghe