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