Submitted:
12 November 2025
Posted:
13 November 2025
You are already at the latest version
Abstract
Keywords:
1. Introduction
2. Literature Overview
3. Controller Stack
4. L0 Model
5. Movement Control
6. Programming
| Listing 1. Simulation engine in Arduino Sketch |
| 1 #include "L0Lidar.h" |
| 2 #include "L0Main.h" |
| 3 L0Lidar Lidar(LIDAR_SERVO); |
| 4 L0Main Main(M1DIR, M1PWM, /* ... */); |
| 5 void setup() { |
| 6 Lidar.set(); Main.set(); |
| 7 Lidar.init(); Main.init(); |
| 8 } // setup |
| 9 unsigned long dt = 25; // [ms] |
| 10 void loop() { |
| 11 unsigned long starttime = millis(); |
| 12 Lidar.write_outputs(); Main.write_outputs(); |
| 13 Lidar.read_inputs(Main.get_target()); |
| 14 Main.read_inputs(Lidar.get_distance(), Lidar.get_update()); |
| 15 Lidar.assign_delayed(); Main.assign_delayed(); |
| 16 Lidar.assign_immediate(); Main.assign_immediate(); |
| 17 if(!Lidar.is_active()) {Lidar.init();} |
| 18 if(!Main.is_active()) {Main.init();} |
| 19 while (millis()-starttime<dt) {;} |
| 20 } // loop |
| Listing 2. EFSM header file for L0Lidar |
| 1 class L0Lidar { |
| 2 public: |
| 3 L0Lidar( ... ) |
| 4 void set() { ... } |
| 5 void init(); |
| 6 void write_outputs(); |
| 7 long get_distance(); |
| 8 bool get_update(); |
| 9 void read_inputs(float angle); |
| 10 void assign_delayed(); |
| 11 void assign_immediate(); |
| 12 bool is_active(); |
| 13 private: |
| 14 char _SERVOPIN; |
| 15 Servo _Servo; |
| 16 VL53L0X _Sensor; |
| 17 float _wrot; // Rot. speed [deg/s] |
| 18 int A; // Target angle [deg] |
| 19 unsigned E; // Obstacle dist. [mm] |
| 20 enum {S_ROTATE, S_PING, S_ECHO, |
| 21 S_SINK} state[2]; |
| 22 int Y[2]; // Yaw |
| 23 float Z[2]; // Servo position |
| 24 float B[2]; // Begin time |
| 25 float D[2]; // Delay |
| 26 float Q[2]; // Distance to obstacle |
| 27 bool u[2]; // Distance update |
| 28 bool s[2]; // Send ping |
| 29 int Y2Z(int A); |
| 30 }; |
| Listing 3. Delayed and immediate assignments in L0Lidar |
| 1 void L0Lidar::assign_delayed() { |
| 2 if (state[_CURR_]==S_ROTATE) { |
| 3 if (T-B[_CURR_]>=D[_CURR_]) { |
| 4 Z[_NEXT_] = Y2Z(360); state[_NEXT_] = S_PING; |
| 5 } // if |
| 6 } else if (state[_CURR_]==S_PING) { |
| 7 u[_NEXT_] = false; |
| 8 if (A!=Y[_CURR_]) { |
| 9 B[_NEXT_] = T; D[_NEXT_] = abs(A-Y[_CURR_])/_wrot; |
| 10 Y[_NEXT_] = A; Z[_NEXT_] = Y2Z(A); |
| 11 state[_NEXT_] = S_ROTATE; |
| 12 } else { // A==Y[_CURR_] |
| 13 s[_NEXT_] = true; state[_NEXT_] = S_ECHO; |
| 14 } // if |
| 15 } else if (state[_CURR_]==S_ECHO) { |
| 16 s[_NEXT_] = false; |
| 17 if (E>=0 ) { |
| 18 u[_NEXT_] = true; Q[_NEXT_] = E; state[_NEXT_] = S_PING; |
| 19 } // if |
| 20 } else { // error handling |
| 21 } // if chain |
| 22 } // L0Lidar::assign_delayed() |
| 23 void L0Lidar::assign_immediate() { |
| 24 state[_CURR_] = state[_NEXT_]; |
| 25 Y[_CURR_] = Y[_NEXT_]; Z[_CURR_] = Z[_NEXT_]; |
| 26 // (... omitted ...) |
| 27 } // L0Lidar::assign_immediate() |
7. Discussion
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
Abbreviations
| ASM | Algorithmic State Machine |
| BT | Behavior Tree |
| EFSM | Extended Finite State Machine |
| FSM | Finite State Machine |
| HSM | Hierarchical State Machine |
| LoC | Lines-of-Code |
| PID | Proportional-Integral-Derivative |
| UML | Unified Modeling Language |
References
- Sauer, L.; Henrich, D.; Martens, W. Towards Intuitive Robot Programming Using Finite State Automata. In KI 2019: Advances in Artificial Intelligence: 42nd German Conference on AI, Kassel, Germany, September 23–-26, 2019, Proceedings. Springer-Verlag, Berlin, Heidelberg, 290–298. [CrossRef]
- Halim, J.; Eichler, P.; Krusche, S.; Bdiwi, M.; Ihlenfeldt, S. No-code robotic programming for agile production: A new markerless-approach for multimodal natural interaction in a human-robot collaboration context. Frontiers in Robotics and AI, 9, 2022. [CrossRef]
- Samek, M.; Montgomery, P. State-oriented programming. Embedded Systems Programming 13(8), 2000, 22–43.
- Brunner, S.G.; Steinmetz, F.; Belder, R.; Dömel, A. RAFCON: A Graphical Tool for Engineering Complex, Robotic Tasks. In: IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), 3283—3290, 2016, Daejeon, South Korea. [CrossRef]
- Li, W.; Miyazawa, A.; Ribeiro, P.; Cavalcanti, A.; Woodcock, J.; Timmis, J. From Formalised State Machines to Implementations of Robotic Controllers. In: , et al. Distributed Autonomous Robotic Systems. Springer Proceedings in Advanced Robotics, vol 6. Springer, Cham. 2018. [CrossRef]
- Miyazawa, A.; Ribeiro, P.; Li, W.; Cavalcanti, A.; Timmis, J.; Woodcock, J. RoboChart: modelling and verification of the functional behaviour of robotic applications. Software & Systems Modeling. 18, 1–53. 2019. [CrossRef]
- Tousignant, S.; Van Wyk, E.; Gini, M. An Overview of XRobots: A Hierarchical State Machine Based Language. In: ICRA-2011 Workshop on Software Development and Integration in Robotics, Shanghai, China May 2011.9–13.
- Ribas-Xirgo, Ll. How to code finite state machines (FSMs) in C. A systematic approach. 2014. [CrossRef]
- Rivas, D.; Das, P.; Saiz-Alcaine, J.; Ribas-Xirgo, Ll. Synthesis of Controllers from Finite State Stack Machine Diagrams. IEEE 23rd International Conference on Emerging Technologies and Factory Automation (ETFA), 2018, 1179–1182. [CrossRef]
- Zhou, H.; Min, H.; Lin, Y.; Zhang, S. A Robot Architecture of Hierarchical Finite State Machine for Autonomous Mobile Manipulator. In: Huang, Y., Wu, H., Liu, H., Yin, Z. (eds) Intelligent Robotics and Applications. ICIRA 2017. Lecture Notes in Computer Science, 10464. Springer, Cham.. 425–436. [CrossRef]
- González-Santamarta, M.Á.; Rodríguez-Lera, F.; Fernández, C.; Martín, F.; Matellán, V. YASMIN: Yet Another State MachINe library for ROS 2. 2022. [CrossRef]
- Poppinga, M. & Bestmann M. DSD – Dynamic Stack Decider. International Journal of Social Robotics. 14:73–83. Springer. (2022). [CrossRef]
- Levin, I.; Kolberg, E.; Reich, Y. Robot Control Teaching with a State Machine-based Design Method. International Journal of Engineering Education, 20(2), 2004.
- Rustam, I.; Tahir, N.M.; Yassin, A.I.M.; Wahid, N.; Kassim. A.H. Linear Differential Driven Wheel Mobile Robot Based on MPU9250 and Optical Encoder. TEM Journal 11(1), 30—36, February 2022. [CrossRef]
- Myint, C.; Win, N.N. Position and Velocity control for Two-Wheel Differential Drive Mobile Robot International Journal of Science, Engineering and Technology Research (IJSETR) 5(9), September 2016.
- Hirpo, B.D.; Zhongmin W. Design and Control for Differential Drive Mobile Robot. International Journal of Engineering Research & Technology (IJERT), 6(10), 2017. 327–334.
- Dòria-Cerezo, A.; Biel, D.; Olm. J.M.; Repecho, V. Sliding mode control of a differential-drive mobile robot following a path. 18th European Control Conference (ECC), 2019, 4061—4066. [CrossRef]
- Nurmaini, S.; Dewi, K.; Tutuko, B. Differential-Drive Mobile Robot Control Design based-on Linear Feedback Control Law. IOP Conference Series: Materials Science and Engineering, Volume 190, IAES International Conference on Electrical Engineering, Computer Science and Informatics 23–25 November 2016, Semarang, Indonesia. [CrossRef]
- Tafrishi, S.A.; Ravankar, A.A.; Salazar Luces, J.V.; Hirata, Y. A Novel Assistive Controller Based on Differential Geometry for Users of the Differential-Drive Wheeled Mobile Robots, arXiv:2202.01969v1, 4 Feb. 2022. [CrossRef]










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. |
© 2025 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 (http://creativecommons.org/licenses/by/4.0/).