{"id":1107,"date":"2023-11-19T13:33:15","date_gmt":"2023-11-19T13:33:15","guid":{"rendered":"https:\/\/open-cube.fel.cvut.cz\/?p=1107"},"modified":"2023-11-19T13:33:15","modified_gmt":"2023-11-19T13:33:15","slug":"open-cube-self-balancing-robot","status":"publish","type":"post","link":"https:\/\/open-cube.fel.cvut.cz\/?p=1107","title":{"rendered":"Open-Cube, self-balancing robot"},"content":{"rendered":"\n<p><strong>Nice toy to play with&#8230; uses internal gyroscope and accelerometer, see description below.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"ast-oembed-container\" style=\"height: 100%;\"><iframe loading=\"lazy\" title=\"Open-cube Self-balancing Robot\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/YVZB2zTYLSw?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe><\/div>\n<\/div><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Segway is a robot that balances on two wheels using data obtained from an integrated IMU (three-axis gyroscope and accelerometer).<\/p>\n\n\n\n<p>The tilt angle with respect to the horizontal axis of the robot is determined by fusing the gyroscope and accelerometer data using a complementary filter. A high-pass filter is applied to the gyroscope data and a low-pass filter is applied to the accelerometer data.<\/p>\n\n\n\n<p>The position of the robot and the angle of rotation about the vertical axis are determined by the rotary encoders of the motors. The distance to the obstacle is measured by an NXT ultrasonic sensor.<\/p>\n\n\n\n<p>The robot control is mediated by five PID regulators. The most important of these are the three cascaded position, velocity and tilt regulators, which result in desired power output on the motors. These regulators maintain the vertical position and allow translational motion. A fourth rotation regulator ensures that the robot maintains a constant rotation about the vertical axis and rotational motion. The fifth regulator allows deceleration and distance maintenance in front of an obstacle.<\/p>\n\n\n\n<p>The robot can be controlled from a computer connected via Bluetooth to the ESP32 module in the cube. A Simulink model running on the computer is used to communicate with the cube. This way the robot states such as position, speed, tilt and more can be monitored in real time. Furthermore, the controller constants can be set remotely, which allows a quick experimental determination of these constants. It is also possible to send motion commands for forward motion and rotation.&nbsp; In the left part of the Simulink model, controller constants can be set and motion commands can be entered, graphs can be displayed on the right, and a block in the middle provides wireless communication. In another configuration, the cube can be connected from a computer or mobile phone via Wi-Fi to a web server running on the ESP32. Using the web server buttons, translational and rotational motion commands can be sent to the robot and the current regulator action, current and reference position and velocity can be monitored.<\/p>\n\n\n\n<p>You can check the code here: <a href=\"https:\/\/gitlab.fel.cvut.cz\/open-cube\/firmware\/-\/tree\/main\/programs\/examples\/robots\">https:\/\/gitlab.fel.cvut.cz\/open-cube\/firmware\/-\/tree\/main\/programs\/examples\/robots<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"646\" src=\"https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway_simulink-1024x646.png\" alt=\"\" class=\"wp-image-1109\" srcset=\"https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway_simulink-1024x646.png 1024w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway_simulink-300x189.png 300w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway_simulink-768x485.png 768w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway_simulink.png 1249w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">MATLAB Simulink &#8211; serial line (Bluetooth) connection to the Open-Cube via ESP32 module&#8230;<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"859\" src=\"https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway_regulators_en-1024x859.png\" alt=\"\" class=\"wp-image-1110\" srcset=\"https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway_regulators_en-1024x859.png 1024w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway_regulators_en-300x252.png 300w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway_regulators_en-768x644.png 768w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway_regulators_en-1536x1288.png 1536w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway_regulators_en.png 1706w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Some graphs from Simulink &#8211; first trace is requested and real position&#8230;.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" width=\"791\" height=\"1024\" src=\"https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway_webseerver-791x1024.png\" alt=\"\" class=\"wp-image-1111\" style=\"aspect-ratio:0.7724609375;width:362px;height:auto\" srcset=\"https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway_webseerver-791x1024.png 791w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway_webseerver-232x300.png 232w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway_webseerver-768x994.png 768w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway_webseerver-1187x1536.png 1187w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway_webseerver.png 1439w\" sizes=\"(max-width: 791px) 100vw, 791px\" \/><figcaption class=\"wp-element-caption\">A simple web page created with ESP32 (only used for wireless communication in Open-Cube), buttons and other items are configurable with Python script from RP2040\u2026<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"820\" src=\"https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway2-1024x820.jpg\" alt=\"\" class=\"wp-image-1114\" style=\"aspect-ratio:1.248780487804878;width:672px;height:auto\" srcset=\"https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway2-1024x820.jpg 1024w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway2-300x240.jpg 300w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway2-768x615.jpg 768w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway2.jpg 1215w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Segway with a final Open-Cube box version &#8211; azure blue PLA by PRUSA&#8230;.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" width=\"771\" height=\"1024\" src=\"https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway-771x1024.jpg\" alt=\"\" class=\"wp-image-1115\" style=\"aspect-ratio:0.7529296875;width:489px;height:auto\" srcset=\"https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway-771x1024.jpg 771w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway-226x300.jpg 226w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway-768x1020.jpg 768w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway-1157x1536.jpg 1157w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway-1542x2048.jpg 1542w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway-scaled.jpg 1928w\" sizes=\"(max-width: 771px) 100vw, 771px\" \/><figcaption class=\"wp-element-caption\">Segway with the Open-Cube second prototype&#8230; and NXT ultrasonic rangefinder for obstacle avoidance&#8230;<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" width=\"669\" height=\"945\" src=\"https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/big_robot.jpg\" alt=\"\" class=\"wp-image-1116\" style=\"aspect-ratio:0.707936507936508;width:472px;height:auto\" srcset=\"https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/big_robot.jpg 669w, https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/big_robot-212x300.jpg 212w\" sizes=\"(max-width: 669px) 100vw, 669px\" \/><figcaption class=\"wp-element-caption\">&#8230;.with a big friend from Department of Control Engineering, FEE, CTU in Prague<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"ast-oembed-container\" style=\"height: 100%;\"><iframe loading=\"lazy\" title=\"Balancing robot based on Open-Cube brick trying to play basketball\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/MHKjJtB_r4I?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe><\/div>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Nice toy to play with&#8230; uses internal gyroscope and accelerometer, see description below. Segway is a robot that balances on two wheels using data obtained from an integrated IMU (three-axis gyroscope and accelerometer). The tilt angle with respect to the horizontal axis of the robot is determined by fusing the gyroscope and accelerometer data using &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/open-cube.fel.cvut.cz\/?p=1107\"> <span class=\"screen-reader-text\">Open-Cube, self-balancing robot<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":1112,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"disabled","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","footnotes":""},"categories":[1],"tags":[],"uagb_featured_image_src":{"full":["https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway2mini.jpg",292,326,false],"thumbnail":["https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway2mini-150x150.jpg",150,150,true],"medium":["https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway2mini-269x300.jpg",269,300,true],"medium_large":["https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway2mini.jpg",292,326,false],"large":["https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway2mini.jpg",292,326,false],"1536x1536":["https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway2mini.jpg",292,326,false],"2048x2048":["https:\/\/open-cube.fel.cvut.cz\/wp-content\/uploads\/2023\/11\/segway2mini.jpg",292,326,false]},"uagb_author_info":{"display_name":"admin","author_link":"https:\/\/open-cube.fel.cvut.cz\/?author=1"},"uagb_comment_info":0,"uagb_excerpt":"Nice toy to play with&#8230; uses internal gyroscope and accelerometer, see description below. Segway is a robot that balances on two wheels using data obtained from an integrated IMU (three-axis gyroscope and accelerometer). The tilt angle with respect to the horizontal axis of the robot is determined by fusing the gyroscope and accelerometer data using&hellip;","_links":{"self":[{"href":"https:\/\/open-cube.fel.cvut.cz\/index.php?rest_route=\/wp\/v2\/posts\/1107"}],"collection":[{"href":"https:\/\/open-cube.fel.cvut.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/open-cube.fel.cvut.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/open-cube.fel.cvut.cz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/open-cube.fel.cvut.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1107"}],"version-history":[{"count":6,"href":"https:\/\/open-cube.fel.cvut.cz\/index.php?rest_route=\/wp\/v2\/posts\/1107\/revisions"}],"predecessor-version":[{"id":1140,"href":"https:\/\/open-cube.fel.cvut.cz\/index.php?rest_route=\/wp\/v2\/posts\/1107\/revisions\/1140"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/open-cube.fel.cvut.cz\/index.php?rest_route=\/wp\/v2\/media\/1112"}],"wp:attachment":[{"href":"https:\/\/open-cube.fel.cvut.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/open-cube.fel.cvut.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/open-cube.fel.cvut.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}