{"id":22440060,"url":"https://github.com/niewiaro/husarion-telegraf","last_synced_at":"2025-03-27T09:26:54.101Z","repository":{"id":259846839,"uuid":"879620832","full_name":"Niewiaro/Husarion-Telegraf","owner":"Niewiaro","description":"AGH 🟩⬛🟥 project for Mechatronic Design","archived":false,"fork":false,"pushed_at":"2024-11-25T07:48:01.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T14:23:43.641Z","etag":null,"topics":["agh","husarion"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Niewiaro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-28T08:52:52.000Z","updated_at":"2024-11-25T07:48:05.000Z","dependencies_parsed_at":"2024-11-18T08:30:30.934Z","dependency_job_id":null,"html_url":"https://github.com/Niewiaro/Husarion-Telegraf","commit_stats":null,"previous_names":["niewiaro/husarion-telegraf"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Niewiaro%2FHusarion-Telegraf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Niewiaro%2FHusarion-Telegraf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Niewiaro%2FHusarion-Telegraf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Niewiaro%2FHusarion-Telegraf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Niewiaro","download_url":"https://codeload.github.com/Niewiaro/Husarion-Telegraf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245816342,"owners_count":20677088,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agh","husarion"],"created_at":"2024-12-06T01:16:51.242Z","updated_at":"2025-03-27T09:26:54.085Z","avatar_url":"https://github.com/Niewiaro.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Husarion Telegraf\n\nProjekt na zajęcia \"Mechatronic Design\" na AGH 🟩⬛🟥.\n\n## Spis Treści\n\n- [Opis](#opis)\n- [Wymagania](#wymagania)\n- [Instalacja](#instalacja)\n- [Użycie](#użycie)\n  - [Inicjalizacja](#inicjalizacja)\n  - [Obsługa enkodera wejściowego](#obsługa-enkodera-wejściowego)\n  - [Wyświetlanie danych na kole wyjściowym](#wyświetlanie-danych-na-kole-wyjściowym)\n  - [Konwersja danych binarnych](#konwersja-danych-binarnych)\n  - [Reset pozycji i bufora](#reset-pozycji-i-bufora)\n  - [Debugowanie](#debugowanie)\n- [Autor](#autor)\n- [Licencja](#licencja)\n\n## Opis\n\nProjekt **Husarion Telegraf** pozwala na kontrolę i monitorowanie danych z platformy Husarion. Wykorzystuje enkodery, aby śledzić pozycje kół robota, przetwarzać dane binarne i wyświetlać wynik na kole wyjściowym. Dodatkowo umożliwia reset pozycji oraz funkcję debugowania. Projekt napisany w C++.\n\n## Wymagania\n\n- Platforma Husarion z STM32\n- Husarion SDK\n- Platforma Husarion IDE lub lokalne środowisko C++ (np. GCC, CMake)\n- Kabel USB do programowania i debugowania\n\n## Instalacja\n\n1. Sklonuj repozytorium:\n    ```sh\n    git clone https://github.com/Niewiaro/Husarion-Telegraf.git\n    cd Husarion-Telegraf\n    ```\n\n2. Skonfiguruj środowisko zgodnie z dokumentacją Husarion:\n    - W przypadku Husarion IDE, otwórz projekt i przeprowadź proces kompilacji i wysyłki.\n    - Jeśli używasz lokalnego środowiska, zainstaluj wymagane biblioteki i użyj CMake do kompilacji.\n\n## Użycie\n\n### Inicjalizacja\n\nSkrypt inicjalizuje stany początkowe enkoderów, ustawia domyślne wartości przesunięć oraz przygotowuje wątki odpowiedzialne za obsługę enkoderów i reset pozycji.\n\n```cpp\nvoid init()\n{\n    input_wheel_start_state = hMot1.getEncoderCnt();\n    output_wheel_start_state = hMot2.getEncoderCnt();\n    actuator_start_state = hMot3.getEncoderCnt();\n\n    for (int i = 0; i \u003c binary_array_size; ++i)\n    {\n        binary_array[i] = 1;\n    }\n    binary_array_index = 0;\n\n    sys.taskCreate(input_wheel_encoder);\n    sys.taskCreate(clear_button_thread_loop);\n}\n```\n\n### Obsługa enkodera wejściowego\n\nFunkcja `input_wheel_encoder` monitoruje zmiany pozycji enkodera i na podstawie przesunięcia względem pozycji początkowej ustawia wartości w tablicy `binary_array`.\n\n```cpp\nvoid input_wheel_encoder()\n{\n    while (input_wheel_encoder_run)\n    {\n        input_wheel_curent_state = hMot1.getEncoderCnt();\n\n        if (!input_wheel_home_position_run \u0026\u0026\n            abs(input_wheel_start_state - input_wheel_curent_state) \u003e input_wheel_offset \u0026\u0026\n            binary_array_index \u003c binary_array_size)\n        {\n            binary_array[binary_array_index] = (input_wheel_curent_state \u003e input_wheel_start_state) ? 1 : 0;\n            binary_array_index++;\n        }\n        sys.delay(input_wheel_encoder_delay);\n    }\n}\n```\n\n### Wyświetlanie danych na kole wyjściowym\n\nFunkcja `output_wheel_show` obraca koło wyjściowe na podstawie przetworzonej wartości binarnej i aktywuje siłownik.\n\n```cpp\nvoid output_wheel_show()\n{\n    int position = output_number * output_wheel_step;\n    hMot2.rotAbs(position, output_wheel_power, true, INFINITE);\n    hMot3.rotAbs(actuator_start_state + actuator_target_state, actuator_power, true, INFINITE);\n}\n```\n\n### Konwersja danych binarnych\n\nFunkcja `binaryToDecimal` konwertuje dane binarne z tablicy na liczbę dziesiętną i weryfikuje, czy wynik nie przekracza ustalonego limitu.\n\n```cpp\nint binaryToDecimal(const bool* binary, int size) {\n    int decimal = 0;\n    for (int i = 0; i \u003c size; ++i) {\n        decimal += binary[i] * (1 \u003c\u003c (size - 1 - i));\n    }\n    if (decimal \u003e border_top) {\n        Serial.printf(\"ERROR: Value out of range\\r\\n\");\n        return 0;\n    }\n    return decimal;\n}\n```\n\n### Reset pozycji i bufora\n\nFunkcja `input_wheel_home_position` resetuje pozycję koła wejściowego do wartości początkowej. Funkcja `clear_buffor` umożliwia reset danych binarnych w przypadku błędu lub potrzeby ponownego uruchomienia.\n\n```cpp\nvoid input_wheel_home_position()\n{\n    hMot1.rotAbs(input_wheel_start_state, input_wheel_power, true, INFINITE);\n}\n\nvoid clear_buffor(bool all = false)\n{\n    if (all) {\n        for (int i = 0; i \u003c binary_array_size; ++i) {\n            binary_array[i] = 1;\n        }\n        binary_array_index = 0;\n    } else {\n        if (binary_array_index \u003e 0) {\n            binary_array[--binary_array_index] = 1;\n        }\n    }\n}\n```\n\n### Debugowanie\n\nFunkcja `debug_info` wyświetla dane diagnostyczne z enkoderów w regularnych odstępach czasu.\n\n```cpp\nvoid debug_info()\n{\n    while (debug)\n    {\n        Serial.printf(\"hMot1: %d\\thMot2: %d\\thMot3: %d\\r\\n\", hMot1.getEncoderCnt(), hMot2.getEncoderCnt(), hMot3.getEncoderCnt());\n        sys.delay(debug_info_delay);\n    }\n}\n```\n\n## Autor\n\nJakub Niewiarowski\n\n## Licencja\n\nProjekt jest licencjonowany na zasadach licencji MIT. Szczegóły znajdują się w pliku [LICENSE](LICENSE). \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniewiaro%2Fhusarion-telegraf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniewiaro%2Fhusarion-telegraf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniewiaro%2Fhusarion-telegraf/lists"}