Pacer Components: Writing a Perception, Planner or Controller plugin - PositronicsLab/Pacer GitHub Wiki

The library Pacer uses a modular plugin framework for perception, planning and control tools.

To add capabilities to the robot, add a plugin to Pacer.

Writing a Plugin

The template for a plugin is described in: ${PACER_HOME}/Plugin/Component/plugin.h

All plugins are of the form:

#include "plugin.h"

void loop(){
 boost::shared_ptr<Pacer::Controller> ctrl(ctrl_weak_ptr);
/*
 YOUR CODE HERE
*/
}

void setup(){
 boost::shared_ptr<Pacer::Controller> ctrl(ctrl_weak_ptr);
/*
 YOUR CODE HERE
*/
}

Using a plugin

Pacer is made aware of plugin names, file-paths, and parameters by reading the vars.xml file in your working directory. First, it determines which plugins to load and use based on the <plugin> tag

<plugins type="string vector">
  plugin1
  plugin2
</plugins>

<plugin1>
  <file type="string">libplugin1.so</file>
  <real-time-factor type="double">1</real-time-factor>
  <priority type="double">1</priority>
</plugin1>

<plugin2>
  <file type="string">libplugin2.so</file>
  <real-time-factor type="double">1</real-time-factor>
  <priority type="double">2</priority>
</plugin2>

the compiled plugin file is relative to environment variable $PACER_COMPONENT_PATH unless it's an absolute path starting with a /.

every plugin must have a tag for its file, real-time-factor and priority

  • The plugin calls its update function once every real-time-factor controller iterations
  • All plugins of the same priority number (integer value between [0..10]) are called asynchronously, while different priority values are handled in order from least to greatest.

To add a new plugin:

  • Create a new plugin.cpp in ${PACER_HOME}/Plugin/Component/ and run cmake again to add it to Pacer's build OR compile your own plugin while linking to Pacer, and Ravelin.
  • To make Pacer run the plugin add your plugin's name to plugins in the vars.xml file in your working directory and point to the compiled library with the file tag.
  • Add the your plugin's necessary variables to the vars.xml file in your working directory under the <plugin's name> tag.
  • Variable types: (<variable_name type="TYPE"> VALUE </variable_name>)
    • VALUE contains information for the variable of the described type.
    • TYPEs can be: bool, int, double, string, bool vector, int vector, double vector, string vector, and file
      • file is a special case. It will import all variables in the filename.xml at path/filename.xml equal to VALUE (relative to the working directory if no leading /). The variables are imported under the same tag as variable_name. The variable_name for tags with type="file" are discarded.
⚠️ **GitHub.com Fallback** ⚠️