eeros_architecture:hal:config_ros
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
eeros_architecture:hal:config_ros [2017/11/30 19:56] – graf | eeros_architecture:hal:config_ros [2023/02/27 14:44] (current) – [Configuration File for ROS] ursgraf | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Configuration File for ROS ====== | ====== Configuration File for ROS ====== | ||
- | ^ Keyword ^ Type ^ Remarks ^ | + | As described in [[getting_started: |
- | | deviceX | + | 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. |
- | As described in [[getting_started:ros#Using ROS through EEROS HAL|]] you can directly map | + | WARNING |
- | The wrapper library '' | + | The naming of messages changes from ROS1 to ROS2, e.g. |
+ | * ROS1: std_msgs:: | ||
+ | * ROS2: std_msgs:: | ||
+ | The information below is for ROS1. Change accordingly for ROS2. | ||
- | The EEROS HAL digital and analogue inputs and outputs can be defined with an *.json file. | + | The keywords for the EEROS-ROS wrapper library must be set as follows: |
- | + | ^ Keyword ^ Type ^ Remarks ^ | |
- | If you want to test your application with a \textit{Gazebo} simulation, you can define your inputs and outputs | + | | library |
- | + | | devHandle | string | e.g. testNodeHAL, this is the name of the node created by the HAL | | |
- | To use your application with hardware, you can, for example, use the wrapper | + | | type | string | e.g. AnalogIn / AnalogOut / DigIn / DigOut |
- | + | | additionalArguments | |
- | 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 '' | + | |
- | + | ||
- | 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 | + | |
- | + | ||
- | library | + | |
- | + | ||
- | devHandle | + | |
- | + | ||
- | type & | + | |
- | + | ||
- | additionalArguments | + | |
- | + | ||
- | \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}. | + | |
+ | ===== Additional Arguments ===== | ||
+ | The '' | ||
+ | ^ Keyword ^ Type ^ Remarks ^ | ||
+ | | topic | string | topic to listen or subscribe | | ||
+ | | msgType | string | message type | | ||
+ | | dataField | string | data member of message | | ||
+ | | callOne | boolean | newest availabe message is fetched (false), oldest not yet read message is fetched (true) | | ||
+ | | queueSize | int | size of buffer, default = 1000 | | ||
+ | | useEerosSystemTime | boolean | use system time or timestamp of message | | ||
An example for an additional argument could be: | An example for an additional argument could be: | ||
+ | < | ||
+ | " | ||
+ | </ | ||
+ | ===== Implemented Message Types ===== | ||
+ | The table below shows 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 below. | ||
+ | ^ type ^ msgType ^ dataField ^ | ||
+ | | AnalogIn | std_msgs:: | ||
+ | | ::: | sensor_msgs:: | ||
+ | | ::: | ::: | angle_max | | ||
+ | | ::: | ::: | angle_increment | | ||
+ | | ::: | ::: | time_increment | | ||
+ | | ::: | ::: | scan_time | | ||
+ | | ::: | ::: | range_min | | ||
+ | | ::: | ::: | range_max | | ||
+ | | AnalogOut | std_msgs:: | ||
+ | | ::: | sensor_msgs:: | ||
+ | | ::: | ::: | angle_max | | ||
+ | | ::: | ::: | angle_increment | | ||
+ | | ::: | ::: | time_increment | | ||
+ | | ::: | ::: | scan_time | | ||
+ | | ::: | ::: | range_min | | ||
+ | | ::: | ::: | range_max | | ||
+ | | DigIn | std_msgs:: | ||
+ | | DigOut | std_msgs:: | ||
- | \begin{snugshade*} | + | You can find a complete example, including a *.json file, in the [[getting_started: |
- | + | ||
- | \textit{\char" | + | |
- | + | ||
- | dataField=scan\_time; | + | |
- | + | ||
- | \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 | + | |
- | + | ||
- | \textbf{topic} | + | |
- | + | ||
- | \textbf{msgType } & sensor\_msgs:: | + | |
- | + | ||
- | dataField & scan\_time | + | |
- | + | ||
- | callOne | + | |
- | + | ||
- | callOne | + | |
- | + | ||
- | queueSize | + | |
- | + | ||
- | useEerosSystemTime | + | |
- | + | ||
- | \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 | + | |
- | + | ||
- | AnalogIn | + | |
- | + | ||
- | & sensor\_msgs:: | + | |
- | + | ||
- | & & angle\_max | + | |
- | + | ||
- | & & angle\_increment \\ | + | |
- | + | ||
- | & & time\_increment | + | |
- | + | ||
- | & & scan\_time | + | |
- | + | ||
- | & & range\_min | + | |
- | + | ||
- | & & range\_max | + | |
- | + | ||
- | AnalogOut & std\_msgs:: | + | |
- | + | ||
- | & sensor\_msgs:: | + | |
- | + | ||
- | & & angle\_max | + | |
- | + | ||
- | & & angle\_increment \\ | + | |
- | + | ||
- | & & time\_increment | + | |
- | + | ||
- | & & scan\_time | + | |
- | + | ||
- | & & range\_min | + | |
- | + | ||
- | & & range\_max | + | |
- | + | ||
- | DigIn & sensor\_msgs:: | + | |
- | + | ||
- | DigOut | + | |
- | + | ||
- | \end{tabular} | + | |
- | + | ||
- | \end{table} | + | |
- | + | ||
- | + | ||
- | + | ||
- | You can find a complete example, including a *.json file, in the eeros framework (/ | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | \subsection{How to use} | + | |
- | + | ||
- | Refere to the documentation of the EEROS HAL\footnote{http:// | + | |
- | + | ||
- | + | ||
- | + | ||
- | First initialize the HAL in your main function: | + | |
- | + | ||
- | \lstset{language=c} | + | |
- | + | ||
- | \begin{lstlisting} | + | |
- | + | ||
- | ... | + | |
- | + | ||
- | int main(int argc, char **argv) { | + | |
- | + | ||
- | ... | + | |
- | + | ||
- | // HAL | + | |
- | + | ||
- | // //////////////////////////////////////////////////////////////////////// | + | |
- | + | ||
- | HAL& hal = HAL:: | + | |
- | + | ||
- | hal.readConfigFromFile(& | + | |
- | + | ||
- | ... | + | |
- | + | ||
- | \end{lstlisting} | + | |
- | + | ||
- | + | ||
- | + | ||
- | Add the header file to your control system: | + | |
- | + | ||
- | \lstset{language=c} | + | |
- | + | ||
- | \begin{lstlisting} | + | |
- | + | ||
- | #include < | + | |
- | + | ||
- | \end{lstlisting} | + | |
- | + | ||
- | + | ||
- | + | ||
- | You can now declare \textit{PeripheralInputs} and \textit{PeripheralOutputs}: | + | |
- | + | ||
- | \lstset{language=c} | + | |
- | + | ||
- | \begin{lstlisting} | + | |
- | + | ||
- | PeripheralInput< | + | |
- | + | ||
- | PeripheralInput< | + | |
- | + | ||
- | PeripheralOutput< | + | |
- | + | ||
- | PeripheralOutput< | + | |
- | + | ||
- | \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:: | + | |
- | + | ||
- | dt(ts), | + | |
- | + | ||
- | ... | + | |
- | + | ||
- | analogIn0(" | + | |
- | + | ||
- | digitalIn0(" | + | |
- | + | ||
- | analogOut0(" | + | |
- | + | ||
- | digitalOut0(" | + | |
- | ... | ||
- | } |
eeros_architecture/hal/config_ros.1512068179.txt.gz · Last modified: 2017/11/30 19:56 (external edit)