View Full Version : Why using Python to control robots?

01-01-2015, 08:35 PM
Hello, in the past C was a popular language for robot control. In trossen's forums, I read a couple of postings about using Python to control robots. What are the reasons for using Python rather than C or C++?

01-01-2015, 09:40 PM
Python is easier and faster to just type at and see things happen. Especially for smaller programs.

When computers are fast enough, the overhead of Python (which is significant) may not matter as much as programmer productivity.

01-01-2015, 10:48 PM
jwatte pretty much nailed it. Python is a really easy language to get started with and is capable of performing very complex tasks with the addition of some math and science libraries (numpy, etc.). When you are doing experimental work, the performance issue is secondary to just getting functional code and testing new algorithms. Also worth mentioning that the better funded developers usually have multiple powerful computers that can be easily accessed when extra computing is needed, so the performance hit from using is even less of an issue for them.

An example: ROS was originally a lot of python programs expanding on a small, reliable C++ core so that users could quickly prototype/experiment in python (and C++ if that was their preference). If the experiment's results proved worthy of further effort, then it would be easy enough to convert it to C/C++ for higher performance and/or reliability (compiler error checking and debugging). With time and user contributions, many once-experimental components have been converted to C++ and other languages like java have had support added.