ERSP Templates

From ImageWiki

Jump to: navigation, search

The first time you work with ERSP it can be helpful to have a project template. Once you're used to working with ERSP, you'll probably stop using these templates, but at first they are helpful.


In the "Robot Eksperimentarum" SVN repository (under Examples/ERSP/skabelon/) you'll find a simple project template that only uses ERSP. If you're also using OpenCV you should see the next section of this page. The template consist of two files and Makefile. To adopt Makefile simply change 'EXECUTABLE' and 'SOURCES' to match your project. includes the most often used header files and contains three functions

  • bool initialize_interfaces(). As the name implies the function initializes the robot interfaces that are relevant to the project. It is assumed that the variables containing the interface handles are global. It is often said that global variables are bad, but the initialization code is usually so ugly that you want it out of your main function. The function should return true if the needed interfaces was succesfully initialized and false otherwise.
  • bool shutdown_interfaces(). This function should simply close the interfaces that were opened by initialize_interfaces. This function should also return true if the interfaces were handled succesfully, and false otherwise.
  • int main(). Just a standard 'main' function, that calls the two other functions and returns 0.

ERSP and OpenCV

If ERSP and OpenCV are used at the same time the template above only needs small changes. Basicly the Makefile needs a small change, and some more header files need including. A template that does this can be found in the "Robot Eksperimentarium" SVN under Examples/ERSP/skabelon_OpenCV/.

When the two software platforms are used together there is one minor problem. OpenCV typedefs uchar type, while ERSP typedefs Evolution::uchar. This means that you shouldn't open the Evolution namespace. So, don't write

using namespace Evolution;     // Do not write this line of code!

anywhere in your code (even if you really want to).

Personal tools