Projektarbeit Line Following Robot bei Prof. Chowanetz im WS22/23
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.cpp 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include <iostream>
  2. #include <lfr.h>
  3. #include <lfr_socket.h>
  4. #include <uart_communication.h>
  5. #include "lfr_state_machine.h"
  6. #include "lfr_states.h"
  7. int main(void)
  8. {
  9. std::cout << "started central" << std::endl;
  10. const int thresholdBinary = 140;
  11. const int videoHeight = 720;
  12. const int videoWidth = 1280;
  13. const int gaussKernelSize = 11;
  14. std::mutex mutex;
  15. // Init State Machine;
  16. std::cout << "create State Machine" << std::endl;
  17. LFR_StateMachine stateMachine(State::Idle::getInstance());
  18. // Init LFR Autonomous mode
  19. std::cout << "create lfr" << std::endl;
  20. LFR lfr(videoHeight, videoWidth, thresholdBinary, gaussKernelSize, [&](std::exception const &ex)
  21. {
  22. std::unique_lock<std::mutex> lock(mutex);
  23. std::cerr<<"camera exception:"<<ex.what()<<std::endl;
  24. return false;
  25. });
  26. // Init UART Communication
  27. std::cout << "create uart" << std::endl;
  28. LFR_UART uartCommunicator;
  29. // Init Socket Communication
  30. std::cout << "create socket" << std::endl;
  31. LFR_Socket socket([&](std::exception const &ex)
  32. {
  33. std::unique_lock<std::mutex> lock(mutex);
  34. std::cerr<<"socket exception:"<<ex.what()<<std::endl;
  35. return false;
  36. });
  37. // Connect String parser to socket
  38. socket.addListener([&](LFR_Socket::LFR_Telegram telegram)
  39. {
  40. std::unique_lock<std::mutex> lock(mutex);
  41. std::cout << telegram;
  42. }, &mutex);
  43. socket.startLoop();
  44. //Start the permanent loop
  45. char input;
  46. std::cout << "press q to quit" << std::endl;
  47. std::cin >> input;
  48. std::cout << "cinned" << std::endl;
  49. while (input != 'q')
  50. {
  51. std::cin >> input;
  52. std::cout << "cinned" << std::endl;
  53. }
  54. std::cout << "Exiting central" << std::endl;
  55. return 0;
  56. }