new_podo_al
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
new_podo_al [2018/09/14 14:31] – created yuhanghe | new_podo_al [2018/10/25 15:33] (current) – [Create a New AL] yuhanghe | ||
---|---|---|---|
Line 5: | Line 5: | ||
**Email:** < | **Email:** < | ||
\\ | \\ | ||
- | **Date:** Last modified on <09/14/18> | + | **Date:** Last modified on <10/25/18> |
\\ | \\ | ||
**Keywords: | **Keywords: | ||
Line 42: | Line 42: | ||
*Right click on PODOGUI project -> Add new -> QT -> Click Qt Designer Form Class. | *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 | ||
+ | *''# | ||
+ | *''# | ||
+ | |||
+ | *Editing the GUI dialog.h file. Found under project PODOGUI/ | ||
+ | *''# | ||
+ | |||
+ | *Declaring private objects in the GUI dialog.h file, basic variables for communicating with Al | ||
+ | *'' | ||
+ | *'' | ||
+ | *'' | ||
+ | *'' | ||
+ | *'' | ||
===== Create New AL ===== | ===== Create New AL ===== | ||
+ | This section will demonstrate how to create a new AL for PODO. | ||
+ | *Within QT Creator, '' | ||
+ | *In New Project window '' | ||
+ | {{ : | ||
+ | *Name the project similar to the GUI project name you created earlier. | ||
+ | *Using Files Navigator, go to the file '' | ||
+ | *Open the ALTutorial/ | ||
+ | *Right click on the new AL project created in '' | ||
+ | {{ : | ||
+ | *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 '' | ||
+ | *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. | ||
+ | *'' | ||
+ | *'' | ||
+ | *'' | ||
+ | *'' | ||
+ | *'' | ||
+ | |||
+ | *Return to new AL/main.cpp and delete or comment out the FingerControl function on line 25. | ||
+ | *'' | ||
+ | *'' | ||
+ | *From line 64::70 delete or comment out the switch case TUTORIAL_FINGER_CONTROL. | ||
+ | *Finally, imported the RBTaskThread and RBFlagThread functions from ALTutorial/ | ||
+ | *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 ===== | ===== 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, | ||
+ | *AlnumXXXX = PODOALDialog :: GetALNumFromFileName (" | ||
+ | *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: | ||
+ | *'' | ||
+ | *Inside the UI constructor: | ||
+ | *'' | ||
+ | *'' | ||
+ | *'' | ||
+ | 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: | ||
+ | *'' | ||
+ | *'' | ||
+ | *'' | ||
+ | *'' | ||
+ | *Edit GUIMainWindow.h | ||
+ | *#include "your own gui header file" | ||
+ | *Declare a Gui object | ||
+ | *ex) TestDialog *dialogTest; | ||
+ | {{ : | ||
+ | *Modify GUIMainWindow.cpp | ||
+ | *'' | ||
+ | *'' | ||
+ | {{ : | ||
+ | *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, | ||
+ | *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/ | ||
===== 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 < | For questions and comments, email < | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | 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 " | ||
- | #include " | ||
- | Editing the GUI dialog.h file. Found under project PODOGUI/ | ||
- | #include " | ||
- | Declaring private objects in the GUI dialog.h file, basic variables for communicating with Al | ||
- | private: | ||
- | LANDialog * lanData; // | ||
- | int AlnumXXXX; // Choose the name of AL you want to use or create | ||
- | int AlnumOmniWheel; | ||
- | int AlnumWalkReady; | ||
- | 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/ | ||
- | Open the ALTutorial/ | ||
- | 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 = ../ | ||
- | } else { | ||
- | DESTDIR = ../ | ||
- | } | ||
- | 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, | ||
- | From line 64::70 delete or comment out the switch case TUTORIAL_FINGER_CONTROL. | ||
- | Finally, imported the RBTaskThread and RBFlagThread functions from ALTutorial/ | ||
- | 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, | ||
- | AlnumXXXX = PODOALDialog :: GetALNumFromFileName (" | ||
- | 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, | ||
- | displayTimer-> | ||
- | 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-> | ||
- | 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, | ||
- | 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/ |
new_podo_al.txt · Last modified: 2018/10/25 15:33 by yuhanghe