6 Tricks for Python Robot Programming

If you’re a fan of the Python programming language (and who isn’t?) you might wonder if you can use it to program your industrial robot.

But is it even possible to program an industrial robot with Python? Or is the language only suitable for hobby or research applications? And are there any tricks to improve your Python robot programming?

Python is one of the top programming languages for robot programming… but it’s only very common to see Python used in research settings. However, you can also use Python in industrial settings.

There are advantages and disadvantages to use Python for industrial robotics, just as there are for other programming languages. Advantages include ease-of-learning, a strong user basis, and the flexibility of the language. Disadvantages include a lack of native support by robot controllers and a traditionally limited usage in industrial settings.

Increasingly, the benefits far outweigh the drawbacks, especially when you are using a good robot programming software.

There are some clear steps you can take to improve your Python robot programming.

Isn’t Python Only for Researchers and Hobbyists?

You might think that Python is only suitable for research or hobby robotics, given its prevalence in these areas. It is certainly a popular programming language amongst researchers and hobbyists!

Python is often ranked as one of the easiest programming languages to learn. This is a reason that it is so common in hobby applications. A significant benefit of the language is that it is ubiquitous, simple, and was designed with readability in mind.

In the world of robotics, we often see Python robot programming within the context of the software ROS (which stands for Robot Operating System). This is an open-source robot middleware that researchers use extensively. It is written in both the C++ and Python programming languages (and a little bit of Lisp).

But, just because Python is popular in research applications doesn’t mean that it is only suited to them.

When you are programming robots in an industrial environment, you can get the same benefits from this easy-to-learn and easy-to-use language.

Why It’s Important to Use the Right Python Robot Framework

The challenge is that most industrial robots don’t natively support Python. You need to use a robot programming framework that can translate your Python programming into a language that the robot understands (usually the manufacturer’s proprietary language).

Fans of ROS might propose a solution to use ROS Industrial for such applications. This is an add-on to ROS that extends its capabilities for industrial applications.

The problem? ROS Industrial might be suitable for some industrial applications… but it’s very complicated!

Learning to use ROS can easily take months of your time. If you just want an easy, intuitive way to program your industrial robot in Python, using any version of ROS is overkill.

It’s much better to use a robot programming framework that is specifically designed for industrial robot applications. One that natively supports Python programming such as RoboDK.

6 Little Tricks to Improve Your Python Robot Programming

How can you make sure that you are getting the most from your Python robot programming?

Here are 6 helpful little tricks that you can use to improve your programming:

1. Use and Industrial-Focused Robot Programming Software

First and foremost, the robot programming software you choose will have a huge impact on your success. If you choose the right software, programming your robot in Python will be extremely simple.

Choose a robot programming software that is specially designed for industrial use. One which has thousands of users already using it for industrial applications.

2. Get Familiar with the Python API

If you want to program your robot in Python, there are a couple of ways to do this. In RoboDK, you can either write a Python script within the graphical software or you can use the Python API.

Our API is used extensively by our more experienced users. While it might be tempting to start by using RoboDK’s graphical programming interface, you will master Python robot programming much better if you use the API.

Robot Debug Program

3. Use a Good Editor for Robot Programming

Programming is always easier when you can quickly edit the files of your robot program. For this reason, simple text editors like Notepad, TextEdit, or equivalent just won’t do.

RoboDK, for example, is supported by the very popular coding editor VSCode. This includes features like syntax highlighting for specific robot brands and allows you generate a robot program at the touch of a button.

4. Check Your Output in the Robot Simulator

When you are programming your robot in Python, you will edit a text file. But it’s always important to remember that you are creating instructions for a physical robot.

Whenever you create a new feature in your robot program, check the output in RoboDK’s 3D simulator. This will help to ensure the program functions as you want it to on the robot hardware.

5. Create Your Own Plugins and Apps

When you are comfortable with Python robot programming, the next step is to start coding your own Plugins and Apps. These are self-contained programs that add extra functionality to the interface of RoboDK, allowing for even more powerful robot programming.

We recently updated RoboDK’s App Loader to make it even easier to extend the software with your own code.

6. Ask the Community for Help

Finally, remember that programming is always easier when you do it with the help of other people. You don’t need to learn Python robot programming alone.

One great source of help for your programming questions is the RoboDK forum. There is a dedicated discussion board for the Python API where you can ask a question or browse the questions other users have already asked.

Where to Start Your Python Robot Project

What should be your first step when you want to start programming a robot with Python?

It’s often helpful to see an example of a robot programming project in action. Some examples that come with RoboDK use Python scripts instead of the basic visual instructions.

One such example is the project titled “Example 7c Script curve follow custom.” You can find this and many more example projects in the examples folder of your RoboDK installation.

What has stopped you from programming robots in Python up until now? Tell us in the comments below or join the discussion on LinkedIn, Twitter, Facebook, Instagram, or in the RoboDK Forum.. Also, check out our extensive video collection and subscribe to the RoboDK YouTube Channel

About Alex Owen-Hill

Alex Owen-Hill is a freelance writer and public speaker who blogs about a large range of topics, including science, presentation skills at CreateClarifyArticulate.com, storytelling and (of course) robotics. He completed a PhD in Telerobotics from Universidad Politecnica de Madrid as part of the PURESAFE project, in collaboration with CERN. As a recovering academic, he maintains a firm foot in the robotics world by blogging about industrial robotics.

View all posts by Alex Owen-Hill

Leave a Reply

Your email address will not be published. Required fields are marked *