calibrate-suite 0.1.0__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.
- calibrate_suite-0.1.0.dist-info/METADATA +761 -0
- calibrate_suite-0.1.0.dist-info/RECORD +47 -0
- calibrate_suite-0.1.0.dist-info/WHEEL +5 -0
- calibrate_suite-0.1.0.dist-info/entry_points.txt +3 -0
- calibrate_suite-0.1.0.dist-info/licenses/LICENSE +201 -0
- calibrate_suite-0.1.0.dist-info/top_level.txt +4 -0
- fleet_server/__init__.py +32 -0
- fleet_server/app.py +377 -0
- fleet_server/config.py +91 -0
- fleet_server/templates/error.html +57 -0
- fleet_server/templates/index.html +137 -0
- fleet_server/templates/viewer.html +490 -0
- fleet_server/utils.py +178 -0
- gui/__init__.py +2 -0
- gui/assets/2d-or-3d-fleet-upload.png +0 -0
- gui/assets/2d_3d_overlay_output.jpg +0 -0
- gui/assets/3d-or-2d-overlay_page.png +0 -0
- gui/assets/3d-or-2d-record-page.png +0 -0
- gui/assets/3d_3d_overlay_output.png +0 -0
- gui/assets/3d_or_2d_calibrate-page.png +0 -0
- gui/assets/GUI_homepage.png +0 -0
- gui/assets/hardware_setup.jpeg +0 -0
- gui/assets/single_lidar_calibrate_page.png +0 -0
- gui/assets/single_lidar_output.png +0 -0
- gui/assets/single_lidar_record_page.png +0 -0
- gui/assets/virya.jpg +0 -0
- gui/main.py +23 -0
- gui/widgets/calibrator_widget.py +977 -0
- gui/widgets/extractor_widget.py +561 -0
- gui/widgets/home_widget.py +117 -0
- gui/widgets/recorder_widget.py +127 -0
- gui/widgets/single_lidar_widget.py +673 -0
- gui/widgets/three_d_calib_widget.py +87 -0
- gui/widgets/two_d_calib_widget.py +86 -0
- gui/widgets/uploader_widget.py +151 -0
- gui/widgets/validator_widget.py +614 -0
- gui/windows/main_window.py +56 -0
- gui/windows/main_window_ui.py +65 -0
- rviz_configs/2D-3D.rviz +183 -0
- rviz_configs/3D-3D.rviz +184 -0
- rviz_configs/default_calib.rviz +167 -0
- utils/__init__.py +13 -0
- utils/calibration_common.py +23 -0
- utils/cli_calibrate.py +53 -0
- utils/cli_fleet_server.py +64 -0
- utils/data_extractor_common.py +87 -0
- utils/gui_helpers.py +25 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
calibrate_suite-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
2
|
+
fleet_server/__init__.py,sha256=Jf0LmjLdSxA38SIb-lY0nIdeW66QK_FsMxbh-ZqqGx4,870
|
|
3
|
+
fleet_server/app.py,sha256=qzc0ycWyFTjvi_DppD_TqGeO3vxJT6tv2EEUDiSJL7I,13307
|
|
4
|
+
fleet_server/config.py,sha256=aMrHL_z6YuVharn9OLejgKgldxe8wRh8t5NKIrsDMa4,2737
|
|
5
|
+
fleet_server/utils.py,sha256=IoE40x__8T8cGm7uOwDE_lysbtE53WU_uJI9Ip0ZRlA,4680
|
|
6
|
+
fleet_server/templates/error.html,sha256=ZlZD0zy_c2XdgcWnJEFPQIJBqgscj-KUEXnhvDFcx_U,1570
|
|
7
|
+
fleet_server/templates/index.html,sha256=YpAqEIQfWN46DP8N5mawyzRiypk56vIpExq9_Xmsmc0,3373
|
|
8
|
+
fleet_server/templates/viewer.html,sha256=2veSnySQiw6w8O7j0rIwSe4j2ANDCsctaaUXyMige9g,16620
|
|
9
|
+
gui/__init__.py,sha256=NQP_dgQPkLbTEhfhg02dSnsEhav5nS5_BN6CUeNjG1Y,71
|
|
10
|
+
gui/main.py,sha256=aiVmi8WUiErp75DxEk26lcIsCGETW8bDmDl1bGTaE6Y,492
|
|
11
|
+
gui/assets/2d-or-3d-fleet-upload.png,sha256=oYGgiSd2sI3yliMyHNYjkkhmpL8K3fTnHPCArszqi-E,41886
|
|
12
|
+
gui/assets/2d_3d_overlay_output.jpg,sha256=UX77BHFz76YG32E6Ondgstkv6qyNE9m2Tv6MrhK2oBg,801670
|
|
13
|
+
gui/assets/3d-or-2d-overlay_page.png,sha256=s59mEWhtqlXg04p4vmVQbMR0g20AXAZ2_nXYP_21KrI,62965
|
|
14
|
+
gui/assets/3d-or-2d-record-page.png,sha256=Lsbi0XjJgVDJeKZfSqzWKS90K-xsLzd_DGdaCRNDXVg,71243
|
|
15
|
+
gui/assets/3d_3d_overlay_output.png,sha256=kA20FdLb7H_AZW0iPPQ7KWHIdpYQ9ku8UsaQOau7NBY,143166
|
|
16
|
+
gui/assets/3d_or_2d_calibrate-page.png,sha256=MmzOANq-ny9WwLH26tXNdqdQw22HyLZmyYw5Wd0SIQE,91215
|
|
17
|
+
gui/assets/GUI_homepage.png,sha256=-Ev-hZ7l2zaOslxL-x3lpWLfBOxybJaHtFSt0C4VWQ4,74582
|
|
18
|
+
gui/assets/hardware_setup.jpeg,sha256=IrcbI8ADXQO_yiUtembTqP0uBbkQS89P1JLhxnXQNxY,77890
|
|
19
|
+
gui/assets/single_lidar_calibrate_page.png,sha256=wAJ2_l0Hqf_Tq5wTlk6j1ev6VYDk7VkKFp9Xkfna3PM,45377
|
|
20
|
+
gui/assets/single_lidar_output.png,sha256=L6nwvXaS2noNq4W13ZG65miI_AG1I8EuY2sDMy7t7gQ,56091
|
|
21
|
+
gui/assets/single_lidar_record_page.png,sha256=OwZAuXOoiE443kZkopZOxhehvDwTjej85xgkJ9xX1tM,60437
|
|
22
|
+
gui/assets/virya.jpg,sha256=F4VdYXoMO8F80jc32n-tgWQwJTCEGjtd7vgya18Diag,23752
|
|
23
|
+
gui/widgets/calibrator_widget.py,sha256=wS5Bo6VIJBOXj-mi1vB8tO9zKocieQd08TdL_Lejn7U,40732
|
|
24
|
+
gui/widgets/extractor_widget.py,sha256=ztlGSIzUsMKlqSXSjdVvDxpsUsrm7Z0FylgVAXjpvWs,22146
|
|
25
|
+
gui/widgets/home_widget.py,sha256=XRDCcAZNqFfS41aCkotT-hET9n4IR0TtGV7qhMQkR88,4305
|
|
26
|
+
gui/widgets/recorder_widget.py,sha256=5DBI7rrDTSQrBJ4Bp_iFvdv0rNmKvBPLNW_WeVDapA0,4612
|
|
27
|
+
gui/widgets/single_lidar_widget.py,sha256=AtM5cKzXglNZjFUdksVwQVYpFvlqwFbAe9xZwrvqupI,25731
|
|
28
|
+
gui/widgets/three_d_calib_widget.py,sha256=_WskIWSl3hYbaCbkzYwNI3GVoqHTNXyqASASimzHPx0,3213
|
|
29
|
+
gui/widgets/two_d_calib_widget.py,sha256=3l6BHhDLO4ETTSMVdKwL4rWMsluKBlHPsngSsoInOVA,3104
|
|
30
|
+
gui/widgets/uploader_widget.py,sha256=udzqiS8bPJy_6li8zV8a6-QbyBfkEFi5CB9g1wgsqdw,5395
|
|
31
|
+
gui/widgets/validator_widget.py,sha256=lS4EI-9hWZwOJwX1d0EtgsGioPRvdbmtBSeCLukcdTw,24655
|
|
32
|
+
gui/windows/main_window.py,sha256=6OstmZfWjQzBgnHyCTJc3LzEymgTQpWrapx2cjORHmY,1982
|
|
33
|
+
gui/windows/main_window_ui.py,sha256=4yVIRJ6KIDwxeP0kvy_IkoI29cIBp2LSUarr7AZuEH4,1627
|
|
34
|
+
rviz_configs/2D-3D.rviz,sha256=QfBz1jXWHeZH93HYoq2Ee_tXFS6QC1DIO2rexUB6Wgk,6143
|
|
35
|
+
rviz_configs/3D-3D.rviz,sha256=p4EA2kVYB-FNCRapjBjkIIn_uv6Ysznfj9aW1SMQ6es,6094
|
|
36
|
+
rviz_configs/default_calib.rviz,sha256=nYIH16YlNcbQhAXPBfQbsQ5AXkNT7BXTWfdxwkvOJgo,5610
|
|
37
|
+
utils/__init__.py,sha256=jGrHBgfZKHPs8RloUjIW-f7LAH_n6uGKfCaDnjcz7Yk,376
|
|
38
|
+
utils/calibration_common.py,sha256=M6IAyi97tPpQk320aoPruGffa7dAO679RWax5tVQoL4,606
|
|
39
|
+
utils/cli_calibrate.py,sha256=F1l-JLTOs39JHm-sTLWcUwcjKerZGpXjEXm8USFt9QY,1267
|
|
40
|
+
utils/cli_fleet_server.py,sha256=OvkCo-ClGlwNKDJTfH5InLm0NWjxWSiSf-yAZnl2QVk,1700
|
|
41
|
+
utils/data_extractor_common.py,sha256=3DsIwFd35dfl8ZoKfsm5VA-gZmveySmBUkiErXbCN18,2611
|
|
42
|
+
utils/gui_helpers.py,sha256=hgj5AG0oH2dZMnclwzazFQlwebpBPW0JjNM_AHb9hko,723
|
|
43
|
+
calibrate_suite-0.1.0.dist-info/METADATA,sha256=Y_mxIIZjcbnkocqexaznleEvkwGNmkWcQK_fQdqkFHk,25332
|
|
44
|
+
calibrate_suite-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
45
|
+
calibrate_suite-0.1.0.dist-info/entry_points.txt,sha256=huEnH7M9a_ycUhzZ3FnXR0rw8iRsr3jj71TTSd4Srl8,104
|
|
46
|
+
calibrate_suite-0.1.0.dist-info/top_level.txt,sha256=SCAdU5VbFfkNGQO4zgAwM2qsZnWr0I_8k3F70Ch0EcQ,36
|
|
47
|
+
calibrate_suite-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
fleet_server/__init__.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Fleet Server - REST API for Calibration Management
|
|
3
|
+
|
|
4
|
+
Provides web dashboard and REST API for managing robot calibration results.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
__version__ = "0.1.0"
|
|
8
|
+
|
|
9
|
+
def create_app(debug=False, env_file=None):
|
|
10
|
+
|
|
11
|
+
import os
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from flask import Flask
|
|
14
|
+
|
|
15
|
+
# Load environment configuration if specified
|
|
16
|
+
if env_file and os.path.exists(env_file):
|
|
17
|
+
from dotenv import load_dotenv
|
|
18
|
+
load_dotenv(env_file)
|
|
19
|
+
|
|
20
|
+
# Import app from main module (when installed via pip/setup.py)
|
|
21
|
+
try:
|
|
22
|
+
# When installed as package
|
|
23
|
+
from fleet_server.app import app as flask_app
|
|
24
|
+
except ImportError:
|
|
25
|
+
# Fallback for development (src in path)
|
|
26
|
+
from .app import app as flask_app
|
|
27
|
+
|
|
28
|
+
if debug:
|
|
29
|
+
flask_app.config['DEBUG'] = True
|
|
30
|
+
flask_app.config['ENV'] = 'development'
|
|
31
|
+
|
|
32
|
+
return flask_app
|
fleet_server/app.py
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
"""Fleet Server - Calibration Artifact Management
|
|
2
|
+
|
|
3
|
+
REST API server for managing robot calibration results across a fleet.
|
|
4
|
+
Handles upload, storage, retrieval, and visualization of calibration data.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import datetime
|
|
9
|
+
import json
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from flask import Flask, request, jsonify, render_template, send_from_directory, abort
|
|
12
|
+
import sqlite3
|
|
13
|
+
|
|
14
|
+
from .config import get_config, Config
|
|
15
|
+
|
|
16
|
+
# Initialize configuration and directories BEFORE importing utils
|
|
17
|
+
config = get_config()
|
|
18
|
+
config.ensure_directories()
|
|
19
|
+
|
|
20
|
+
# Now safe to import utils (which uses logging)
|
|
21
|
+
from .utils import logger, sanitize_filename, validate_upload, get_safe_path, format_filesize
|
|
22
|
+
|
|
23
|
+
# Create Flask app
|
|
24
|
+
app = Flask(__name__, template_folder='templates')
|
|
25
|
+
|
|
26
|
+
DB_PATH = config.DATABASE_PATH
|
|
27
|
+
UPLOAD_FOLDER = config.UPLOAD_FOLDER
|
|
28
|
+
MAX_UPLOAD_SIZE = config.MAX_UPLOAD_SIZE
|
|
29
|
+
|
|
30
|
+
logger.info(f"Fleet Server starting in {config.FLASK_ENV} mode")
|
|
31
|
+
logger.info(f"Database: {DB_PATH}")
|
|
32
|
+
logger.info(f"Upload folder: {UPLOAD_FOLDER}")
|
|
33
|
+
|
|
34
|
+
def init_db():
|
|
35
|
+
"""Initialize SQLite database with required schema"""
|
|
36
|
+
try:
|
|
37
|
+
conn = sqlite3.connect(DB_PATH)
|
|
38
|
+
c = conn.cursor()
|
|
39
|
+
|
|
40
|
+
# Robots Table
|
|
41
|
+
c.execute('''CREATE TABLE IF NOT EXISTS robots
|
|
42
|
+
(id TEXT PRIMARY KEY,
|
|
43
|
+
name TEXT,
|
|
44
|
+
model TEXT,
|
|
45
|
+
last_calib_date TEXT,
|
|
46
|
+
status TEXT DEFAULT 'active')''')
|
|
47
|
+
|
|
48
|
+
# Calibrations Table with more metadata
|
|
49
|
+
c.execute('''CREATE TABLE IF NOT EXISTS calibrations
|
|
50
|
+
(id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
51
|
+
robot_id TEXT,
|
|
52
|
+
timestamp TEXT,
|
|
53
|
+
artifacts_path TEXT,
|
|
54
|
+
file_size INTEGER,
|
|
55
|
+
score REAL,
|
|
56
|
+
notes TEXT,
|
|
57
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
58
|
+
FOREIGN KEY(robot_id) REFERENCES robots(id))''')
|
|
59
|
+
|
|
60
|
+
# Create indices for faster queries
|
|
61
|
+
c.execute('''CREATE INDEX IF NOT EXISTS idx_robot_id
|
|
62
|
+
ON calibrations(robot_id)''')
|
|
63
|
+
c.execute('''CREATE INDEX IF NOT EXISTS idx_timestamp
|
|
64
|
+
ON calibrations(timestamp)''')
|
|
65
|
+
|
|
66
|
+
conn.commit()
|
|
67
|
+
conn.close()
|
|
68
|
+
logger.info("Database initialized successfully")
|
|
69
|
+
except Exception as e:
|
|
70
|
+
logger.error(f"Database initialization failed: {e}")
|
|
71
|
+
raise
|
|
72
|
+
|
|
73
|
+
# Initialize database on startup
|
|
74
|
+
init_db()
|
|
75
|
+
|
|
76
|
+
@app.template_filter('basename')
|
|
77
|
+
def basename_filter(s):
|
|
78
|
+
"""Jinja2 filter to get basename of path"""
|
|
79
|
+
return os.path.basename(s)
|
|
80
|
+
|
|
81
|
+
@app.template_filter('filesize')
|
|
82
|
+
def filesize_filter(size_bytes):
|
|
83
|
+
"""Jinja2 filter to format file size"""
|
|
84
|
+
return format_filesize(size_bytes)
|
|
85
|
+
|
|
86
|
+
@app.template_filter('format_timestamp')
|
|
87
|
+
def format_timestamp_filter(timestamp_str):
|
|
88
|
+
"""Jinja2 filter to format timestamp from YYYYMMDD_HHMMSS to readable format"""
|
|
89
|
+
if not timestamp_str:
|
|
90
|
+
return 'Unknown'
|
|
91
|
+
try:
|
|
92
|
+
# Parse from YYYYMMDD_HHMMSS format
|
|
93
|
+
dt = datetime.datetime.strptime(timestamp_str, '%Y%m%d_%H%M%S')
|
|
94
|
+
# Return in readable format: YYYY-MM-DD HH:MM:SS
|
|
95
|
+
return dt.strftime('%Y-%m-%d %H:%M:%S')
|
|
96
|
+
except (ValueError, TypeError):
|
|
97
|
+
return timestamp_str
|
|
98
|
+
|
|
99
|
+
@app.before_request
|
|
100
|
+
def log_request():
|
|
101
|
+
"""Log incoming requests"""
|
|
102
|
+
logger.debug(f"{request.method} {request.path}")
|
|
103
|
+
|
|
104
|
+
@app.after_request
|
|
105
|
+
def log_response(response):
|
|
106
|
+
"""Log outgoing responses"""
|
|
107
|
+
logger.debug(f"Response: {response.status_code}")
|
|
108
|
+
return response
|
|
109
|
+
|
|
110
|
+
# ============================================================================
|
|
111
|
+
# ROUTES
|
|
112
|
+
# ============================================================================
|
|
113
|
+
|
|
114
|
+
@app.route('/')
|
|
115
|
+
def index():
|
|
116
|
+
"""Dashboard showing robots and recent calibrations"""
|
|
117
|
+
try:
|
|
118
|
+
conn = sqlite3.connect(DB_PATH)
|
|
119
|
+
conn.row_factory = sqlite3.Row
|
|
120
|
+
c = conn.cursor()
|
|
121
|
+
|
|
122
|
+
c.execute("SELECT * FROM robots ORDER BY last_calib_date DESC")
|
|
123
|
+
robots = c.fetchall()
|
|
124
|
+
|
|
125
|
+
c.execute("""SELECT * FROM calibrations
|
|
126
|
+
ORDER BY timestamp DESC LIMIT 20""")
|
|
127
|
+
recent = c.fetchall()
|
|
128
|
+
|
|
129
|
+
conn.close()
|
|
130
|
+
logger.info(f"Dashboard accessed: {len(robots)} robots, {len(recent)} recent calibrations")
|
|
131
|
+
return render_template('index.html', robots=robots, recent=recent)
|
|
132
|
+
|
|
133
|
+
except Exception as e:
|
|
134
|
+
logger.error(f"Dashboard error: {e}")
|
|
135
|
+
return render_template('error.html', error=str(e)), 500
|
|
136
|
+
|
|
137
|
+
@app.route('/api/robots', methods=['GET'])
|
|
138
|
+
def get_robots():
|
|
139
|
+
"""API endpoint: Get all robots"""
|
|
140
|
+
try:
|
|
141
|
+
conn = sqlite3.connect(DB_PATH)
|
|
142
|
+
conn.row_factory = sqlite3.Row
|
|
143
|
+
c = conn.cursor()
|
|
144
|
+
c.execute("SELECT * FROM robots ORDER BY last_calib_date DESC")
|
|
145
|
+
robots = [dict(row) for row in c.fetchall()]
|
|
146
|
+
conn.close()
|
|
147
|
+
|
|
148
|
+
return jsonify({'status': 'success', 'robots': robots}), 200
|
|
149
|
+
except Exception as e:
|
|
150
|
+
logger.error(f"Get robots error: {e}")
|
|
151
|
+
return jsonify({'error': str(e)}), 500
|
|
152
|
+
|
|
153
|
+
@app.route('/files/<path:filename>')
|
|
154
|
+
def serve_file(filename):
|
|
155
|
+
"""Serve uploaded calibration files with security checks"""
|
|
156
|
+
try:
|
|
157
|
+
# Sanitize filename and check path
|
|
158
|
+
safe_filename = sanitize_filename(filename)
|
|
159
|
+
safe_path = get_safe_path(UPLOAD_FOLDER, safe_filename)
|
|
160
|
+
|
|
161
|
+
if safe_path is None:
|
|
162
|
+
logger.warning(f"Attempted unsafe file access: {filename}")
|
|
163
|
+
abort(403)
|
|
164
|
+
|
|
165
|
+
if not os.path.exists(safe_path):
|
|
166
|
+
logger.warning(f"File not found: {safe_path}")
|
|
167
|
+
abort(404)
|
|
168
|
+
|
|
169
|
+
logger.info(f"Serving file: {safe_filename}")
|
|
170
|
+
return send_from_directory(UPLOAD_FOLDER, safe_filename)
|
|
171
|
+
|
|
172
|
+
except Exception as e:
|
|
173
|
+
logger.error(f"File serve error: {e}")
|
|
174
|
+
abort(500)
|
|
175
|
+
|
|
176
|
+
@app.route('/view/<int:calib_id>')
|
|
177
|
+
def view_calibration(calib_id):
|
|
178
|
+
"""View 3D visualization of calibration result"""
|
|
179
|
+
try:
|
|
180
|
+
conn = sqlite3.connect(DB_PATH)
|
|
181
|
+
conn.row_factory = sqlite3.Row
|
|
182
|
+
c = conn.cursor()
|
|
183
|
+
|
|
184
|
+
c.execute("SELECT * FROM calibrations WHERE id = ?", (calib_id,))
|
|
185
|
+
calib = c.fetchone()
|
|
186
|
+
conn.close()
|
|
187
|
+
|
|
188
|
+
if calib:
|
|
189
|
+
filename = os.path.basename(calib['artifacts_path'])
|
|
190
|
+
file_url = f"/files/{filename}"
|
|
191
|
+
logger.info(f"Viewing calibration {calib_id}")
|
|
192
|
+
return render_template('viewer.html', file_url=file_url, calib=calib)
|
|
193
|
+
else:
|
|
194
|
+
logger.warning(f"Calibration not found: {calib_id}")
|
|
195
|
+
abort(404)
|
|
196
|
+
|
|
197
|
+
except Exception as e:
|
|
198
|
+
logger.error(f"View calibration error: {e}")
|
|
199
|
+
abort(500)
|
|
200
|
+
|
|
201
|
+
@app.route('/api/upload', methods=['POST'])
|
|
202
|
+
def upload_calibration():
|
|
203
|
+
"""Upload calibration artifacts and metadata"""
|
|
204
|
+
try:
|
|
205
|
+
# Validate request
|
|
206
|
+
if 'artifacts' not in request.files:
|
|
207
|
+
logger.warning("Upload: No file part in request")
|
|
208
|
+
return jsonify({'error': 'No file part'}), 400
|
|
209
|
+
|
|
210
|
+
file = request.files['artifacts']
|
|
211
|
+
if file.filename == '':
|
|
212
|
+
logger.warning("Upload: Empty filename")
|
|
213
|
+
return jsonify({'error': 'No selected file'}), 400
|
|
214
|
+
|
|
215
|
+
# Parse metadata
|
|
216
|
+
meta_str = request.form.get('metadata', '{}')
|
|
217
|
+
try:
|
|
218
|
+
metadata = json.loads(meta_str)
|
|
219
|
+
except json.JSONDecodeError:
|
|
220
|
+
logger.warning("Upload: Invalid JSON metadata")
|
|
221
|
+
return jsonify({'error': 'Invalid metadata JSON'}), 400
|
|
222
|
+
|
|
223
|
+
robot_id = metadata.get('robot_id', 'unknown')
|
|
224
|
+
score = float(metadata.get('score', 0.0))
|
|
225
|
+
notes = metadata.get('notes', '')
|
|
226
|
+
|
|
227
|
+
# Validate upload
|
|
228
|
+
is_valid, error_msg = validate_upload(file, file.filename)
|
|
229
|
+
if not is_valid:
|
|
230
|
+
logger.warning(f"Upload validation failed for {robot_id}: {error_msg}")
|
|
231
|
+
return jsonify({'error': error_msg}), 400
|
|
232
|
+
|
|
233
|
+
# Sanitize filename
|
|
234
|
+
original_filename = file.filename
|
|
235
|
+
filename = sanitize_filename(original_filename)
|
|
236
|
+
if not filename:
|
|
237
|
+
logger.warning(f"Upload: Could not sanitize filename {original_filename}")
|
|
238
|
+
return jsonify({'error': 'Invalid filename'}), 400
|
|
239
|
+
|
|
240
|
+
# Generate unique filename
|
|
241
|
+
ts = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
242
|
+
final_filename = f"{robot_id}_{ts}_{filename}"
|
|
243
|
+
filepath = os.path.join(UPLOAD_FOLDER, final_filename)
|
|
244
|
+
|
|
245
|
+
# Save file
|
|
246
|
+
file.save(filepath)
|
|
247
|
+
file_size = os.path.getsize(filepath)
|
|
248
|
+
|
|
249
|
+
# Update database
|
|
250
|
+
conn = sqlite3.connect(DB_PATH)
|
|
251
|
+
c = conn.cursor()
|
|
252
|
+
|
|
253
|
+
try:
|
|
254
|
+
# Upsert Robot
|
|
255
|
+
c.execute("""INSERT OR REPLACE INTO robots
|
|
256
|
+
(id, name, model, last_calib_date, status)
|
|
257
|
+
VALUES (?, ?, ?, ?, 'active')""",
|
|
258
|
+
(robot_id, metadata.get('robot_name', robot_id),
|
|
259
|
+
metadata.get('robot_model', 'Unknown'), ts))
|
|
260
|
+
|
|
261
|
+
# Insert Calibration
|
|
262
|
+
c.execute("""INSERT INTO calibrations
|
|
263
|
+
(robot_id, timestamp, artifacts_path, file_size, score, notes)
|
|
264
|
+
VALUES (?, ?, ?, ?, ?, ?)""",
|
|
265
|
+
(robot_id, ts, final_filename, file_size, score, notes))
|
|
266
|
+
|
|
267
|
+
conn.commit()
|
|
268
|
+
calib_id = c.lastrowid
|
|
269
|
+
conn.close()
|
|
270
|
+
|
|
271
|
+
logger.info(f"Upload successful: Robot={robot_id}, File={final_filename}, Size={format_filesize(file_size)}, Score={score:.4f}")
|
|
272
|
+
|
|
273
|
+
return jsonify({
|
|
274
|
+
'status': 'success',
|
|
275
|
+
'id': calib_id,
|
|
276
|
+
'filename': final_filename,
|
|
277
|
+
'file_size': file_size
|
|
278
|
+
}), 201
|
|
279
|
+
|
|
280
|
+
except sqlite3.Error as e:
|
|
281
|
+
conn.close()
|
|
282
|
+
logger.error(f"Database error during upload: {e}")
|
|
283
|
+
return jsonify({'error': f'Database error: {str(e)}'}), 500
|
|
284
|
+
|
|
285
|
+
except Exception as e:
|
|
286
|
+
logger.error(f"Upload error: {e}")
|
|
287
|
+
return jsonify({'error': str(e)}), 500
|
|
288
|
+
|
|
289
|
+
@app.route('/api/calibrations/<robot_id>', methods=['GET'])
|
|
290
|
+
def get_robot_calibrations(robot_id):
|
|
291
|
+
"""Get all calibrations for a specific robot"""
|
|
292
|
+
try:
|
|
293
|
+
conn = sqlite3.connect(DB_PATH)
|
|
294
|
+
conn.row_factory = sqlite3.Row
|
|
295
|
+
c = conn.cursor()
|
|
296
|
+
|
|
297
|
+
c.execute("""SELECT * FROM calibrations
|
|
298
|
+
WHERE robot_id = ?
|
|
299
|
+
ORDER BY timestamp DESC""", (robot_id,))
|
|
300
|
+
calibrations = [dict(row) for row in c.fetchall()]
|
|
301
|
+
conn.close()
|
|
302
|
+
|
|
303
|
+
logger.info(f"Retrieved {len(calibrations)} calibrations for {robot_id}")
|
|
304
|
+
return jsonify({'status': 'success', 'calibrations': calibrations}), 200
|
|
305
|
+
|
|
306
|
+
except Exception as e:
|
|
307
|
+
logger.error(f"Get robot calibrations error: {e}")
|
|
308
|
+
return jsonify({'error': str(e)}), 500
|
|
309
|
+
|
|
310
|
+
@app.route('/api/stats', methods=['GET'])
|
|
311
|
+
def get_stats():
|
|
312
|
+
"""Get fleet statistics"""
|
|
313
|
+
try:
|
|
314
|
+
conn = sqlite3.connect(DB_PATH)
|
|
315
|
+
c = conn.cursor()
|
|
316
|
+
|
|
317
|
+
c.execute("SELECT COUNT(*) FROM robots")
|
|
318
|
+
robot_count = c.fetchone()[0]
|
|
319
|
+
|
|
320
|
+
c.execute("SELECT COUNT(*) FROM calibrations")
|
|
321
|
+
calib_count = c.fetchone()[0]
|
|
322
|
+
|
|
323
|
+
c.execute("SELECT AVG(score) FROM calibrations")
|
|
324
|
+
avg_score = c.fetchone()[0] or 0.0
|
|
325
|
+
|
|
326
|
+
c.execute("SELECT AVG(file_size) FROM calibrations")
|
|
327
|
+
avg_size = c.fetchone()[0] or 0
|
|
328
|
+
|
|
329
|
+
conn.close()
|
|
330
|
+
|
|
331
|
+
logger.info(f"Stats: {robot_count} robots, {calib_count} calibrations")
|
|
332
|
+
|
|
333
|
+
return jsonify({
|
|
334
|
+
'status': 'success',
|
|
335
|
+
'robots': robot_count,
|
|
336
|
+
'calibrations': calib_count,
|
|
337
|
+
'avg_score': round(avg_score, 4),
|
|
338
|
+
'avg_file_size': format_filesize(int(avg_size))
|
|
339
|
+
}), 200
|
|
340
|
+
|
|
341
|
+
except Exception as e:
|
|
342
|
+
logger.error(f"Get stats error: {e}")
|
|
343
|
+
return jsonify({'error': str(e)}), 500
|
|
344
|
+
|
|
345
|
+
# ============================================================================
|
|
346
|
+
# ERROR HANDLERS
|
|
347
|
+
# ============================================================================
|
|
348
|
+
|
|
349
|
+
@app.errorhandler(404)
|
|
350
|
+
def not_found(e):
|
|
351
|
+
"""Handle 404 errors"""
|
|
352
|
+
logger.warning(f"404 Not Found: {request.path}")
|
|
353
|
+
return jsonify({'error': 'Not found'}), 404
|
|
354
|
+
|
|
355
|
+
@app.errorhandler(500)
|
|
356
|
+
def internal_error(e):
|
|
357
|
+
"""Handle 500 errors"""
|
|
358
|
+
logger.error(f"500 Internal Server Error: {str(e)}")
|
|
359
|
+
return jsonify({'error': 'Internal server error'}), 500
|
|
360
|
+
|
|
361
|
+
# ============================================================================
|
|
362
|
+
# MAIN
|
|
363
|
+
# ============================================================================
|
|
364
|
+
|
|
365
|
+
if __name__ == '__main__':
|
|
366
|
+
try:
|
|
367
|
+
logger.info(f"Starting Fleet Server on {config.FLASK_HOST}:{config.FLASK_PORT}")
|
|
368
|
+
app.run(
|
|
369
|
+
host=config.FLASK_HOST,
|
|
370
|
+
port=config.FLASK_PORT,
|
|
371
|
+
debug=config.FLASK_DEBUG,
|
|
372
|
+
use_reloader=False # Disable reloader in production
|
|
373
|
+
)
|
|
374
|
+
except Exception as e:
|
|
375
|
+
logger.error(f"Failed to start server: {e}")
|
|
376
|
+
raise
|
|
377
|
+
|