Revision 3c3c3bb9 devices/DiWheelDrive/userthread.hpp
devices/DiWheelDrive/userthread.hpp | ||
---|---|---|
6 | 6 |
#include <amiro/Color.h> |
7 | 7 |
// #include "global.hpp" |
8 | 8 |
// #include "linefollow.hpp" |
9 |
#include <cmath> |
|
10 | 9 |
|
11 | 10 |
|
12 | 11 |
|
... | ... | |
59 | 58 |
#define DEVIATION_CORRECTION_VALUE (DEVIATION_CORRECTION_SPEED / 2) |
60 | 59 |
#define DEVIATION_DIST_THRESH 25000 |
61 | 60 |
|
61 |
|
|
62 |
|
|
63 |
// Map Tracking Parameters |
|
64 |
// enable amiro map to continuously build internal map representation |
|
65 |
#define AMIRO_MAP_AUTO_TRACKING true |
|
66 |
|
|
67 |
|
|
68 |
|
|
62 | 69 |
namespace amiro { |
63 | 70 |
|
64 | 71 |
|
... | ... | |
69 | 76 |
public: |
70 | 77 |
|
71 | 78 |
// States of user thread state machine |
72 |
enum states : int8_t{ |
|
73 |
IDLE = 0, |
|
74 |
FOLLOW_LINE = 1, |
|
75 |
DETECT_STATION = 2, |
|
76 |
REVERSE = 3, |
|
77 |
PUSH_BACK = 4, |
|
78 |
CHECK_POSITIONING = 5, |
|
79 |
CHECK_VOLTAGE = 6, |
|
80 |
CHARGING = 7, |
|
81 |
RELEASE = 8, |
|
82 |
RELEASE_TO_CORRECT = 9, |
|
83 |
CORRECT_POSITIONING = 10, |
|
84 |
TURN = 12, |
|
85 |
INACTIVE = 13, |
|
86 |
CALIBRATION = 14, |
|
87 |
CALIBRATION_CHECK = 15, |
|
88 |
DEVIATION_CORRECTION = 16, |
|
89 |
TEST_MAP_STATE = 17, |
|
90 |
DOCKING_ERROR = -1, |
|
91 |
REVERSE_TIMEOUT_ERROR = -2, |
|
92 |
CALIBRATION_ERROR = -3, |
|
93 |
WHITE_DETECTION_ERROR = -4, |
|
94 |
PROXY_DETECTION_ERROR = -5, |
|
95 |
NO_CHARGING_POWER_ERROR = -6, |
|
96 |
UNKNOWN_STATE_ERROR = -7 |
|
97 |
}; |
|
98 |
|
|
99 |
struct ut_counter{ |
|
79 |
// enum ut_states : int8_t { |
|
80 |
// UT_IDLE = 0, |
|
81 |
// UT_FOLLOW_LINE = 1, |
|
82 |
// UT_DETECT_STATION = 2, |
|
83 |
// UT_REVERSE = 3, |
|
84 |
// UT_PUSH_BACK = 4, |
|
85 |
// UT_CHECK_POSITIONING = 5, |
|
86 |
// UT_CHECK_VOLTAGE = 6, |
|
87 |
// UT_CHARGING = 7, |
|
88 |
// UT_RELEASE = 8, |
|
89 |
// UT_RELEASE_TO_CORRECT = 9, |
|
90 |
// UT_CORRECT_POSITIONING = 10, |
|
91 |
// UT_TURN = 12, |
|
92 |
// UT_INACTIVE = 13, |
|
93 |
// UT_CALIBRATION = 14, |
|
94 |
// UT_CALIBRATION_CHECK = 15, |
|
95 |
// UT_DEVIATION_CORRECTION = 16, |
|
96 |
// UT_TEST_MAP_STATE = 17, |
|
97 |
// UT_TEST_MAP_AUTO_STATE = 18, |
|
98 |
// UT_DOCKING_ERROR = -1, |
|
99 |
// UT_REVERSE_TIMEOUT_ERROR = -2, |
|
100 |
// UT_CALIBRATION_ERROR = -3, |
|
101 |
// UT_WHITE_DETECTION_ERROR = -4, |
|
102 |
// UT_PROXY_DETECTION_ERROR = -5, |
|
103 |
// UT_NO_CHARGING_POWER_ERROR = -6, |
|
104 |
// UT_UNKNOWN_STATE_ERROR = -7 |
|
105 |
// }; |
|
106 |
|
|
107 |
struct ut_counter { |
|
100 | 108 |
int whiteCount = 0; |
101 | 109 |
int ringProxCount = 0; |
102 | 110 |
// int correctionCount = 0; |
... | ... | |
195 | 203 |
*/ |
196 | 204 |
int checkDockingSuccess(); |
197 | 205 |
|
198 |
// State Variables |
|
199 |
states prevState = states::IDLE; |
|
200 |
states currentState = states::IDLE; |
|
201 |
states newState = states::IDLE; |
|
206 |
|
|
202 | 207 |
|
203 | 208 |
bool continue_on_obstacle = true; |
204 | 209 |
uint16_t rProx[8]; // buffer for ring proxy values |
Also available in: Unified diff