Feasibility Study for a Python-Based Embedded Real-Time Control System
Abstract
:1. Introduction
- The development of a Python method for executing real-time periodical tasks under the real-time Linux extension RT-Preempt, using a POSIX Linker and the Ctypes module;
- An evaluation of the method on a Raspberry Pi 4 device through various real-time performance analyses, including periodicity and interrupt latency;
- A comparison of the results to those of the same program developed in C/C++ to validate the potential of the Python-based real-time system;
- A demonstration of the feasibility of a Python-based real-time embedded control system by performing servo motor control using the industrial Fieldbus EtherCAT;
- Providing a stepping-stone for easier integration of recent trends in machine learning and numerical analysis on real-time systems for use in various fields, such as data analytics, robotics, and industrial control.
2. Python-Based Real-Time System
2.1. Python-Based Real-Time System Architecture
2.2. Interface Real-Time Library to Python
2.3. Performance in a Multi-Tasking Environment
2.3.1. Periodicity and Responsiveness
2.3.2. Interrupt Response
2.3.3. Discussion
3. Experimental Validation
3.1. Environment
3.2. Experimental Method
3.3. Experimental Results
4. Conclusions
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Kim, M. Guaranteeing That Multilevel Prioritized DNN Models on an Embedded GPU Have Inference Performance Proportional to Respective Priorities. IEEE Embed. Syst. Lett. 2022, 14, 83–86. [Google Scholar] [CrossRef]
- Meyer, E.; Robinson, H.; Rasheed, A.; San, O. Taming an Autonomous Surface Vehicle for Path Following and Collision Avoidance Using Deep Reinforcement Learning. IEEE Access 2020, 8, 41466–41481. [Google Scholar] [CrossRef]
- Stephen Cass Top Programming Languages 2021. Available online: https://spectrum.ieee.org/top-programming-languages-2021 (accessed on 10 February 2023).
- Ian Skerrett Profile of an Iot Developer: Results of the Iot Developer Survey. Available online: https://ianskerrett.wordpress.com/2016/04/14/profile-of-an-iot-developer-results-of-the-iot-developer-survey (accessed on 10 February 2023).
- Reghenzani, F.; Massari, G.; Fornaciari, W. The Real-Time Linux Kernel: A Survey on PREEMPT_RT. ACM Comput. Surv. 2019, 52, 1–36. [Google Scholar] [CrossRef]
- Krishna, C.M. Fault-Tolerant Scheduling in Homogeneous Real-Time Systems. ACM Comput. Surv. 2014, 46, 1–34. [Google Scholar] [CrossRef] [Green Version]
- Devaraj, R.; Sarkar, A. Resource-Optimal Fault-Tolerant Scheduler Design for Task Graphs Using Supervisory Control. IEEE Trans. Industr. Inform. 2021, 17, 7325–7337. [Google Scholar] [CrossRef]
- Jerome Joseph, T.; Swaminathan, J. An Experimental Study of Parallelism in Different Python Frameworks. In Proceedings of the 2022 International Conference on Inventive Computation Technologies (ICICT), Kathmandu, Nepal, 20–22 July 2022; pp. 363–366. [Google Scholar]
- Ionescu, V.M.; Enescu, F.M. Investigating the Performance of MicroPython and C on ESP32 and STM32 Microcontrollers. In Proceedings of the 2020 IEEE 26th International Symposium for Design and Technology in Electronic Packaging (SIITME), Pitesti, Romania, 21–24 October 2020; pp. 234–237. [Google Scholar]
- Bucher, R. Practical Experiences with Python and Linux RT at the SUPSI Laboratory. IFAC-PapersOnLine 2019, 52, 133–138. [Google Scholar] [CrossRef]
- Jun, L.; Ling, L. Comparative Research on Python Speed Optimization Strategies. In Proceedings of the 2010 International Conference on Intelligent Computing and Integrated Systems, Guilin, China, 22–24 October 2010; pp. 57–59. [Google Scholar]
- Python Software Foundation Ctypes—A Foreign Function Library for Python. Available online: https://docs.python.org/3/library/ctypes.html (accessed on 10 February 2023).
- Carvalho, A.; Machado, C.; Moraes, F. Raspberry Pi Performance Analysis in Real-Time Applications with the RT-Preempt Patch. In Proceedings of the 2019 Latin American Robotics Symposium (LARS), 2019 Brazilian Symposium on Robotics (SBR) and 2019 Workshop on Robotics in Education (WRE), Rio Grande do Sul, Brazil, 22–26 October 2019; pp. 162–167. [Google Scholar]
- Wang, S.; Ouyang, J.; Li, D.; Liu, C. An Integrated Industrial Ethernet Solution for the Implementation of Smart Factory. IEEE Access 2017, 5, 25455–25462. [Google Scholar] [CrossRef]
- Delgado, R.; Park, J.; Choi, B.W. Open Embedded Real-Time Controllers for Industrial Distributed Control Systems. Electronics 2019, 8, 223. [Google Scholar] [CrossRef] [Green Version]
- Lee, S.-Y.; Sung, M. Design and Implementation of an Ethernet-Based Linear Motor Drive for Industrial Transport Systems. IEEE Access 2021, 9, 33061–33074. [Google Scholar] [CrossRef]
- Chan, C.-C.; Tsai, C.-C. Collision-Free Speed Alteration Strategy for Human Safety in Human-Robot Coexistence Environments. IEEE Access 2020, 8, 80120–80133. [Google Scholar] [CrossRef]
- Delgado, R.; Jo, Y.H.; Choi, B.W. RT-AIDE: A RTOS-Agnostic and Interoperable Development Environment for Real-Time Systems. IEEE Trans. Industr. Inform. 2022, 19, 2772–2781. [Google Scholar] [CrossRef]
- King, C.I. Stress-Ng. Available online: https://github.com/ColinIanKing/stress-ng (accessed on 1 March 2023).
- Delgado, R.; Choi, B.W. New Insights into the Real-Time Performance of a Multicore Processor. IEEE Access 2020, 8, 186199–186211. [Google Scholar] [CrossRef]
- Florian, P. IgH EtherCAT Master1.5.2 Documentation. Available online: https://www.etherlab.org/download/ethercat/ethercat-1.5.2.pdf (accessed on 10 February 2023).
- Akpinar, K.O.; Ozcelik, I. Analysis of Machine Learning Methods in EtherCAT-Based Anomaly Detection. IEEE Access 2019, 7, 184365–184374. [Google Scholar] [CrossRef]
- Yasar, M.S.; Evans, D.; Alemzadeh, H. Context-Aware Monitoring in Robotic Surgery. In Proceedings of the 2019 International Symposium on Medical Robotics (ISMR), Atlanta, GA, USA, 3–5 April 2019; pp. 1–7. [Google Scholar]
- Li, Z.; Hutchinson, K.; Alemzadeh, H. Runtime Detection of Executional Errors in Robot-Assisted Surgery. In Proceedings of the 2022 International Conference on Robotics and Automation (ICRA), Philadelphia, PA, USA, 23–27 May 2022; pp. 3850–3856. [Google Scholar]
- Long, Y.; Wu, J.Y.; Lu, B.; Jin, Y.; Unberath, M.; Liu, Y.-H.; Heng, P.A.; Dou, Q. Relational Graph Learning on Visual and Kinematics Embeddings for Accurate Gesture Recognition in Robotic Surgery. In Proceedings of the 2021 IEEE International Conference on Robotics and Automation (ICRA), Xi’an, China, 30 May–5 June 2021; pp. 13346–13353. [Google Scholar]
Functionality | POSIX Wrapper | POSIX Linker |
---|---|---|
Task Handler | POSIX_TASK | PY_POSIX_TASK |
Task Creation | create_rt_task | py_create_rt_task |
Start Execution | start_task | py_start_task |
Set Task Timer | set_task_period | py_set_task_period |
Wait Period | wait_next_period | py_wait_next_period |
Task | Period (ms) | Deadline (ms) | Execution (ms) | Priority |
---|---|---|---|---|
τ1 | 10 | 10 | 3 | 99 |
τ2 | 20 | 20 | 5 | 80 |
τ3 | 40 | 40 | 10 | 70 |
Metric | C/C++ | |||
---|---|---|---|---|
τ1 | τ2 | τ3 | ||
Period [ms] | Mean | 10.000 | 20.000 | 40.000 |
Min | 9.954 | 19.948 | 39.949 | |
Max | 10.048 | 20.051 | 40.051 | |
Sdev | 0.003 | 0.004 | 0.004 | |
Response [ms] | Mean | 3.008 | 8.017 | 29.021 |
Min | 3.006 | 8.014 | 29.019 | |
Max | 3.056 | 8.067 | 29.068 | |
Sdev | 0.002 | 0.003 | 0.003 | |
Metric | Python | |||
τ1 | τ2 | τ3 | ||
Period [ms] | Mean | 10.000 | 20.000 | 40.000 |
Min | 9.918 | 19.783 | 39.693 | |
Max | 10.088 | 20.222 | 40.312 | |
Sdev | 0.023 | 0.038 | 0.013 | |
Response [ms] | Mean | 3.064 | 8.136 | 29.184 |
Min | 3.041 | 8.106 | 29.135 | |
Max | 3.190 | 8.399 | 29.441 | |
Sdev | 0.016 | 0.020 | 0.013 |
Metric | C/C++ | |||
---|---|---|---|---|
τ1 | τ2 | τ3 | ||
Period [ms] | Mean | 10.000 | 19.999 | 40.000 |
Min | 9.935 | 19.929 | 39.935 | |
Max | 10.068 | 20.068 | 40.058 | |
Sdev | 0.009 | 0.014 | 0.010 | |
Response [ms] | Mean | 3.018 | 8.035 | 29.041 |
Min | 3.007 | 8.018 | 29.028 | |
Max | 3.082 | 8.100 | 29.101 | |
Sdev | 0.007 | 0.008 | 0.007 | |
Metric | Python | |||
τ1 | τ2 | τ3 | ||
Period [ms] | Mean | 10.000 | 20.000 | 40.000 |
Min | 9.715 | 19.646 | 39.702 | |
Max | 10.262 | 20.298 | 40.282 | |
Sdev | 0.064 | 0.082 | 0.066 | |
Response [ms] | Mean | 3.216 | 8.474 | 29.636 |
Min | 3.060 | 8.219 | 29.287 | |
Max | 3.459 | 8.751 | 29.871 | |
Sdev | 0.066 | 0.067 | 0.069 |
Item | Description |
---|---|
Master | |
Board | MIO-5272U-U6A1E |
CPU | Intel i7-6600U |
Memory | DDR4 8GB |
Network Controller | intel i219 |
Linux Kernel | kernel 4.14.134-rt63 |
OS Distribution | Lubuntu 18.04 |
Python | 3.6.9 |
EtherCAT Master | IgH EtherCAT Master 1.5.2 |
Slave-1 | |
Product | LS Mecapion L7N Servo Drive |
PDO | 26 bytes for each slave (RxPDO 13 bytes, TxPDO 13 bytes) |
Slave-2 | |
Product | Beckhoff EL2024 Digital Output |
PDO | 1 byte for each slave (RxPDO 1 byte, TxPDO 0 bytes) |
Metric | Response Time [ms] | Period [ms] |
---|---|---|
Mean | 0.077 | 1 |
Max | 0.131 | 1.238 |
Min | 0.069 | 0.766 |
Std | 0.004 | 0.001 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Cho, S.Y.; Delgado, R.; Choi, B.W. Feasibility Study for a Python-Based Embedded Real-Time Control System. Electronics 2023, 12, 1426. https://doi.org/10.3390/electronics12061426
Cho SY, Delgado R, Choi BW. Feasibility Study for a Python-Based Embedded Real-Time Control System. Electronics. 2023; 12(6):1426. https://doi.org/10.3390/electronics12061426
Chicago/Turabian StyleCho, Se Yeon, Raimarius Delgado, and Byoung Wook Choi. 2023. "Feasibility Study for a Python-Based Embedded Real-Time Control System" Electronics 12, no. 6: 1426. https://doi.org/10.3390/electronics12061426
APA StyleCho, S. Y., Delgado, R., & Choi, B. W. (2023). Feasibility Study for a Python-Based Embedded Real-Time Control System. Electronics, 12(6), 1426. https://doi.org/10.3390/electronics12061426