In this whitepaper, we are exploring Python® language support of ACROME’s educational robotic systems. In the overview section, we are giving brief info on why we have decided to support Python in our systems. Then; we will explain the Python infrastructure options that we are providing, followed by examples on how to use these structures. Scroll down the conclusion section to access the Python files.
Nearly in all market researches about programming languages, Python is listed among the first 3 languages of preference for today’s technology and science communities. A major feature to mention that Python provides a simple, readable with a very high-level programming structure supporting its users to develop complex applications. There are many text-books written for Python for robotics, data science, and artificial intelligence.
Apart from academic teaching and cutting-edge research; Python is also one of the leading programming languages in STEM learning as well. Many Introduction to the coding classes supports a Python backend. Also, it makes a great sense to learn Python between K12 and higher education to support a soft transition into academic studies.
As an educational robotics solutions provider, we have found these features of the language matching with our products and our vision. Moreover; Python also supports our mission of accessibility, thanks for being free and supporting the open-source software community. Hence -along with other engineering software/languages we support- we have decided also to support the Python language in our systems. In the next section, Python programming capabilities of our platforms will be explained in detail.
Our major products have native Python libraries, developed to be an SDK (Software Development Kit) in specific, with fundamental functions pre-written by ACROME to control the system. These SDKs provide students the ability to develop robotic programs in Python, right out-of-the box. Also, because our SDK’s are provided as open-source, students can investigate the code and develop their coding skills. Example programs are included as part of the SDKs and brief information is provided in Example Program section of this whitepaper. Please note that Python SDK currently supported natively under Raspberry Pi® controllers only. Users may use the functions of SDK with myRIO® controllers or with Arduino controllers as well; in the same order via with the Executable Package as explained below or via Matlab® 's recently released Python interface.
As an alternative path, we are providing a neat tool for Python users in our educational systems. An integrated Python editor is provided as a part of the software delivered along with our “Executable Packages”. We can define this executable software as a “User Interface with Visual Integrated Development Environment (abbrev. User Interface)” for that specific system. Executable packages are alternatives to our LabVIEW® or Matlab®/Simulink® Packages (these packages are delivered as open source codes), giving users an option to run the systems if they don’t have licenses or not willing to use any of these software.
The User Interface consists of chapters covering the underlying theory and exercises. It includes acquisition and visualization tools for data interpretation. The integrated Python editor; enables students to develop further algorithms using the SDK directly from this interface. At this time, we have built our executable packages using NI MyRIO™ controllers only.
Moreover, User Interface also includes a graph view, enabling students to acquire data from the educational system and visualize it. Sensor data and actuator commands can be visualized in the graph view. They can also be exported to Ms Excel® or to clipboard for further processing. The ability of exporting data enables students in creating electronic reports, removing the need for hand-written notes and sketches. As an important remark; a typical programming language editor does not provide an easy visualization of the data, however the data visualization plays a key role in technical and engineering education and grading of the performance. Hence our User Interfaces are solving a major need while giving an easy access to Python programmers to our robotic systems.
In this section we are sharing small robotic applications written in the Python editor for our Ball Balancing Table experiment system. We will explain the important code blocks and analyze the outcomes of the program.
First, we need to call the Python SDK with its file name such as “ Ball_balance_table_sdk_v2. ball_balance_table_controller_ v2 ” (it should be downloaded through the link given in the conclusion section), and import the “BallBalanceTableControllerv2” module from this package. Note that this SDK is written for ACROME’s Ball Balancing Table system. You’ll need to use relevant SDKs if you are using another ACROME educational system.
Then, system’s handle is obtained along with the selected control parameters (P-D controller is used for this example). Note that, as Ball Balancing Table has 2 axis (hence 2 motors), we have 2 identical numbers for each K_P and K_D parameters. Users may read our article in order to get more information about P-I-D controllers.
After initializing the system with bbt.arm_system() and adding a small pause for communication delay, we start the program by calling the defined control_system() procedure, which includes the bbt.start_control() function. Notice that, highlighted function names are common among our other SDKs, where the preceding plant name should be changed with different plant names -such as bb.arm_system() or stewart.start_control().
Next, we will be generating a map of points for circular movement by calling the bbt.draw_circle() method:
Where the method parameters are as follows;
Notice that the self argument is omitted while calling the method (as this is an instance method and we use some instance variables in this method).
Let’s skip the standard Python methods and primitives such as the while loop and if clause and come to the major function of the balancing systems, ie. the bbt.set_desired_position() method.
This is “the” function that controls the ball’s position closed-loop with the controller type selected in Line #5. Program runs indefinitely while updating the x,y coordinate pairs going into this function.
Program ends if the standard exit interrupt (Ctrl + C) is pressed with the keyboard. Afterwards, we move the ball into the center location first and then terminate the system’s handle (and it automatically disables the motors as well) with the last command:
----- End of Example #1 -----
To run the example, users have to install the Executable Package via the Installer provided. Following dependencies should be installed separately after the Executable Package installation:
The User Interface opens with the Automatic Calibration Tab active, requiring the system to be calibrated before using. This is an automatic process, hence users should wait for this to finish.
User Interface is split into 3 regions (as part of panes) as described in Figure #6.
As explained before, this User Interface could be used to execute the major experiments of the educational system. Moreover, as seen in Figure 6, there is a section for Python language special commands, that could be used in the Python Code Editor available in “Chapter 7: Python Code” and its sub-chapters.
For each educational system, we have 3-4 pre-coded examples (such as blinking the LEDs, executing a circular or rectangular path etc.) that can be read and modified (changes will not prevail and original codes will be placed upon software restart). Though, any user code can be easily exported or imported using the Save and Load buttons. Also, additional libraries (packages) could be imported and used in the editor by executing Python’s import function primitive (such as “import math“ to use the standard math library for mathematical calculations).
In Figure #7, users may investigate the Orientational Circle example of the Stewart platform in a single view. The snapshot of this example’s User Interface is already provided in Figure #3 above.
In this whitepaper, we have provided an outlook for Python language support with ACROME’s popular robotic educational systems. First, we have defined our motivation for supporting Python in our systems. Then, we have provided information about our 2 different Python infrastructures and discussed the code examples using both infrastructures.
In summary, with ACROME’s educational robotics platforms; users can improve their robotic knowledge skill set with the Python programming language as well. With this new addition, Python is also listed as a supported language along with our other engineering software languages of Matlab® and LabVIEW®.
Please follow us through social media and register to our newsletter to hear about the announcements and new features of the ACROME educational systems.
Arduino is the trademark of Arduino AG and Raspberry Pi is a trademark of the Raspberry Pi Foundation. Matlab and Simulink are trademarks of The Mathworks Company. NI myRIO and LabVIEW are trademarks of National Instruments. Other product and company names listed are trademarks and trade names of their respective companies.