User Tools

Site Tools


eeros_architecture:hal:config_ros

This is an old revision of the document!


Configuration File for ROS

Keyword Type Remarks
deviceX object device, X is the device number

As described in Using ROS through EEROS HALThe wrapper library \textit{ros-eeros} is used to connect the EEROS HAL with ROS topics.

The EEROS HAL digital and analogue inputs and outputs can be defined with an *.json file.

If you want to test your application with a \textit{Gazebo} simulation, you can define your inputs and outputs as ROS topics to connect your application with the simulation completely without any real hardware.

To use your application with hardware, you can, for example, use the wrapper library \textit{comedi-eeros} or \textit{flink-eeros}.

If you adapt the *.json file correctly, your application should now run on hardware with real encoders and motors without any problems.

It is also possible to use ROS-topics alongside real hardware.

You can use \textit{comedi-eeros} to read an encoder and set a control value for a motor.

At the same time, you can publish the same values to ROS topics to visualize the state of the robot with \textit{rviz} (if you have a model of your robot) or you can monitor the values with a ROS tool like \textit{rqt} and display them in a graph with \textit{Multiplot} or as numbers with \textit{TopicMonitor}.

With \textit{Multiplot} you can also store the values in a text file.

There are hundreds of different message types in ROS and it is possible to create custom types.

Because every message type has to be handled differently, only a few are supported by default.

But the wrapper library can easily be extended to support additional message types.

Chapter \ref{sectionImplementMsgType} describes how you can add a new ROS msg type to the library.

\subsection{The *.json file}

Table \ref{tableKeyValueEeros} shows the most important key-value pairs for using the HAL with ROS.

\begin{table}[]

\centering

\caption{Most important key-value pairs for ros-eeros}

\label{tableKeyValueEeros}

\begin{tabular}{@{}lll@{}}

\toprule

Key & Typical value & Description
\midrule

library & libroseeros.so & Wrapper library for ROS

devHandle & testNodeHAL & ROS node created by HAL

type & AnalogIn / AnalogOut / DigIn / DigOut & Type of input / output

additionalArguments & 'see next table' & 'see next table'
\bottomrule

\end{tabular}

\end{table}

The \textit{additionalArguments} are special arguments which are parsed in the wrapper library \textit{ros-eeros}.

These arguments contain additional information which are necessary to communicate with a ROS network.

All arguments are separated with a semicolon.

The available arguments are listed in table \ref{tableAdditionalArgumentsEeros}.

An example for an additional argument could be:

\begin{snugshade*}

\textit{\char“22additionalArguments\char”22: \char“22topic=/testNode/TestTopic3; msgType=sensor\_msgs::LaserScan;

dataField=scan\_time; callOne=false; queueSize=100\char”22,}

\end{snugshade*}

Table \ref{tableAdditionalArgumentsEeros} shows all currently available \textit{additionalArguments}.

\textbf{Topic} and \textbf{msgType} are mandatory arguments.

\begin{table}

\centering

\caption{Additional arguments specific for ros-eeros}

\label{tableAdditionalArgumentsEeros}

\begin{tabular}{@{}lll@{}}

\toprule

Key & Typical value & Description
\midrule

\textbf{topic} & /testNode/TestTopic1 & Topic to listen / subscribe

\textbf{msgType } & sensor\_msgs::LaserScan & ROS message type of topic

dataField & scan\_time & Desired data member of message

callOne & true & Oldest, not yet fetched message is fetched

callOne & false & Newest available message is fetched

queueSize & 1000 & Size of buffer; queueSize=1000 if omitted

useEerosSystemTime & fals & Use system time or timestamp of received msg
\bottomrule

\end{tabular}

\end{table}

In table \ref{tableImplementedMsgTypes} are all currently implemented message types and associated data fields.

If your desired message type is not implemented yet, you can easily implement it yourself.

See chapter \ref{sectionImplementMsgType} for a guide to implement additional message types and data fields in \textit{ros-eeros}.

\begin{table}[]

\centering

\caption{Currently implemented message types in ros-eeros}

\label{tableImplementedMsgTypes}

\begin{tabular}{lll}

\cline{2-3}

HAL type & msgType & dataField
\cline{2-3}

AnalogIn & std\_msgs::Float64 & -

        & sensor\_msgs::LaserScan    & angle\_min       \\
        &                            & angle\_max       \\
        &                            & angle\_increment \\
        &                            & time\_increment  \\
        &                            & scan\_time       \\
        &                            & range\_min       \\
        &                            & range\_max       \\

AnalogOut & std\_msgs::Float64 & -

        & sensor\_msgs::LaserScan    & angle\_min       \\
        &                            & angle\_max       \\
        &                            & angle\_increment \\
        &                            & time\_increment  \\
        &                            & scan\_time       \\
        &                            & range\_min       \\
        &                            & range\_max       \\

DigIn & sensor\_msgs::BatteryState & present

DigOut & sensor\_msgs::BatteryState & present
\cline{2-3}

\end{tabular}

\end{table}

You can find a complete example, including a *.json file, in the eeros framework (/examples/hal/Ros*).

\subsection{How to use}

Refere to the documentation of the EEROS HAL\footnote{http://wiki.eeros.org/eeros\_architecture/hal/start?s[]=hal} and check the example in the eeros framework (/examples/ros).

First initialize the HAL in your main function:

\lstset{language=c}

\begin{lstlisting}

int main(int argc, char **argv) {

...
// HAL
// ////////////////////////////////////////////////////////////////////////
HAL& hal = HAL::instance();
hal.readConfigFromFile(&argc, argv);
...

\end{lstlisting}

Add the header file to your control system:

\lstset{language=c}

\begin{lstlisting}

#include <eeros/hal/HAL.hpp>

\end{lstlisting}

You can now declare \textit{PeripheralInputs} and \textit{PeripheralOutputs}:

\lstset{language=c}

\begin{lstlisting}

PeripheralInput<double>		analogIn0;
PeripheralInput<bool>		digitalIn0;
PeripheralOutput<double>	analogOut0;
PeripheralOutput<bool>		digitalOut0;

\end{lstlisting}

Call the constructor of the peripheral IOs with the \textit{signalID} used in the *.json file

\begin{lstlisting}

class MyControlSystem {

public:

MyControlSystem(double ts, ros::NodeHandle& rosNodeHandler):
	dt(ts),
	...
	analogIn0("scanTimeIn0"),		// argument has to match signalId of json
	digitalIn0("batteryPresent0"),
	analogOut0("scanTimeEchoOut0"),
	digitalOut0("batteryPresentEchoOut0"),
	...

}

eeros_architecture/hal/config_ros.1512068144.txt.gz · Last modified: 2017/11/30 19:55 by graf