dobotkit 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.
@@ -0,0 +1,322 @@
1
+ Metadata-Version: 2.4
2
+ Name: dobotkit
3
+ Version: 0.1.0
4
+ Summary: Complete pure-Python control library for Dobot Magician Lite (arm) and Magician GO (car) over DobotLink
5
+ Project-URL: Homepage, https://github.com/mslopgk/dobotkit
6
+ Project-URL: Repository, https://github.com/mslopgk/dobotkit
7
+ Project-URL: Issues, https://github.com/mslopgk/dobotkit/issues
8
+ Author: dobotkit contributors
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: dobot,dobotlink,education,magicbox,magician-go,magician-lite,robot-arm,robotics
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Education
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Education
23
+ Classifier: Topic :: Scientific/Engineering
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.9
26
+ Requires-Dist: websockets>=11.0
27
+ Provides-Extra: dev
28
+ Requires-Dist: mypy; extra == 'dev'
29
+ Requires-Dist: pytest-cov; extra == 'dev'
30
+ Requires-Dist: pytest>=7; extra == 'dev'
31
+ Requires-Dist: ruff; extra == 'dev'
32
+ Provides-Extra: publish
33
+ Requires-Dist: build; extra == 'publish'
34
+ Requires-Dist: twine; extra == 'publish'
35
+ Description-Content-Type: text/markdown
36
+
37
+ # dobotkit
38
+
39
+ Complete, pure-Python control for the **Dobot Magician Lite** robotic arm and the
40
+ **Dobot Magician GO** mobile robot — one library, no DLLs, no native binaries.
41
+
42
+ `dobotkit` wraps both devices' **DobotLink** JSON-RPC bridge in clean,
43
+ type-hinted Python over `websockets`, so the same code runs on Windows, macOS,
44
+ and Linux with nothing more than `pip install`. **DobotLink.exe must be
45
+ running** for either device -- neither is driven over a raw serial port.
46
+
47
+ ```python
48
+ import dobotkit
49
+
50
+ with dobotkit.MagicianLite(port="auto") as arm:
51
+ arm.home()
52
+ arm.move_to(220, 0, 40, wait=True)
53
+ arm.suck(True)
54
+ ```
55
+
56
+ ---
57
+
58
+ ## Features
59
+
60
+ - **Magician Lite arm over DobotLink** — an ergonomic high-level `MagicianLite`
61
+ API (home, move, pick-and-place, IO, sensors, end-effectors) wraps the arm's
62
+ `Magician.*` DobotLink JSON-RPC surface. No serial port, no serial-library
63
+ runtime dependency.
64
+ - **Magician GO over DobotLink** — a clean `MagicianGO` core: continuous drive
65
+ (forward/strafe/spin + bounded `drive_for`), ultrasonic/IMU/odometer/battery
66
+ sensors, RGB LEDs, buzzer, alarms, and `PreciseMover` sensor-feedback motion
67
+ (drive an exact distance / turn an exact angle). Its **MagicBox** peripherals
68
+ read through `go.sensors` / `go.io` (ADC/DI by EIO pin, color/infrared/Seeed
69
+ by Grove connector) on the same connection.
70
+ - **Pure Python** — only `websockets` at runtime. No DLL, no vendored native
71
+ code, no DobotDll/DobotRPC dependency. Cross-platform and `pip`-installable.
72
+ - **Fully type-hinted** — every public symbol is typed and the package ships
73
+ `py.typed`, so editors and `mypy` see real types.
74
+ - **Safety-first** — context-manager teardown for both devices (queue stop +
75
+ disconnect on every exit path, including exceptions), and a sensor-feedback
76
+ navigation layer for the GO with absolute wall-clock timeouts and pre-move
77
+ clearance checks.
78
+ - **Lazy device imports** — `import dobotkit` never pulls in `websockets`; it
79
+ is imported only when you first access `MagicianLite` or `MagicianGO`.
80
+ - **Ergonomic pydobot-flavoured API** — `suck`, `grip`, `move_to`, and
81
+ `move_relative` read like `pydobot.Dobot`, so the everyday arm workflow
82
+ (home -> move -> grab -> move -> release) needs no protocol knowledge.
83
+
84
+ ## Installation
85
+
86
+ > **Not yet published to PyPI** — install from a local checkout for now:
87
+
88
+ ```bash
89
+ pip install -e path/to/dobotkit
90
+ ```
91
+
92
+ For development (editable install with the test/lint toolchain):
93
+
94
+ ```bash
95
+ git clone <repo-url> dobotkit
96
+ cd dobotkit
97
+ pip install -e ".[dev]"
98
+ ```
99
+
100
+ Requires **Python ≥ 3.9**. The only runtime dependency, `websockets` (used to
101
+ talk to DobotLink for both the arm and the GO), is installed automatically.
102
+
103
+ 한국어 문서: [빠른 시작 quickstart-ko](docs/quickstart-ko.md) ·
104
+ [GO API 치트시트](docs/cheatsheet_go.md) (LLM 프롬프트/RAG 접지용 1장 요약)
105
+
106
+ ---
107
+
108
+ ## Quickstart — Magician Lite (arm)
109
+
110
+ The arm is not driven over a serial port: Python talks to the **DobotLink**
111
+ desktop service over a WebSocket (JSON-RPC 2.0), and DobotLink relays commands
112
+ to the arm over its COM port. **DobotLink.exe must be running.** Open a
113
+ `MagicianLite` as a context manager so the on-device command queue is stopped
114
+ and DobotLink is disconnected on every exit path, including exceptions.
115
+
116
+ ```python
117
+ import dobotkit
118
+ from dobotkit import PTPMode
119
+
120
+ # port="auto" picks the first port DobotLink reports; pass "COM3" to be explicit.
121
+ with dobotkit.MagicianLite(port="auto") as arm:
122
+ # Home first so absolute coordinates are trustworthy (blocks until done).
123
+ arm.home(wait=True)
124
+
125
+ # Set a gentle speed/acceleration (percentages; pydobot-compatible).
126
+ arm.set_speed(velocity=100, acceleration=100)
127
+
128
+ # Absolute straight-line move to (x, y, z, r) in mm/degrees; wait for finish.
129
+ arm.move_to(220, 0, 40, 0, mode=PTPMode.MOVL_XYZ, wait=True)
130
+
131
+ # Toggle the suction cup directly...
132
+ arm.suck(True)
133
+ arm.move_relative(dz=-20, wait=True)
134
+ arm.suck(False)
135
+
136
+ # ...or run the whole eight-step pick-and-place cycle as one queued program.
137
+ # Waypoints are (x, y, z) in mm; z_safe is the travel clearance between them.
138
+ arm.pick_and_place(
139
+ src=(200.0, 0.0, -30.0),
140
+ dst=(100.0, 150.0, -30.0),
141
+ z_safe=50.0,
142
+ settle_ms=300,
143
+ )
144
+
145
+ pose = arm.get_pose()
146
+ print(f"final pose: x={pose['x']:.1f} y={pose['y']:.1f} z={pose['z']:.1f}")
147
+ ```
148
+
149
+ `wait=True` sends `isWaitForFinish=true`, so DobotLink blocks until the move
150
+ physically completes before returning (raising `DobotTimeoutError` only if the
151
+ per-call deadline elapses). Keep targets inside the workspace — a target that
152
+ drives a joint near its travel limit can fault.
153
+
154
+ > **If the arm accepts commands but does not move**, its controller has an
155
+ > active alarm (motion is silently blocked while sensors/IO/effector still
156
+ > work). This is not reliably clearable from software — **power-cycle the arm**
157
+ > to clear it, then reconnect.
158
+
159
+ ### MagicBox peripherals (sensors, ADC/DI reads)
160
+
161
+ Every `sensors.*` read (`adc`, `di`, `color`, `infrared`, `distance`, `temp`,
162
+ `light`, `rgb`) and the read-only `io.get_di` / `io.get_adc` are routed
163
+ through the **MagicBox**. If it (or its device) is not connected, these calls
164
+ **warn and return `None`** rather than raising, so teaching code keeps
165
+ running:
166
+
167
+ ```python
168
+ reading = arm.sensors.color(port=0) # RuntimeWarning + None if no MagicBox
169
+ if reading is None:
170
+ print("색 센서를 읽지 못했습니다 — 매직박스/센서 연결 확인")
171
+ else:
172
+ print(reading)
173
+
174
+ v = arm.sensors.adc(24) # RuntimeWarning + None if no MagicBox
175
+ if v is None:
176
+ print("매직박스/센서 미연결")
177
+ ```
178
+
179
+ Arm-native operations (motion, `effector.suck` / `grip` / `servo`, `io.set_do`
180
+ / `set_pwm` / `set_multiplexing`) are unaffected and still raise on error, as
181
+ does a genuine connection error (`DobotConnectionError`, e.g. DobotLink is not
182
+ running).
183
+
184
+ ## Quickstart — Magician GO (mobile robot)
185
+
186
+ The GO is not driven directly: Python talks to the **DobotLink** desktop service
187
+ over a WebSocket (JSON-RPC 2.0), and DobotLink relays commands to the car.
188
+ DobotLink must be running.
189
+
190
+ ```
191
+ Python --(WebSocket JSON-RPC)--> DobotLink --(COM/wireless)--> GO
192
+ ```
193
+
194
+ ```python
195
+ from dobotkit import MagicianGO
196
+ from dobotkit.go.navigation import PreciseMover
197
+
198
+ # open() connects DobotLink + verifies the GO link with a battery read-back,
199
+ # and (as a context manager) stops the car + closes the socket on every exit.
200
+ with MagicianGO.open(port_name="COM5") as go:
201
+ try:
202
+ # Continuous velocity control is reliable: check clearance, then drive.
203
+ ok, info = go.clearance_ok(x=1, threshold=20)
204
+ if ok:
205
+ go.drive_for(x=20, seconds=1.0) # bounded forward pulse, auto-stops
206
+ finally:
207
+ go.emergency_stop() # fire-and-forget safety stop (never blocks)
208
+
209
+ # For precise motion use the sensor-feedback layer (continuous move + IMU/
210
+ # odometer feedback) — drive an exact distance or turn an exact angle.
211
+ mover = PreciseMover(go)
212
+ mover.goto_distance(300, speed=20) # ~300 mm forward, then stop
213
+ mover.turn_degrees(90, speed=20) # +90 deg (CCW), IMU-closed-loop
214
+
215
+ # MagicBox peripherals ride the same connection (guarded -> None if absent):
216
+ knob = go.sensors.adc(22) # potentiometer on EIO pin 22 (0..4095)
217
+ print("knob:", knob)
218
+ ```
219
+
220
+ ---
221
+
222
+ ## Safety
223
+
224
+ Robot hardware moves under power and can collide, pinch, or topple. `dobotkit` is
225
+ built to fail safe, but you must still operate it responsibly. The guidance below
226
+ comes from the Dobot Magician Lite and Magician GO operating notes.
227
+
228
+ **Arm (Magician Lite)**
229
+
230
+ - **Power-on home.** Always `home()` after powering on so that absolute
231
+ coordinates are trustworthy before issuing `move_to` / `pick_and_place`.
232
+ - **Clearance checks.** Verify the workspace is clear of obstacles, fingers, and
233
+ fixtures along the planned path before commanding a move. Start with the
234
+ illustrative coordinates lowered/slowed and tune to *your* setup.
235
+ - **Wait timeouts, not silent success.** `wait=True` raises `DobotTimeoutError`
236
+ if the queued command never finishes, instead of returning as if it had.
237
+ - **Always disconnect.** Use the `MagicianLite` context manager
238
+ (`with ... as arm:`) so the command queue is stopped and DobotLink is
239
+ disconnected on every exit path — including exceptions.
240
+
241
+ **GO (Magician GO)**
242
+
243
+ - **Verify the link.** Use `go.connect()` (it follows the connect handshake with
244
+ a real battery read), because the raw handshake can report a *false* success.
245
+ - **Clearance before driving.** Call `clearance_ok(...)` for the intended
246
+ direction of travel and only drive when it returns `True`.
247
+ - **Timeouts everywhere.** The `PreciseMover` control loops use absolute
248
+ wall-clock timeouts (`time.monotonic`) so they can never spin forever, and
249
+ every path ends in `emergency_stop`.
250
+ - **Always stop.** Wrap motion in `try/finally` ending in `go.emergency_stop()`
251
+ (a non-blocking notify, safe from a `finally` block or interrupt path even if
252
+ the link is degraded); the `MagicianGO` context manager also stops on exit.
253
+ - **Precise motion = continuous move + feedback.** For exact distances/turns use
254
+ `PreciseMover` (continuous `move()` sampled against the odometer/IMU). The
255
+ firmware's own built-in closed-loop commands were removed from this library
256
+ because they can hang indefinitely on this chassis.
257
+
258
+ ---
259
+
260
+ ## Feature coverage & verification
261
+
262
+ - **Magician Lite arm via DobotLink.** The ergonomic `MagicianLite` API (and
263
+ its `effector` / `sensors` / `io` groups) wraps the arm's `Magician.*`
264
+ DobotLink JSON-RPC surface. DobotLink owns the wire protocol, struct
265
+ packing, and command IDs -- there is no serial transport or wire-level code
266
+ in this library.
267
+ - **Magician GO core, hardware-verified.** The typed `MagicianGO` class wraps a
268
+ clean, generally-used slice of the `MagicianGO.*` surface (drive, native
269
+ sensors, RGB/buzzer, alarms) plus `PreciseMover` feedback motion. Turn
270
+ direction is confirmed: `r+` = CCW (`PreciseMover.turn_degrees(+90)` verified).
271
+ - **GO MagicBox peripherals, hardware-verified (2026-07-16).** `go.sensors` /
272
+ `go.io` read the GO's MagicBox on the `MagicBox.*` namespace over the same
273
+ connection. ADC/DI/DO/PWM address an **EIO pin (1..26)**; color/infrared/Seeed
274
+ address a **Grove connector (1..6)**. Reads degrade to `None` + a warning when
275
+ the MagicBox or sensor is absent. (Verified: potentiometer on Grove 4 = EIO 22.)
276
+
277
+ ---
278
+
279
+ ## Project layout
280
+
281
+ ```
282
+ dobotkit/
283
+ ├── src/dobotkit/
284
+ │ ├── __init__.py # public exports (MagicianLite, MagicianGO, enums, exceptions)
285
+ │ ├── enums.py # PTPMode, JOGMode, GPIOType, EndEffectorType, ...
286
+ │ ├── exceptions.py # DobotError hierarchy
287
+ │ ├── link.py # DobotLinkClient (JSON-RPC over websockets) -- shared by arm + GO
288
+ │ ├── arm/ # Magician Lite arm, via DobotLink
289
+ │ │ ├── commands/ # ArmCommands: Magician.* RPC wrapper mixins
290
+ │ │ ├── groups.py # IO / Sensor / Effector facades
291
+ │ │ └── magicianlite.py # high-level MagicianLite API
292
+ │ └── go/ # Magician GO stack, via DobotLink
293
+ │ ├── geometry.py # pure helpers (yaw_delta, bearing, clamp_speed)
294
+ │ ├── groups.py # MagicBox sensor/IO facades (go.sensors / go.io)
295
+ │ ├── magiciango.py # high-level MagicianGO wrapper
296
+ │ └── navigation.py # PreciseMover (sensor-feedback motion)
297
+ ├── examples/ # runnable demos:
298
+ │ # arm — arm_magicianlite
299
+ │ # GO — go_discover, go_teleop, go_magicbox_sensor
300
+ ├── tests/ # mirror of src; FakeWebSocket / FakeClient doubles
301
+ └── docs/ # API reference
302
+ ```
303
+
304
+ ## Public API
305
+
306
+ ```python
307
+ from dobotkit import MagicianLite, MagicianGO # device classes
308
+ from dobotkit import ( # enums
309
+ PTPMode, JOGMode, ContinuousPathMode, GPIOType,
310
+ EndEffectorType, ColorPort, LEDChannel,
311
+ )
312
+ from dobotkit import ( # exceptions
313
+ DobotError, DobotConnectionError, DobotTimeoutError,
314
+ DobotProtocolError, DobotAlarmError, DobotLinkError, DobotValueError,
315
+ )
316
+ from dobotkit.link import DobotLinkClient
317
+ from dobotkit.go.navigation import PreciseMover, NavigationAborted
318
+ ```
319
+
320
+ ## License
321
+
322
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,24 @@
1
+ dobotkit/__init__.py,sha256=83GRBHea9p3LdsF4beDp2mgzhFdt9MBUxIqIjsT27Uo,3869
2
+ dobotkit/_version.py,sha256=QTYqXqSTHFRkM9TEgpDFcHvwLbvqHDqvqfQ9EiXkcAM,23
3
+ dobotkit/enums.py,sha256=mFAFmvliB7GwYzUMkNmiBjfN1KxeqTHDA9v_Wa8FUdc,1191
4
+ dobotkit/exceptions.py,sha256=YhacLvatyV_Yc46I9Hz60Zce4D7bU1ZqX6Nf1vnOX08,1072
5
+ dobotkit/link.py,sha256=O3rTvPMoObTSl8khKBU0edP7z_qUt9GU8rKGYqJ8YVQ,8690
6
+ dobotkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ dobotkit/arm/__init__.py,sha256=JoMPxe-QAD3Cds8eicZ8SeGf-7WUFMcHPnFBla66PPM,1711
8
+ dobotkit/arm/groups.py,sha256=bYqz3cuFHSwDmhti5qGWgJQer8zWOUbyCOD4LCbKBm8,6833
9
+ dobotkit/arm/magicianlite.py,sha256=AIN3WgC3NOExBNtdxZ8O61uKB7d0YszFavZpMjNx8Rs,8618
10
+ dobotkit/arm/commands/__init__.py,sha256=l1GrpptD7-wAOnDt9wPaJzESjJWhqzEtXzCovJWO3js,806
11
+ dobotkit/arm/commands/_base.py,sha256=T54AeS0n1aqeFHslbeCtcyuqzB-Q21akU9c9HBtQ4SI,803
12
+ dobotkit/arm/commands/connection.py,sha256=gH-RW6y3JTkZSD1eNazAdPRB_leEwbiMQV4ZaKi9jbI,983
13
+ dobotkit/arm/commands/effector_io.py,sha256=k5VZi25gJCDMJbLxWwXQAHJlgzqn6IoZyugPm2ffVB4,3692
14
+ dobotkit/arm/commands/motion.py,sha256=x0FcVYB_z56-ySwBIOP_jgT7EKggQnKhNH0rwc3tC04,3037
15
+ dobotkit/arm/commands/sensors.py,sha256=CYGVUbul3ljwgWqdbZ5RwlRNjl0a0dKeYgqHmeaeWOw,1499
16
+ dobotkit/go/__init__.py,sha256=oxPa7pYyo6pq41ZHF9_rmaYRh8MnOEkHT-873uS6ICU,2442
17
+ dobotkit/go/geometry.py,sha256=QRggXnGM4oA8IzlUlZ9HwE_gSLYfa117Ip5oEimU-go,3624
18
+ dobotkit/go/groups.py,sha256=7gIUwRk550MJ-l8uX9O--UXHnNkhmQ5DSiulKhKMnK8,7218
19
+ dobotkit/go/magiciango.py,sha256=KmmZw0X2Rl1UplMwtgPTBczW7LBiCbXMPN6f4wq52uA,22531
20
+ dobotkit/go/navigation.py,sha256=ciO1Y8t9wYBjMbHOl_XUqlwd53w03m3kCooU4aTn240,17269
21
+ dobotkit-0.1.0.dist-info/METADATA,sha256=NSr-igBrPFmQy3XUP2X3OcwkoCkn4wOouXVEILCVN4s,13976
22
+ dobotkit-0.1.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
23
+ dobotkit-0.1.0.dist-info/licenses/LICENSE,sha256=JPsZc7WjRHA1C2sGjpCWd3rOvwJz2ok0BzUJ6RAtQbs,1078
24
+ dobotkit-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.31.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dobotkit contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.