ERSP Templates

From ImageWiki

(Difference between revisions)
Jump to: navigation, search
m (ERSP skabeloner moved to ERSP Templates: Moving to english)
Line 1: Line 1:
-
ERSP have en projektskabelon at arbejde udfra. , .
+
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 ==
== ERSP ==
-
I Robot Eksperimentarums [[Robot_Eksperimentarium_2006#The_SVN_Repository|SVN]] findes (under ''Examples/ERSP/skabelon/'') en simpel skabelon til projekter der udelukkende benytter ERSP. Hvis OpenCV .
+
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.
-
''skabelon.cc'' og ''Makefile''. Makefile'EXECUTABLE' og 'SOURCES' .
+
The template consist of two files ''skabelon.cc'' and ''Makefile''. To adopt ''Makefile'' simply change 'EXECUTABLE' and 'SOURCES' to match your project.
-
''skabelon.cc'' inkluderer de mest relevante header
+
''skabelon.cc'' includes the most often used header files and contains three functions
-
* '''bool initialize_interfaces().''' Som navnet antyder initialiserer funktionen de interfaces der er relevante for det aktuelle projekt. Det antages at de variable der indeholder handles til de relevante interfaces er globale variable. , main' funktionen. 'true' interfaces blev initialiseret korrekt og 'false' ellers.
+
* '''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 shutdown_interfaces().''' interfaces som 'initialize_interfaces' . Igen returneres 'true' hvis alt gik godt og 'false' ellers.
+
* '''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()'''. Standard 'main' funktion, 0.
+
* '''int main()'''. Just a standard 'main' function, that calls the two other functions and returns 0.
-
== ERSP og OpenCV ==
+
== ERSP and OpenCV ==
-
Hvis ERSP og OpenCV . ''Makefile'' og i hvilke header filer der inkluderes. Robot Eksperimentariums [[Robot_Eksperimentarium_2006#The_SVN_Repository|SVN]] (under ''Examples/ERSP/skabelon_OpenCV/''). problem. OpenCV stiller typen 'uchar' , mens ERSP stiller 'Evolution::uchar' . 'Evolution' namespacet. I praksis betyder dette at du '''ikke''' skal skrive
+
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/''.
-
  using namespace Evolution;    // Skriv ikke denne linie kode!
+
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
-
noget sted i din kode uanset hvor gerne du vil.
+
  using namespace Evolution;    // Do not write this line of code!
 +
anywhere in your code (even if you ''really'' want to).

Revision as of 17:57, 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 the 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 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 the moral is, 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