Latest / Talk Python To Me / #7: Robot Operating System (ROS) and ROSPy
Transcript
- 0:00Talk Python To Me, episode number seven, with guest Dirk Thomas, recorded Monday, April 27th, 2015.
- 0:08Hello and welcome to Talk Python To Me, a weekly podcast on Python.
- 0:38The language, the libraries, the ecosystem, and the personalities.
- 0:42This is your host, Michael Kennedy.
- 0:44Follow me on Twitter where I'm @mkennedy and keep up with the show and listen to past episodes at talkpythontome.com.
- 0:52This episode, we'll be talking to Dirk Thomas about the robot operating system ROS and ROSPi.
- 0:59Before we get to Dirk, I have a couple of news items.
- 1:03Top of the queue is a huge show announcement.
- 1:06We have our first long-term sponsor of the show.
- 1:09I'm happy to tell you that Codeship is now the premier sponsor of Talk Python.
- 1:14Codeship is a platform for powerful continuous integration and continuous delivery as a service.
- 1:20I'll talk more about them later in the show, but please take a moment and check them out at codeship.com
- 1:26or follow them on Twitter where they're at codeship, C-O-D-E-S-H-I-P.
- 1:31And if you love this podcast, please send Codeship a message to say thank you.
- 1:36Jump on Twitter and say something like,
- 1:38Thank you, at Codeship, for sponsoring the Talk Python podcast.
- 1:42You rock!
- 1:43Or however you want to say it.
- 1:45Next up, timestamps.
- 1:47Several listeners have asked for something like an outline with timestamps so they can go back into the show and look up topics.
- 1:53It's a great idea, but I'm taking that to the next level.
- 1:56I intend to have full-text, searchable transcripts for the shows, which of course include timestamps.
- 2:03Only a couple of shows have transcripts so far, and I'm adding them as fast as I can.
- 2:08Check out episode number four on Enterprise Python or episode number five on SQLAlchemy
- 2:13and click the full transcript button to the right to see what I'm talking about.
- 2:17I think you'll find it really useful.
- 2:19Special thanks to Mark Weimer for recommending a show on RossPi.
- 2:23We probably wouldn't have this show that you're listening to right now without you, Mark, so thanks a bunch.
- 2:29There are comments everywhere.
- 2:32I've added a comment section to every show on our site.
- 2:35So now, in addition to using @talkpython on Twitter or just emailing us,
- 2:39you can send us feedback via the Discus comment area at the bottom of each show,
- 2:44and I've already received some great comments that way.
- 2:46Finally, I have created a Twitter list aggregating all the tweets from all the guests who have been on our show.
- 2:53Visit Talk Python on Twitter, choose the View Lists option, and subscribe to the show underscore guest list.
- 3:00There you'll find the Twitter stream from all the guests who have been on the show, and of course, that list will be growing over time.
- 3:06You can also find the link to the list on our homepage.
- 3:09Wow, what a week.
- 3:11Now, let's get on to the interview with Dirk Thomas.
- 3:15Hello, Dirk.
- 3:16Welcome to the show.
- 3:16Thank you for having me.
- 3:18Yeah, I'm really excited to have you as a guest.
- 3:21We've had some what I would consider mainstream developer topics so far, and we have more coming up.
- 3:27Of course, they're mainstream, so we'll probably have a lot of them throughout the show.
- 3:31But I'm thinking of things like web frameworks, data access libraries, Pyramid.
- 3:35We're going to do a show on Flask.
- 3:37A show on SQLAlchemy is coming out pretty soon.
- 3:41And what we're going to talk about today is a little bit different.
- 3:44It's a little more edgy, and I think it's something that so many people that go into software development,
- 3:51maybe it's the reason they got into software, and then they got drug over to the financial section
- 3:55where they're building reports out of databases or something like that, which is robotics.
- 4:00Yeah, that's a very great project because robotics in general is, I think, more interesting than classic software engineering
- 4:08because it's just much more hands-on, and you have real results which you can try
- 4:12instead of the big business projects.
- 4:14Absolutely.
- 4:15And I think one of the things that is sort of representative of that is I do a lot of work with schools and training.
- 4:22I do professional training for real developers, but I also help my kids' schools out with after-school projects and stuff,
- 4:29and they very rarely want to write a financial trading system.
- 4:32They're more like, how do we build a robot?
- 4:33How do we build a game?
- 4:34And so you're really involved with this thing called ROS, the Robotic Operating System,
- 4:40and we're going to talk about that for this show.
- 4:41Before we get to it, though, I think the listeners are really interested to hear
- 4:45kind of how everyone who's gotten to some really cool place contributed to some great project.
- 4:49Well, how did you get started?
- 4:50What's your background?
- 4:51How did you get into Python?
- 4:52So basically my background is I started computer science at the university
- 4:56because I liked computer.
- 4:59I liked programming.
- 5:00Of course, I liked games at that time.
- 5:02So I thought computer science, that's like a nice thing to do.
- 5:05And at the university, you learn a lot about languages and algorithms
- 5:10and a lot of like technical background.
- 5:13But we also had projects at the university which were more hands-on.
- 5:17And one of the big ones was RoboCup where you play like soccer with the robot.
- 5:22And you try to make the robot play soccer on its own.
- 5:26So you're not like steering him with a joystick but make him like autonomous.
- 5:28And that was a really interesting project.
- 5:31And that's how I got into robotics in the first place.
- 5:33And what languages did you use to teach the robot to be autonomous?
- 5:37Yeah.
- 5:37So usually a lot of things in robotics, if they're like the algorithms which do like C objects in the camera and make decisions,
- 5:45a lot of those things are like in C++ classically.
- 5:48Of course.
- 5:49But C++ is like a good language for doing like the lower level languages where you need a lot of libraries
- 5:56which are only available in that language potentially.
- 5:58Or you need like things which need to be really fast.
- 6:01But for other things, when you do like put things together, like the glue making the overall system work,
- 6:08that might not even require like really fast code or something.
- 6:13And then something like Python comes in more handy because you're just much more efficient in writing code and putting things together.
- 6:19Right.
- 6:20It's more about understanding what you build than it is building, you know, shaving that millisecond or microsecond off there.
- 6:24Exactly.
- 6:25Yeah.
- 6:25Especially if you think about like user interfaces or when you start the robot to determine which parts to start and how to configure them.
- 6:32Those are not time critical.
- 6:33So you want to be like as fast as possible developing them.
- 6:37And it doesn't need to be like that fast at runtime.
- 6:40Perfect.
- 6:40So you started working on these robotics projects.
- 6:43And they were in C++.
- 6:44And somewhere along the way, you're like, all right, enough C++, Python.
- 6:48Where did that happen?
- 6:49Yeah, that was actually an interesting project.
- 6:51We had like a graphical user interface to like do all the controlling of the robot and look into the state of the robot to see what it's currently doing and changing like plans.
- 7:01And we started because the rest of the software was in C++.
- 7:05We're all familiar with it.
- 7:06So we started with C++, of course.
- 7:09And then we figured out that like for a graphical user interface, you want to be really fast and developing new things to interact with the robot.
- 7:15And I tried to like look at different languages.
- 7:19And with some coworkers, we looked into Python.
- 7:22And I tried first, actually, a C++ user interface, which was able to run like parts of it in Python.
- 7:30So that was my first contact with Python.
- 7:33Very nice.
- 7:34So maybe you could give us a little bit of an overview of what the robotics, the sort of where Python is being used throughout the robotics industry.
- 7:43Oh, yeah.
- 7:44So especially in the robot operating system, which we work on at the Open Source Robotic Foundation, it is usually like twofold that you have a lot of code in C++ on one hand.
- 7:55And on the other side, you have a lot of code in Python.
- 7:58And usually you decide like which one is better for the part of the work you're doing.
- 8:04And while there are many language bindings for different languages, those are the two common ones.
- 8:09And Python especially is used for, for example, writing command line tools because they are very easy to write.
- 8:18They are really fast to develop.
- 8:20And you don't need like features which are specific to C++ at that point.
- 8:27And also on the user interfaces, a lot of user interfaces are mostly based on Python.
- 8:32Sometimes you use some C libraries if you need to access some other libraries which are not available in Python.
- 8:38But, yeah, all those kinds of like glue code to put things together to make a bigger system, those are usually relying on Python in our cases.
- 8:48Sure, that makes perfect sense.
- 8:50Like when you're down talking to the serial port or the hardware interrupt, maybe Python is not the right choice.
- 8:55But once you have that in place, you do the higher level logic, the sort of orchestration with Python, right?
- 9:00That's actually a really interesting problem.
- 9:02If you think about like serial communication, you would think like serial communication, very low level.
- 9:08Like C, C++ is the most fitting language for that.
- 9:12Sure.
- 9:12But if you try like implementing a little communication over USB or like a serial link, actually in C++ that gets really tedious.
- 9:22It's like a lot of work, a lot of cases to consider, and you have to do a lot manually.
- 9:27Python is really well suited for that because you're not dealing with a lot of data because serial is usually like low bandwidth.
- 9:34And the latency is also usually not an issue.
- 9:37So actually writing data to a serial port or reading from a serial port, I probably would choose Python for that.
- 9:43That's really interesting.
- 9:44I wouldn't have guessed that, but I guess it makes sense.
- 9:47That's cool.
- 9:47So you're associated with the ROS project, the robotic operating system at ROS.org, ROS.org.
- 9:55Maybe we should talk about that for a little while.
- 9:57Yeah.
- 9:58So when I first started at the university, we were just working on our own little software, you know, like you want to develop it yourself to learn.
- 10:06But in the near future, we noticed that, well, it just is better to reuse something which already exists.
- 10:14And the robot operating system has been started like seven years ago at Willow Garage.
- 10:19And they developed it for a very huge humanoid-like robot.
- 10:25It's like a robot on a mobile platform with two very complex arms and a head with like different camera systems.
- 10:31And ROS was basically just the outcome of trying to use this robot and make it usable for different researchers.
- 10:41So it was not the first goal to develop the software, but first they developed the robot, and then they developed the software for the robot, basically.
- 10:48That's interesting.
- 10:49So it was almost, you know, extracted from the construction of the robot and the needs that they had.
- 10:56Yes.
- 10:57So basically, that was the first application.
- 10:59And seven years later, we still have like things in the software which are like basically designed and evolved based on that robot.
- 11:08So later on, more robots came into the game, and we tried to support more of them and different variety of things.
- 11:14But you see a lot of design decisions in the system are just based because they were like developed for that first robot.
- 11:19So you're also working on this thing called ROSPi, which is part of the ROSCon or communication project on GitHub.
- 11:27What's the relationship between those two?
- 11:30So basically, ROSPi is like many things at the same time.
- 11:34On the one hand, you have the communication system, which provides you like communication patterns like publish, subscribe, or service response, which are very common ways to communicate between components.
- 11:46This is like the low-level like communication functionality of ROS.
- 11:52But then there is like, and ROSPi is one of those.
- 11:55So ROSPi is basically the Python implementation of this communication primitives.
- 12:00But ROS provides more than just the bare communication.
- 12:05There's on the one hand a lot of tooling.
- 12:08So you have a lot of tools to help you develop software for robots.
- 12:12You can introspect the state of a robot.
- 12:14You can change things at one time.
- 12:16Additionally, besides these tools, you have a lot of visualization.
- 12:20Developers around the world write applications and functional components, capabilities, for example, to make a robot be able to navigate, make a robot be able to recognize objects with a camera.
- 12:36Excellent.
- 12:36So there's like a simulator or something.
- 12:38Is that right?
- 12:39Oh, yeah.
- 12:39There's also the option for a simulator.
- 12:42You can actually use different ones.
- 12:44But one of the most common ones is Gazebo, which is used to try your software with a simulated robot before you actually run it on the real robot.
- 12:53Okay.
- 12:54So could I actually build and have a virtual robot before I even touch a piece of hardware and then decide, okay, now I'm ready to go in and actually get the hardware?
- 13:02Yeah, absolutely.
- 13:04And that's the big advantage because you don't want to spend the cost of the hardware first.
- 13:08And then you figure out, oh, well, that's actually not good for a certain use case.
- 13:12So you want to try that out before.
- 13:13So the simulation allows you to rapidly prototype a certain design of your robot and iterate on that one.
- 13:20You can make it run the same kind of code to drive around and pick up objects.
- 13:25And if you're not happy with the geometry of your robot, you can change it and iterate on it over time.
- 13:31And when you're happy with it, you actually go to the hardware.
- 13:34Now let me take a minute and tell you about our sponsor for the show, CodeChip.
- 13:48CodeChip is a hosted continuous delivery service focused on speed, security, and customizability.
- 13:54You can set up continuous integration in a matter of seconds and automatically deploy when your tests have passed.
- 14:00CodeChip supports your GitHub and Bitbucket projects.
- 14:04You can get started with CodeChip's free plan today.
- 14:08Should you decide to go with a premium plan, Talk Python listeners can save 20% off any plan for the next three months by using the code TALKPYTHON.
- 14:17That's T-A-L-K-P-Y-T-H-O-N, all caps, no spaces.
- 14:24Thanks to CodeChip for sponsoring the show, and I encourage you to check them out right now at CodeChip.com and thank them on Twitter where they're at CodeChip.
- 14:31So you mentioned some other tools.
- 14:37Like when I was looking through the project, I noticed there's one called RViz and one called RQT.
- 14:43Oh, yeah.
- 14:44So these are the two most commonly used user interfaces to interact and look into a robot and control it.
- 14:53RViz is the older software.
- 14:56It's like the more mature one.
- 14:57It has more features.
- 14:58It provides you basically with a 3D scene of the environment, and your robot can move in this 3D scene.
- 15:06So you have a CAD model, for example, which you can import as like a mesh of the robot.
- 15:12And the robot can actually drive through an environment which you can render.
- 15:18And, for example, if you see a camera image from the robot's head, it can project this image into the scene as the robot sees it.
- 15:29So it's very, very good for the user to get a feel what the robot currently sees and what his information about his world is.
- 15:36That's really cool.
- 15:37So it's like a 3D environment, and it basically sets the viewport of the 3D simulator to be where the camera would be?
- 15:43Exactly.
- 15:43And you can actually put multiple viewports in there where you have multiple views on the same scene.
- 15:48Or you can render all the sensor information the robot has.
- 15:52So if he has a laser in the base, you can render the laser scan itself, and you see how good does it fit with the walls where they actually are.
- 16:01And you can, for example, render a path where the robot plans to go next.
- 16:06It's very good for you to get a sense of why the robot is doing something, because the more complex it gets, the more difficult it is for the developer to follow what's actually going on in the system.
- 16:17Yeah, and you said there's some debugging capabilities that can let you capture those messages and that data flowing in and replay it and stuff, right?
- 16:24Yeah, so that's another feature for us in general, that since you try to decouple your logic into different components which communicate over messages,
- 16:34you can record all those messages and later look at them or play them back.
- 16:39And that helps to figure out problems which happened on a robot like yesterday.
- 16:44But if you have the information written down to the log file, you can actually introspect the problem from yesterday and actually try to reproduce it, for example, in simulation.
- 16:54And that helps you, like, actually fixing things which are really hard to debug otherwise.
- 16:59Yeah, it sounds like it'd be really hard to set a breakpoint on, like, a live robot moving around.
- 17:03But maybe you could do that on the simulator if it was, you know, getting the same sort of inputs or something, right?
- 17:08Exactly.
- 17:09With a simulator, you're able to reproduce it.
- 17:11And you're not even able to do a breakpoint, actually pause the simulator and then change something in the debugging code and continue.
- 17:19But you're actually able to, like, change your code and run it against the same laser information, for example.
- 17:25And you can ensure that now with your changes, it's fixed.
- 17:29With a live system, you have a hard time doing that.
- 17:31Yeah, the reproducibility part of it sounds really hard.
- 17:34So that's fantastic.
- 17:35Yeah.
- 17:36And the second part you asked about, that was RQT.
- 17:39It's basically a different approach than Arvis.
- 17:41So they are both, like, serving a little bit different needs.
- 17:44And RQT is where a lot of Python comes in, actually.
- 17:48Because Arvis is mostly based in C++.
- 17:50It has some ability to run Python plugins.
- 17:54And RQT is the other way around.
- 17:56RQT is like a Python application, which has the option to run, like, C++ plugins if you really need, like, the logic, the power of C++.
- 18:07And RQT is not built around, like, a 3D environment.
- 18:10It's more like a, I would say, like a development environment where you can add different things.
- 18:16So we have plugins which visualize, for example, just single numeric values over time, like a function, like a controller or a distance to an object.
- 18:26Or you can visualize images just as a plain 2D image.
- 18:31And you can look into all the communication which is going on.
- 18:35So it's more like a kind of tool set the developer can use to look into certain things and have that all in one powerful environment.
- 18:42Very nice.
- 18:44So Arvis is kind of the simulation bit.
- 18:47And RQT is more like setting it up and debugging it, maybe.
- 18:52Yeah, almost.
- 18:53The Arvis thing, though, does not do real simulation.
- 18:57It only shows you the current 3D state.
- 18:59It does not, it doesn't do, like, physics-based simulation or something.
- 19:04That would be, like, a similar external tool then.
- 19:06Right.
- 19:07Okay.
- 19:07Fantastic.
- 19:08You know, mostly I touch computers through software.
- 19:12So the hardware parts are a little unknown to me.
- 19:14Like, if I've got servos and hydraulics and stuff, like, what do I put together to put ROS on?
- 19:22Do I have, like, an embedded Linux in my robot?
- 19:24Does it run on other types of things?
- 19:26Where do I install the robot operation system?
- 19:29It completely depends on the use case.
- 19:31There's such a variety.
- 19:32For example, the PR2 robot from Willow Garage I mentioned earlier is, like, this huge robot.
- 19:37It has, like, two I7 multicore machines.
- 19:41It's, like, a heavy beast, I would say.
- 19:43It does a lot of things, but it's, like, it's very powerful.
- 19:46On the other end, you have, like, really small, like, Adreno-based ones or Raspberry Pi-based computers, which just have a connector to, like, motors or sensors.
- 19:57And that's totally enough to do, like, smaller projects.
- 20:00So it all depends on your use case.
- 20:02And some of the microcontrollers, depending on what you use, very common is the Linux version, the Linux distribution Ubuntu.
- 20:12But people have run it on various different other systems.
- 20:16So we are very flexible in that term.
- 20:19That's really cool.
- 20:21There's a lot of functionality here.
- 20:22Is this something I would consider using for, like, a toy, or is it only really for, like, professional use, or is it kind of more general?
- 20:29Would it make sense in a lot of places?
- 20:31So that's actually the difficulty of the project, I would say, since it's an open-source project and many people contribute to it.
- 20:38You have a large variety of people trying to use the system.
- 20:42So on the one hand, we have the hobbyist who tries to, like, just put his, like, Raspberry Pi and a couple of motors and sensors into a small robot, like a toy,
- 20:51which just, as, like, kids or teenagers, just trying to, like, make it, like, drive around, avoid obstacles, and that's, like, a great project.
- 20:59And on the other hand, you have developers which really use that on, like, product-level, like, robots, which are, like, car-sized robots,
- 21:08which drive around, for example, on a field for farming.
- 21:12And they have to drive reliable.
- 21:14They have to drive autonomously.
- 21:16They have to be, like, if something goes wrong, they have to, like, have fail-safes.
- 21:20So you have the whole spectrum of, like, kind of users which use the system.
- 21:23Wow.
- 21:24I suspect that presents some design challenges architecturally in the software, right?
- 21:29Like, on one hand, you want to make it so kids can, like, build little fun robots.
- 21:33But the requirements for a real thing that could run someone over, those are different.
- 21:38So what's the tension like there?
- 21:41Oh, the tension is definitely that it's really difficult to, like, satisfy, like, everybody in the community.
- 21:46So you have, like, very different demands in terms of, like, the people who want, like, that for a hobby project.
- 21:52They want a very lower entry barrier.
- 21:54They want, like, really easy tutorials.
- 21:56A lot of people are not software engineers which, like, look at those things and try to build, like, their small robot at home.
- 22:03They're, like, eventually mechanical engineers or probably even not that, but might be teenagers just trying to play with it, right?
- 22:12So it's really difficult to bridge that whole area of users.
- 22:18And I would say there are a lot of design challenges.
- 22:21So one example is when it was originally developed for the PR2, it was meant for, like, researchers, for, like, developers who knew, like, what they tried to achieve.
- 22:36And if it didn't work, it was fine to just, like, restart, right?
- 22:39So if the experiment didn't work, you just, like, control C everything and restart, restart the camera for the video for your presentation.
- 22:46And you try again.
- 22:48That was totally feasible at that time.
- 22:50But if you have a robot, for example, Ross also runs on the Robonaut 2, which is on the ISS space station.
- 22:59That's amazing.
- 22:59So at that point, you probably have a harder time, like, retrying things over and over.
- 23:04You want some kind of deterministic behavior.
- 23:07And these are still things where Ross needs to improve in the future.
- 23:12So we're always working on, like, making it more suitable for, like, production-level software that you can actually rely on it and can sell the product and don't have to worry about it ever going wrong.
- 23:24But that's definitely an ongoing effort to make it more solid in these domains.
- 23:28That's really cool.
- 23:29I'm sure it's a challenge, but it probably also makes it a better thing in the end.
- 23:33Oh, yeah.
- 23:33I mean, the more use cases your software has, the more flexible it gets.
- 23:38We often get, like, you know, a totally different operating system, which we don't even have in our office.
- 23:49We can't even test it.
- 23:50So we rely on external people, which use it on their systems to contribute back and make it more usable in different scenarios.
- 23:57Wow, that's amazing.
- 23:59So maybe we should talk a little bit about the core components.
- 24:04Like, what is Ross meta before we talk about more how PyOnton's working there?
- 24:08Yeah, so the core components for the communication.
- 24:12So first of all, the system encourages the developer to split functional components in separate pieces.
- 24:21So if you think about something which, a component which reads the camera image, and then a component which extracts from the camera image a certain feature where it wants to drive to,
- 24:33and then the actual planning where to drive to, and then the component which talks to the motors and actually maps the drive command to a real action in the world.
- 24:45And the system tries to, like, keep those things separate.
- 24:49And this abstraction on the first level allows the developer later to swap out a certain thing with a new implementation and try them out.
- 24:58And that's where all this communication infrastructure comes in, that every component talks to other components by exchanging messages.
- 25:08It's like a data-centric approach.
- 25:11Right, and these are asynchronous messages.
- 25:12You kick them off, and then eventually maybe a new message comes back for you or something like that.
- 25:16Yeah, so most of the times they are asynchronous.
- 25:18There are times when you can do synchronous request response and you wait for the answer.
- 25:22But this is something you usually want to avoid because maybe the answer comes in, like, two minutes.
- 25:27That's probably not how long you want to wait.
- 25:29So writing your code in an asynchronous fashion is usually the preferred style, yes.
- 25:34Excellent, and Ross really encourages that with its APIs and so on, right?
- 25:38Yes, so if you look at the PR2 robot,
- 25:41it runs, I think, roughly 150 processes in parallel, and they all talk to each other.
- 25:46And as long as you remove one of the components, which has a certain interface on a message level,
- 25:54it receives certain messages on a so-called topic, basically a named bus,
- 25:59and it responds on another topic.
- 26:02If you replace it with a different component which has the same kind of interface,
- 26:06nobody will notice as long as you, like, produce similar results.
- 26:10That's really excellent.
- 26:12I'm sure it's good for, you know, testing or adapting or maybe even trying different pieces of hardware in your robot, right?
- 26:19Yeah, exactly.
- 26:20So that's another big strength of the size of the community because so many people use the software,
- 26:26that if you have, like, a set of cameras, for example, or motors,
- 26:31then somebody very likely has, if it's used in other robots,
- 26:35then somebody very likely has already implemented the driver's side of it
- 26:39and make it a ROS component that you can just send it a ROS message,
- 26:43you drive forward with that speed, and the motor will do it,
- 26:48and you don't have to take care about how it actually maps to the protocol of that motor
- 26:52and how it communicates over serial.
- 26:54It's all hidden and abstracted from you.
- 26:56So these nice little building blocks are kind of there,
- 26:58so you're almost ready to start using the Python stuff to just orchestrate that.
- 27:02Exactly.
- 27:03And that's where Python is very strong at, the orchestration part.
- 27:06For example, we have a tool which is called ROS Lounge,
- 27:09and it's basically a description in an XML file which tells you what kind of software
- 27:15and programs you want to run at the same time and how they talk to each other.
- 27:18And all this, like, orchestration happens in Python because it's just,
- 27:22it's way easier and faster to write, and you have the power of, like, dynamic language
- 27:28where you don't need to know all the types at compile time.
- 27:31It gives you a lot of, like, power over, like, static and compile languages.
- 27:36So another strength of the core building blocks seems to be around geometry, right?
- 27:40Like, that's got to be a real hard problem.
- 27:42I've got all these moving parts to my robot.
- 27:44Maybe it's got an arm and it's got wheels and it's moving around.
- 27:48That's hard.
- 27:49So there's support for modeling, that kind of stuff, right?
- 27:51Yeah, exactly.
- 27:52So if you think that you receive a camera image and in the image you see a certain object you want to grasp,
- 27:59then you don't really know yet where that object is because you don't know without any further information
- 28:06where your camera was when it took the picture.
- 28:09So one thing which the robots usually keep track of is, like, first, their location in a known environment.
- 28:16So it's usually, like, the base where your robot stands or where your wheels are.
- 28:21But then you know all your joints and your arms and your head and neck, how all these, like, joints are oriented.
- 28:28And then you can build up a transformation to where your camera is.
- 28:31And to do that, like, in a very easy way, there's, like, packages which support you with that.
- 28:38Like, geometry is one.
- 28:39There's another one called TF for transform.
- 28:42It can basically transform, if you see in your camera, in the middle of the camera, in a meter away, a certain object.
- 28:49You can transform how far is that away from my left hand, for example.
- 28:53So you can do all these computations very nicely.
- 28:56That's cool.
- 28:57I bet there's a lot of matrix multiplication going on in there, right?
- 29:00Oh, yeah, for sure.
- 29:02And that can get really difficult.
- 29:04And depending on how complex your robot is,
- 29:06you have to be careful setting up the kinematic and the computation
- 29:11that it's, like, actually, like, fast.
- 29:12Because you probably are not interested in every joint of your robot.
- 29:15It's probably fast, fine enough if you only know a certain amount of them.
- 29:20That's math you want to just put into a library and forget.
- 29:23Exactly.
- 29:24Because not everybody wants to write and see that stuff.
- 29:26That's right.
- 29:27So I actually have a couple of questions from some listeners
- 29:30who sent in some messages or questions for you.
- 29:33So one of them was,
- 29:35what's the process of writing and deploying your own packages using Rospy?
- 29:40Oh, so that's another interesting question for Ross in general,
- 29:45because we don't only provide the software.
- 29:47There's a lot of infrastructure because we have this federated approach.
- 29:50Everybody contributes a package.
- 29:52And I think the latest Ross release has, like, about 1,500 packages,
- 29:57which we build for people into Debian packages,
- 30:00because also nobody wants to deal with, like, creating a Debian package manually,
- 30:04if you can avoid it, because you really don't care how the internals work.
- 30:08And so we also make this packaging process very easy.
- 30:12So if you want to write, for example, a simple package which does a certain task,
- 30:17you just create a repository somewhere.
- 30:22You want to share your code.
- 30:23A lot of our code is on GitHub, but that's not, like, the only platform.
- 30:27You can put it, like, anywhere else.
- 30:29You have to be able to build your package.
- 30:33Usually, if it's Python, you have a setup.py file.
- 30:35Additionally, we have an XML file describing, like, meta information,
- 30:42like what's your package's name, what's the license,
- 30:44because people want to know if they can use your code or not.
- 30:47What's the maintainer?
- 30:49Does he have an email address which I can, like, talk to?
- 30:51Is there a website which contains more information?
- 30:55And also very important, what kind of other packages do you depend on?
- 30:59And then, besides those meta information, it's all about your code.
- 31:03So you put your Python code in there.
- 31:05And after that one, you just go to our, like, website.
- 31:09And there is a process how you can tell us that there is a repository with a ROS package.
- 31:13And if you give us the location and we can access it, so it must be publicly readable,
- 31:18then we can actually, like, provide that information to others.
- 31:21And we can potentially even build, like, packages out of that.
- 31:24And people can easily reuse it.
- 31:26That's cool.
- 31:27Is there, like, a central repository, kind of like PyPI with Python packages?
- 31:32Yeah, that's kind of it.
- 31:34But we don't separate them by language.
- 31:36But there is a so-called repository called ROS Distro.
- 31:39And that one defines repositories, external ones, where ROS packages are.
- 31:45And there's, like, basically, I would say, like, two classes of packages.
- 31:49There are the ones which are, like, released in terms of that we build, like, Debian packages out of them.
- 31:54Or Fedora RPM packages.
- 31:57Or whatever platform you want to imagine.
- 31:59OS X is also one thing where we actively support people to build their code on.
- 32:05And, yeah, you just have to register in this, like, it's basically a huge YAML file.
- 32:10And you register your repository with a name and the URL.
- 32:13And you can specify which branch it's coming from.
- 32:16And after that one, anybody can use on his computer, like, a command similar to PyPI.
- 32:21But it's a ROS-specific one which says, like, hey, give me the repository for the repository foo.
- 32:26And it pulls down the information.
- 32:28You can just either build it, if it's C++ code, if it's Python code, you can basically just run it.
- 32:34So you talked about licensing.
- 32:35And some of this, I'm sure, is open source, probably a lot of it.
- 32:39Is there, like, a commercial ecosystem?
- 32:41Are there companies that, like, build these packages and sell them?
- 32:45That's a very good question.
- 32:46I can't say for sure because the community is so big.
- 32:48But I'm not aware of companies which sell, like, packages.
- 32:51But there are definitely companies which use, like, the open source core packages, which are available.
- 32:59And they build their own proprietary software on top, which they are free to do because most of the packages is licensed under BSD.
- 33:06So we actually encourage people to build, like, commercial software on top.
- 33:10And then they use these proprietary packages either to sell their products or use it only for their in-house robots, depending on their use case.
- 33:20So another listener question is, says, is there a time where we can build ROS nodes without Katkin make?
- 33:27When using ROSPy, they don't really feel that it's super Pythonic.
- 33:31Oh, that's a good one.
- 33:33So classically, in the very beginning, we had a tool called ROSMake, which was basically a make file, and it built the whole process.
- 33:42And, like, two years ago, two and a half years ago, we introduced a new build system, which is called Katkin, which is based on CMake.
- 33:52So CMake calls Python setup.py install, which is definitely not very native for a Python developer.
- 34:00So for the current system, what I would call ROS1, which is currently ROS Indigo, we name them, like, in alphabetic order, like a lot of other projects.
- 34:10There will be ROS Jade soon.
- 34:13But for those things, we might not touch that because a lot of these changes will affect a lot of users.
- 34:19And updating our tutorials and teaching the whole community to change their workflow is really difficult.
- 34:26We learned that when we deployed the new build system, Katkin, like, two and a half years ago.
- 34:31And we would not go for a change in the new future again, I would say.
- 34:35Yeah, it's too much infrastructure and support knowledge around it to change it, right?
- 34:40Exactly.
- 34:41But we always work on, like, new stuff.
- 34:44And that's currently one thing we focus on.
- 34:46It's called ROS2.
- 34:47It's basically we have learned a lot in the last seven years.
- 34:50And we know that there are certain things where we have to make the system more flexible and more capable,
- 34:57especially if you think about, like, really small systems like microcontrollers.
- 35:02That's something we currently don't support very well.
- 35:04Because of early design decisions, we use XML for some RPCs.
- 35:09And generating XML on a microcontroller is really, like, not something you want to do.
- 35:13That made sense, you know, seven years ago, probably, when XML was the thing, right?
- 35:19Yeah.
- 35:19And you had two i7s in the first robot, so they didn't care.
- 35:24But now you have, like, Raspberry Pis and really smaller microcontrollers where you want to run stuff on.
- 35:28And on the other hand, you have people who want to ship their robot, like the vacuum robot or their lawnmower,
- 35:34which just works 100% of the time out of the box without ever a developer touching it.
- 35:40The user can just use the product.
- 35:42And for those things, the requirements are very different than the first systems ROS was built for.
- 35:48And so we currently work on the next thing called ROS2.
- 35:53And for this one, we actually think about and have some prototyping which have a pure, what you would call pure Python package.
- 36:01It contains of the meta information, an XML file, because you still need, like, a coherent way to, like, describe your package.
- 36:08Like, I don't know, like, other languages have the same thing, like manifest file, basically.
- 36:13And beside that, you only have to set up the Py file, what you would expect.
- 36:17And there's no, like, CMake around because you don't want to have, like, you don't need CMake to build a Python package.
- 36:23Absolutely.
- 36:24And then you also gain back features which the previous system didn't have.
- 36:29For example, you could only use a very limited set of the setup.py functionality.
- 36:33For example, like a C extension was really difficult to do because our system just, like, didn't allow you to do that.
- 36:41But with a pure setup.py file, you can use the full power of whatever, for example, setup tools gives you to build your package.
- 36:49That sounds fantastic.
- 36:50So when's ROS2 planned?
- 36:53That's always a good question.
- 36:54Of course.
- 36:55I would say it's going to be shipped when it's ready.
- 36:58But we aim to release a first version in this summer.
- 37:03But due to the scope of the project, it might not be something every user wants to switch over immediately.
- 37:10It will be something which developers are interested in to see the new features.
- 37:14And if they want to try it out and see how it fits their applications.
- 37:19But it will take a long time for the majority of the user base to migrate.
- 37:24So we don't plan to replace the original system with a new one.
- 37:29It will be more a coexistence.
- 37:31You can still use the old system.
- 37:32It will be maintained.
- 37:33And the new system will give you changes, but also more features and functionality.
- 37:38And it's your choice when you want to adopt the new thing.
- 37:42That's cool.
- 37:43What kind of features are coming?
- 37:44So that's actually a lot of things.
- 37:49All right.
- 37:49What are the highlights?
- 37:50The highlights.
- 37:51Let me think about it.
- 37:52So the first thing is the new system uses a completely different communication system under the hood.
- 37:58For the first version of ROS, we developed everything from serialization,
- 38:03messages to the TCP transfer, UDP transfer, everything from scratch.
- 38:08Because seven years ago, there was not that great library support for that.
- 38:12But, yeah, time has changed.
- 38:14And for the new thing, we actually rely on a standard from the OMG, which is called DDS,
- 38:20the Data Distribution Services.
- 38:21And relying on that gives us a lot of functionality without having to reimplement it from scratch.
- 38:28And built on that system, we can provide you with much better support for,
- 38:33for example, deterministic startup, reliable delivery of a message.
- 38:37We can tell you your message got delivered, or we will give you an event like a callback and tell you that it has not.
- 38:44And you can tune how often you want to retry it and things like this, which matter in a bigger system.
- 38:51I could probably fill a whole podcast about the features of ROS 2, which will hopefully be better than ROS 1.
- 38:57For example, one of the interesting things is ROS 1 always focused on Linux support, so Ubuntu.
- 39:03There are a lot of versions where you can build it on Fedora and Pure Debian and OS X.
- 39:08But one thing which it is not good at is building it on Windows.
- 39:12And this is something we have fixed for the ROS 2 prototypes very early on.
- 39:17So ROS 2 will just build natively in Visual Studio on Windows, the same as on other platforms.
- 39:24So it's really like from day one to support it well.
- 39:27And once you support it, it will be supported in the future.
- 39:30But adding the support later is really difficult.
- 39:33Yeah, because you've got to go back and fix a thousand errors and you've got to rewrite this and that.
- 39:37That's great that you're supporting Windows as well.
- 39:38It's nice to just say, yes, we support everything.
- 39:41There's still a lot of people using Windows for this kind of stuff.
- 39:44Exactly.
- 39:44And currently, they have a really hard time using it.
- 39:46Either they use virtual machines inside of Windows or they try it with Segwin.
- 39:51And there are some tutorials where people make it work.
- 39:54But it's everything but a smooth process.
- 39:56It takes a lot of effort.
- 39:57That's right.
- 39:58Let's see.
- 39:59So I have a couple of sort of larger scale pictures for you.
- 40:03First of all, what kind of robots or automation have you seen using ROS?
- 40:07You said something about the International Space Station, which is just amazing.
- 40:11Oh, yeah.
- 40:12That was actually a really interesting project.
- 40:13The first, Robonaut, which is like a humanoid robot.
- 40:16The first one had only torso and arms and the head.
- 40:20That was not yet running ROS.
- 40:22But the second iteration, which was launched last year, now has legs.
- 40:27So it's more like four arms if you look at it.
- 40:30And that one has a new computer system.
- 40:32And the computer system is completely ROS-based.
- 40:34And I think they made the choice to use ROS because it allows them to really fast prototype new functionality,
- 40:43try them out.
- 40:44And then if that goes well, focus on something they want to make more detailed.
- 40:51And sure, our communication protocol is not the best one to communicate with a space station because that's definitely not designed for.
- 40:58But they just wrapped the whole communication in the VPN tunnel.
- 41:01And that's good enough for them because it's like it's isolated, it's secure.
- 41:06And if our protocol has like 15 seconds or something latency to talk to the space station, that was totally fine for their use case.
- 41:14Probably part of the benefit of the async message passing, not waiting on things and all that kind of stuff.
- 41:19Exactly, yeah.
- 41:19You have to be a little bit more defensive when you write your component to like not embed assumptions in your code, which don't hold in those scenarios.
- 41:29But if you're careful about your code, obviously you can make it work for those cases.
- 41:33Other notable use cases that you can talk about?
- 41:36There are a lot of references of robots.
- 41:39For example, there are a lot of industrial arms where they try to use ROS to do the higher level planning.
- 41:47So classically, the robot in an industrial setting has like this really like tailored embedded controller, which is very robust and has to fulfill a lot of safety requirements.
- 42:02But then you have the really complex behavior to plan a path around obstacles, probably in a dynamic environment.
- 42:11And that's where ROS is very good at.
- 42:13And so a lot of these use cases, they use like the industrial controllers on the lower level and then put ROS on top to do the more sophisticated dynamic environment planning.
- 42:23And of course, there's a variety of vehicles from like small autonomous cars to like platforms in like warehouses to drive around and deliver things, which all rely on like localizing yourself and then autonomously navigating in an environment.
- 42:39How do you see the future of robotics and what role do you think Python and ROS are playing in it?
- 42:46I think ROS has a very bright future in robotics because the community is just very big.
- 42:53A lot of people use it and that makes it grow very well.
- 42:57So it addresses a lot of use cases and makes the things that people want to do achieve more easy.
- 43:04So I think that will continue to grow and just spread into more use cases.
- 43:09For example, quadrotors or things which are currently evolving.
- 43:13The people, when they start these projects, look at what's out there.
- 43:15And a lot of people just choose ROS because it helps them to like get there faster and prototype faster and get their product ready faster.
- 43:23And usually that's to a very big amount due to Python because they can just like rapidly prototype what they have in mind.
- 43:31And later on, if they figure out something is not fast enough or they can still like migrate code to C++ if there's need.
- 43:38But a lot of stuff is not that critical.
- 43:41Yeah, it seems like there's maybe two ways to go faster.
- 43:44One hand is to write something in C++ and ROS directly.
- 43:47And the other is maybe write a C extension for your Python code.
- 43:52Is that a thing that would actually work?
- 43:53Yeah, that's definitely something which works.
- 43:56It's always a matter of like first you have to identify what's really the bottleneck.
- 44:01And in a lot of cases, it's not the Python code.
- 44:04It's like it's more like you have an algorithm which is just like not well structured.
- 44:09And even if you restructure that in Python, you will be already good to go.
- 44:13So it's really like finding the knob which you have to tune and not like just merge your code to C++ and then are not even better because your algorithm has a flaw.
- 44:23Yeah.
- 44:24Sometimes choosing the right data structure like a dictionary instead of a list or something would make all the difference.
- 44:30Oh, yeah.
- 44:31Lookups, right?
- 44:32Exactly.
- 44:32And especially in Python, a lot of things where you like sometimes unintentionally duplicate lists which are big instead of just mutating the list in place.
- 44:42Those things can matter a lot.
- 44:44So before moving code from one language to another, I would always suggest spending a good amount of like debugging and profiling before like making something like that because it's a lot of effort.
- 44:55So it sounds like you guys are taking contributions for your projects and people are working on it.
- 45:00They can find it at github.com/ROS, R-O-S.
- 45:05And then the ROS pie is really in the ROS underscore com repository, right?
- 45:09Yes, correct.
- 45:10And probably the easiest entry point is usually wiki.ros.org because that gives you like the documentation like front end.
- 45:18And from there, you find a lot of links to the repositories with the code.
- 45:23And also a lot of tutorials, especially for the Python part.
- 45:26So that sort of answers one of my other questions is if I've got, you know, a motor and I've got a Raspberry Pi and I've got some servos and I just want to make this thing.
- 45:36I want to build a robot and I have some parts.
- 45:38How do I get started?
- 45:39I think the best thing for something like that is always like, I mean, depending if you want to like get there fast or if you just want the full learning experience, I would expect first like, of course, Googling.
- 45:51We also have a platform where people ask questions.
- 45:53It's answers.ros.org.
- 45:55And just like, look if other people have done something similar.
- 45:58And I'm pretty much sure that for this specific use case, people have tried that.
- 46:04So you will see people how they did that, what kind of motors they used and what kind of applications they like try to develop and see how they did it.
- 46:13And then try your project based on that one.
- 46:16And I think that's always a good thing because you can just get back to the community and ask questions.
- 46:22And usually you get like really good responses in like a short amount of time, which help you keep going on the project.
- 46:28Did you guys do anything with the hour of code?
- 46:32Like were there projects going on that you knew of or anything like that?
- 46:36It seems like robotics would play a big role in that area.
- 46:40Was the hour of code?
- 46:41Are you familiar with this, the hour of code?
- 46:42I'm sadly not.
- 46:44I might miss something.
- 46:45Oh, yeah.
- 46:46So check it out next year.
- 46:47It's in, oh, gosh, it feels like it was like three or four months ago.
- 46:51Just check out code.org.
- 46:53And there's a lot of robotics sort of projects.
- 46:57The idea of the hour of code is have every student in the world do one hour of programming during that week.
- 47:03And many of the projects that were sort of formed from there were robot based.
- 47:07And so it seems like a really cool place to get involved with.
- 47:10Oh, that sounds great because that will get the people engaged into the project.
- 47:15That sounds really amazing.
- 47:16Absolutely.
- 47:16I will look that up.
- 47:17Yeah, check it out.
- 47:17Okay, awesome.
- 47:19I think that might be a good place to call it a show.
- 47:21A question I ask all my guests sort of near the end of the show is there's a ton of packages on PyPI.
- 47:28And there's a lot of stuff on GitHub.
- 47:30There's some really awesome stuff out there in Python you want to call people's attention to.
- 47:34And, you know, Rospy might be the best one.
- 47:38I don't know.
- 47:39Yeah, Rospy, which you can sadly not get over PyPI because it requires more than just Python because of all the dependencies it uses.
- 47:46But I think there are a good amount of tools available which came from the ROS project, which are really nice to use.
- 47:55So just when you go through the wiki of ros.org, look at packages.
- 48:00And maybe some of them are even useful for you without using them in the context of ROS.
- 48:05And that's the big advantage that people can actually make use of them and apply them to different areas.
- 48:11So anything you want to give a shout out to your organization, something like that?
- 48:16Oh, well, I'm happy to work on the project.
- 48:19So it's a fun project.
- 48:21You see great results.
- 48:22You have the hands-on experience in contrast to classic software engineering.
- 48:26It's a great community.
- 48:28And it's really fun to be a part of and design the future of robotics.
- 48:31Well, thank you so much for being on the show, Dirk.
- 48:33Thank you, Michael, for having me.
- 48:35You bet.
- 48:35This has been another episode of Talk Python To Me.
- 48:39Today's guest was Dirk Thomas.
- 48:41And this episode has been sponsored by Codeship.
- 48:44Please check them out at Codeship.com and thank them on Twitter via at Codeship.
- 48:49Don't forget the discount code for listeners.
- 48:52It's easy.
- 48:52Talk Python.
- 48:53All caps, no spaces.
- 48:55Remember, you can find the links to the show at talkpythontome.com slash episodes slash show slash seven.
- 49:05And if you're feeling generous, please check out our Patreon campaign at patreon.com slash mkennedy.
- 49:09Be sure to subscribe to the show.
- 49:12Visit the website and choose subscribe in iTunes or grab the episode RSS feed and drop it into your favorite podcatcher.
- 49:19You'll find the link at the bottom of every page.
- 49:21This is your host, Michael Kennedy.
- 49:23Thanks for listening.
- 49:25Smix, take us out of here.
- 49:27Stating with my voice.
- 49:29There's no norm that I can feel within.
- 49:31Haven't been sleeping.
- 49:32I've been using lots of rest.
- 49:33I'll pass the mic back to who rocked it best.
- 49:36I'll pass the mic back to who rocked it best.
- 49:48Bye.
- 49:48.
- 49:49you