ar drone parrot support

During this summer, between the end of my high school education and the beginning of my undergraduate studies, I had the opportunity to participate in the Wolfram Mentorship program where I worked on a project called "Connecting ROS to the Wolfram Language". ROS, which is an abbreviation for "Robot Operating System", is a software available for Linux which acts as a 'conductor' between different electronic components of one or more robots (such as the engine, the cameras...) such that the components and the controller (a computer for example) can communicate together. A good introduction to ROS can be found here and in depth tutorials are available there.The aim of this project was to implement a connection to ROS from the Wolfram Language, i.e. to be able to collect and interpret data from the robots controlled by ROS in Mathematica as well as to control ROS and the robots from Mathematica and to test the results using a Parrot ArDrone 2.0. This post, which marks the end of the project, describes the different steps I went through to complete this project.

It assumes prior knowledge of ROS (and the ardrone autonomy package) as well as basic Linux and Mathematica. It is divided into two parts: These are independent and throughout the first part code developed is illustrated using turtlesim (a simulator of a turtle - used in ROS tutorials) and throughout the second part, the examples refer to the Parrot ArDrone 2.0. After installing ROS and getting familiar with the environment, the first step is to figure out how to extract data from it, or to be more precise, how to log all the messages published over one or more topic in a file which can be retrieved by the user. Although, there is a tool called a rosbag which records the selected ROS topics and store them in a .bag file, it turns out that I only managed to open these files in ROS so a different procedure was used. It consists of echoing the messages published on selected topics (using the command rostopic echo) to a file of the chosen format (since messages are just simple text files the format used will be .txt).

This can simply be done by executing the following command in the Linux terminal before sending messages over the topic(s) (once ROS is installed and started): For example, if we were going to extract the velocity commands sent to the turtle to a file called rosdata.txt, the command would be: And opening the text file (once the ROS session is ended) would return a sequence of messages looking like the one below (the values of x,y,z might change): Now, In order to 'use' the data, it is necessary to understand the structure of the text file. It can be represented by the 'fomula' below : So, going back to the turtlesim example: Note: the meaning of a variable in a message might not always be obvious at first sight (due to ambiguous variable name such as x,y,z for instance) however, by observing the values of the variables against the action of the robots (the trajectory it takes in our case), this meaning can be quite easily retrieved. Now that is possible to retrieve and understand messages published over a ROS topic the next step is to import those messages in Mathematica.

In order to do this, a function, taking the path of the text file containing the messages as an argument and returning the messages in a list created; And, it is then possible to represent this in a dataset like so:
storm drone 4 vs 6 Hence, returning to the turtlesim example, if rosdata.txt is the file where the velocity command messages are published, the code below:
storm drone 6 price would return something of the form:Having imported the Data into Mathematica it can now be interpreted using the Wolfram Language.
ar drone gps reviewFor example, in the case of a topic where the messages published contain linear and angular velocities like the one described above, the path of the robot can be retrieved using the following code (using the function AnglePath):
ar drone parts for sale

Therefore,considering the turtlesim example, if the path of the turtle was: which is the same as the actual path taken by the turtle. Yet another thing to consider is how to send ROS commands from Mathematica in order to be able to directly operate ROS and record ROS data from a Mathematica notebook.
ar drone parrot controlsOne possible way to do so would be to use the Run command, however, it is necessary to source ROS commands before executing them and I did not manage to do so with the Run command.
best drone for filmingSo, another method to execute ROS commands from Mathematica is to create an empty shell script (using the chmod command in the Linux terminal) and then one can write the desired commands in the script and execute it from Mathematica, thanks to the function below (which takes the desired commands as an argument) :

Note: a second kernel is used in that code in order to kill the process running in the first one as some commands executed by the ROS command function would evaluate indefinitely.Hence, to start the ROS master, the command would be : Finally, another thing to implement in order to be able to perform most of ROS's basic features from Mathematica is to be able to publish messages on topics. In some cases this can be done by using the ROS command $rostopic publish through the RosCommand function described in the previous section. This method works fine however there is quite a considerable latency between the moment command is evaluated and the moment the command is actually published (about 1-2 seconds). Hence, this way only works for topics where messages have to be published at a rate lower than 0.5 Hz, for example the take off and land commands for the drone, as shown below: For topics where the rate for which the messages have to be published at a rate greater than 0.5 Hz, a publisher ROS node (a 'Mathematica' node), intaking the arguments from Mathematica should be created.

This can be written in C++ and the arguments from Mathematica can be transferred by simple file I/O code; i.e. this process would have the following structure: Note: the instructions to build the node are available here.Hence, to send velocity commands to the ArDrone from Mathematica, the Mathematica Notebook could be : where p={angluarz, linearx, linear_z} and: Moreover, the C++ code could look like: Throughout the Mentorship program, I developed functions enabling me to fully interact with ROS and the robot(s) it is controlling from a Mathematica notebook. Owning a Parrot ArDrone myself, which is a device supported by ROS, I tested this in real conditions and the result can be seen below:This is only a GIF, the full video is available here. All, in all, I have thoroughly enjoyed working on this project and would love to hear your feedback. I see it as a starting point towards using the many abilities of the Wolfram Language in order to improve the capabilities of ROS supported robots: I can already imagine myself using Mathematica to create an autopilot for my drone !