This is an old revision of the document!
Configuration File for ROS
As described in Using ROS through EEROS HAL you can directly map EEROS signal onto ROS messages through the EEROS HAL. The wrapper library EEROS-ROS is used to connect the EEROS HAL with ROS topics.
The EEROS HAL digital and analog inputs and outputs can be defined as usual in a JSON file. In this file you specify into which message type these signals get packed. There are hundreds of different message types in ROS and it is possible to create custom types. For this reason, we currently support only a few by default. If one wishes to use other message types, the wrapper library can easily be extended.
The keywords for the EEROS-ROS wrapper library must be set as follows:
Keyword | Type | Remarks |
---|---|---|
library | string | libroseeros.so (include version e.g. *.so.0.1.2) |
devHandle | string | e.g. testNodeHAL, this is the name of the node created by the HAL |
type | string | e.g. AnalogIn / AnalogOut / DigIn / DigOut |
additionalArguments | string | see table below |
The additionalArguments
are special arguments containing additional information about the communication with a ROS network. The next table shows all currently available arguments. topic
and msgType
are mandatory.
Keyword | Type | Remarks |
---|---|---|
topic | string | topic to listen or subscribe |
msgType | string | message type |
dataField | string | data member of message |
callOne | boolean | ???? |
queueSize | int | size of buffer, default = 1000 |
useEerosSystemTime | boolean | use system time or timestamp of message |
An example for an additional argument could be:
"additionalArguments": "topic=/testNode/TestTopic3; msgType=sensor_msgs::LaserScan; dataField=scan_time; callOne=false; queueSize=100"
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"),
...
}