Manual
17
Developer’s guide - C++, Urbi, Flex, Java - V2.0
robopec
This document is the property of Robopec. The information contained herein may not be used, reproduced or
communicated without its prior written consent.
Declare a function
In your class, you can create all functions as normal, but if you want a function to be accessible by
URBI, you must declare it as:
- Declare your function public.
- Declare your function to URBI :
o UBindFunction(ma_classe, ma_fonction);
- The binded function accepts only the following types of arguments:
o int
o double
o string
o std::list
o URBI type (see URBI documentation)
You can declare your functions to be called in a separate thread:
UBindThreadedFunction(ma_classe, ma_fonction, LOCK_NONE);
Call URBI function
Use the liburbi C++ as in chapter 5 to call URBI functions in your module.
Compilation
To compile, use the umake tool from URBI or compile your project as static library (.so) including
/usr/local/gostai/lib/liburbi.so and /usr/lib/libpthread.so in compilation libraries.
A cmake template with samples is given to easily compile your projects.
Example :
Header file: Ma_classe.h
#ifndef MA_CLASSE_H
#define MA_CLASSE_H
#include<string.h>
#include<iostream>
#include<stdio.h>
// headers inclusions
#include<urbi/uobject.hh>
#include<urbi/uclient.hh>
using namespace std;
//namespace URBI
using namespace urbi;
//our class inherits from UObject
class Ma_classe:public UObject{
public:
//default constructor, always with an argument : const string&