Difference between revisions of "Pprzros"

From PaparazziUAV
Jump to navigation Jump to search
 
(14 intermediate revisions by the same user not shown)
Line 7: Line 7:
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.<br/>
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.<br/>
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:
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:
* /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/to_ros : PPRZROS is publishing in this topic. Messages coming from the ''Destination'' will be translated into ROS format and published on this topic.
* /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''.
* /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''.
[[File:Pprzros.png|thumb|PPRZROS in a glimpse]]
[[File:Pprzros.png|thumb|PPRZROS in a glimpse]]
A connexion to Paparazzi is also setup, depending on the specified connexion type.
A connexion to Paparazzi is also setup, depending on the specified connexion type.


== Installation ==
== Installation ==
This section assumes that you already successfully installed [http://wiki.ros.org/ROS/Installation ROS] and [https://wiki.paparazziuav.org/wiki/Installation Paparazzi] on your system.
This section assumes that you have successfully installed [http://wiki.ros.org/ROS/Installation ROS] and [https://wiki.paparazziuav.org/wiki/Installation Paparazzi] on your system.
You also need a working [http://wiki.ros.org/catkin/Tutorials/create_a_workspace catkin workspace]<br/>


Why pprzlink is needed
Now, go into the /src folder of you catkin workspace
Installing pprzlink
    $ cd my_catkin_ws/src
Installing pprzros
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 ==
== Running PPRZROS ==
Line 24: Line 39:
First, be sure that the rosmaster is up and running by starting the roscore<br/>
First, be sure that the rosmaster is up and running by starting the roscore<br/>
     $ roscore
     $ roscore
And then start the node,<br/>
Then, start Paparazzi
    $ cd my_paparazzi_folder/
    $ ./paparazzi
Finally start the PPRZROS node,<br/>
     $ rosrun pprzros pprzros_run connexion_type destination [OPTIONS]
     $ 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, information can be displayed by starting the rosnode with the -h (--help) option.
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,<br/>
* Via a .launch file which allows to start the PPRZROS node along with some other nodes that might be useful for your application,<br/>
Line 32: Line 50:
The following section contains an example .launch showing, among other things, how to start a PPRZROS node.
The following section contains an example .launch showing, among other things, how to start a PPRZROS node.


== Example ==
== Example: Ping/Pong ==
An example .launch file is provided in the /launch directory of the package.  
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 it to show how a message can be sent to the Paparazzi Destination from ROS.
[[File:Pingpong.png|thumb|The nodes and topics created in the Ping/Pong example]]
We will go through the pingpong.launch file it to understand the process.
     <?xml version="1.0"?>
     <?xml version="1.0"?>
     <launch>
     <launch>
       <node pkg="pprzros" type="pprzros_run" name="pprzros" args="udp -d 192.168.1.1" output="screen"/>
       <node pkg="pprzros" type="pprzros_run" name="pprzros" args="udp -d 192.168.1.1" output="screen"/>
       <node pkg="rostopic" type="rostopic" name="send_test_ping" args="pub -r 10 /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="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_test_pong" args="echo -c /to_ros" output="screen"/>
       <node pkg="rostopic" type="rostopic" name="echo_pong" args="echo -c /pprzros/to_ros" output="screen"/>
     </launch>
     </launch>


Line 46: Line 65:
     <node pkg="pprzros" type="pprzros_run" name="pprzros" args="udp -d 192.168.1.1" output="screen"/>
     <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 /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 == []).
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_test_ping" args="pub -r 10 /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="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 /to_ros topic and listen if any PONG is message is answering our PINGs.
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_test_pong" args="echo -c /to_ros" output="screen"/>
     <node pkg="rostopic" type="rostopic" name="echo_pong" args="echo -c /pprzros/to_ros" output="screen"/>


<br/>- Under development -
<br/>- Under development -

Latest revision as of 07:20, 31 July 2017

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.
PPRZROS in a glimpse

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.

The nodes and topics created in the Ping/Pong example

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 -