nf-robot 0.1.0__tar.gz

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 (69) hide show
  1. nf_robot-0.1.0/LICENSE +201 -0
  2. nf_robot-0.1.0/MANIFEST.in +8 -0
  3. nf_robot-0.1.0/PKG-INFO +147 -0
  4. nf_robot-0.1.0/README.md +108 -0
  5. nf_robot-0.1.0/pyproject.toml +66 -0
  6. nf_robot-0.1.0/setup.cfg +4 -0
  7. nf_robot-0.1.0/src/nf_robot/__init__.py +0 -0
  8. nf_robot-0.1.0/src/nf_robot/common/__init__.py +0 -0
  9. nf_robot-0.1.0/src/nf_robot/common/config_loader.py +102 -0
  10. nf_robot-0.1.0/src/nf_robot/common/cv_common.py +427 -0
  11. nf_robot-0.1.0/src/nf_robot/common/definitions.py +61 -0
  12. nf_robot-0.1.0/src/nf_robot/common/kalman_filter.py +182 -0
  13. nf_robot-0.1.0/src/nf_robot/common/util.py +20 -0
  14. nf_robot-0.1.0/src/nf_robot/generated/__init__.py +0 -0
  15. nf_robot-0.1.0/src/nf_robot/generated/google/__init__.py +0 -0
  16. nf_robot-0.1.0/src/nf_robot/generated/google/protobuf/__init__.py +226 -0
  17. nf_robot-0.1.0/src/nf_robot/generated/message_pool.py +3 -0
  18. nf_robot-0.1.0/src/nf_robot/generated/nf/__init__.py +0 -0
  19. nf_robot-0.1.0/src/nf_robot/generated/nf/common/__init__.py +51 -0
  20. nf_robot-0.1.0/src/nf_robot/generated/nf/config/__init__.py +171 -0
  21. nf_robot-0.1.0/src/nf_robot/generated/nf/control/__init__.py +378 -0
  22. nf_robot-0.1.0/src/nf_robot/generated/nf/telemetry/__init__.py +570 -0
  23. nf_robot-0.1.0/src/nf_robot/generated/py.typed +0 -0
  24. nf_robot-0.1.0/src/nf_robot/host/__init__.py +0 -0
  25. nf_robot-0.1.0/src/nf_robot/host/anchor_client.py +530 -0
  26. nf_robot-0.1.0/src/nf_robot/host/calibration.py +377 -0
  27. nf_robot-0.1.0/src/nf_robot/host/data_store.py +97 -0
  28. nf_robot-0.1.0/src/nf_robot/host/frequency_estimator.py +278 -0
  29. nf_robot-0.1.0/src/nf_robot/host/gripper_client.py +80 -0
  30. nf_robot-0.1.0/src/nf_robot/host/observer.py +1784 -0
  31. nf_robot-0.1.0/src/nf_robot/host/position_estimator.py +579 -0
  32. nf_robot-0.1.0/src/nf_robot/host/ssh_launch.py +70 -0
  33. nf_robot-0.1.0/src/nf_robot/host/stats.py +37 -0
  34. nf_robot-0.1.0/src/nf_robot/host/target_queue.py +303 -0
  35. nf_robot-0.1.0/src/nf_robot/host/video_streamer.py +153 -0
  36. nf_robot-0.1.0/src/nf_robot/ml/__init__.py +0 -0
  37. nf_robot-0.1.0/src/nf_robot/ml/centering.py +668 -0
  38. nf_robot-0.1.0/src/nf_robot/ml/control_service.py +102 -0
  39. nf_robot-0.1.0/src/nf_robot/ml/models/sock_tracker.pth +0 -0
  40. nf_robot-0.1.0/src/nf_robot/ml/models/square_centering.pth +0 -0
  41. nf_robot-0.1.0/src/nf_robot/ml/models/target_heatmap.pth +0 -0
  42. nf_robot-0.1.0/src/nf_robot/ml/target_heatmap.py +648 -0
  43. nf_robot-0.1.0/src/nf_robot/protos/common.proto +15 -0
  44. nf_robot-0.1.0/src/nf_robot/protos/control.proto +136 -0
  45. nf_robot-0.1.0/src/nf_robot/protos/robot-config.proto +71 -0
  46. nf_robot-0.1.0/src/nf_robot/protos/telemetry.proto +192 -0
  47. nf_robot-0.1.0/src/nf_robot/qa/__init__.py +0 -0
  48. nf_robot-0.1.0/src/nf_robot/qa/anchor_eval.py +54 -0
  49. nf_robot-0.1.0/src/nf_robot/qa/gripper_arp_eval.py +151 -0
  50. nf_robot-0.1.0/src/nf_robot/qa/gripper_eval.py +93 -0
  51. nf_robot-0.1.0/src/nf_robot/robot/__init__.py +0 -0
  52. nf_robot-0.1.0/src/nf_robot/robot/anchor_server.py +445 -0
  53. nf_robot-0.1.0/src/nf_robot/robot/component_server.py +56 -0
  54. nf_robot-0.1.0/src/nf_robot/robot/connect_wifi.py +180 -0
  55. nf_robot-0.1.0/src/nf_robot/robot/debug_motor.py +37 -0
  56. nf_robot-0.1.0/src/nf_robot/robot/gripper_arp_server.py +151 -0
  57. nf_robot-0.1.0/src/nf_robot/robot/gripper_server.py +260 -0
  58. nf_robot-0.1.0/src/nf_robot/robot/mks42c_motor.py +164 -0
  59. nf_robot-0.1.0/src/nf_robot/robot/simple_st3215.py +391 -0
  60. nf_robot-0.1.0/src/nf_robot/robot/spools.py +292 -0
  61. nf_robot-0.1.0/src/nf_robot/scripts/add_wifi_config.sh +84 -0
  62. nf_robot-0.1.0/src/nf_robot/scripts/install_pi.sh +57 -0
  63. nf_robot-0.1.0/src/nf_robot/scripts/local_deploy.py +47 -0
  64. nf_robot-0.1.0/src/nf_robot.egg-info/PKG-INFO +147 -0
  65. nf_robot-0.1.0/src/nf_robot.egg-info/SOURCES.txt +67 -0
  66. nf_robot-0.1.0/src/nf_robot.egg-info/dependency_links.txt +1 -0
  67. nf_robot-0.1.0/src/nf_robot.egg-info/entry_points.txt +6 -0
  68. nf_robot-0.1.0/src/nf_robot.egg-info/requires.txt +31 -0
  69. nf_robot-0.1.0/src/nf_robot.egg-info/top_level.txt +1 -0
nf_robot-0.1.0/LICENSE ADDED
@@ -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.
@@ -0,0 +1,8 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include src/nf_robot/ui/assets *
4
+ recursive-include src/nf_robot/protos *.proto
5
+ recursive-include src/nf_robot/scripts *.sh
6
+ recursive-include src/nf_robot/ml/models *
7
+ global-exclude *.pyc
8
+ global-exclude pycache
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: nf_robot
3
+ Version: 0.1.0
4
+ Summary: Robot control system for Stringman
5
+ Author-email: Nathaniel Nifong <naavox@gmail.com>
6
+ License: Apache 2.0
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: numpy>=2.0
11
+ Requires-Dist: zeroconf
12
+ Requires-Dist: asyncio
13
+ Requires-Dist: websockets
14
+ Requires-Dist: betterproto2
15
+ Provides-Extra: host
16
+ Requires-Dist: opencv-contrib-python>=4.0; extra == "host"
17
+ Requires-Dist: scipy; extra == "host"
18
+ Requires-Dist: torch>=2.4.0; extra == "host"
19
+ Requires-Dist: torchvision; extra == "host"
20
+ Requires-Dist: pupil-apriltags; extra == "host"
21
+ Requires-Dist: av; extra == "host"
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest; extra == "dev"
24
+ Requires-Dist: pytest-cov; extra == "dev"
25
+ Requires-Dist: grpcio-tools; extra == "dev"
26
+ Requires-Dist: betterproto2_compiler; extra == "dev"
27
+ Provides-Extra: pi
28
+ Requires-Dist: pyserial; extra == "pi"
29
+ Requires-Dist: getmac; extra == "pi"
30
+ Requires-Dist: inventorhatmini; extra == "pi"
31
+ Requires-Dist: gpiodevice; extra == "pi"
32
+ Requires-Dist: Adafruit-Blinka; extra == "pi"
33
+ Requires-Dist: adafruit-circuitpython-bno08x; extra == "pi"
34
+ Requires-Dist: adafruit-circuitpython-vl53l1x; extra == "pi"
35
+ Requires-Dist: adafruit-circuitpython-ads1x15; extra == "pi"
36
+ Requires-Dist: RPi.GPIO; extra == "pi"
37
+ Requires-Dist: pyzbar; extra == "pi"
38
+ Dynamic: license-file
39
+
40
+ # nf_robot
41
+
42
+ Control code for the Stringman household robotic crane from Neufangled Robotics
43
+
44
+ ## [Build Guides and Documentation](https://nhnifong.github.io/neufangled-site-2/)
45
+
46
+ Purchase assembled robots or kits at [neufangled.com](https://neufangled.com)
47
+
48
+ ## Installation of Robot Control Panel (end users)
49
+
50
+ Linux (python 3.11 or later)
51
+
52
+ sudo apt install python3-dev python3-virtualenv python3-pip ffmpeg
53
+ python -m virtualenv venv
54
+ pip install "stringman[host]"
55
+
56
+ ### Run
57
+
58
+ Start headless robot controller in a mode that connects to remote telemetry
59
+
60
+ stringman-headless
61
+
62
+ ## Installation of Robot Control Panel (developers)
63
+
64
+ git clone https://github.com/nhnifong/cranebot3-firmware.git
65
+
66
+ sudo apt install python3-dev python3-virtualenv python3-pip ffmpeg
67
+ python -m virtualenv venv
68
+ source venv/bin/activate
69
+ pip install -e ".[host,dev,pi]"
70
+
71
+ ### If you have an RTX 5090
72
+
73
+ pip install --force-reinstall torch==2.8.0 torchvision==0.23.0 torchaudio==2.8.0 torchcodec==0.6.0 --index-url https://download.pytorch.org/whl/cu129
74
+
75
+ ### Run tests
76
+
77
+ pytest tests
78
+
79
+ ## Raspberry Pi setup
80
+
81
+ `stringman-pilot-rpi-image` contains the configuration needed to build an SD card image for various stringman robot components.
82
+
83
+ Build the image with
84
+
85
+
86
+
87
+ After booting the robot component with the image for the first time, it will use it's camera to look for a wifi share QR code to get connected. You can produce a code with [qifi.org](htts://qifi.org)
88
+
89
+ Once the pi sees the code it will connect to the network and remember those settings. It should then be discoverable by the control panel via multicast DNS (Bonjour)
90
+
91
+ ## Starting from a base image
92
+
93
+ Alternatively the software can be set up from a fresh raspberry pi lite 64 bit image.
94
+ After booting any raspberry pi from a fresh image, perform an update
95
+
96
+ sudo apt update
97
+ sudo apt full-upgrade
98
+
99
+ When starting with the lite raspi image, you will be missing the following, so install those.
100
+
101
+ sudo apt install git python3-dev python3-virtualenv
102
+
103
+ Set the component type by uncommenting the appropriate line in server.conf
104
+
105
+ nano server.conf
106
+
107
+ Install stringman
108
+
109
+ git clone https://github.com/nhnifong/cranebot3-firmware.git && cd cranebot3-firmware
110
+ chmod +x install.sh
111
+ sudo ./install.sh
112
+
113
+ ### additional settings for anchors
114
+
115
+ Setup for any raspberry pi that will be part of an anchor
116
+ Enable uart serial harware interface interactively.
117
+
118
+ sudo raspi-config
119
+
120
+ In interface optoins, select serial port. disable the login shell, but enable hardware serial.
121
+
122
+ add the following lines lines to to `/boot/firmware/config.txt` at the end this disables bluetooth, which would otherwise occupy the uart hardware.
123
+ Then reboot after this change
124
+
125
+ enable_uart=1
126
+ dtoverlay=disable-bt
127
+
128
+ ### additional settings for gripper
129
+
130
+ Setup for the raspberry pi in the gripper with the inventor hat mini
131
+ Enable i2c
132
+
133
+ sudo raspi-config nonint do_i2c 0
134
+
135
+ Add this line to `/boot/firmware/config.txt` just under `dtparam=i2c_arm=on` and reboot
136
+
137
+ dtparam=i2c_baudrate=400000
138
+
139
+ ## Rebuilding the raspberry pi image
140
+
141
+
142
+ ## Training models
143
+
144
+
145
+ ## Support this project
146
+
147
+ [Donate on Ko-fi](https://ko-fi.com/neufangled)
@@ -0,0 +1,108 @@
1
+ # nf_robot
2
+
3
+ Control code for the Stringman household robotic crane from Neufangled Robotics
4
+
5
+ ## [Build Guides and Documentation](https://nhnifong.github.io/neufangled-site-2/)
6
+
7
+ Purchase assembled robots or kits at [neufangled.com](https://neufangled.com)
8
+
9
+ ## Installation of Robot Control Panel (end users)
10
+
11
+ Linux (python 3.11 or later)
12
+
13
+ sudo apt install python3-dev python3-virtualenv python3-pip ffmpeg
14
+ python -m virtualenv venv
15
+ pip install "stringman[host]"
16
+
17
+ ### Run
18
+
19
+ Start headless robot controller in a mode that connects to remote telemetry
20
+
21
+ stringman-headless
22
+
23
+ ## Installation of Robot Control Panel (developers)
24
+
25
+ git clone https://github.com/nhnifong/cranebot3-firmware.git
26
+
27
+ sudo apt install python3-dev python3-virtualenv python3-pip ffmpeg
28
+ python -m virtualenv venv
29
+ source venv/bin/activate
30
+ pip install -e ".[host,dev,pi]"
31
+
32
+ ### If you have an RTX 5090
33
+
34
+ pip install --force-reinstall torch==2.8.0 torchvision==0.23.0 torchaudio==2.8.0 torchcodec==0.6.0 --index-url https://download.pytorch.org/whl/cu129
35
+
36
+ ### Run tests
37
+
38
+ pytest tests
39
+
40
+ ## Raspberry Pi setup
41
+
42
+ `stringman-pilot-rpi-image` contains the configuration needed to build an SD card image for various stringman robot components.
43
+
44
+ Build the image with
45
+
46
+
47
+
48
+ After booting the robot component with the image for the first time, it will use it's camera to look for a wifi share QR code to get connected. You can produce a code with [qifi.org](htts://qifi.org)
49
+
50
+ Once the pi sees the code it will connect to the network and remember those settings. It should then be discoverable by the control panel via multicast DNS (Bonjour)
51
+
52
+ ## Starting from a base image
53
+
54
+ Alternatively the software can be set up from a fresh raspberry pi lite 64 bit image.
55
+ After booting any raspberry pi from a fresh image, perform an update
56
+
57
+ sudo apt update
58
+ sudo apt full-upgrade
59
+
60
+ When starting with the lite raspi image, you will be missing the following, so install those.
61
+
62
+ sudo apt install git python3-dev python3-virtualenv
63
+
64
+ Set the component type by uncommenting the appropriate line in server.conf
65
+
66
+ nano server.conf
67
+
68
+ Install stringman
69
+
70
+ git clone https://github.com/nhnifong/cranebot3-firmware.git && cd cranebot3-firmware
71
+ chmod +x install.sh
72
+ sudo ./install.sh
73
+
74
+ ### additional settings for anchors
75
+
76
+ Setup for any raspberry pi that will be part of an anchor
77
+ Enable uart serial harware interface interactively.
78
+
79
+ sudo raspi-config
80
+
81
+ In interface optoins, select serial port. disable the login shell, but enable hardware serial.
82
+
83
+ add the following lines lines to to `/boot/firmware/config.txt` at the end this disables bluetooth, which would otherwise occupy the uart hardware.
84
+ Then reboot after this change
85
+
86
+ enable_uart=1
87
+ dtoverlay=disable-bt
88
+
89
+ ### additional settings for gripper
90
+
91
+ Setup for the raspberry pi in the gripper with the inventor hat mini
92
+ Enable i2c
93
+
94
+ sudo raspi-config nonint do_i2c 0
95
+
96
+ Add this line to `/boot/firmware/config.txt` just under `dtparam=i2c_arm=on` and reboot
97
+
98
+ dtparam=i2c_baudrate=400000
99
+
100
+ ## Rebuilding the raspberry pi image
101
+
102
+
103
+ ## Training models
104
+
105
+
106
+ ## Support this project
107
+
108
+ [Donate on Ko-fi](https://ko-fi.com/neufangled)
@@ -0,0 +1,66 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "nf_robot"
7
+ version = "0.1.0"
8
+ description = "Robot control system for Stringman"
9
+ authors = [{name = "Nathaniel Nifong", email = "naavox@gmail.com"}]
10
+ requires-python = ">=3.11"
11
+ readme = "README.md"
12
+ license = {text = "Apache 2.0"}
13
+
14
+ dependencies = [
15
+ "numpy>=2.0",
16
+ "zeroconf",
17
+ "asyncio",
18
+ "websockets",
19
+ "betterproto2",
20
+ ]
21
+
22
+ [project.optional-dependencies]
23
+ host = [
24
+ "opencv-contrib-python>=4.0",
25
+ "scipy",
26
+ "torch>=2.4.0",
27
+ "torchvision",
28
+ "pupil-apriltags",
29
+ "av",
30
+ ]
31
+ dev = [
32
+ "pytest",
33
+ "pytest-cov",
34
+ "grpcio-tools",
35
+ "betterproto2_compiler",
36
+ ]
37
+ pi = [
38
+ "pyserial",
39
+ "getmac",
40
+ "inventorhatmini",
41
+ "gpiodevice",
42
+ "Adafruit-Blinka",
43
+ "adafruit-circuitpython-bno08x",
44
+ "adafruit-circuitpython-vl53l1x",
45
+ "adafruit-circuitpython-ads1x15",
46
+ "RPi.GPIO",
47
+ "pyzbar",
48
+ ]
49
+
50
+ [project.scripts]
51
+ # Main Applications
52
+ component-server = "nf_robot.robot.component_server:main"
53
+ stringman-headless = "nf_robot.host.observer:main"
54
+
55
+ # QA Tools
56
+ qa-anchor = "nf_robot.qa.anchor_eval:main"
57
+ qa-gripper = "nf_robot.qa.gripper_eval:main"
58
+ qa-anchor-arp = "nf_robot.qa.anchor_arp_eval:main"
59
+
60
+ [tool.setuptools.package-data]
61
+ "nf_robot.scripts" = ["*.sh"]
62
+ "nf_robot.ml" = ["models/*"]
63
+
64
+ [tool.pytest.ini_options]
65
+ testpaths = ["tests"]
66
+ pythonpath = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
File without changes
@@ -0,0 +1,102 @@
1
+ import numpy as np
2
+ from pathlib import Path
3
+ import uuid
4
+ from nf_robot.generated.nf import common, config as nf_config
5
+
6
+ DEFAULT_CONFIG_PATH = Path(__file__).parent / 'configuration.json'
7
+
8
+ def create_default_config() -> nf_config.StringmanPilotConfig:
9
+ """
10
+ Creates a protobuf configuration object populated with reasonable defaults.
11
+ """
12
+ config = nf_config.StringmanPilotConfig()
13
+ # provision a random ID
14
+ # once the robot tells the backend what this ID is, it has to stick to it, or the owner may see it disappear from their dashboard
15
+ config.robot_id = str(uuid.uuid4())
16
+ config.has_been_calibrated = False
17
+ config.connect_cloud_telemetry = False
18
+
19
+ # Anchors
20
+ # Defaults based on a square room setup, pointing towards center.
21
+ anchor_defs = [
22
+ # (num, position_xyz, rotation_rvec_xyz)
23
+ (0, (3.0, 3.0, 2.0), (0.0, 0.0, -np.pi/4)), # -45 deg
24
+ (1, (3.0, -3.0, 2.0), (0.0, 0.0, -3*np.pi/4)), # -135 deg
25
+ (2, (-3.0, 3.0, 2.0), (0.0, 0.0, np.pi/4)), # 45 deg
26
+ (3, (-3.0, -3.0, 2.0),(0.0, 0.0, 3*np.pi/4)), # 135 deg
27
+ ]
28
+
29
+ for num, pos, rot in anchor_defs:
30
+ anchor = nf_config.Anchor()
31
+ anchor.num = num
32
+ # leaving service_name None is a indicator that this anchor config is a placeholder
33
+ # and no such service has been disovered yet and assigned this anchor number
34
+
35
+ # Construct Pose using common.Vec3 for rvec (rotation) and tvec (translation)
36
+ anchor.pose = common.Pose(
37
+ rotation=common.Vec3(x=rot[0], y=rot[1], z=rot[2]),
38
+ position=common.Vec3(x=pos[0], y=pos[1], z=pos[2]),
39
+ )
40
+ config.anchors.append(anchor)
41
+
42
+ # Camera Calibration
43
+ config.camera_cal = nf_config.CameraCalibration()
44
+ config.camera_cal.resolution = nf_config.Resolution(
45
+ width=1920,
46
+ height=1080
47
+ )
48
+
49
+ # Default Intrinsic Matrix.
50
+ # This is calibrated for the standard FOV Raspberry Pi Camera module 3
51
+ # with the autofocus set to a fixed lens position of 0.1
52
+ intrinsic_np = np.array([
53
+ [1424., 0., 960.],
54
+ [ 0., 1424., 540.],
55
+ [ 0., 0., 1.]
56
+ ])
57
+ config.camera_cal.intrinsic_matrix = intrinsic_np.flatten().tolist()
58
+
59
+ # Default Distortion Coefficients
60
+ distortion_np = np.array([ 0.0115842, 0.18723804, -0.00126164, 0.00058383, -0.38807272])
61
+ config.camera_cal.distortion_coeff = distortion_np.flatten().tolist()
62
+
63
+ # Gripper
64
+ config.gripper = nf_config.Gripper()
65
+ config.gripper.frame_room_spin = (50.0 / 180.0) * np.pi
66
+
67
+ # Preferred Cameras
68
+ config.preferred_cameras = [0, 3]
69
+
70
+ # Miscelleneous anchor vars
71
+ config.max_accel = 0.3
72
+ config.rec_mod = 1
73
+ config.running_ws_delay = 0.03
74
+
75
+ return config
76
+
77
+ def save_config(config: nf_config.StringmanPilotConfig, path: Path=DEFAULT_CONFIG_PATH):
78
+ """Writes the proto to a JSON file."""
79
+ with open(path, 'w') as f:
80
+ f.write(config.to_json(indent=2))
81
+
82
+ def load_config(path: Path=DEFAULT_CONFIG_PATH) -> nf_config.StringmanPilotConfig:
83
+ """Loads the proto from a JSON file."""
84
+ try:
85
+ with open(path, 'r') as f:
86
+ return nf_config.StringmanPilotConfig().from_json(f.read())
87
+
88
+ except FileNotFoundError:
89
+ print(f"No config found at {path}, creating default.")
90
+ config = create_default_config()
91
+ print(f"New robot id chosen {config.robot_id}.")
92
+ save_config(config, path)
93
+ return config
94
+
95
+ def config_has_any_address(config: nf_config.StringmanPilotConfig):
96
+ """Return true if this config has the address of at least one component"""
97
+ return any([c.address is not None for c in [config.gripper, *config.anchors]])
98
+
99
+ if __name__ == "__main__":
100
+ cfg = load_config(DEFAULT_CONFIG_PATH)
101
+ print(f"Loaded config for robot: {cfg.robot_id}")
102
+ print(f"Gripper Spin: {cfg.gripper.frame_room_spin}")