Pprzros

= PPRZROS =
PPRZROS is a Robot Operating System (ROS) package bridging ROS and Paparazzi, to get the best of both worlds.
== Overview ==
The role of PPRZROS is to convert Paparazzi messages into ROS format and ROS messages into Paparazzi format.
More specifically, incoming paparazzi messages are converted into a generic ROS message containing generic information about the message and the binary data associated with the message. Messages coming in ROS format are translated to a generic paparazzi message with the same format: generic information and data in binary form.
To start the PPRZROS node, it requires a connexion type (UDP, Serial or Ivy) and a Destination (plus some other optional infos). Once started the PPRZROS node will create two ROS topics:
* /pprzros/to_ros : PPRZROS is publishing in this topic. Messages coming from the Destination will be translated into ROS format and published on this topic.
* /pprzros/from_ros : PPRZROS is subscribing (listening) to this topic. Any message sent to this topic, by other ROS nodes (programs), will be translated into a Paparazzi message and sent to the Destination.
A connexion to Paparazzi is also setup, depending on the specified connexion type.
== Installation ==
This section assumes that you have successfully installed ROS and Paparazzi on your system.
You also need a working catkin workspace
Now, go into the /src folder of you catkin workspace
 $ cd my_catkin_ws/src
and clone the PPRZROS repository
 $ git clone --recursive https://github.com/enacuavlab/pprzros.git
Then, do go to the pprzros folder, e.g. using roscd
 $ roscd pprzros
and use catkin_make to compile and generate messages.
 $ catkin_make
Please note that the PPRZROS repository contains a sub-module linking to PPRZLINK repository (thus the git clone --recursive). When updating PPRZROS don't forget to update the PPRZLINK sub-module as well.
 $ git submodule update
== Stack content ==
The PPRZROS repository contains four folders:
* PPRZLINK: contains the interfaces needed to communicate with Paparazzi through UDP, Serial and Ivy. It is used by PPRZROS in order to communicate with the Paparazzi world.
* PPRZROS: this package contains the code for creating a node capable of communicating both with ROS and Paparazzi. It relies on ROS and PPRZLINK interfaces.
* PPRZROS_MSGS: this package contains ROS message definitions. For now it only contains a generic message, but more useful messages can be added in the futur.
* SLAMDUNK_PPRZ: Todo
== Running PPRZROS ==
There are two ways to start the PPRZROS node:
* Directly as an independent ROS node : 
First, be sure that the rosmaster is up and running by starting the roscore
 $ roscore
Then, start Paparazzi
 $ cd my_paparazzi_folder/
 $ ./paparazzi
Finally start the PPRZROS node,
 $ rosrun pprzros pprzros_run connexion_type destination [OPTIONS]
The connexion_type can be UDP, Serial or IVY. The destination and OPTIONS will vary depending on the connexion_type, help can be displayed by starting the rosnode with the -h (--help) option.
* Via a .launch file which allows to start the PPRZROS node along with some other nodes that might be useful for your application,
 $  roslaunch pprzros my_script.launch
The following section contains an example .launch showing, among other things, how to start a PPRZROS node.
== Example: Ping/Pong ==
An example is provided in pprzros/launch/pingpong.launch. A rostopic node is created to send a Ping to a Paparazzi simulator through PPRZROS and the outgoing Pong is transmitted to ROS and ouput on the screen.
We will go through the pingpong.launch file it to understand the process.
 <?xml version="1.0"?>
 <launch>
 <node pkg="pprzros" type="pprzros_run" name="pprzros" args="udp -d 192.168.1.1" output="screen"/>
 <node pkg="rostopic" type="rostopic" name="send_ping" args="pub -r 10 /pprzros/from_ros pprzros_msgs/PprzrosMsg '{header: auto, version: 1, len: 0, class_name: 'datalink', comp_id: 0, msg_name: 'PING', sender_id: 0, receiver_id: 201, checksum: 0, data: []}'" output="screen"/>
 <node pkg="rostopic" type="rostopic" name="echo_pong" args="echo -c /pprzros/to_ros" output="screen"/>
 </launch>
In the following, we go through each line to understand its role
First starting the PPRZROS node
 <node pkg="pprzros" type="pprzros_run" name="pprzros" args="udp -d 192.168.1.1" output="screen"/>
Then, the rostopic package is called to create a node publishing a given message. This message is published on the /pprzros/from_ros topic and is of type PprzrosMsg. The content of the message is then described in YAML format. We can see here that it is a simple PING message, so there is no content (data == []). For the communication to work properly, please check that the receiver_id and sender_id match the ones your are using in your setting.
 <node pkg="rostopic" type="rostopic" name="send_ping" args="pub -r 10 /pprzros/from_ros pprzros_msgs/PprzrosMsg '{header: auto, version: 1, len: 0, class_name: 'datalink', comp_id: 0, msg_name: 'PING', sender_id: 0, receiver_id: 201, checksum: 0, data: []}'" output="screen"/>
Finally, we create a node, from the rostopic package, to subscribe to the /pprzros/to_ros topic and listen if any PONG message is answering our PINGs.
 <node pkg="rostopic" type="rostopic" name="echo_pong" args="echo -c /pprzros/to_ros" output="screen"/>
- Under development -