Before You Begin: Installing Python and the Code Editor - madibabaiasl/kinematics-robotic-arms-modern-approach GitHub Wiki

Learning Objectives

  • Equip you with a functional Python environment and an integrated development environment (IDE) for robotics coding.
  • Build foundational coding habits that support later development of robot kinematics and ROS2 integration.

Learning Outcomes

By the end of this lesson, you will be able to:

  • Install and configure Python and Visual Studio Code on Ubuntu 22.04.
  • Write, run, and debug basic Python scripts in an IDE environment.

Why This Matters

Programming is how we speak to robots. Installing Python and setting up VS Code is the first step toward commanding mechanical intelligence. A clean, well-configured environment removes friction, so you can focus on problem-solving rather than system errors. Understanding IDEs, virtual environments, and code structure connects directly to the course’s larger objectives: implementing forward and inverse kinematics in Python, controlling manipulators through ROS 2, and documenting robotic systems with professional clarity.

Installing Python and the Code Editor

By now, you should have installed Ubuntu 22.04 on your computers.

Then we need a code editor to write our Python programs. In the past, people were using just text editors to write their programs but thanks to the current code editors, we can get the most of their debugging properties. These code editors are called IDEs or integrated development environments.

There are different IDEs and some are specially designed for Python. In this class, we are going to use Visual Studio Code editor from Microsoft and it has the advantage that you can organize your codes in different languages in one place and it is the most widely used code editor among programmers. Other options are PyCharm and Spyder.

Here is the Spyder tutorial in case you are interested (but we will use VS code): https://www.youtube.com/watch?v=HOH6tMriJRc

code-editers-ides

Steps to install VS code and Python in Ubuntu 22.04:

  • Open a terminal: ctrl + alt + T
  • Type: sudo snap install code - - classic This is the same as going to the software center and typing visual studio code and then installing it.
  • Head over to all apps and add the VS Code to your favorites and then run it.
  • Go to the extensions tab and search for Python and get the recommended Python extension.
  • Head over to the gear icon, then extension settings, then configure it as you want like setting your desired path for things like Conda virtual environments.

Note: A virtual environment is like the Construct in the movie Matrix where Morpheus trained Neo and the reason to use them is that some packages that you may have developed for different projects have conflicting dependencies (for instance if you want to work on a ML project using Python3 and the web development project on Python2, this is not possible since the system can have only one default Python. In this case, you will need to install a virtual environment). Learn more about virtual environments and how to set them at the link below:

https://youtu.be/EJStaG326NU

  • You can also install a C/C++ extension if you need to program in those languages as well or if you want to use ROS packages that use C++.
  • Write your very first program and test your IDE:
    • Open a new folder and give it a name. I named it Intro to Python
    • Create a new Python file and name it hello_world
    • Write:
# This is the first program
print(“Hello World”)

And you will see that Hello World will be printed on the console. The first line that starts with # is just for human users to understand the code and it is called a comment. “ “ is used for strings. print will print anything that you pass to it on the console.

⚠️ **GitHub.com Fallback** ⚠️