ERSP Templates

From ImageWiki

(Difference between revisions)
Jump to: navigation, search
Line 2: Line 2:
== ERSP ==
== ERSP ==
-
In the "Robot Eksperimentarum" [[Robot_Eksperimentarium_2006#The_SVN_Repository|SVN repository]] (under ''Examples/ERSP/skabelon/'') you'll find a simple project template the only uses ERSP. If you're also using OpenCV you should see the nect section of this page.
+
In the "Robot Eksperimentarum" [[Robot_Eksperimentarium_2006#The_SVN_Repository|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 nect section of this page.
The template consist of two files ''skabelon.cc'' and ''Makefile''. To adopt ''Makefile'' simply change 'EXECUTABLE' and 'SOURCES' to match your project.
The template consist of two files ''skabelon.cc'' and ''Makefile''. To adopt ''Makefile'' simply change 'EXECUTABLE' and 'SOURCES' to match your project.
''skabelon.cc'' includes the most often used header files and contains three functions
''skabelon.cc'' 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 want it out of your main function. The function should return ''true'' if the needed interfaces was succesfully initialized and ''false'' otherwise.
+
* '''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.
* '''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.
* '''int main()'''. Just a standard 'main' function, that calls the two other functions and returns 0.
Line 12: Line 12:
== ERSP and OpenCV ==
== 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" [[Robot_Eksperimentarium_2006#The_SVN_Repository|SVN]] under ''Examples/ERSP/skabelon_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" [[Robot_Eksperimentarium_2006#The_SVN_Repository|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 the moral is, '''don't''' write
+
 
 +
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!
  using namespace Evolution;    // Do not write this line of code!
anywhere in your code (even if you ''really'' want to).
anywhere in your code (even if you ''really'' want to).

Revision as of 18:00, 8 August 2006

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.

ERSP

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 nect section of this page. The template consist of two files skabelon.cc and Makefile. To adopt Makefile simply change 'EXECUTABLE' and 'SOURCES' to match your project.

skabelon.cc 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