How to write your own sensor/robot web plugin ?

:!: DEPRECATED Information

This page explains how to write a web plugin for your sensor/robot to be visualize through hughweb application.

This plugin enables to retrieve hugr data via hugrweb program. This program launchs a web application where data created and updated within hugr middleware can be displayed.

Sensor/Robot Structure

Let assume you have already developped a sensor for hugh which structure is defined in : Structs/yourSensorStructs.hpp

class YourSensorState {
   double val1;
   double val2;
namespace boost
namespace serialization
template<class Archive>
void serialize(Archive &ar, YourSensorState &st, const unsigned int version)
    ar & st.val1;
    ar & st.val2;

Sensor/Robot plugin programs

Here are the files defining the web plugin for yoursensor. This files enable to display yoursensor values, ie val1 and val2 values via hugrweb, ie via a web page.

  • File Hugrweb-plugins/inc/yoursensorplug.hpp
#include <typeinfo>
#include <sstream>
#include "hugr.hpp"
#include "hugrweb-plugin.hpp"
#include "youSensorStructs.hpp"
namespace hugr
inline void printVariable( const YourSensorState& Data, std::stringstream &response)
   response << "state.val1 = " << Data.val1 << " in m/s <br/>";
   response << "state.val2 = " << Data.val2 << " in rad <br/>";
class DisplayYourSensorData : public DisplayPlugin
    YourSensorState Data;
    inline const char *getTypeId()
        return typeid(Data).name();
    inline void renderType(std::stringstream &response)
        response << "yoursensor Data";
    void renderVariable(std::stringstream &response);
    void readVariable(hugr::StoreAdmin &store, hugr::VariableId &id);
  • Source File Hugrweb-plugins/src/yoursensorplug.cpp
#include <fstream>
#include <iostream>
#include "hugr.hpp"
#include "yoursensorplug.hpp"
using namespace std;
using namespace hugr;
void DisplayYourSensorData::readVariable(hugr::StoreAdmin &store, hugr::VariableId &id)
    store.readVariable(id, Data);
void DisplayYourSensorData::renderVariable( stringstream &response)
{ printVariable( Data, response ); }

Using the plugin for your Sensor/Robot

Once you compiled and obtained the library file for your sensor/robot plugin, you need to set the ~/.hugr/plugins.lst file.

Let assume your sensor/robot plugin library is, you need to add to ~/.hugr/plugins.lst the following line :


After launching hugrstore, hugrweb and the program where your sensor is used, if you go to http://localhost:8000, you will be displayed the data info of your sensor.

deprecated/howto/devel-plugin.txt · Last modified: 2012/01/24 15:44 by arias
Recent changes RSS feed Creative Commons License Donate Minima Template by Wikidesign Driven by DokuWiki