This project documents my journey in building self-balancing Segway-like robots based on LEGO Mindstorms sets (NXT and EV3), with a focus on advanced control theory, including state observers, Kalman filtering, \(H_2\)/\(H_\infty\) controllers, and trajectory tracking. It is intended for robotics enthusiasts interested in control theory.
My interest in self-balancing robots began with models like NXTWay-GS and HTWay after the release of the LEGO Mindstorms NXT set. I used a HiTechnic gyroscopic sensor and programmed the robot with Java using the LeJOS firmware. With the release of Lego EV3, the project was redesigned using the new platform and the LeJOS EV3 firmware. I used the Gyroboy Matlab Project and Balanc3r as a reference.
However, all these models used numerical differentiation and integration to reconstruct the unmeasurable elements of the robot's state vector. I wanted to implement a controller using a state observer. Another challenge for me was the desire to study and apply \(H_2\) and \(H_\infty\) controllers. I hoped they would help solve the instability issues encountered when using an observer.
When the Xiaomi MI MITU builder kit came out, which can move along a trajectory drawn on a smartphone screen, I wanted to implement this feature as well.
The developed control algorithm allows the robot to follow a given trajectory, but for now, I define the trajectory through an algorithm rather than by drawing on a smartphone screen. Maybe in the future, I’ll implement that too.
I used EV3 medium motors because they have less backlash, and I initially thought that the observer wasn't working due to the large backlash in the gearboxes. Eventually, I managed to adapt the controller for EV3 large motors.
Previously, I had measured the parameters of the large motors, but for the new robot, I needed to estimate the parameters of the medium motors. This time, I used current and voltage sensors to more accurately measure motor parameters.
During the project, I became dissatisfied with the performance of the Java platform, as programs took a long time to start and the control loop intervals were not stable. So, I ported part of the LeJOS EV3 library to C++, which allowed me to use the same firmware as LeJOS. The similarity in class structures made it possible to transfer my work to the new platform without major modifications. I built a cross-compiler for Lego EV3 using Crosstool-NG.
As a gyroscopic sensor, I used a previously developed IMU based on the LSM6DS3. The problems described in this and this post were not observed with my sensor.
During the research, I studied the Kalman filter, learned how to synthesize a reduced-order Luenberger observer, studied the synthesis of \(H_2\) and \(H_\infty\) controllers, and learned how to add an integrator and gyroscope drift estimation to an \(H_\infty\) controller — which is a non-trivial task.
I implemented two variants of trajectory tracking control: a nonlinear controller based on Lyapunov functions and a feedback linearized controller.
I did not prepare assembly instructions for the robots but did create CAD model files with medium and large motors.
The description is provided in two files: motor parameter estimation and controller synthesis.
Этот проект описывает мои эксперименты по созданию балансирующих Segway-подобных роботов на основе наборов LEGO Mindstorms (NXT и EV3), с акцентом на продвинутую теорию управления, включая наблюдатели состояния, фильтр Калмана, \(H_2\)/\(H_\infty\) регуляторы, траекторное управление. Он предназначен для любителей робототехники, интересующихся теорией управления.
Мой интерес к балансирующим роботам начался с моделей NXTWay-GS и HTWay после выхода набора LEGO Mindstorms NXT. Я использовал гироскопический датчик HiTechnic и запрограммировал робота на Java с помощью прошивки LeJOS. С выходом Lego EV3 проект был переработан с использованием новой платформы и прошивки LeJOS EV3. В качестве образца я использовал Gyroboy Matlab Project и Balanc3r.
Но все эти модели использовали численное дифференцирование и интегрирование для восстановления неизмеряемых элементов вектора состояния робота. Хотелось реализовать регулятор с использованием наблюдателя состояния. Ещё одним вызовом для меня было желание изучить и применить \(H_2\) и \(H_\infty\) регуляторы. Я надеялся, что они помогут решить проблемы с нестабильностью робота при использовании наблюдателя.
После появления набора Xiaomi MI MITU builder, который может двигаться по нарисованной на экране смартфона траектории, мне захотелось реализовать эту возможность.
Разработанный алгоритм управления позволяет роботу ехать по заданной траектории, но саму траекторию я пока задаю в виде алгоритма, а не по рисунку на экране смартфона. Возможно, в будущем, я реализую и это.
Я использовал средние моторы EV3, т.к. у них меньше люфт, а я изначально думал, что наблюдатель не работает из-за большого люфта в редукторах. В итоге, мне удалось адаптировать регулятор под большие моторы EV3.
Ранее, я измерял параметры больших моторов, но для нового робота нужно было оценить параметры средних моторов. В этот раз я использовал датчики тока и напряжения для более точного измерения параметров моторов.
По ходу реализации проекта меня перестала устраивать производительность платформы Java, т.к. программы долго запускались, и стабильность интервалов управляющего цикла оставляла желать лучшего. Поэтому я перенёс часть библиотеки LeJOS EV3 на C++, что позволило мне использовать ту же прошивку, что и для LeJOS. Схожесть структуры классов позволила перенести мои наработки на новую платформу без больших переделок. Кросс-компилятор для Lego EV3 я собрал, используя Crosstool-NG.
В качестве гироскопического датчика я использовал ранее разработанный IMU на базе LSM6DS3. Проблем, описанных в этом и этом сообщениях, с моим датчиком замечено не было.
В ходе исследований я разобрался с фильтром Калмана, научился синтезировать наблюдатель Люенбергера пониженного порядка, изучил синтез \(H_2\) и \(H_\infty\) регуляторов, научился добавлять интегратор и оценку дрейфа гироскопа в \(H_\infty\) регулятор, что является нетривиальной задачей.
Реализовал два варианта траекторного управления. Нелинейный регулятор на базе функций Ляпунова, и регулятор, линеаризованный обратной связью.
Инструкций по сборке роботов я не делал, но подготовил CAD файлы моделей со средними и большими моторами.
Описание я разместил в двух файлах: измерение параметров двигателей и синтез регулятора.
No comments:
Post a Comment