/ru/robot/robot.h

https://bitbucket.org/VladimirL/robotutils · C Header · 121 lines · 88 code · 21 blank · 12 comment · 0 complexity · fa1e43d1075f7bcae70f63c63acfdb23 MD5 · raw file

  1. #ifndef ROBOT_H
  2. #define ROBOT_H
  3. #include <QPointF>
  4. #include <QReadWriteLock>
  5. #include <QDebug>
  6. #include <cmath>
  7. #include "ru/gui/map_widget.h"
  8. #include "ru/utils/angle.h"
  9. //! ???? ????? ????????
  10. enum point_state{
  11. ps_none = 0,
  12. ps_old = 1,
  13. ps_current = 2,
  14. ps_new = 3
  15. };
  16. // ???????? ????????? ????? ??????
  17. // ??? ???????? ? ?????? ? ????????
  18. class RobotDescription {
  19. public:
  20. float wheel_left_length;
  21. float wheel_right_length;
  22. float chasis_width_d2; // ???????? ?????????? ????? ????????
  23. float steps_count; // ????? ???????? ?? ??????
  24. RobotDescription() {
  25. wheel_left_length = 1;
  26. wheel_right_length = 1;
  27. chasis_width_d2 = 0.5;
  28. steps_count = 32;
  29. }
  30. RobotDescription(float wheel_l, float wheel_r, float width_d2, float steps_count) {
  31. RobotDescription::wheel_left_length = wheel_l;
  32. RobotDescription::wheel_right_length = wheel_r;
  33. RobotDescription::chasis_width_d2 = width_d2;
  34. RobotDescription::steps_count = steps_count;
  35. }
  36. };
  37. //! ??????? ??????
  38. class RobotPosition {
  39. public:
  40. float x;
  41. float y;
  42. float a;
  43. float speed; //!< ???????? ? ?/?
  44. RobotPosition() {
  45. x = 0;
  46. y = 0;
  47. a = 0;
  48. speed = 0;
  49. }
  50. RobotPosition(float x, float y, float ang, float speed = 0.0f) {
  51. RobotPosition::x = x;
  52. RobotPosition::y = y;
  53. RobotPosition::a = ang;
  54. RobotPosition::speed = speed;
  55. }
  56. inline operator QPointF() const {
  57. return QPointF(x,y);
  58. }
  59. inline float distanceTo(const RobotPosition& pos)
  60. {
  61. return sqrt(sqr(pos.x-x)+sqr(pos.y-y));
  62. }
  63. };
  64. //-----------------------------------------------------
  65. //! Gozel desc
  66. class robot_gozel_description {
  67. public:
  68. float chassis_lenght; //!< ????? ???????? ????
  69. float chassis_width; //!< ?????? ???????? ????
  70. float wheel_length; //!< ????? ??????
  71. float steps_count; //!< ????? ???????? ?? ?????? ??????
  72. robot_gozel_description() {
  73. chassis_lenght = 2.9f;
  74. chassis_width = 1.6f;
  75. wheel_length = 2.101f;
  76. steps_count = 32.0;
  77. }
  78. robot_gozel_description(float lenght, float width, float wheel_length, float steps_count) {
  79. robot_gozel_description::chassis_lenght = lenght;
  80. robot_gozel_description::chassis_width = width;
  81. robot_gozel_description::wheel_length = wheel_length;
  82. robot_gozel_description::steps_count = steps_count;
  83. }
  84. };
  85. //---------------------------------------------------------------------------------------------------------
  86. //! ????? ????????
  87. class Waypoint {
  88. public:
  89. // ?????????
  90. RobotPosition pos;
  91. // ??????. ????? ?????? ??? ????????? ??? ???
  92. point_state attr; // 0 - ??? 1 - ????????? 2 - ??????? 3 - ?????
  93. // tag
  94. int point_tag;
  95. Waypoint();
  96. Waypoint(const RobotPosition& pos, point_state attr = ps_new);
  97. };
  98. //! ??? ??????????
  99. typedef std::vector<Waypoint> WaypointList;
  100. #endif // ROBOT_H