-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClassDiagram.pu
423 lines (390 loc) · 15 KB
/
ClassDiagram.pu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
@startuml ETRobocon2024
hide empty members
package "etrobocon2024" {
package "module" {
package "API" {
class Controller{
+ static constexpr double MOTOR_PWM_MAX = 100.0
+ static constexpr double MOTOR_PWM_MIN = -100.0
+ Controller(rightWheel(PORT_B), leftWheel(PORT_C), armMortor(PORT_A))
+ void setRightMotorPwm(const double pwm)
+ void setLeftMotorPwm(const double pwm)
+ void resetRightMotorPwm()
+ void resetLeftMotorPwm()
+ void resetWheelsMotorPwm()
+ void stopWheelsMotor()
+ void setArmMotorPwm(const double pwm)
+ void resetArmMotorPwm()
+ void stopArmMotor()
+ double getRightMotorPwm()
+ double getLeftMotorPwm()
- ev3api::Motor rightWheel
- ev3api::Motor leftWheel
- ev3api::Motor armMotor
- static double pwmOfRightWheel
- static double pwmOfLeftWheel
- static double pwmOfArm
- double limitPwmValue(const double inputPwm)
}
class Measurer {
+ Measurer(colorSensor(PORT_2), sonarSensor(PORT_3), leftWheel(PORT_C), rightWheel(PORT_B), armMotor(PORT_A))
+ int getBrightness()
+ rgb_raw_t getRawColor()
+ int getLeftCount()
+ int getRightCount()
+ int getArmMotorCount()
+ bool getLeftButton()
+ bool getRightButton()
+ bool getEnterButton()
+ int getForwardDistance()
+ double getVoltage()
- ev3api::ColorSensor colorSensor
- ev3api::SonarSensor sonarSensor
- ev3api::Motor leftWheel
- ev3api::Motor rightWheel
- ev3api::Motor armMotor
}
class Timer {
+ Timer()
+ void sleep(int milliSec = 10)
+ int now()
- ev3api::Clock clock
}
}
package "Calculator" {
enum COLOR <<int>> {
NONE = 0
BLACK = 1
WHITE = 2
BLUE = 3
GREEN = 4
YELLOW = 5
RED = 6
}
struct Hsv {
- int hue
- int saturation
- int value
}
class ColorJudge {
+ ColorJudge() = delete
+ static COLOR getColor(rgb_raw_t const& rgb)
+ static COLOR stringToColor(const char* str)
+ static const char* colorToString(COLOR color)
- static constexpr int SATURATION_BORDER = 27
- static constexpr int BLACK_LIMIT_BORDER = 10
- static constexpr int WHITE_LIMIT_BORDER = 250
- static constexpr int BLACK_BORDER = 110
- static constexpr int RED_BORDER = 25
- static constexpr int YELLOW_BORDER = 50
- static constexpr int GREEN_BORDER = 170
- static constexpr int BLUE_BORDER = 300
- static constexpr rgb_raw_t MAX_RGB = { 244, 245, 252 }
- static constexpr rgb_raw_t MIN_RGB = { 9, 10, 10 }
- static Hsv convertRgbToHsv(rgb_raw_t const& rgb)
}
class Mileage {
+ static double calculateWheelMileage(int angle)
+ static double calculateMileage(int rightAngle, int leftAngle)
- Mileage()
}
struct PidGain {
+ double kp
+ double ki
+ double kd
- PidGain(double _kp, double _ki, double _kd)
}
class Pid {
+ Pid(double _kp, double _ki, double _kd, double _targetValue)
+ void setPidGain(double _kp, double _ki, double _kd)
+ double calculatePid(double currentValue, double delta = 0.01)
- PidGain pidGain
- double prevDeviation
- double integral
- double targetValue
}
class SpeedCalculator {
+ SpeedCalculator(double _targetSpeed)
+ SpeedCalculator(double _rightTargetSpeed, double _leftTargetSpeed)
+ double calculateRightMotorPwmFromTargetSpeed()
+ double calculateLeftMotorPwmFromTargetSpeed()
- const double rightTargetSpeed
- const double leftTargetSpeed
- Pid rightPid
- Pid leftPid
- Timer timer
- Measurer measurer
- double rightMotorPwm
- double leftMotorPwm
- double prevRightMileage
- double prevLeftMileage
- int prevRightTime
- int prevLeftTime
- static constexpr double K_P = 0.004
- static constexpr double K_I = 0.0000005
- static constexpr double K_D = 0.0007
- static constexpr double R_K_P = 0.004
- static constexpr double R_K_I = 0.0000005
- static constexpr double R_K_D = 0.0007
- double calculateSpeed(double diffMileage, double diffTime)
}
}
package "common" {
class Logger {
+ Logger()
+ void log(const char* logMessage)
+ void logWarning(const char* warningMessage)
+ void logError(const char* errorMessage)
+ void logHighlight(const char* highlightLog)
+ void outputToFile()
+ void initLogs()
- static char logs[65536]
}
class StringOperator {
+ static char* removeEOL(const char* string)
- StringOperator()
}
}
package "Motion" {
class ColorLineTracing {
+ ColorLineTracing(COLOR _targetColor, double _targetSpeed, int _targetBrightness, const PidGain& _gain, bool& _isLeftEdge)
+ using LineTracing::run
# bool isMetPreCondition(double targetSpeed) override
# bool isMetContinuationCondition() override
# void logRunning() override
- static constexpr int JUDGE_COUNT = 3
- int colorCount = 0
- COLOR targetColor
}
LineTracing <|-- ColorLineTracing
class ColorStraight {
+ ColorStraight(COLOR _targetColor, double _speed)
# virtual bool isMetPreCondition() override
# virtual bool isMetContinuationCondition() override
# virtual void logRunning() override
- static constexpr int JUDGE_COUNT = 3
- int colorCount = 0
- COLOR targetColor
}
Straight <|-- ColorStraight
class DistanceLineTraicing {
+ DistanceLineTracing(double _targetDistance, double _targetSpeed, int _targetBrightness, const PidGain& _pidGain, bool& _isLeftEdge)
+ using LineTracing::run
# bool isMetPreCondition(double targetSpeed) override
# bool isMetContinuationCondition() override
# void logRunning() override
- double targetDistance
}
LineTracing <|-- DistanceLineTraicing
class DistanceStraight {
+ DistanceStraight(double _targetDiatance, double _speed)
# virtual bool isMetPreCondition() override
# virtual bool isMetContinuationCondition() override
# virtual void logRunning() override
- double targetDistance
}
Straight <|-- DistanceStraight
class EdgeChanging {
+ EdgeChanging(bool& _isLeftEdge, bool _nextEdge)
# void run()
# void logRunning()
- bool& isLeftEdge
- bool nextEdge
}
Motion <|-- EdgeChanging
class LineTracing {
+ LineTracing(double _targetSpeed, int _targetBrightness, const PidGain& _pidGain, bool& _isLeftEdge)
+ void run()
# virtual bool isMetPreCondition(double targetSpeed) = 0
# virtual bool isMetContinuationCondition() = 0
# virtual void logRunning()
# double targetSpeed
# int targetBrightness
# PidGain pidGain
# bool& isLeftEdge
# double initLeftMileage
# double initRightMileage
# double initDistance
# Timer timer
# Measurer measurer
# Controller controller
}
Motion <|-- LineTracing
class Motion {
+ Motion()
+ virtual void run() = 0
+ virtual void logRunning() = 0
# Logger logger
}
class PwmRotation {
+ PwmRotation(int _targetAngle, int _pwm, bool _isClockwise)
+ using Rotation::run
+ bool isMetPreCondition() override
+ bool isMetContCondition(double initLeftMileage, double initRightMileage, int leftSign, int rightSign) override
+ void logRunning() override
}
Rotation <|-- PwmRotation
class ResetWheelsMotorPwm {
+ ResetWheelsMotorPwm()
+ void run()
+ void logRunning()
- Controller controller
}
Motion <|-- ResetWheelsMotorPwm
class Rotation {
+ Rotation(int _targetAngle, int _pwm, bool _isClockwise)
+ void run()
+ virtual bool isMetPreCondition() = 0
+ virtual bool isMetContCondition(double targetLeftDistance, double targetRightDistance, int leftSign, int rightSign) = 0
+ virtual void logRunning() = 0
# int targetAngle
# int pwm
# bool isClockwise
# Timer timer
# Controller controller
# Measurer measurer
}
Motion <|-- Rotation
class Sleeping {
+ Sleeping(int milliSec)
+ void run()
+ void logRunning()
- int milliSec
- Timer timer
}
Motion <|-- Sleeping
class StopWheelsMotor {
+ StopWheelsMotor()
+ void run()
+ void logRunning()
- Controller controller
}
Motion <|-- StopWheelsMotor
class Straight {
+ Straight(double _speed)
+ void run()
# virtual bool isMetPreCondition()
# virtual bool isMetContinuationCondition() = 0
# virtual void logRunning()
# double targetSpeed
# double initialDistance
# Timer timer
# Measurer measurer
}
Motion <|-- Straight
}
enum Area <<int>> {
LineTrace = 0
DoubleLoop = 1
DebrisRemoval = 2
SmartCarry = 3
}
class AreaMaster {
- Area area
- bool isLeftCourse
- bool isLeftEdge
- int targetBrightness
- const char* basePath = "etrobocon2024/datafiles/"
- const char* commandFileNames[4] = { "LineTrace", "DoubleLoop", "DebrisRemoval", "SmartCarry" }
+ AreaMaster(Area area, bool isLeftCourse, bool& isLeftEdge, int targetBrightness)
+ void run()
}
class Calibrator {
- bool isLeftCourse
- int targetBrightness
- Timer timer
- Measurer measurer
--
+ Calibrator(bool isLeftCourse = true, int targetBrightness = 50)
+ void run()
+ void waitForStart()
+ bool getIsLeftCourse()
+ int getTargetBrightness()
- void selectAndSetCourse()
- void measureAndSetTargetBrightness()
}
class EtRobocon2024 {
+ static void start()
- static void sigint(int _)
}
enum COMMAND <<int>> {
DL = 0
CL = 1
DS = 2
CS = 3
PR = 4
DT = 5
EC = 6
SL = 7
AU = 8
AD = 9
XR = 10
RM = 11
SM = 12
NONE = 13
}
class MotionParser {
+ static std::vector<Motion*> createMotions(const char* filePath, int targetBrightness, bool& isLeftEdge)
- MotionParser()
- static COMMAND convertCommand(char* str)
- static bool convertBool(char* command, char* stringParameter)
}
}
package "front_camera" {
class CameraInterface {
start_camera(self) -> None
capture_image_picamera2(self, save_path) -> None
capture_save_image(self, save_path) -> None
}
class CaptureImage {
sharpen_image(self, np.ndarray img) -> np.ndarray
resize_image(self, np.ndarray img) -> np.ndarray
capture(self) -> None
}
}
}
package "etrobocon2024-camera-system" {
package "src" {
class CameraSystem {
start(self) -> None
}
class CameraInterface {
start_record(self) -> cv2.VideoWriter, cv2.VideoWriter
end_record(self) -> None
get_frame(self) -> None
}
class Client {
get_robot_state(self) -> str
set_true_camera_action_skip(self) -> None
}
CameraSystem <-- Client
class DetectObject {
detect_object(self, str image_path, str save_path) -> List[object]
}
class ImageProcessing {
sharpen_image(str image_path, str save_path) -> np.ndarray
resize_image(str image_path, str save_path, int resize_h, int resize_w) -> np.ndarray
}
class ResponseError {
ResponseError(self, str message)
}
class OfficialInterface {
str server_ip
int team_id
upload_snap(cls, int pwm) -> bool
}
class RoboSnap {
RoboSnap(self, str raspike_ip) -> None
scp_fig_image(self) -> str, str
check_best_shot(self, List[object] objects) -> int
start_snap(self) -> None
}
class TrainTracker {
calibrate(self) -> None
observe(self) -> None
detect_train(self, frame, initial_frame) -> None
}
CameraInterface <|.. TrainTracker
}
}
@enduml