/**
\page yarp_with_ros_writing_code_topics Writing code to talk to ROS topics

While you can configure conventional YARP ports to talk to ROS topics (see
\ref yarp_with_ros_existing_yarp_ports), YARP provides specialized classes that
simplify this task:

\li `yarp::os::Node`: a class to create a ROS node.
\li `yarp::os::Subscriber`: a class to subscribe to a topic.
\li `yarp::os::Publisher`: a class to publish to a topic.

An important thing to keep in mind is that YARP needs to be aware of ROS types.
If you are writing new code it is easy to generate ROS compatible YARP data
types starting.

For example the following code shows how to write a program that listen to the
/chatter topic. In this case we use the ROS type std_msgs/String.

The first thing to do is to generate a YARP compatible type for std_msgs/String:

~~~{.sh}
$ yarpidl_rosmsg String
~~~

This will produce the file `yarp/rosmsg/String.h` which can be used directly
in our YARP program.

Type the following code in a file, e.g. listener.cpp:

\include example/ros/listener.cpp

An example CMakeLists.txt file to compile this code would be:

~~~{.cpp}
    cmake_minimum_required(VERSION 3.12)
    find_package(YARP COMPONENTS os REQUIRED)
    add_executable(listener)
    target_sources(listener PRIVATE listener.cpp)
    target_link_libraries(listener PRIVATE YARP::YARP_os
                                           YARP::YARP_init)
~~~

You can now publish the string "Hello World" to the topic /chatter using ROS:

~~~{.sh}
rostopic pub /chatter std_msgs/String "hello yarp" --r 10
~~~

and listen to it using the YARP program above:

~~~{.sh}
./listener
~~~
\verbatim
yarp: Port /yarp/listener active at tcp://192.168.152.130:10002
yarp: Port /chatter-@/yarp/listener active at tcp://192.168.152.130:10003
yarp: Receiving input from /rostopic_36275_1464212662655 to /chatter-@/yarp/listener using tcpros+role.pub+topic./chatter
Received:hello yarp
Received:hello yarp
Received:hello yarp
...
\endverbatim

You can verify the existence of a node called /yarp/listener by running:

~~~{.sh}
rosnode list
~~~
\verbatim
/rosout
/yarp/listener
\endverbatim

We can now write our own publisher using YARP. The code is quite simple, type it
in a file, e.g. talker.cpp:

\include example/ros/talker.cpp

an example `CMakeLists.txt` file to compile this code would be:

~~~{.cmake}
    cmake_minimum_required(VERSION 3.12)
    find_package(YARP COMPONENTS os REQUIRED)
    add_executable(talker)
    target_sources(talker PRIVATE talker.cpp)
    target_link_libraries(talker PRIVATE YARP::YARP_os
                                         YARP::YARP_init)
~~~

We can run this code on a terminal:
~~~{.sh}
./talker
~~~
\verbatim
yarp: Port /yarp/talker active at tcp://192.168.152.130:10004
yarp: Port /chatter+@/yarp/talker active at tcp://192.168.152.130:10006
yarp: Sending output from /chatter+@/yarp/talker to /listener using tcpros
yarp: Removing output from /chatter+@/yarp/talker to /listener
\endverbatim

You can verify the existence of a node called `/yarp/talker` and topic
`/chatter`
by running:

~~~{.sh}
rosnode list
~~~
\verbatim
/rosout
/yarp/talker
\endverbatim

~~~{.sh}
rostopic list
~~~
\verbatim
/chatter
/rosout
/rosout_agg
\endverbatim

And see the output using the listener from ros tutorials:

~~~{.sh}
rosrun roscpp_tutorials listener
~~~
\verbatim
[ INFO] [1464213813.965287858]: I heard: [Hello from YARP]
[ INFO] [1464213814.066799996]: I heard: [Hello from YARP]
[ INFO] [1464213814.169264100]: I heard: [Hello from YARP]
[ INFO] [1464213814.271588965]: I heard: [Hello from YARP]
[ INFO] [1464213814.373758392]: I heard: [Hello from YARP]
...
\endverbatim

The following tutorials show how to write your own data type using ROS syntax:

\li \subpage rostypes_tutorial_portable
\li \subpage rostypes_tutorial_continued

*/
