dexcontrol 0.2.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.

Potentially problematic release.


This version of dexcontrol might be problematic. Click here for more details.

Files changed (72) hide show
  1. dexcontrol/__init__.py +45 -0
  2. dexcontrol/apps/dualsense_teleop_base.py +371 -0
  3. dexcontrol/config/__init__.py +14 -0
  4. dexcontrol/config/core/__init__.py +22 -0
  5. dexcontrol/config/core/arm.py +32 -0
  6. dexcontrol/config/core/chassis.py +22 -0
  7. dexcontrol/config/core/hand.py +42 -0
  8. dexcontrol/config/core/head.py +33 -0
  9. dexcontrol/config/core/misc.py +37 -0
  10. dexcontrol/config/core/torso.py +36 -0
  11. dexcontrol/config/sensors/__init__.py +4 -0
  12. dexcontrol/config/sensors/cameras/__init__.py +7 -0
  13. dexcontrol/config/sensors/cameras/gemini_camera.py +16 -0
  14. dexcontrol/config/sensors/cameras/rgb_camera.py +15 -0
  15. dexcontrol/config/sensors/imu/__init__.py +6 -0
  16. dexcontrol/config/sensors/imu/gemini_imu.py +15 -0
  17. dexcontrol/config/sensors/imu/nine_axis_imu.py +15 -0
  18. dexcontrol/config/sensors/lidar/__init__.py +6 -0
  19. dexcontrol/config/sensors/lidar/rplidar.py +15 -0
  20. dexcontrol/config/sensors/ultrasonic/__init__.py +6 -0
  21. dexcontrol/config/sensors/ultrasonic/ultrasonic.py +15 -0
  22. dexcontrol/config/sensors/vega_sensors.py +65 -0
  23. dexcontrol/config/vega.py +203 -0
  24. dexcontrol/core/__init__.py +0 -0
  25. dexcontrol/core/arm.py +324 -0
  26. dexcontrol/core/chassis.py +628 -0
  27. dexcontrol/core/component.py +834 -0
  28. dexcontrol/core/hand.py +170 -0
  29. dexcontrol/core/head.py +232 -0
  30. dexcontrol/core/misc.py +514 -0
  31. dexcontrol/core/torso.py +198 -0
  32. dexcontrol/proto/dexcontrol_msg_pb2.py +69 -0
  33. dexcontrol/proto/dexcontrol_msg_pb2.pyi +168 -0
  34. dexcontrol/proto/dexcontrol_query_pb2.py +73 -0
  35. dexcontrol/proto/dexcontrol_query_pb2.pyi +134 -0
  36. dexcontrol/robot.py +1091 -0
  37. dexcontrol/sensors/__init__.py +40 -0
  38. dexcontrol/sensors/camera/__init__.py +18 -0
  39. dexcontrol/sensors/camera/gemini_camera.py +139 -0
  40. dexcontrol/sensors/camera/rgb_camera.py +98 -0
  41. dexcontrol/sensors/imu/__init__.py +22 -0
  42. dexcontrol/sensors/imu/gemini_imu.py +139 -0
  43. dexcontrol/sensors/imu/nine_axis_imu.py +149 -0
  44. dexcontrol/sensors/lidar/__init__.py +3 -0
  45. dexcontrol/sensors/lidar/rplidar.py +164 -0
  46. dexcontrol/sensors/manager.py +185 -0
  47. dexcontrol/sensors/ultrasonic.py +110 -0
  48. dexcontrol/utils/__init__.py +15 -0
  49. dexcontrol/utils/constants.py +12 -0
  50. dexcontrol/utils/io_utils.py +26 -0
  51. dexcontrol/utils/motion_utils.py +194 -0
  52. dexcontrol/utils/os_utils.py +39 -0
  53. dexcontrol/utils/pb_utils.py +103 -0
  54. dexcontrol/utils/rate_limiter.py +167 -0
  55. dexcontrol/utils/reset_orbbec_camera_usb.py +98 -0
  56. dexcontrol/utils/subscribers/__init__.py +44 -0
  57. dexcontrol/utils/subscribers/base.py +260 -0
  58. dexcontrol/utils/subscribers/camera.py +328 -0
  59. dexcontrol/utils/subscribers/decoders.py +83 -0
  60. dexcontrol/utils/subscribers/generic.py +105 -0
  61. dexcontrol/utils/subscribers/imu.py +170 -0
  62. dexcontrol/utils/subscribers/lidar.py +195 -0
  63. dexcontrol/utils/subscribers/protobuf.py +106 -0
  64. dexcontrol/utils/timer.py +136 -0
  65. dexcontrol/utils/trajectory_utils.py +40 -0
  66. dexcontrol/utils/viz_utils.py +86 -0
  67. dexcontrol-0.2.1.dist-info/METADATA +369 -0
  68. dexcontrol-0.2.1.dist-info/RECORD +72 -0
  69. dexcontrol-0.2.1.dist-info/WHEEL +5 -0
  70. dexcontrol-0.2.1.dist-info/licenses/LICENSE +188 -0
  71. dexcontrol-0.2.1.dist-info/licenses/NOTICE +13 -0
  72. dexcontrol-0.2.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,136 @@
1
+ # Copyright (c) 2025 Dexmate CORPORATION & AFFILIATES. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 with Commons Clause License
4
+ # Condition v1.0 [see LICENSE for details].
5
+
6
+ """Utility for measuring code execution time."""
7
+
8
+ import time
9
+ from collections.abc import Callable
10
+ from functools import wraps
11
+ from typing import Any, TypeVar, cast
12
+
13
+ from loguru import logger
14
+
15
+ # Type variable for preserving function return type in decorator
16
+ F = TypeVar("F", bound=Callable[..., Any])
17
+
18
+
19
+ class ExecutionTimer:
20
+ """A utility class for measuring execution time of code blocks.
21
+
22
+ This class can be used either as a context manager or decorator.
23
+
24
+ Examples:
25
+ As context manager:
26
+ with ExecutionTimer("operation name"):
27
+ # code to time
28
+
29
+ As decorator:
30
+ @ExecutionTimer("operation name")
31
+ def function_to_time():
32
+ # code to time
33
+ """
34
+
35
+ def __init__(self, name: str | None = "Operation") -> None:
36
+ """Initialize the timer.
37
+
38
+ Args:
39
+ name: Optional name to identify this timing operation in logs.
40
+ Defaults to "Operation" if not provided.
41
+ """
42
+ self.name = name or "Operation"
43
+ self.start_time: float = 0.0
44
+ self.end_time: float | None = None
45
+
46
+ def __enter__(self) -> "ExecutionTimer":
47
+ """Start timing when entering context.
48
+
49
+ Returns:
50
+ Self reference for context manager usage.
51
+ """
52
+ self.start_time = time.perf_counter()
53
+ self.end_time = None
54
+ return self
55
+
56
+ def __exit__(self, *args: Any) -> None:
57
+ """Stop timing when exiting context and log the duration.
58
+
59
+ Args:
60
+ *args: Exception information passed by context manager.
61
+ """
62
+ self.end_time = time.perf_counter()
63
+ duration = self.elapsed
64
+ logger.info(f"{self.name} took {duration:.4f} seconds")
65
+
66
+ def __call__(self, func: F) -> F:
67
+ """Allow the ExecutionTimer to be used as a decorator.
68
+
69
+ Args:
70
+ func: The function to be timed.
71
+
72
+ Returns:
73
+ Wrapped function that measures and logs execution time.
74
+ """
75
+
76
+ @wraps(func)
77
+ def wrapper(*args: Any, **kwargs: Any) -> Any:
78
+ with self:
79
+ return func(*args, **kwargs)
80
+
81
+ return cast(F, wrapper)
82
+
83
+ def start(self) -> "ExecutionTimer":
84
+ """Start timing manually.
85
+
86
+ Returns:
87
+ Self reference for method chaining.
88
+ """
89
+ return self.__enter__()
90
+
91
+ def stop(self) -> float:
92
+ """Stop timing manually and return elapsed time.
93
+
94
+ Returns:
95
+ Elapsed time in seconds.
96
+ """
97
+ self.__exit__(None, None, None)
98
+ return self.elapsed
99
+
100
+ @property
101
+ def elapsed(self) -> float:
102
+ """Get the elapsed time in seconds.
103
+
104
+ Returns:
105
+ Time elapsed since start in seconds. If timer is still running,
106
+ returns current elapsed time.
107
+ """
108
+ if self.end_time is not None:
109
+ return self.end_time - self.start_time
110
+ return time.perf_counter() - self.start_time
111
+
112
+
113
+ if __name__ == "__main__":
114
+ # Test as a context manager
115
+ logger.info("Testing ExecutionTimer as context manager:")
116
+ with ExecutionTimer("Sleep operation"):
117
+ time.sleep(1.0)
118
+
119
+ # Test as a decorator
120
+ logger.info("\nTesting ExecutionTimer as decorator:")
121
+
122
+ @ExecutionTimer("Decorated function")
123
+ def slow_function() -> str:
124
+ time.sleep(0.5)
125
+ return "Done!"
126
+
127
+ result = slow_function()
128
+ logger.info(f"Function returned: {result}")
129
+
130
+ # Test with manual timing
131
+ logger.info("\nTesting ExecutionTimer with manual timing:")
132
+ timer = ExecutionTimer("Manual timing")
133
+ timer.start()
134
+ time.sleep(3.0)
135
+ timer.stop()
136
+ logger.info(f"Elapsed time property: {timer.elapsed:.4f} seconds")
@@ -0,0 +1,40 @@
1
+ # Copyright (c) 2025 Dexmate CORPORATION & AFFILIATES. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 with Commons Clause License
4
+ # Condition v1.0 [see LICENSE for details].
5
+
6
+ """Trajectory utility functions for smooth motion generation."""
7
+
8
+ import numpy as np
9
+
10
+
11
+ def generate_linear_trajectory(
12
+ current_pos: np.ndarray,
13
+ target_pos: np.ndarray,
14
+ max_vel: float = 0.5,
15
+ control_hz: float = 100,
16
+ ) -> tuple[np.ndarray, int]:
17
+ """Generate a linear trajectory between current and target positions.
18
+
19
+ Args:
20
+ current_pos: Current position array.
21
+ target_pos: Target position array.
22
+ max_vel: Maximum velocity in units per second.
23
+ control_hz: Control frequency in Hz.
24
+
25
+ Returns:
26
+ Tuple containing:
27
+ - trajectory: Array of waypoints from current to target position.
28
+ - num_steps: Number of steps in the trajectory.
29
+ """
30
+ # Calculate linear interpolation between current and target positions
31
+ max_diff = np.max(np.abs(target_pos - current_pos))
32
+ num_steps = int(max_diff / max_vel * control_hz)
33
+
34
+ # Ensure at least one step
35
+ num_steps = max(1, num_steps)
36
+
37
+ # Generate trajectory with endpoints (exclude the starting point in the return)
38
+ trajectory = np.linspace(current_pos, target_pos, num_steps + 1, endpoint=True)[1:]
39
+
40
+ return trajectory, num_steps
@@ -0,0 +1,86 @@
1
+ # Copyright (c) 2025 Dexmate CORPORATION & AFFILIATES. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 with Commons Clause License
4
+ # Condition v1.0 [see LICENSE for details].
5
+
6
+ """Utility functions for displaying information in a Rich table format."""
7
+
8
+ from typing import Literal
9
+
10
+ from rich.console import Console
11
+ from rich.table import Table
12
+
13
+ TYPE_VERSION = dict[Literal["hardware_version", "software_version", "main_hash"], str]
14
+
15
+
16
+ def show_software_version(version_info: dict[str, TYPE_VERSION]) -> None:
17
+ """Create a Rich table for displaying firmware version information.
18
+
19
+ Args:
20
+ version_info: Dictionary containing version info for each component.
21
+ """
22
+ table = Table(title="Firmware Version")
23
+ table.add_column("Component", style="cyan")
24
+ table.add_column("Hardware Version")
25
+ table.add_column("Software Version")
26
+ table.add_column("Main Hash")
27
+
28
+ for component, version in sorted(version_info.items()):
29
+ table.add_row(
30
+ component,
31
+ str(version["hardware_version"]),
32
+ str(version["software_version"]),
33
+ str(version["main_hash"]),
34
+ )
35
+
36
+ console = Console()
37
+ console.print(table)
38
+
39
+
40
+ def show_component_status(status_info: dict[str, dict]) -> None:
41
+ """Create a Rich table for displaying component status information.
42
+
43
+ Args:
44
+ status_info: Dictionary containing status info for each component.
45
+ """
46
+ from dexcontrol.utils.pb_utils import ComponentStatus
47
+
48
+ table = Table(title="Component Status")
49
+ table.add_column("Component", style="cyan")
50
+ table.add_column("Connected", justify="center")
51
+ table.add_column("Enabled", justify="center")
52
+ table.add_column("Error", justify="center")
53
+
54
+ status_icons = {
55
+ True: ":white_check_mark:",
56
+ False: ":x:",
57
+ ComponentStatus.NORMAL: ":white_check_mark:",
58
+ ComponentStatus.NA: "N/A",
59
+ }
60
+
61
+ # Sort components by name to ensure consistent order
62
+ for component in sorted(status_info.keys()):
63
+ status = status_info[component]
64
+ # Format connection status
65
+ connected = status_icons[status["connected"]]
66
+
67
+ # Format enabled status
68
+ enabled = status_icons.get(status["enabled"], ":x:")
69
+
70
+ # Format error status
71
+ if status["error_state"] == ComponentStatus.NORMAL:
72
+ error = ":white_check_mark:"
73
+ elif status["error_state"] == ComponentStatus.NA:
74
+ error = "N/A"
75
+ else:
76
+ error = status["error_code"]
77
+
78
+ table.add_row(
79
+ component,
80
+ connected,
81
+ enabled,
82
+ error,
83
+ )
84
+
85
+ console = Console()
86
+ console.print(table)
@@ -0,0 +1,369 @@
1
+ Metadata-Version: 2.4
2
+ Name: dexcontrol
3
+ Version: 0.2.1
4
+ Summary: A Python library of Robot Motion Control
5
+ Author-email: Dexmate <contact@dexmate.com>
6
+ License: “Commons Clause” License Condition v1.0
7
+
8
+ The Software is provided to you by the Licensor under the License, as defined below, subject to the following condition.
9
+
10
+ Without limiting other conditions in the License, the grant of rights under the License will not include, and the License does not grant to you, right to Sell the Software.
11
+
12
+ For purposes of the foregoing, “Sell” means practicing any or all of the rights granted to you under the License to provide to third parties, for a fee or other consideration (including without limitation fees for hosting or consulting/ support services related to the Software), a product or service whose value derives, entirely or substantially, from the functionality of the Software. Any license notice or attribution required by the License must also include this Commons Cause License Condition notice.
13
+
14
+ Software: dexcontrol
15
+ License: Apache 2.0
16
+ Licensor: Dexmate
17
+
18
+ Apache License
19
+ Version 2.0, January 2004
20
+ http://www.apache.org/licenses/
21
+
22
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
23
+
24
+ 1. Definitions.
25
+
26
+ "License" shall mean the terms and conditions for use, reproduction,
27
+ and distribution as defined by Sections 1 through 9 of this document.
28
+
29
+ "Licensor" shall mean the copyright owner or entity authorized by
30
+ the copyright owner that is granting the License.
31
+
32
+ "Legal Entity" shall mean the union of the acting entity and all
33
+ other entities that control, are controlled by, or are under common
34
+ control with that entity. For the purposes of this definition,
35
+ "control" means (i) the power, direct or indirect, to cause the
36
+ direction or management of such entity, whether by contract or
37
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
38
+ outstanding shares, or (iii) beneficial ownership of such entity.
39
+
40
+ "You" (or "Your") shall mean an individual or Legal Entity
41
+ exercising permissions granted by this License.
42
+
43
+ "Source" form shall mean the preferred form for making modifications,
44
+ including but not limited to software source code, documentation
45
+ source, and configuration files.
46
+
47
+ "Object" form shall mean any form resulting from mechanical
48
+ transformation or translation of a Source form, including but
49
+ not limited to compiled object code, generated documentation,
50
+ and conversions to other media types.
51
+
52
+ "Work" shall mean the work of authorship, whether in Source or
53
+ Object form, made available under the License, as indicated by a
54
+ copyright notice that is included in or attached to the work
55
+ (an example is provided in the Appendix below).
56
+
57
+ "Derivative Works" shall mean any work, whether in Source or Object
58
+ form, that is based on (or derived from) the Work and for which the
59
+ editorial revisions, annotations, elaborations, or other modifications
60
+ represent, as a whole, an original work of authorship. For the purposes
61
+ of this License, Derivative Works shall not include works that remain
62
+ separable from, or merely link (or bind by name) to the interfaces of,
63
+ the Work and Derivative Works thereof.
64
+
65
+ "Contribution" shall mean any work of authorship, including
66
+ the original version of the Work and any modifications or additions
67
+ to that Work or Derivative Works thereof, that is intentionally
68
+ submitted to Licensor for inclusion in the Work by the copyright owner
69
+ or by an individual or Legal Entity authorized to submit on behalf of
70
+ the copyright owner. For the purposes of this definition, "submitted"
71
+ means any form of electronic, verbal, or written communication sent
72
+ to the Licensor or its representatives, including but not limited to
73
+ communication on electronic mailing lists, source code control systems,
74
+ and issue tracking systems that are managed by, or on behalf of, the
75
+ Licensor for the purpose of discussing and improving the Work, but
76
+ excluding communication that is conspicuously marked or otherwise
77
+ designated in writing by the copyright owner as "Not a Contribution."
78
+
79
+ "Contributor" shall mean Licensor and any individual or Legal Entity
80
+ on behalf of whom a Contribution has been received by Licensor and
81
+ subsequently incorporated within the Work.
82
+
83
+ 2. Grant of Copyright License. Subject to the terms and conditions of
84
+ this License, each Contributor hereby grants to You a perpetual,
85
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
86
+ copyright license to reproduce, prepare Derivative Works of,
87
+ publicly display, publicly perform, sublicense, and distribute the
88
+ Work and such Derivative Works in Source or Object form.
89
+
90
+ 3. Grant of Patent License. Subject to the terms and conditions of
91
+ this License, each Contributor hereby grants to You a perpetual,
92
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
93
+ (except as stated in this section) patent license to make, have made,
94
+ use, offer to sell, sell, import, and otherwise transfer the Work,
95
+ where such license applies only to those patent claims licensable
96
+ by such Contributor that are necessarily infringed by their
97
+ Contribution(s) alone or by combination of their Contribution(s)
98
+ with the Work to which such Contribution(s) was submitted. If You
99
+ institute patent litigation against any entity (including a
100
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
101
+ or a Contribution incorporated within the Work constitutes direct
102
+ or contributory patent infringement, then any patent licenses
103
+ granted to You under this License for that Work shall terminate
104
+ as of the date such litigation is filed.
105
+
106
+ 4. Redistribution. You may reproduce and distribute copies of the
107
+ Work or Derivative Works thereof in any medium, with or without
108
+ modifications, and in Source or Object form, provided that You
109
+ meet the following conditions:
110
+
111
+ (a) You must give any other recipients of the Work or
112
+ Derivative Works a copy of this License; and
113
+
114
+ (b) You must cause any modified files to carry prominent notices
115
+ stating that You changed the files; and
116
+
117
+ (c) You must retain, in the Source form of any Derivative Works
118
+ that You distribute, all copyright, patent, trademark, and
119
+ attribution notices from the Source form of the Work,
120
+ excluding those notices that do not pertain to any part of
121
+ the Derivative Works; and
122
+
123
+ (d) If the Work includes a "NOTICE" text file as part of its
124
+ distribution, then any Derivative Works that You distribute must
125
+ include a readable copy of the attribution notices contained
126
+ within such NOTICE file, excluding those notices that do not
127
+ pertain to any part of the Derivative Works, in at least one
128
+ of the following places: within a NOTICE text file distributed
129
+ as part of the Derivative Works; within the Source form or
130
+ documentation, if provided along with the Derivative Works; or,
131
+ within a display generated by the Derivative Works, if and
132
+ wherever such third-party notices normally appear. The contents
133
+ of the NOTICE file are for informational purposes only and
134
+ do not modify the License. You may add Your own attribution
135
+ notices within Derivative Works that You distribute, alongside
136
+ or as an addendum to the NOTICE text from the Work, provided
137
+ that such additional attribution notices cannot be construed
138
+ as modifying the License.
139
+
140
+ You may add Your own copyright statement to Your modifications and
141
+ may provide additional or different license terms and conditions
142
+ for use, reproduction, or distribution of Your modifications, or
143
+ for any such Derivative Works as a whole, provided Your use,
144
+ reproduction, and distribution of the Work otherwise complies with
145
+ the conditions stated in this License.
146
+
147
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
148
+ any Contribution intentionally submitted for inclusion in the Work
149
+ by You to the Licensor shall be under the terms and conditions of
150
+ this License, without any additional terms or conditions.
151
+ Notwithstanding the above, nothing herein shall supersede or modify
152
+ the terms of any separate license agreement you may have executed
153
+ with Licensor regarding such Contributions.
154
+
155
+ 6. Trademarks. This License does not grant permission to use the trade
156
+ names, trademarks, service marks, or product names of the Licensor,
157
+ except as required for reasonable and customary use in describing the
158
+ origin of the Work and reproducing the content of the NOTICE file.
159
+
160
+ 7. Disclaimer of Warranty. Unless required by applicable law or
161
+ agreed to in writing, Licensor provides the Work (and each
162
+ Contributor provides its Contributions) on an "AS IS" BASIS,
163
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
164
+ implied, including, without limitation, any warranties or conditions
165
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
166
+ PARTICULAR PURPOSE. You are solely responsible for determining the
167
+ appropriateness of using or redistributing the Work and assume any
168
+ risks associated with Your exercise of permissions under this License.
169
+
170
+ 8. Limitation of Liability. In no event and under no legal theory,
171
+ whether in tort (including negligence), contract, or otherwise,
172
+ unless required by applicable law (such as deliberate and grossly
173
+ negligent acts) or agreed to in writing, shall any Contributor be
174
+ liable to You for damages, including any direct, indirect, special,
175
+ incidental, or consequential damages of any character arising as a
176
+ result of this License or out of the use or inability to use the
177
+ Work (including but not limited to damages for loss of goodwill,
178
+ work stoppage, computer failure or malfunction, or any and all
179
+ other commercial damages or losses), even if such Contributor
180
+ has been advised of the possibility of such damages.
181
+
182
+ 9. Accepting Warranty or Additional Liability. While redistributing
183
+ the Work or Derivative Works thereof, You may choose to offer,
184
+ and charge a fee for, acceptance of support, warranty, indemnity,
185
+ or other liability obligations and/or rights consistent with this
186
+ License. However, in accepting such obligations, You may act only
187
+ on Your own behalf and on Your sole responsibility, not on behalf
188
+ of any other Contributor, and only if You agree to indemnify,
189
+ defend, and hold each Contributor harmless for any liability
190
+ incurred by, or claims asserted against, such Contributor by reason
191
+ of your accepting any such warranty or additional liability.
192
+
193
+ END OF TERMS AND CONDITIONS
194
+ Project-URL: Repository, https://github.com/dm-ai-core/dexcontrol
195
+ Keywords: robot,python,control,learning
196
+ Classifier: Programming Language :: Python :: 3
197
+ Classifier: Programming Language :: Python :: 3.10
198
+ Classifier: Programming Language :: Python :: 3.11
199
+ Classifier: Programming Language :: Python :: 3.12
200
+ Classifier: Operating System :: OS Independent
201
+ Classifier: Typing :: Typed
202
+ Requires-Python: >=3.10
203
+ Description-Content-Type: text/markdown
204
+ License-File: LICENSE
205
+ License-File: NOTICE
206
+ Requires-Dist: protobuf>=6.31.0
207
+ Requires-Dist: numpy>=2.2.6
208
+ Requires-Dist: eclipse-zenoh>=1.2.0
209
+ Requires-Dist: hydra-core==1.3.2
210
+ Requires-Dist: loguru>=0.7.3
211
+ Requires-Dist: jaxtyping>=0.2.38
212
+ Requires-Dist: rich
213
+ Requires-Dist: opencv-python>=4.11.0
214
+ Provides-Extra: dev
215
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
216
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
217
+ Requires-Dist: ruff; extra == "dev"
218
+ Requires-Dist: isort>=5.12.0; extra == "dev"
219
+ Requires-Dist: pyright; extra == "dev"
220
+ Requires-Dist: pre-commit; extra == "dev"
221
+ Provides-Extra: docs
222
+ Requires-Dist: sphinx>=7.0.0; extra == "docs"
223
+ Requires-Dist: furo>=2023.09.10; extra == "docs"
224
+ Requires-Dist: sphinx-autodoc-typehints>=1.24.0; extra == "docs"
225
+ Requires-Dist: sphinx-rtd-theme>=1.3.0; extra == "docs"
226
+ Requires-Dist: myst-parser>=2.0.0; extra == "docs"
227
+ Requires-Dist: markitdown[all]>=0.1.0; extra == "docs"
228
+ Provides-Extra: example
229
+ Requires-Dist: matplotlib>=3.8.0; extra == "example"
230
+ Requires-Dist: tyro; extra == "example"
231
+ Requires-Dist: dualsense-controller>=0.3.1; extra == "example"
232
+ Requires-Dist: pytransform3d==3.13.0; extra == "example"
233
+ Requires-Dist: ruckig; extra == "example"
234
+ Dynamic: license-file
235
+
236
+ # dexcontrol
237
+
238
+ A user-friendly robot learning oriented control library implemented in Python.
239
+
240
+
241
+ ## Development Guide
242
+
243
+ ### Pre-commit Hooks
244
+ This repository uses pre-commit hooks to maintain high code quality standards. The hooks automatically run code formatting and linting checks before each commit, ensuring consistent code style and catching potential issues early in the development process.
245
+
246
+ To set up pre-commit:
247
+
248
+ 1. Install the development dependencies:
249
+ ```bash
250
+ pip install pre-commit
251
+ ```
252
+
253
+ 2. Install the pre-commit hooks:
254
+ ```bash
255
+ pre-commit install
256
+ ```
257
+
258
+
259
+ ## Setup
260
+
261
+ ### 1. Install dextop
262
+
263
+ First, install [dextop](https://github.com/dm-ai-core/dextop) for secure robot communication. This handles authentication of zenoh communication and robot selection when multiple robots are present.
264
+
265
+ The robot (SOC and Jetson) and your development computer must use certificates generated by the same CA. For internal Dexmate users, you can use the pre-generated `dexmate_internal_certs.zip`.
266
+
267
+ > [!TIP]
268
+ > For security reasons, find these certificates in the slack channel rather than Github. Internal certificates are removed before customer delivery.
269
+
270
+ Install the certificates (no need to unzip manually):
271
+ ```shell
272
+ dextop cert unpack dexmate_internal_certs.zip
273
+ dextop cfg gen
274
+ ```
275
+
276
+ Install certificates on all three devices (SOC, Jetson, and development computer). This is a one-time setup, and certificates will be stored in `~/.dexmate/comm/zenoh`.
277
+
278
+ ### 2. Install pylibdexcontrol
279
+
280
+ Install [pylibdexcontrol](https://github.com/dm-ai-core/pylibdexcontrol) on the **SOC**. Start the zenoh server:
281
+ ```shell
282
+ robot-server --start
283
+ ```
284
+
285
+ ### 3. Network Configuration
286
+
287
+ **Standard Setup**
288
+ For running dexcontrol on Jetson, no additional configuration is needed. The default network architecture looks like this:
289
+
290
+ ```ASCII
291
+ Router (192.168.0.1)
292
+
293
+ Jetson [WiFi: 192.168.0.70, Ethernet: 192.168.50.20]
294
+
295
+ SOC [192.168.50.21 / 192.168.100.22:50000]
296
+ ```
297
+
298
+ **Remote Development Setup**
299
+ You'll need additional configuration in these scenarios:
300
+ - You want to control the robot from your development computer
301
+ - The zenoh server is running on SOC
302
+ - SOC is only connected to Jetson via Ethernet (no WiFi connection)
303
+
304
+ In this case, run the following command on Jetson:
305
+ ```shell
306
+ dextop node start --config ~/.dexmate/comm/zenoh/zenoh_peer_config.json5
307
+ ```
308
+
309
+ This command configures Jetson to act as a network bridge:
310
+ - Jetson will route traffic between your development computer and the SOC
311
+ - Allows dexcontrol (on your computer) to communicate with pylibdexcontrol (on SOC)
312
+ - Enables control even when your computer and SOC are on different networks
313
+
314
+ ## Examples
315
+
316
+ Check out the [examples](./examples) for examples.
317
+
318
+
319
+ ## Changelist from V1 to V2
320
+
321
+ The primary difference between V1 and V2. After migration, the v2 will take over these files:
322
+ 1. `configs/`
323
+ 2. `core/`
324
+
325
+ ## System Design
326
+
327
+ Dexcontrol acts as a client for the Dexmate robot. It fetches robot information and sends control commands by communicating with the robot server via the zenoh protocol.
328
+
329
+ ### Units
330
+
331
+ All API units use the International System of Units (SI):
332
+ - Distance: meters (m)
333
+ - Angles: radians (rad)
334
+ - Angular velocity: radians per second (rad/s)
335
+ - Force: newtons (N)
336
+ - Torque: newton-meters (N·m)
337
+
338
+ The only exception is temperature, we use degree celsius instead of Kelvin in dexcontrol.
339
+
340
+ ### Zenoh Communication Protocol
341
+
342
+ DexControl uses the following naming convention for zenoh communication:
343
+
344
+ | Name | Type | Example | Description |
345
+ | ----------- | ------------- | -------------------- | ------------------------------------------------------------------------------------------------- |
346
+ | `state/*` | Topic (async) | `state/arm/left` | Robot motor state information. DexControl handles this automatically. |
347
+ | `control/*` | Topic (async) | `control/torso` | Send control commands to robot motors. Requires a control message. |
348
+ | `mode/*` | Query (sync) | `mode/arm/left` | Set the mode of robot motors (e.g., position mode, disable a motor). Requires a query message. |
349
+ | `system/*` | Query (sync) | `system/clear_error` | System-level commands (e.g., reboot components, handle emergency stop). Requires a query message. |
350
+ | `info/*` | Get (sync) | `info/version` | Retrieve information from the robot. No query message needed and no impact on the physical robot. |
351
+
352
+ The final name of zenoh topic is `{robot_name}/{topic_name}`, e.g. `dm-d17edf944753/state/hand/left`.
353
+
354
+ ## Documentation
355
+
356
+ Documentation generation tools and scripts are located in the `docgen/` directory. To build documentation:
357
+
358
+ ```bash
359
+ # Install documentation dependencies
360
+ pip install -e ".[docs]"
361
+
362
+ # Build HTML documentation
363
+ python docgen/build_docs.py
364
+
365
+ # Build GitBook documentation
366
+ python docgen/build_docs.py --gitbook
367
+ ```
368
+
369
+ For detailed documentation setup and configuration, see [`docgen/DOCUMENTATION_SETUP.md`](docgen/DOCUMENTATION_SETUP.md).