A basic usage of the MIP plugins is that one of a developer that wants to use a MIP standard functionality with its own mobile robot. In this case, the developer will only need to develop a Resource derived from the generic MobileRob resource and the appropriate configfiles. In example, if a developer need a simple joystick for its custom mobile (say MyMobileRobot) he will need to define a MyMobileRobot derived from the class MobileRob and then use it in a configfile launching the KhbHitTask and the JoystickTask.
If a developer wants to develop his own task, he is free to do it as long as his task is derived from the MipTasks::Task class.
The definition of custom algorithms and baselib is instead completely open and does not require any feature. This because a developer will use its own baselib and algorithms only in its resources and tasks, hence not impacting the main functionalities of MIP.
Now, we will give a step-by-step guide to build a MIP plugin. MIP offers a semi-automated way to build your plugins. Although the creation of a custom plugin can be done manually, to follow this procedure. This will create more MIP-like plugins and will be usefull to avoid annoying bugs and linking problems.
$ cd $MIP_ROOT/PluginExample/ $ ./MIPCreatePlugin.sh MY_PLUGIN MY_PLUGIN_PATH
where MY_PLUGIN is the name of the plugin and MY_PLUGIN_PATH is a valid path in which you want to put your plugin.
Now that your plugin has been built, go and check it:
$ cd MY_PLUGIN_PATH/MY_PLUGIN/ $ ls ./*
from the ls command you should get something like:
./CMakeLists.txt ./MIPCreate.sh ./MIPRegisterPlugin.sh ./algorithms: ./baselib: ./build: MIPPluginManifest.MIP ./buildFiles: CMakeMIPUtils.cmake ./configFiles: ./resources: ./tasks: ./tests: CMakeLists.txt
This means that in your MY_PLUGIN there are:
To get your plugin registered in MIP execute:
MIPPluginsProfile
Now, you need to start populating your plugin with the resources, tasks and tests you need. MIP offers a simple way to do this through the MIPCreate.sh script.
$ ./MIPCreate.sh resource MyResource
this command will create two files in ./resources/ called MyResource.h and MyResource.cpp. To verify, execute
$ ls ./resources/
whose output should be:
MyResource.cpp MyResource.h
The MyResource.cpp file is automatically put in compilation. If you want to remove MyResource.cpp from the compilation you need to manually edit the file CMakeLists.txt, removing the file name from the line beginning with:
set(RESOURCES_SRC ...
$ ./MIPCreate.sh task MyTask
this command will create two files in ./tasks/ called MyTask.h and MyTask.cpp. To verify, execute
$ ls ./Task/
whose output should be:
MyTask.cpp MyTask.h
The MyTask.cpp file is automatically put in compilation. If you want to remove MyTask.cpp from the compilation you need to manually edit the file CMakeLists.txt, removing the file name from the line beginning with:
set(RESOURCES_SRC ...
$ ./MIPCreate.sh test MyTest
this command will create one file in ./tests/ called testMyTest.cpp. To verify, execute
$ ls ./tests/
whose output should be:
CMakeLists.txt testMyTest.cpp
The file testMyTest.cpp is automatically put in compilation by the script, hence you do not need to do it manually. If you want to remove MyTask.cpp from the compilation you need to manually edit the file tests/CMakeLists.txt
To add your custom baselib and algorithms, you only need to create the files and put the *.cpp files in compilation in the respective sections. This means, if you create a new baselib you should modify the file CMakeLists.txt simply adding the *.cpp that you want to compile in the lines beginning with:
set(BASELIB_SRC ... set(RESOURCES_SRC ...
$ cd MY_PLUGIN_PATH/MY_PLUGIN/build
$ cmake .. $ make
Once you have created and built the plugin you have to make it rechable from MIP. To do this, you have to run the command MIPPluginsProfile.
$ MIPPluginsProfile
Whenever you install or create a new plugin, you need to run the MIPPluginsProfile command.
$ cd MY_PLUGIN_PATH/MY_PLUGIN/configFiles $ gedit myConfigFile.txt
Then, edit myConfigFile.txt, and write:
$ RESOURCES $ PluginResource:MY_PLUGIN:MyResource $ TASKS $ PluginTask:MY_PLUGIN:MyTask
Now, go in the MIP_HOME directory and run mip:
$ cd MIP_HOME/build/bin $ ./mip -configFile MY_PLUGIN_PATH/MY_PLUGIN/configFiles -id 0
and your task plugin will start running. If you recall your resource in your task, you can also check that the resource is running as well.