cfclient 2017.4__py3-none-any.whl → 2025.12.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. cfclient/__init__.py +16 -11
  2. cfclient/configs/config.json +4 -3
  3. cfclient/configs/input/Generic_OS_X.json +1 -0
  4. cfclient/configs/input/Joystick.json +1 -0
  5. cfclient/configs/input/PS3_Mode_1.json +1 -0
  6. cfclient/configs/input/PS3_Mode_2.json +1 -0
  7. cfclient/configs/input/PS3_Mode_3.json +1 -0
  8. cfclient/configs/input/PS4_Mode_1.json +1 -0
  9. cfclient/configs/input/PS4_Mode_2.json +1 -0
  10. cfclient/configs/input/PS4_shoulder_btns_yaw.json +1 -0
  11. cfclient/configs/input/xbox360_mode1.json +1 -0
  12. cfclient/configs/log/PID_tuning/Attitude.json +46 -0
  13. cfclient/configs/log/PID_tuning/Attitude_rate.json +46 -0
  14. cfclient/configs/log/PID_tuning/Position.json +46 -0
  15. cfclient/configs/log/PID_tuning/Velocity.json +46 -0
  16. cfclient/configs/log/PID_tuning_components/Pitch.json +22 -0
  17. cfclient/configs/log/PID_tuning_components/Pitch_rate.json +22 -0
  18. cfclient/configs/log/PID_tuning_components/Position_x.json +22 -0
  19. cfclient/configs/log/PID_tuning_components/Position_y.json +22 -0
  20. cfclient/configs/log/PID_tuning_components/Position_z.json +22 -0
  21. cfclient/configs/log/PID_tuning_components/Roll.json +22 -0
  22. cfclient/configs/log/PID_tuning_components/Roll_rate.json +22 -0
  23. cfclient/configs/log/PID_tuning_components/Velocity_x.json +22 -0
  24. cfclient/configs/log/PID_tuning_components/Velocity_y.json +22 -0
  25. cfclient/configs/log/PID_tuning_components/Velocity_z.json +22 -0
  26. cfclient/configs/log/PID_tuning_components/Yaw.json +22 -0
  27. cfclient/configs/log/PID_tuning_components/Yaw_rate.json +22 -0
  28. cfclient/gui.py +44 -9
  29. cfclient/headless.py +3 -12
  30. cfclient/resources/log_param_doc.json +1 -0
  31. cfclient/ui/connectivity_manager.py +198 -0
  32. cfclient/ui/dialogs/about.py +53 -36
  33. cfclient/ui/dialogs/about.ui +23 -3
  34. cfclient/ui/dialogs/anchor_position_dialog.py +252 -0
  35. cfclient/ui/dialogs/anchor_position_dialog.ui +138 -0
  36. cfclient/ui/dialogs/basestation_mode_dialog.py +185 -0
  37. cfclient/ui/dialogs/basestation_mode_dialog.ui +186 -0
  38. cfclient/ui/dialogs/bootloader.py +448 -85
  39. cfclient/ui/dialogs/bootloader.ui +387 -134
  40. cfclient/ui/dialogs/cf2config.py +4 -4
  41. cfclient/ui/dialogs/cf2config.ui +3 -4
  42. cfclient/ui/dialogs/inputconfigdialogue.py +24 -19
  43. cfclient/ui/dialogs/inputconfigdialogue.ui +53 -30
  44. cfclient/ui/dialogs/lighthouse_bs_geometry_dialog.py +220 -0
  45. cfclient/ui/dialogs/lighthouse_bs_geometry_dialog.ui +110 -0
  46. cfclient/ui/dialogs/lighthouse_system_type_dialog.py +93 -0
  47. cfclient/ui/dialogs/lighthouse_system_type_dialog.ui +121 -0
  48. cfclient/ui/dialogs/logconfigdialogue.py +401 -101
  49. cfclient/ui/dialogs/logconfigdialogue.ui +117 -72
  50. cfclient/ui/icons/bl.webp +0 -0
  51. cfclient/ui/icons/bolt.webp +0 -0
  52. cfclient/ui/icons/cf21.webp +0 -0
  53. cfclient/ui/icons/checkmark_black.png +0 -0
  54. cfclient/ui/icons/checkmark_white.png +0 -0
  55. cfclient/ui/icons/create.png +0 -0
  56. cfclient/ui/icons/delete.png +0 -0
  57. cfclient/ui/icons/flapper.webp +0 -0
  58. cfclient/ui/icons/tag.webp +0 -0
  59. cfclient/ui/main.py +328 -258
  60. cfclient/ui/main.ui +184 -80
  61. cfclient/ui/pluginhelper.py +7 -1
  62. cfclient/ui/pose_logger.py +116 -0
  63. cfclient/ui/tab_toolbox.py +208 -0
  64. cfclient/ui/tabs/ColorLEDTab.py +752 -0
  65. cfclient/ui/tabs/ConsoleTab.py +48 -13
  66. cfclient/ui/{toolboxes → tabs}/CrtpSharkToolbox.py +19 -34
  67. cfclient/ui/tabs/ExampleTab.py +9 -16
  68. cfclient/ui/tabs/FlightTab.py +437 -325
  69. cfclient/ui/tabs/GpsTab.py +14 -20
  70. cfclient/ui/tabs/LEDRingTab.py +277 -0
  71. cfclient/ui/tabs/LogBlockDebugTab.py +20 -27
  72. cfclient/ui/tabs/LogBlockTab.py +35 -35
  73. cfclient/ui/tabs/LogClientTab.py +85 -0
  74. cfclient/ui/tabs/LogTab.py +50 -27
  75. cfclient/ui/tabs/ParamTab.py +443 -57
  76. cfclient/ui/tabs/PlotTab.py +23 -25
  77. cfclient/ui/tabs/TuningTab.py +292 -0
  78. cfclient/ui/tabs/__init__.py +12 -2
  79. cfclient/ui/tabs/colorLEDTab.ui +624 -0
  80. cfclient/ui/tabs/consoleTab.ui +46 -0
  81. cfclient/ui/tabs/flightActionContainer.ui +103 -0
  82. cfclient/ui/tabs/flightTab.ui +724 -237
  83. cfclient/ui/tabs/{ledTab.ui → ledRingTab.ui} +63 -46
  84. cfclient/ui/tabs/lighthouse_tab.py +714 -0
  85. cfclient/ui/tabs/lighthouse_tab.ui +430 -0
  86. cfclient/ui/tabs/locopositioning_tab.py +606 -389
  87. cfclient/ui/tabs/locopositioning_tab.ui +370 -253
  88. cfclient/ui/tabs/logClientTab.ui +52 -0
  89. cfclient/ui/tabs/logTab.ui +1 -1
  90. cfclient/ui/tabs/paramTab.ui +204 -3
  91. cfclient/ui/tabs/tuningTab.ui +773 -0
  92. cfclient/ui/widgets/ai.py +37 -39
  93. cfclient/ui/widgets/hexspinbox.py +16 -10
  94. cfclient/ui/widgets/plotter.ui +39 -47
  95. cfclient/ui/widgets/plotwidget.py +57 -22
  96. cfclient/ui/widgets/super_slider.py +112 -0
  97. cfclient/ui/wizards/__init__.py +0 -0
  98. cfclient/ui/wizards/bslh_1.png +0 -0
  99. cfclient/ui/wizards/bslh_2.png +0 -0
  100. cfclient/ui/wizards/bslh_3.png +0 -0
  101. cfclient/ui/wizards/bslh_4.png +0 -0
  102. cfclient/ui/wizards/bslh_5.png +0 -0
  103. cfclient/ui/wizards/lighthouse_geo_bs_estimation_wizard.py +465 -0
  104. cfclient/utils/config_manager.py +5 -4
  105. cfclient/utils/input/__init__.py +77 -19
  106. cfclient/utils/input/inputinterfaces/wiimote.py +2 -2
  107. cfclient/utils/input/inputreaderinterface.py +17 -7
  108. cfclient/utils/input/inputreaders/__init__.py +17 -0
  109. cfclient/utils/logconfigreader.py +245 -25
  110. cfclient/utils/logdatawriter.py +3 -1
  111. cfclient/utils/periodictimer.py +1 -1
  112. cfclient/utils/ui.py +336 -0
  113. cfclient/utils/zmq_led_driver.py +5 -0
  114. cfclient/utils/zmq_param.py +6 -0
  115. cfclient/version.py +34 -1
  116. cfclient-2025.12.1.dist-info/METADATA +70 -0
  117. cfclient-2025.12.1.dist-info/RECORD +152 -0
  118. {cfclient-2017.4.dist-info → cfclient-2025.12.1.dist-info}/WHEEL +1 -1
  119. {cfclient-2017.4.dist-info → cfclient-2025.12.1.dist-info}/entry_points.txt +0 -1
  120. cfclient-2025.12.1.dist-info/licenses/LICENSE.txt +350 -0
  121. {cfclient-2017.4.dist-info → cfclient-2025.12.1.dist-info}/top_level.txt +1 -0
  122. cfconfig/Makefile +51 -0
  123. cfconfig/configblock.py +111 -0
  124. cfloader/__init__.py +41 -55
  125. cfzmq/__init__.py +22 -14
  126. cfclient/ui/dialogs/cf1config.py +0 -265
  127. cfclient/ui/dialogs/cf1config.ui +0 -260
  128. cfclient/ui/tab.py +0 -96
  129. cfclient/ui/tabs/LEDTab.py +0 -169
  130. cfclient/ui/toolboxes/ConsoleToolbox.py +0 -69
  131. cfclient/ui/toolboxes/DebugDriverToolbox.py +0 -107
  132. cfclient/ui/toolboxes/__init__.py +0 -45
  133. cfclient/ui/toolboxes/consoleToolbox.ui +0 -62
  134. cfclient/ui/toolboxes/debugDriverToolbox.ui +0 -86
  135. cfclient-2017.4.dist-info/DESCRIPTION.rst +0 -3
  136. cfclient-2017.4.dist-info/METADATA +0 -22
  137. cfclient-2017.4.dist-info/RECORD +0 -104
  138. cfclient-2017.4.dist-info/metadata.json +0 -1
  139. /cfclient/{icon-256.png → ui/icons/icon-256.png} +0 -0
  140. /cfclient/ui/{toolboxes → tabs}/crtpSharkToolbox.ui +0 -0
cfclient/ui/main.ui CHANGED
@@ -6,8 +6,8 @@
6
6
  <rect>
7
7
  <x>0</x>
8
8
  <y>0</y>
9
- <width>872</width>
10
- <height>671</height>
9
+ <width>1354</width>
10
+ <height>592</height>
11
11
  </rect>
12
12
  </property>
13
13
  <property name="windowTitle">
@@ -22,26 +22,10 @@
22
22
  <layout class="QVBoxLayout" name="verticalLayout_2">
23
23
  <item>
24
24
  <layout class="QGridLayout" name="gridLayout_2">
25
- <item row="0" column="0">
26
- <widget class="QComboBox" name="interfaceCombo">
27
- <property name="minimumSize">
28
- <size>
29
- <width>160</width>
30
- <height>0</height>
31
- </size>
32
- </property>
33
- <property name="editable">
34
- <bool>false</bool>
35
- </property>
36
- </widget>
37
- </item>
38
- <item row="0" column="1">
39
- <widget class="QPushButton" name="connectButton">
40
- <property name="minimumSize">
41
- <size>
42
- <width>60</width>
43
- <height>0</height>
44
- </size>
25
+ <item row="0" column="6">
26
+ <widget class="QLabel" name="batteryLabel">
27
+ <property name="text">
28
+ <string>Battery:</string>
45
29
  </property>
46
30
  </widget>
47
31
  </item>
@@ -53,29 +37,12 @@
53
37
  <height>0</height>
54
38
  </size>
55
39
  </property>
56
- </widget>
57
- </item>
58
- <item row="0" column="3">
59
- <spacer name="horizontalSpacer">
60
- <property name="orientation">
61
- <enum>Qt::Horizontal</enum>
62
- </property>
63
- <property name="sizeHint" stdset="0">
64
- <size>
65
- <width>40</width>
66
- <height>20</height>
67
- </size>
68
- </property>
69
- </spacer>
70
- </item>
71
- <item row="0" column="6">
72
- <widget class="QLabel" name="linkQualityLabel">
73
40
  <property name="text">
74
- <string>Link Quality:</string>
41
+ <string>Scan</string>
75
42
  </property>
76
43
  </widget>
77
44
  </item>
78
- <item row="0" column="7">
45
+ <item row="0" column="11">
79
46
  <widget class="QProgressBar" name="linkQualityBar">
80
47
  <property name="minimumSize">
81
48
  <size>
@@ -104,13 +71,48 @@
104
71
  </widget>
105
72
  </item>
106
73
  <item row="0" column="4">
107
- <widget class="QLabel" name="batteryLabel">
74
+ <widget class="QPushButton" name="esButton">
75
+ <property name="sizePolicy">
76
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
77
+ <horstretch>0</horstretch>
78
+ <verstretch>0</verstretch>
79
+ </sizepolicy>
80
+ </property>
81
+ <property name="minimumSize">
82
+ <size>
83
+ <width>130</width>
84
+ <height>0</height>
85
+ </size>
86
+ </property>
108
87
  <property name="text">
109
- <string>Battery:</string>
88
+ <string>Emergency stop</string>
110
89
  </property>
111
90
  </widget>
112
91
  </item>
113
- <item row="0" column="5">
92
+ <item row="0" column="9">
93
+ <widget class="QLabel" name="label">
94
+ <property name="text">
95
+ <string> volts </string>
96
+ </property>
97
+ </widget>
98
+ </item>
99
+ <item row="0" column="1">
100
+ <widget class="QPushButton" name="connectButton">
101
+ <property name="minimumSize">
102
+ <size>
103
+ <width>80</width>
104
+ <height>0</height>
105
+ </size>
106
+ </property>
107
+ <property name="toolTip">
108
+ <string/>
109
+ </property>
110
+ <property name="text">
111
+ <string>Connect</string>
112
+ </property>
113
+ </widget>
114
+ </item>
115
+ <item row="0" column="7">
114
116
  <widget class="QProgressBar" name="batteryBar">
115
117
  <property name="minimumSize">
116
118
  <size>
@@ -125,13 +127,13 @@
125
127
  </size>
126
128
  </property>
127
129
  <property name="minimum">
128
- <number>3000</number>
130
+ <number>3400</number>
129
131
  </property>
130
132
  <property name="maximum">
131
- <number>4200</number>
133
+ <number>4180</number>
132
134
  </property>
133
135
  <property name="value">
134
- <number>3000</number>
136
+ <number>3800</number>
135
137
  </property>
136
138
  <property name="textVisible">
137
139
  <bool>true</bool>
@@ -147,11 +149,100 @@
147
149
  </property>
148
150
  </widget>
149
151
  </item>
152
+ <item row="0" column="0">
153
+ <widget class="QComboBox" name="interfaceCombo">
154
+ <property name="sizePolicy">
155
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
156
+ <horstretch>2</horstretch>
157
+ <verstretch>0</verstretch>
158
+ </sizepolicy>
159
+ </property>
160
+ <property name="minimumSize">
161
+ <size>
162
+ <width>160</width>
163
+ <height>0</height>
164
+ </size>
165
+ </property>
166
+ <property name="maximumSize">
167
+ <size>
168
+ <width>250</width>
169
+ <height>16777215</height>
170
+ </size>
171
+ </property>
172
+ <property name="editable">
173
+ <bool>false</bool>
174
+ </property>
175
+ </widget>
176
+ </item>
177
+ <item row="0" column="8">
178
+ <widget class="QLineEdit" name="_aff_volts">
179
+ <property name="enabled">
180
+ <bool>true</bool>
181
+ </property>
182
+ <property name="sizePolicy">
183
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
184
+ <horstretch>0</horstretch>
185
+ <verstretch>0</verstretch>
186
+ </sizepolicy>
187
+ </property>
188
+ <property name="minimumSize">
189
+ <size>
190
+ <width>60</width>
191
+ <height>30</height>
192
+ </size>
193
+ </property>
194
+ <property name="maximumSize">
195
+ <size>
196
+ <width>60</width>
197
+ <height>40</height>
198
+ </size>
199
+ </property>
200
+ <property name="alignment">
201
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
202
+ </property>
203
+ <property name="readOnly">
204
+ <bool>true</bool>
205
+ </property>
206
+ </widget>
207
+ </item>
208
+ <item row="0" column="10">
209
+ <widget class="QLabel" name="linkQualityLabel">
210
+ <property name="text">
211
+ <string>Link Quality:</string>
212
+ </property>
213
+ </widget>
214
+ </item>
215
+ <item row="0" column="3">
216
+ <spacer name="horizontalSpacer">
217
+ <property name="orientation">
218
+ <enum>Qt::Horizontal</enum>
219
+ </property>
220
+ <property name="sizeHint" stdset="0">
221
+ <size>
222
+ <width>40</width>
223
+ <height>20</height>
224
+ </size>
225
+ </property>
226
+ </spacer>
227
+ </item>
228
+ <item row="0" column="5">
229
+ <spacer name="horizontalSpacer_3">
230
+ <property name="orientation">
231
+ <enum>Qt::Horizontal</enum>
232
+ </property>
233
+ <property name="sizeHint" stdset="0">
234
+ <size>
235
+ <width>40</width>
236
+ <height>20</height>
237
+ </size>
238
+ </property>
239
+ </spacer>
240
+ </item>
150
241
  </layout>
151
242
  </item>
152
243
  <item>
153
244
  <widget class="QGroupBox" name="groupBox">
154
- <layout class="QHBoxLayout" stretch="0,0,1">
245
+ <layout class="QHBoxLayout" stretch="0,0,0">
155
246
  <item>
156
247
  <widget class="QLabel" name="addressLabel">
157
248
  <property name="text">
@@ -161,26 +252,32 @@
161
252
  </item>
162
253
  <item>
163
254
  <widget class="HexSpinBox" name="address">
255
+ <property name="sizePolicy">
256
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
257
+ <horstretch>0</horstretch>
258
+ <verstretch>0</verstretch>
259
+ </sizepolicy>
260
+ </property>
164
261
  <property name="minimumSize">
165
262
  <size>
166
- <width>140</width>
263
+ <width>158</width>
167
264
  <height>0</height>
168
265
  </size>
169
266
  </property>
170
267
  </widget>
171
268
  </item>
172
269
  <item>
173
- <widget class="QCheckBox" name="autoReconnectCheckBox">
174
- <property name="mouseTracking">
175
- <bool>false</bool>
270
+ <spacer name="horizontalSpacer_2">
271
+ <property name="orientation">
272
+ <enum>Qt::Horizontal</enum>
176
273
  </property>
177
- <property name="text">
178
- <string>Auto Reconnect</string>
179
- </property>
180
- <property name="checked">
181
- <bool>false</bool>
274
+ <property name="sizeHint" stdset="0">
275
+ <size>
276
+ <width>40</width>
277
+ <height>20</height>
278
+ </size>
182
279
  </property>
183
- </widget>
280
+ </spacer>
184
281
  </item>
185
282
  </layout>
186
283
  </widget>
@@ -210,8 +307,8 @@
210
307
  <rect>
211
308
  <x>0</x>
212
309
  <y>0</y>
213
- <width>852</width>
214
- <height>500</height>
310
+ <width>1334</width>
311
+ <height>414</height>
215
312
  </rect>
216
313
  </property>
217
314
  <property name="sizePolicy">
@@ -224,11 +321,20 @@
224
321
  <property name="sizeConstraint">
225
322
  <enum>QLayout::SetNoConstraint</enum>
226
323
  </property>
227
- <property name="margin">
324
+ <property name="leftMargin">
325
+ <number>0</number>
326
+ </property>
327
+ <property name="topMargin">
328
+ <number>0</number>
329
+ </property>
330
+ <property name="rightMargin">
331
+ <number>0</number>
332
+ </property>
333
+ <property name="bottomMargin">
228
334
  <number>0</number>
229
335
  </property>
230
336
  <item row="0" column="0">
231
- <widget class="QTabWidget" name="tabs">
337
+ <widget class="QTabWidget" name="tab_widget">
232
338
  <property name="sizePolicy">
233
339
  <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
234
340
  <horstretch>0</horstretch>
@@ -253,8 +359,8 @@
253
359
  <rect>
254
360
  <x>0</x>
255
361
  <y>0</y>
256
- <width>872</width>
257
- <height>25</height>
362
+ <width>1354</width>
363
+ <height>22</height>
258
364
  </rect>
259
365
  </property>
260
366
  <widget class="QMenu" name="menuFile">
@@ -290,7 +396,6 @@
290
396
  <addaction name="menuItemConnect"/>
291
397
  <addaction name="menuItemBootloader"/>
292
398
  <addaction name="_menu_cf2_config"/>
293
- <addaction name="_menu_cf1_config"/>
294
399
  </widget>
295
400
  <widget class="QMenu" name="_menu_inputdevice">
296
401
  <property name="title">
@@ -300,23 +405,35 @@
300
405
  <addaction name="_menuitem_rescandevices"/>
301
406
  <addaction name="separator"/>
302
407
  </widget>
408
+ <widget class="QMenu" name="menuThemes">
409
+ <property name="title">
410
+ <string>Themes</string>
411
+ </property>
412
+ </widget>
303
413
  <addaction name="menuFile"/>
304
414
  <addaction name="menuConnect"/>
305
415
  <addaction name="_menu_inputdevice"/>
306
416
  <addaction name="menuSettings"/>
307
417
  <addaction name="menuView"/>
308
418
  <addaction name="menuHelp"/>
419
+ <addaction name="menuThemes"/>
309
420
  </widget>
310
421
  <widget class="QStatusBar" name="statusbar"/>
311
422
  <action name="menuItemConnect">
312
423
  <property name="text">
313
- <string>Connect</string>
424
+ <string>Connect Ctrl+C</string>
425
+ </property>
426
+ <property name="shortcut">
427
+ <string/>
314
428
  </property>
315
429
  </action>
316
430
  <action name="menuItemExit">
317
431
  <property name="text">
318
432
  <string>Exit</string>
319
433
  </property>
434
+ <property name="shortcut">
435
+ <string>Ctrl+Q</string>
436
+ </property>
320
437
  </action>
321
438
  <action name="menuItemRegulation">
322
439
  <property name="checkable">
@@ -428,20 +545,7 @@
428
545
  <bool>false</bool>
429
546
  </property>
430
547
  <property name="text">
431
- <string>Configure 2.0</string>
432
- </property>
433
- <property name="menuRole">
434
- <enum>QAction::NoRole</enum>
435
- </property>
436
- </action>
437
- <action name="_menu_cf_config_2">
438
- <property name="text">
439
- <string>Configure 1.0</string>
440
- </property>
441
- </action>
442
- <action name="_menu_cf1_config">
443
- <property name="text">
444
- <string>Configure 1.0</string>
548
+ <string>Configure 2.x</string>
445
549
  </property>
446
550
  <property name="menuRole">
447
551
  <enum>QAction::NoRole</enum>
@@ -7,7 +7,7 @@
7
7
  # +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
8
8
  # || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
9
9
  #
10
- # Copyright (C) 2011-2013 Bitcraze AB
10
+ # Copyright (C) 2011-2021 Bitcraze AB
11
11
  #
12
12
  # Crazyflie Nano Quadcopter Client
13
13
  #
@@ -28,6 +28,7 @@
28
28
  """
29
29
  Used for passing objects to tabs and toolboxes.
30
30
  """
31
+ import os
31
32
 
32
33
  __author__ = 'Bitcraze AB'
33
34
  __all__ = ['PluginHelper']
@@ -40,3 +41,8 @@ class PluginHelper():
40
41
  self.cf = None
41
42
  self.menu = None
42
43
  self.logConfigReader = None
44
+ self.mainUI = None
45
+ self.plotTab = None
46
+ self.pose_logger = None
47
+ self.connectivity_manager = None
48
+ self.current_folder = os.path.expanduser('~')
@@ -0,0 +1,116 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ #
4
+ # || ____ _ __
5
+ # +------+ / __ )(_) /_______________ _____ ___
6
+ # | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
7
+ # +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
8
+ # || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
9
+ #
10
+ # Copyright (C) 2021 Bitcraze AB
11
+ #
12
+ # Crazyflie Nano Quadcopter Client
13
+ #
14
+ # This program is free software; you can redistribute it and/or
15
+ # modify it under the terms of the GNU General Public License
16
+ # as published by the Free Software Foundation; either version 2
17
+ # of the License, or (at your option) any later version.
18
+ #
19
+ # This program is distributed in the hope that it will be useful,
20
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ # GNU General Public License for more details.
23
+ #
24
+ # You should have received a copy of the GNU General Public License
25
+ # along with this program; if not, write to the Free Software
26
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27
+ # 02110-1301, USA.
28
+ """
29
+ Sets up logging for the the full pose of the Crazyflie
30
+ """
31
+ import logging
32
+ import math
33
+
34
+ from cflib.crazyflie import Crazyflie
35
+ from cflib.crazyflie.log import LogConfig
36
+ from cflib.utils.callbacks import Caller
37
+
38
+ __author__ = 'Bitcraze AB'
39
+ __all__ = ['PoseLogger']
40
+
41
+ logger = logging.getLogger(__name__)
42
+
43
+
44
+ class PoseLogger:
45
+ LOG_NAME_ESTIMATE_X = 'stateEstimate.x'
46
+ LOG_NAME_ESTIMATE_Y = 'stateEstimate.y'
47
+ LOG_NAME_ESTIMATE_Z = 'stateEstimate.z'
48
+ LOG_NAME_ESTIMATE_ROLL = 'stateEstimate.roll'
49
+ LOG_NAME_ESTIMATE_PITCH = 'stateEstimate.pitch'
50
+ LOG_NAME_ESTIMATE_YAW = 'stateEstimate.yaw'
51
+ NO_POSE = (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
52
+
53
+ def __init__(self, cf: Crazyflie) -> None:
54
+ self._cf = cf
55
+ self._cf.connected.add_callback(self._connected)
56
+ self._cf.disconnected.add_callback(self._disconnected)
57
+
58
+ self.data_received_cb = Caller()
59
+ self.error_cb = Caller()
60
+
61
+ # The pose is an array containing
62
+ # X, Y, Z, roll, pitch, yaw
63
+ # roll, pitch and yaw in degrees
64
+ self.pose = self.NO_POSE
65
+
66
+ @property
67
+ def position(self):
68
+ """Get the position part of the full pose"""
69
+ return self.pose[0:3]
70
+
71
+ @property
72
+ def rpy(self):
73
+ """Get the roll, pitch and yaw of the full pose in degrees"""
74
+ return self.pose[3:6]
75
+
76
+ @property
77
+ def rpy_rad(self):
78
+ """Get the roll, pitch and yaw of the full pose in radians"""
79
+ return [math.radians(self.pose[3]), math.radians(self.pose[4]), math.radians(self.pose[5])]
80
+
81
+ def _connected(self, link_uri) -> None:
82
+ logConf = LogConfig("Pose", 40)
83
+ logConf.add_variable(self.LOG_NAME_ESTIMATE_X, "float")
84
+ logConf.add_variable(self.LOG_NAME_ESTIMATE_Y, "float")
85
+ logConf.add_variable(self.LOG_NAME_ESTIMATE_Z, "float")
86
+ logConf.add_variable(self.LOG_NAME_ESTIMATE_ROLL, "float")
87
+ logConf.add_variable(self.LOG_NAME_ESTIMATE_PITCH, "float")
88
+ logConf.add_variable(self.LOG_NAME_ESTIMATE_YAW, "float")
89
+
90
+ try:
91
+ self._cf.log.add_config(logConf)
92
+ logConf.data_received_cb.add_callback(self._data_received)
93
+ logConf.error_cb.add_callback(self._error)
94
+ logConf.start()
95
+ except KeyError as e:
96
+ logger.warning(str(e))
97
+ except AttributeError as e:
98
+ logger.warning(str(e))
99
+
100
+ def _disconnected(self, link_uri) -> None:
101
+ self.pose = self.NO_POSE
102
+
103
+ def _data_received(self, timestamp, data, logconf) -> None:
104
+ self.pose = (
105
+ data[self.LOG_NAME_ESTIMATE_X],
106
+ data[self.LOG_NAME_ESTIMATE_Y],
107
+ data[self.LOG_NAME_ESTIMATE_Z],
108
+ data[self.LOG_NAME_ESTIMATE_ROLL],
109
+ data[self.LOG_NAME_ESTIMATE_PITCH],
110
+ data[self.LOG_NAME_ESTIMATE_YAW],
111
+ )
112
+
113
+ self.data_received_cb.call(self, self.pose)
114
+
115
+ def _error(self, log_conf, msg) -> None:
116
+ self.error_cb.call(self, msg)