openscvx 0.3.2.dev170__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 openscvx might be problematic. Click here for more details.

Files changed (79) hide show
  1. openscvx/__init__.py +123 -0
  2. openscvx/_version.py +34 -0
  3. openscvx/algorithms/__init__.py +92 -0
  4. openscvx/algorithms/autotuning.py +24 -0
  5. openscvx/algorithms/base.py +351 -0
  6. openscvx/algorithms/optimization_results.py +215 -0
  7. openscvx/algorithms/penalized_trust_region.py +384 -0
  8. openscvx/config.py +437 -0
  9. openscvx/discretization/__init__.py +47 -0
  10. openscvx/discretization/discretization.py +236 -0
  11. openscvx/expert/__init__.py +23 -0
  12. openscvx/expert/byof.py +326 -0
  13. openscvx/expert/lowering.py +419 -0
  14. openscvx/expert/validation.py +357 -0
  15. openscvx/integrators/__init__.py +48 -0
  16. openscvx/integrators/runge_kutta.py +281 -0
  17. openscvx/lowered/__init__.py +30 -0
  18. openscvx/lowered/cvxpy_constraints.py +23 -0
  19. openscvx/lowered/cvxpy_variables.py +124 -0
  20. openscvx/lowered/dynamics.py +34 -0
  21. openscvx/lowered/jax_constraints.py +133 -0
  22. openscvx/lowered/parameters.py +54 -0
  23. openscvx/lowered/problem.py +70 -0
  24. openscvx/lowered/unified.py +718 -0
  25. openscvx/plotting/__init__.py +63 -0
  26. openscvx/plotting/plotting.py +756 -0
  27. openscvx/plotting/scp_iteration.py +299 -0
  28. openscvx/plotting/viser/__init__.py +126 -0
  29. openscvx/plotting/viser/animated.py +605 -0
  30. openscvx/plotting/viser/plotly_integration.py +333 -0
  31. openscvx/plotting/viser/primitives.py +355 -0
  32. openscvx/plotting/viser/scp.py +459 -0
  33. openscvx/plotting/viser/server.py +112 -0
  34. openscvx/problem.py +734 -0
  35. openscvx/propagation/__init__.py +60 -0
  36. openscvx/propagation/post_processing.py +104 -0
  37. openscvx/propagation/propagation.py +248 -0
  38. openscvx/solvers/__init__.py +51 -0
  39. openscvx/solvers/cvxpy.py +226 -0
  40. openscvx/symbolic/__init__.py +9 -0
  41. openscvx/symbolic/augmentation.py +630 -0
  42. openscvx/symbolic/builder.py +492 -0
  43. openscvx/symbolic/constraint_set.py +92 -0
  44. openscvx/symbolic/expr/__init__.py +222 -0
  45. openscvx/symbolic/expr/arithmetic.py +517 -0
  46. openscvx/symbolic/expr/array.py +632 -0
  47. openscvx/symbolic/expr/constraint.py +796 -0
  48. openscvx/symbolic/expr/control.py +135 -0
  49. openscvx/symbolic/expr/expr.py +720 -0
  50. openscvx/symbolic/expr/lie/__init__.py +87 -0
  51. openscvx/symbolic/expr/lie/adjoint.py +357 -0
  52. openscvx/symbolic/expr/lie/se3.py +172 -0
  53. openscvx/symbolic/expr/lie/so3.py +138 -0
  54. openscvx/symbolic/expr/linalg.py +279 -0
  55. openscvx/symbolic/expr/math.py +699 -0
  56. openscvx/symbolic/expr/spatial.py +209 -0
  57. openscvx/symbolic/expr/state.py +607 -0
  58. openscvx/symbolic/expr/stl.py +136 -0
  59. openscvx/symbolic/expr/variable.py +321 -0
  60. openscvx/symbolic/hashing.py +112 -0
  61. openscvx/symbolic/lower.py +760 -0
  62. openscvx/symbolic/lowerers/__init__.py +106 -0
  63. openscvx/symbolic/lowerers/cvxpy.py +1302 -0
  64. openscvx/symbolic/lowerers/jax.py +1382 -0
  65. openscvx/symbolic/preprocessing.py +757 -0
  66. openscvx/symbolic/problem.py +110 -0
  67. openscvx/symbolic/time.py +116 -0
  68. openscvx/symbolic/unified.py +420 -0
  69. openscvx/utils/__init__.py +20 -0
  70. openscvx/utils/cache.py +131 -0
  71. openscvx/utils/caching.py +210 -0
  72. openscvx/utils/printing.py +301 -0
  73. openscvx/utils/profiling.py +37 -0
  74. openscvx/utils/utils.py +100 -0
  75. openscvx-0.3.2.dev170.dist-info/METADATA +350 -0
  76. openscvx-0.3.2.dev170.dist-info/RECORD +79 -0
  77. openscvx-0.3.2.dev170.dist-info/WHEEL +5 -0
  78. openscvx-0.3.2.dev170.dist-info/licenses/LICENSE +201 -0
  79. openscvx-0.3.2.dev170.dist-info/top_level.txt +1 -0
@@ -0,0 +1,209 @@
1
+ """Spatial and 6-DOF utility operations for trajectory optimization.
2
+
3
+ This module provides efficient symbolic expression nodes for common 6-DOF (six degree of
4
+ freedom) operations used in aerospace and robotics applications. These operations directly
5
+ map to optimized JAX implementations for high-performance evaluation.
6
+ """
7
+
8
+ from typing import Tuple
9
+
10
+ from .expr import Expr, to_expr
11
+
12
+
13
+ class QDCM(Expr):
14
+ """Quaternion to Direction Cosine Matrix (DCM) conversion.
15
+
16
+ Converts a unit quaternion representation to a 3x3 direction cosine matrix
17
+ (also known as a rotation matrix). This operation is commonly used in 6-DOF
18
+ spacecraft dynamics, aircraft simulation, and robotics applications.
19
+
20
+ The quaternion is expected in scalar-last format: [qx, qy, qz, qw] where
21
+ qw is the scalar component. The resulting DCM can be used to transform vectors
22
+ from one reference frame to another.
23
+
24
+ Attributes:
25
+ q: Quaternion expression with shape (4,)
26
+
27
+ Example:
28
+ Use the QDCM to rotate a vector:
29
+
30
+ import openscvx as ox
31
+ q = ox.State("q", shape=(4,))
32
+ dcm = ox.QDCM(q) # Creates rotation matrix, shape (3, 3)
33
+ v_body = ox.Variable("v_body", shape=(3,))
34
+ v_inertial = dcm @ v_body
35
+
36
+ Note:
37
+ The input quaternion does not need to be normalized; the implementation
38
+ automatically handles normalization during evaluation.
39
+ """
40
+
41
+ def __init__(self, q):
42
+ """Initialize a quaternion to DCM conversion.
43
+
44
+ Args:
45
+ q: Quaternion expression with shape (4,) in [qx, qy, qz, qw] format
46
+ """
47
+ self.q = to_expr(q)
48
+
49
+ def children(self):
50
+ return [self.q]
51
+
52
+ def canonicalize(self) -> "Expr":
53
+ q = self.q.canonicalize()
54
+ return QDCM(q)
55
+
56
+ def check_shape(self) -> Tuple[int, ...]:
57
+ """Check that input is a quaternion and return DCM shape.
58
+
59
+ Returns:
60
+ tuple: Shape (3, 3) for the resulting direction cosine matrix
61
+
62
+ Raises:
63
+ ValueError: If quaternion does not have shape (4,)
64
+ """
65
+ q_shape = self.q.check_shape()
66
+ if q_shape != (4,):
67
+ raise ValueError(f"QDCM expects quaternion with shape (4,), got {q_shape}")
68
+ return (3, 3)
69
+
70
+ def __repr__(self):
71
+ return f"qdcm({self.q!r})"
72
+
73
+
74
+ class SSMP(Expr):
75
+ """Angular rate to 4x4 skew-symmetric matrix for quaternion dynamics.
76
+
77
+ Constructs the 4x4 skew-symmetric matrix Ω(ω) used in quaternion kinematic
78
+ differential equations. This matrix relates angular velocity to the time
79
+ derivative of the quaternion:
80
+
81
+ q̇ = (1/2) * Ω(ω) @ q
82
+
83
+ The resulting matrix has the form:
84
+ ⎡ 0 ωz -ωy ωx ⎤
85
+ ⎢-ωz 0 ωx ωy ⎥
86
+ ⎢ ωy -ωx 0 ωz ⎥
87
+ ⎣-ωx -ωy -ωz 0 ⎦
88
+
89
+ This is particularly useful for formulating quaternion-based attitude
90
+ dynamics in spacecraft and aircraft trajectory optimization problems.
91
+
92
+ Attributes:
93
+ w: Angular velocity vector expression with shape (3,)
94
+
95
+ Example:
96
+ Use the SSMP to compute the quaternion derivative:
97
+
98
+ import openscvx as ox
99
+ omega = ox.Control("omega", shape=(3,))
100
+ q = ox.State("q", shape=(4,))
101
+ # Quaternion kinematic equation
102
+ q_dot = 0.5 * ox.SSMP(omega) @ q
103
+
104
+ See Also:
105
+ SSM: 3x3 skew-symmetric matrix for cross product operations
106
+ """
107
+
108
+ def __init__(self, w):
109
+ """Initialize an angular velocity to skew-symmetric matrix conversion.
110
+
111
+ Args:
112
+ w: Angular velocity vector expression with shape (3,) in [ωx, ωy, ωz] format
113
+ """
114
+ self.w = to_expr(w)
115
+
116
+ def children(self):
117
+ return [self.w]
118
+
119
+ def canonicalize(self) -> "Expr":
120
+ w = self.w.canonicalize()
121
+ return SSMP(w)
122
+
123
+ def check_shape(self) -> Tuple[int, ...]:
124
+ """Check that input is a 3D angular velocity and return matrix shape.
125
+
126
+ Returns:
127
+ tuple: Shape (4, 4) for the resulting skew-symmetric matrix
128
+
129
+ Raises:
130
+ ValueError: If angular velocity does not have shape (3,)
131
+ """
132
+ w_shape = self.w.check_shape()
133
+ if w_shape != (3,):
134
+ raise ValueError(f"SSMP expects angular velocity with shape (3,), got {w_shape}")
135
+ return (4, 4)
136
+
137
+ def __repr__(self):
138
+ return f"ssmp({self.w!r})"
139
+
140
+
141
+ class SSM(Expr):
142
+ """Angular rate vector to 3x3 skew-symmetric matrix (cross product matrix).
143
+
144
+ Constructs the 3x3 skew-symmetric matrix [ω]x that represents the cross
145
+ product operation. For any 3D vector v, the cross product ω x v can be
146
+ computed as the matrix-vector product [ω]x @ v.
147
+
148
+ The resulting matrix has the form:
149
+ ⎡ 0 -ωz ωy ⎤
150
+ ⎢ ωz 0 -ωx ⎥
151
+ ⎣-ωy ωx 0 ⎦
152
+
153
+ This operation is widely used in:
154
+ - Rigid body dynamics (angular momentum calculations)
155
+ - DCM time derivatives: Ṙ = [ω]x @ R
156
+ - Velocity kinematics in robotics
157
+ - Coriolis and centrifugal acceleration terms
158
+
159
+ Attributes:
160
+ w: Angular velocity or 3D vector expression with shape (3,)
161
+
162
+ Example:
163
+ Use the SSM to compute the rotation matrix derivative:
164
+
165
+ import openscvx as ox
166
+ omega = ox.Control("omega", shape=(3,))
167
+ R = ox.State("R", shape=(3, 3)) # Direction cosine matrix
168
+ # DCM time derivative
169
+ R_dot = ox.SSM(omega) @ R
170
+
171
+ Note:
172
+ The skew-symmetric property ensures that [ω]xᵀ = -[ω]x, which is
173
+ important for preserving orthogonality in DCM propagation.
174
+
175
+ See Also:
176
+ SSMP: 4x4 skew-symmetric matrix for quaternion dynamics
177
+ """
178
+
179
+ def __init__(self, w):
180
+ """Initialize a vector to skew-symmetric matrix conversion.
181
+
182
+ Args:
183
+ w: 3D vector expression with shape (3,) in [ωx, ωy, ωz] format
184
+ """
185
+ self.w = to_expr(w)
186
+
187
+ def children(self):
188
+ return [self.w]
189
+
190
+ def canonicalize(self) -> "Expr":
191
+ w = self.w.canonicalize()
192
+ return SSM(w)
193
+
194
+ def check_shape(self) -> Tuple[int, ...]:
195
+ """Check that input is a 3D vector and return matrix shape.
196
+
197
+ Returns:
198
+ tuple: Shape (3, 3) for the resulting skew-symmetric matrix
199
+
200
+ Raises:
201
+ ValueError: If input vector does not have shape (3,)
202
+ """
203
+ w_shape = self.w.check_shape()
204
+ if w_shape != (3,):
205
+ raise ValueError(f"SSM expects angular velocity with shape (3,), got {w_shape}")
206
+ return (3, 3)
207
+
208
+ def __repr__(self):
209
+ return f"ssm({self.w!r})"