Author:Alex Cater Email:cater@unlv.nevada.edu
Keywords:Furo, programming, C++, Structure
The project files are zipped here:
furomotion_v3.zip
Note: These files may be updated and changed in the future. If changed please attach the updated files here as a .zip file.
This tutorial's motivation is to teach students/researchers the basic programming structure behind Furo so that they can successful navigate, adjust, implement and manipulate the code that controls it. After viewing the tutorial is it hoped that the reader will fully grasp the concepts behind how Furo is programmed and can successfully navigate the code to pinpoint each pieces primary function. It is expected that the reader is proficient in a Windows environment, knows the basics of C++ programming (although programming knowledge in general may be sufficient), and has some familiarity with programming IDEs.
1) Qt creator version 5.4 or higher - https://www.qt.io/ide/
2) Experience or familiarity of the C++ programming language
3) Experience within a Qt environment is not required but is recommended.
4) The Furo service robot.
Note: This is a general structure for Furo's programming. The project files may be updated in the future to include different header and .cpp files or have some removed. This version was ran on Qt 5.4 on Furo's Windows 7 32-bit Embedded boot (Furo is dual booted with Windows 32-bit Embedded and Ubuntu 32-bit).
Open the Qt project for Furo and on the left hand side you will have a menu like the one above which has all the files that are included in the project. The files we will go in depth with in this tutorial are the main, mainwindow, FuroRobot, FuroMotorController cpp files and header files along with the .pro file and the forms file. Others can be explored but will not be covered in this tutorial as they do not provide significant function.
Below is a structural flow diagram that shows how the entire project works together.
First, let's take a look at the outer box which is our .pro file. This file ties all of our other files together and includes all the external libraries used (OpenCV for example). This file contains all of our header, source, and forms files and has the all paths and libraries listed for our external libraries. If anything is not included then our project will not build. Note: after making ANY changes in the .pro file you MUST run qmake before trying to build in order to update the project. Qmake is found under the build tab.
Next, the main file. This file is rather simple since all it does is call upon the QApplication function and display our mainwindow (GUI). Other functions, calculations, and tasks can be included in the main file but for our purposes this is all that we need. The rest of our programming is included in the mainwindow and FuroRobot files.
Moving forward brings us to the mainwindow file. Notice it works hand in hand with the our form file (mainwindow.ui) which defines all of our push buttons in the GUI. Clicking on the mainwindow.ui file will allow us to graphically edit our GUI. We can drag and drop pushbottons, dialog button boxes, tool buttons, create tables, scroll areas etc. to create a GUI that fits our needs. For Furo I have defined a few pushbottons that include some functions or tasks (line following or object detection for example). After editing our form file you will need to include these in our mainwindow header/source files as functions. Note: As Furo's project becomes larger and more in-depth it may be necessary to create another source/header file that contains specific functions. Mainwindow can hold the push button functions while the other functions that these push button function call are included in a separate source file. This will help keep the mainwindow file from becoming overcrowded and keep better orginization.
Next, the FuroRobot source file. If at any point the mainwindow functions need to directly interact with Furo they will need to be passed through to functions in the FuroRobot source file. These interactions are generally communications with the motors to make Furo move. The functions from mainwindow will call on the Furo object and pass parameters to it's functions to make it do what we need to do. The most common function in the FuroRobot file is the update() function which has a velocity (float value) for each wheel passed. The velocity will be calculated into RPMs and then sent to the DriveWheel function in FuroMotorController to be sent through the serial COM port (COM3 in windows) to the motors. Other functions include RotateZ and TranslateX which are used to pivot and move forward/backward Furo for the Up,Down,Left and Right push buttons.
Finally, the FuroMotorController. This source file contains all the necessary information to communicate with Furo through the COM ports. The header file has all the protocol definitions declared and the source file contains all functions to initialize, close, read and write to the serial port. The FuroRobot source file functions will generally call to the DriveWheel function in FuroMotorController which will send the values serially through the COM ports to the motors. It would be a good idea to familiarize yourself with the protocol used in case you need to write your own communication to Furo.
This tutorial discussed the overall structure of Furo's project files using the Qt creator IDE. It showed which source files interact with other source files and what type of functions they contain as well. Future tutorials will go over the coding functions in greater detail (such as line following and object tracking) and will discuss the algorithms, functions, libraries, capabilities and improvements needed for each.