 So today I'm going to be talking about my talk, which is why are robots becoming Pythonistas? The other alternative would be why Python is popular in robotics. So first of all, I'm going to introduce myself. My name is Maxine Sanja and I'm a free software consultant at Sella Feli Nix. But my main hobby is robotics. I've been heavily involved in robotics for the last three years. I built multiple robots. I am also involved with Robocop at Home League. I've been traveling the world and building cool robots and composition. So first of all, what's a robot? The definition of a robot is something that is going to do something automatically. So it can be technically a toaster as a robot because you put a toast in, you push it down, and it's going to cook it automatically. But in our common sense, a robot is something really more complex than this. So here are some examples of robots. The first one to your left is Sarah, which is one of the robots I built. The middle one is the PR2, which is famous for being one of the first open-source robots. The one on the right, if you're not in the middle of robotics or if you're not in the domain, it's called Atlas. It was originally used for the DARPA robotics grand challenge. Also that the Atlas is super well known for doing back flips. So I'm going to put a little bit of means everywhere just to make things interesting. So this is Sarah. Sarah has been one of the last robots I worked on almost full-time. She's a service human robot built for Robocup at home, which is a leak for the Robocup competition. So each year we changed places. This year it was in Montreal, the year before that it was in Japan, and next year in 2019 it's going to be in Sydney, Australia. So her code base is a majority made of Python and a mix of C++ using what is called the Rust, which is the robot operating system. She was fully built by students who are only undergraduate students and were competition against people who were from research labs. And yeah, she can dab. So this is what I like about robots, is like you can do all sorts of weird things with them. So there's two languages that are like the robotics engineers first choice, Python and C++. There's also some people that code in Java, MATLAB. I think some people code in our list. The list goes on, but the two main ones are Python and C++. So as we know, C++ and Python are completely different language. They have their similarities, but so we can look at the pros of Python. Python is easy to learn and master. There's lots of libraries. You can do anything. I mean literally anything. There is a library for it. We can do machine learning, deep learning. We can use some weird protocol that has been done once in your life. And there's a library for that. Fast development. Because you're using a higher level language than a lower level language, you don't need to do memory management. You don't need to really think about every little detail like you would do with C++. Some of the cons of it is a slow execution compared to compile languages because of how the interpreter works. But if you're using something like OpenCV directly with it, you'll be lucky to know that you're using C++ code and loading modules directly in Python. The lack of true multi-treading is one of the things where it's a bit con in the world of robotics. You need to do multiple things and be able to have multiple threads. And because of how Python, specifically Python 2.7 handled threads, it's not that great. So if we look onto the C++ side, we say it's a faster execution because of the compiled language. It has better training support. But it is hard to learn and master. On Python, you can get into a project, a robotics project with so much code. Three months you're going to be ready to go by yourself. But in C++, it's going to be hard to master because of all the different changes between C++ 98, 11, 17, 20, like the list goes on and on. And there's also compile time. The fun part is like Python, you don't need to compile anything. You just run it and there it goes. So I will bring you an example. I'm going to show you how you built a hard cascade phase detector in OpenCV with Python and C++. If you don't know what a hard cascade is, it's one of the basic detectors in OpenCV, which you can find faces using a predefined model. So to the left is the Python version. To the right is the C++ version. As you can see, the one on the left is super small. It's more legible. You can see what it does. You import numpy, you open Cv2. You just load a classifier, you read an image, you change it to gray, detect it, and you show it. And that's it. On the C++, you do the same thing, but then you have to compile. And then you have to install all your libraries and then you have to use CMake, build something, and it's going to be harder. So yeah, plus for Python. So as I mentioned, why do people in robotics use Python? Well, just for the thing, it's super easy to use. Like anybody can pick it up and just be functional with it. There is no like, oh, you need to know about pointers, don't need to know about the stack, you don't need nothing. You know how to write in English, you can probably write in Python in less time. The other thing, libraries, you can use Catast, you can use TensorFlow, OpenCV, PCL, you can use Django. I use Django in robotics applications a lot, even Flask. The whole library ecosystem and the no compile time. If you're debugging something in the field, you don't want to like compile everything back from scratch. Oh, I have a bug. Oh, let me give me like 15, 20 minutes, and we're going to recompile everything, ship it on the robot and see if it works. No, just go in, change the line, grant it again, see if it fails. When to use Python. These are the things that there's specific things you can use Python for and some are not. Some of the when to use Python vision systems that are not real time. This is one of the things where you can use TensorFlow, any machine learning or deep learning libraries and just build something that works. You're not going to get like a 1690, 120 frames per second vision system, but you're going to get your 10, maybe 15, maybe 20 FPS if you're lucky, web interfaces. Try to code a web interface in C++, it's painful. It is painful, but fun part. Python, flash, Django, bottle, pyramid, all these kinds of neat things are super cool and super offensive. So as I said, deep learning and machine learning, state machines, if you don't know what state machines are is as predefined actions with input and output. Most of the state machines software are based in Python. And that's just for the fact that we can extend it easily and just be able to run it action servers, you need to build a wrapper. As an example, we have a Kinova arm, just the motors, we build the rest out of scratch because we have some fun times to do. So we build an action server between our arms. So our arm actually gets called and then everything is translated to C++ codes. Everything is exposed as a Python API. When not to use Python. These are things where you shouldn't use Python, real-time systems. Because of how the global interpreter lock, you can't really do real-time systems, as you would with C++. Anything related to movement is not a good idea to do in Python. Anything that is super computational and needs to react. It's not really designed for that. Navigation and mapping, almost everybody that does navigation and mapping are using C++ and not Python, just because you need to multi-thread a lot of things. Safety systems, emergency stop, bumpers, sensors that are needed to be fast response time are not going to be coded in Python. What if I wanted the best of both worlds? What if I tell you, you can use Python and C++ in the same robot? This leads on to our next point, which is frameworks. My favorite framework to use in robots is ROS, which is a robot operating system, which was designed in World Garage in around 2008. It has some limitations, but what you can do is build nodes with messaging passing, so publish a subscriber, action servers, services, so you can just build your robots out of Lego blocks. Each Lego block can be a mix of Python, C++, or lists, which means you can get your performance out of C++ and get your easy to use in a Python node. This is used by most of the robots. It's fully open source, which is fun for people doing research, doing cool robots, so you can share anything you do. The next one is Naoakea, which is the Nao SDK. If you ever see the Nao, it's a little red one. The next one is this big brother, the pepper. They both have binding in C++, Python, JavaScript, Java, all the fun languages. The thing is, it's closed source. It's not really useful if you're doing something that needs to interact with multiple things, but it's still one of the frameworks that most people are going to learn if you're going to university, because it's more easy to have a robot, but it is a platform restricted. It's closed source and not really fun. If you look at the photo, the robots look drunk. During one of the times I was in RoboCup, I was doing a night watch and I found those robots in that position. They look super drunk, but what the team did is they shut the robots off because it's going limp. They just put it on one other end. They were joking about it. But when it's like 4am and you stumble onto this, but almost no light, it's super creepy. Here's a conclusion. Here's one of the videos. I found it funny. It did this like two weeks ago, which is my cat decided to go into the shelf and she's like, what is this? What is this thing? I do not put her there. She went there by her own free will and when it came down, we decided to get the robot to go get her. This is what you do when you have a $50,000 arm just sitting around. You just open doors with it and scare cats away. Where did you find me? I'm on GitHub. This is my GitHub ID. I do robotics. I do web. I do almost anything and I super love Python. There's also my email. If you want to shoot me an email about anything robotics, I usually answer quickly. That's it. Any question? That is actually a good question because in the Rust community, drones are not considered robot as like a first class citizen. What happens is there is because the way it says it's an open source, everybody contributes to it. There is stacks for navigation for drones, but they're not as developed as land robots. But yes, I do consider drones as a robot. I am kind of a drone enthusiast, but they're not my main area of what I do with robots. Can you repeat that? What is circuit Python? What is circuit Python? I've seen something in the MicroPython. I think like recently like popped up. I haven't looked at it. I haven't like really dug into it, but it sounds pretty cool to be able to use Python in an embedded circuit.