-
Notifications
You must be signed in to change notification settings - Fork 1
Create a Module
This is a short tutorial on how to create a new Cognition module in the NaoTH project.
Note: the best way to create a new module is to cope an existing one and to clean out everything you don't need.
Open the directory NaoTHSoccer/Source/Core/Cognition/Modules
and choose the cathegory for your new module, e.g., Experiment
. Create a new directory with the name of your new module, e.g., NaoTHSoccer/Source/Core/Cognition/Modules/Experiment/MyModule
. Within this new directory create two new files MyModule.h
and MyModule.cpp
with the following content:
/**
* @file MyModule.h
*/
#ifndef _MyModule_H
#define _MyModule_H
#include <ModuleFramework/Module.h>
#include <Representations/Infrastructure/FrameInfo.h>
BEGIN_DECLARE_MODULE(MyModule)
REQUIRE(FrameInfo)
END_DECLARE_MODULE(MyModule)
class MyModule: public MyModuleBase
{
public:
MyModule();
~MyModule();
virtual void execute();
};
#endif /* _MyModule_H */
/**
* @file MyModule.cpp
*/
#include "MyModule.h"
MyModule::MyModule()
{
// initialize some stuff here
}
MyModule::~MyModule()
{
// clean some stuff here
}
void MyModule::execute()
{
// do some stuff here
}
Open the file NaoTHSoccer/Source/Core/Cognition/Cognition.cpp
. Include the header of your module, e.g.,
#include "Modules/Experiment/MyModule/MyModule.h"
Register your module by adding the following line in the init
method
REGISTER_MODULE(MyModule);
Note: the order of the registration defines the order of the execution of the modules. Make sure your module is executed in the correct order.
Also, don't forget to enable your module in the config (modulename=true
in modules.cfg
).
Close your IDE and regenerate the project files as described in Generate Project Files.