Acta Polytechnica CTU Proceedings doi:10.14311/APP.2015.1.0029 Acta Polytechnica CTU Proceedings 2:29–33, 2015 © Czech Technical University in Prague, 2015 available online at http://ojs.cvut.cz/ojs/index.php/app X-COPTER STUDIO Michal Koutný∗, Ondřej Pilát, Patrik Černý, Maroš Kasinec Charles University in Prague, Faculty of Mathematics and Physics, Ke Karlovu 3, Prague, Czech Republic ∗ corresponding author: xm.koutny+pair@gmail.com Abstract. We present a project that aggregates various existing robotic software and serves as a platform to conveniently control a quadrocopter, mainly for research or educational purposes. User interface runs in a browser and other components are also made with portability in mind. We provide a common interface that unifies different quadrocopter models and we implemented it for the Parrot AR.Drone 2.0. The platform is data oriented, i.e., it is based on dataflow between user objects. We implemented several such objects for: data recording and replaying, inertial and visual localization and following a given path. Keywords: robotics, quadcopter, IDE. 1. Motivation Despite the fact that cheap hardware (such as Par- rot AR.Drone 2.0 [1] or ready kits [2]) is available, there are not many possibilities for application pro- grammers to develop software for these robots without need to distinguish between individual models. Our aim is to provide a platform for development of software for quadrocopters. The target users are AI programmers or students and expected tasks are general algorithms (basic example in Figure 1) for quadrocopters. The result should work with any robot compatible with our software (section 4.3). The test- ing should be further simplified by running the ap- plication without physical access to a quadrocopter either by using a simulator or data previously captured during live flights. at(xcheckpoint.reachedCheckpoint) { xcheckpoint.checkpoint = nextCheckpoint(); },; // x = 3 m, y = 1 m, z = 1.5 m var cp0 = Checkpoint.new(3, 1, 1.5); xcheckpoint.checkpoint = cp0; Figure 1. Sample script that flies through computed checkpoints. It assumes there is created a dataflow graph with the node xcheckpoint in it. 2. Related Work 2.1. Middleware for Robotics Probably most popular middleware for robotics is the Robot Operating System (ROS) [3]. It supports com- munication between objects using publish–subscribe mechanism. It is open source, mainly targeted on Linux platforms. Similar project is Urbi SDK, developed by former private company Gostai [4]. The current maintainer is Aldebaran Robotics [5], unfortunately the commu- nity around Urbi SDK is much smaller and much less active in comparison with ROS. Reasons why we chose Urbi SDK despite this fact are in the section 3.2. 2.2. Parrot AR.Drone 2 API Part of our project is an API for Parrot AR.Drone 2. Various other projects are dealing with this. There is the official SDK [6] with C++ API, Con- trolTower [7] that provide Java interface, a ROS pack- age ardrone_autonomy [8], UObject for Urbi SDK [9] or implementation of Czech Technical University [10]. Because none of the aforementioned fit to our re- quirements for OS portability, stability, functionality or documentation, we implemented our own (see the section 4.3). 2.3. Ground Control System There is official application for Parrot AR.Drone [11] intended for mobile phone users allowing manual con- trol and displaying only limited data from sensors. The PC application ControlTower [7] allows control- ling quadrocopter with specialized computer periph- eries and has airplane-like GUI. More complex appli- cation is QGroundControl [12] that cooperates with Pixhawk project [13] that encompasses own hardware and uses visual localization. 3. Used Technology 3.1. Architecture Our system is divided into three components. First interacts directly with a user, second controls the robot and the last one connects the former two. The components are separate processes that com- municate with each other over network, with intention to run components on different machines. 29 http://dx.doi.org/10.14311/APP.2015.1.0029 http://ojs.cvut.cz/ojs/index.php/app M. Koutný, O. Pilát, P. Černý, M. Kasinec Acta Polytechnica CTU Proceedings 3.1.1. Client Client software is used to create and launch user scripts, edit them, manually control the robot and visualize data (e.g., directly from quadrocopter’s sen- sors). Despite the technology challenges the client is thin – running in a web browser.1 3.1.2. Server The server component conveys communication be- tween the client and the actual control machine (fur- ther onboard). Its task is to control the access to the onboard and monitor quality of the connection between the client and the onboard. In the case the overall connection latency (Client–Server and Server– Onboard) exceeds preset limits, a warning message is shown to the user. If the connection is lost, onboard execution is correctly terminated and user is notified too. 3.1.3. Onboard The onboard is the main executive component. The robot control and data processing run here because it is closest to the robot. The onboard is executing commands obtained from the client and sends back various data selected by user. The onboard component is supposed to run under normal operating system.2 Our implementation ex- ploits a PC that communicates with quadrocopter via Wi-Fi. We did not test the onboard component directly on a robot.3 3.2. Urbi SDK Urbi SDK is a C++ middleware for robotics, which we based the onboard component on. Basically it provides support for communication between user objects (UObjects) and schedules user jobs. Communication is possible via so called UVars, which are slots of UObjects. Sender just writes to these slots and a receiver’s callback handles the change of UVar’s value. This allows both apparently asynchronous communication and really asynchronous when a thread pool is used to run the callbacks. Fur- ther, UObjects can run in different processes and Urbi SDK ensures transparent messaging via TCP or UDP sockets. Orchestration user scripts (written in Urbiscript) can be executed by the Urbi runtime. Urbiscript is a prototype-based object-oriented language concep- tually similar to JavaScript. It is possible to imple- ment UObject functionality exclusively in the Urbis- cript. We chose Urbi SDK because of its portability (Linux and Windows systems are supported) and the own 1Google Chrome is strongly recommended, though Mozilla Firefox will also get by (without visualization of video data). 2We support Windows 7/8 and Ubuntu 14.04 systems. 3The hardware of Parrot AR Drone 2.0 theoretically should be able to run our onboard with limited performance. scripting language and runtime. Considered alterna- tive was Robot Operating System. 3.3. NodeJS NodeJS is a server-side JavaScript engine. Recently, it became quite popular among developers of interac- tive web applications and various modules [14] exist that extend core functionality. It suited our needs for the server component. 3.4. HTML5 Thanks to the standardization efforts many features that were earlier common only for desktop applications or via third party plug-ins (Flash, Java applets, native plug-ins) are now implemented directly in the browser, generally referred to as HTML5. To make client as multi-platform as possible, we decided to implement the client for the browser using aforementioned HTML5 technologies. Most impor- tantly, we use the web socket API [15] for sending data back to the client and