1
1
import dill
2
2
from jax import Array , jit , lax , vmap
3
3
from jax import numpy as jnp
4
+ import numpy as onp
4
5
import sympy as sp
5
6
from pathlib import Path
6
7
from typing import Callable , Dict , List , Tuple , Union
@@ -404,7 +405,7 @@ def operational_space_dynamical_matrices_fn(
404
405
s : Array ,
405
406
B : Array ,
406
407
C : Array ,
407
- operational_space_selector = jnp . array ([ True , True , True ] ),
408
+ operational_space_selector : Tuple = ( True , True , True ),
408
409
eps : float = 1e4 * global_eps ,
409
410
) -> Tuple [Array , Array , Array , Array , Array ]:
410
411
"""
@@ -418,8 +419,8 @@ def operational_space_dynamical_matrices_fn(
418
419
s: point coordinate along the robot in the interval [0, L].
419
420
B: inertia matrix in the generalized coordinates of shape (n_q, n_q)
420
421
C: coriolis matrix derived with Christoffer symbols in the generalized coordinates of shape (n_q, n_q)
421
- operational_space_selector: boolean array of shape (3,) to select the operational space variables.
422
- For examples, jnp.array([ True, True, False] ) selects only the positional components of the operational space.
422
+ operational_space_selector: tuple of shape (3,) to select the operational space variables.
423
+ For examples, ( True, True, False) selects only the positional components of the operational space.
423
424
eps: small number to avoid singularities (e.g., division by zero)
424
425
Returns:
425
426
Lambda: inertia matrix in the operational space of shape (3, 3)
@@ -443,6 +444,9 @@ def operational_space_dynamical_matrices_fn(
443
444
# convert the dictionary of parameters to a list, which we can pass to the lambda function
444
445
params_for_lambdify = select_params_for_lambdify_fn (params )
445
446
447
+ # make operational_space_selector a boolean array
448
+ operational_space_selector = onp .array (operational_space_selector , dtype = bool )
449
+
446
450
# Jacobian and its time-derivative
447
451
J = lax .switch (
448
452
segment_idx , J_lambda_sms , * params_for_lambdify , * xi_epsed , s_segment
0 commit comments