MIP Plugins:

MIP plugins are intended for developers who wants to develop his own code in a MIP framework. This means that the execution of a plugin in MIP will be guaranteed as long as the plugin tasks and resources will respect MIP standards.

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.

Tutorial: building your own MIP plugin

In this tutorial we assume you have a compiled and globally registered version of MIP in your PC. If this is not the case, follow the Build MIP tutorial first.
The first thing to do when building a MIP plugin is to use the MIPCreatePlugin.sh script in the MIP_ROOT/PluginExample/ directory.

$ 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.


Create a new resurce in the plugin

To add a new resource, in the MY_PLUGIN_PATH/MY_PLUGIN/ directory execute:
$ ./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   ... 


Create a new task in the plugin

To add a new task, in the MY_PLUGIN_PATH/MY_PLUGIN/ directory execute:
$ ./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   ... 


Create a new test in the plugin

To add a new test, in the MY_PLUGIN_PATH/MY_PLUGIN/ directory execute:
$ ./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


Create a new baselib or algorithm in the plugin

To add a new baselib or algorithm there is no automated procedure to follow. This is because algorithms and baselibs do not need to follow any standard structure, and are not required to derive from any MIP class (although this is possible).

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


Build the plugin

To build the plugin go in the MY_PLUGIN_PATH/MY_PLUGIN/build directory:
$ cd MY_PLUGIN_PATH/MY_PLUGIN/build 
and execute cmake and make commands:
$ 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.


Run the plugin

To run the plugin you have created, you need first to write a configuration file.
$ 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
then save and exit.

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.


Generated on Mon Feb 20 07:01:08 2017 for MIP by  doxygen 1.5.6