33"""
44
55import invariants_py .reparameterization as reparam
6+ import invariants_py .dynamics_vector_invariants as dyn
67import invariants_py .calculate_invariants .opti_calculate_vector_invariants_position_mf as FS_calculation
8+ import numpy as np
79
810def calculate_invariants_translation (trajectory , progress_definition = "arclength" ):
911
1012 # different progress definition: {time, default: arclength, arcangle, screwbased}
1113 # Reparameterize the trajectory based on arclength
1214 trajectory_geom , arclength , arclength_n , nb_samples , stepsize = reparam .reparameterize_trajectory_arclength (trajectory )
1315
16+ print (stepsize )
17+
1418 # Create an instance of the OCP_calc_pos class
1519 FS_calculation_problem = FS_calculation .OCP_calc_pos (window_len = nb_samples , geometric = True )
1620
@@ -20,5 +24,31 @@ def calculate_invariants_translation(trajectory, progress_definition="arclength"
2024 invariants = result [0 ]
2125 trajectory = result [1 ]
2226 movingframes = result [2 ]
23- return invariants , arclength , trajectory , movingframes
27+ return invariants , arclength , trajectory , movingframes , arclength_n
28+
29+
30+ def reconstruct_trajectory (invariants , progress , p_init = np .zeros ((3 ,1 )), mf_init = np .eye (3 )):
31+
32+ N = len (progress )
33+
34+ positions = np .zeros ((N ,3 ))
35+ R_frames = np .zeros ((N ,3 ,3 ))
36+
37+ stepsize = 1 / N
38+ print (stepsize )
39+
40+ positions [0 ,:] = p_init
41+ R_frames [0 ,:,:] = mf_init
2442
43+ # Use integrator to find the other initial states
44+ for k in range (N - 1 ):
45+
46+ [R_plus1 ,p_plus1 ] = dyn .integrate_vector_invariants_position (mf_init , p_init , invariants [k ,:], stepsize )
47+
48+ positions [k + 1 ,:] = np .array (p_plus1 ).T
49+ R_frames [k + 1 ,:,:] = np .array (R_plus1 )
50+
51+ p_init = p_plus1
52+ mf_init = R_plus1
53+
54+ return positions , R_frames
0 commit comments