Advertisement
Guest User

tets

a guest
Apr 8th, 2020
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.56 KB | None | 0 0
  1. for i in range(N):
  2.  
  3.         phi_t = x_ref[0, i]
  4.         theta_t = x_ref[1, i]
  5.         psi_t = x_ref[2, i]
  6.  
  7.         I_world = np.array([[(Ixx*cos(psi_t) + Iyx*sin(psi_t))*cos(psi_t) + (Ixy*cos(psi_t) + Iyy*sin(psi_t))*sin(psi_t), -(Ixx*cos(psi_t) + Iyx*sin(psi_t))*sin(psi_t) + (Ixy*cos(psi_t) + Iyy*sin(psi_t))*cos(psi_t), Ixz*cos(psi_t) + Iyz*sin(psi_t)], [(-Ixx*sin(psi_t) + Iyx*cos(psi_t))*cos(psi_t) + (-Ixy*sin(psi_t) + Iyy*cos(psi_t))*sin(psi_t), -(-Ixx*sin(psi_t) + Iyx*cos(psi_t))*sin(psi_t) + (-Ixy*sin(psi_t) + Iyy*cos(psi_t))*cos(psi_t), -Ixz*sin(psi_t) + Iyz*cos(psi_t)], [Ixy*sin(psi_t) + Izx*cos(psi_t), Ixy*cos(psi_t) - Izx*sin(psi_t), Izz]])
  8.         # Location of the force vector being applied by the left foot.
  9.         r_x_left = 0.15
  10.         r_y_left = 0
  11.         r_z_left = 0
  12.  
  13.         # Location of the force vector being applied by the right foot.
  14.         r_x_right = -0.15
  15.         r_y_right = 0
  16.         r_z_right = 0
  17.  
  18.         # Skew symmetric versions for the 3x1 foot position vector resembling the matrix version of the cross product of two vectors. This is needed for the matrix form.
  19.         r_left_skew_symmetric = np.array([[0, -r_z_left, r_y_left],
  20.                                         [r_z_left, 0, -r_x_left],
  21.                                         [-r_y_left, r_x_left, 0]])
  22.  
  23.         r_right_skew_symmetric = np.array([[0, -r_z_right, r_y_right],
  24.                                         [r_z_right, 0, -r_x_right],
  25.                                         [-r_y_right, r_x_right, 0]])
  26.  
  27.         A_c = np.array([[0, 0, 0, 0, 0, 0, math.cos(psi_t), math.sin(psi_t), 0, 0, 0, 0, 0],
  28.                             [0, 0, 0, 0, 0, 0, -math.sin(psi_t), math.cos(psi_t), 0, 0, 0, 0, 0],
  29.                             [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
  30.  
  31.                             [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],
  32.                             [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
  33.                             [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
  34.  
  35.                             [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  36.                             [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  37.                             [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  38.  
  39.                             [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  40.                             [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  41.                             [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
  42.  
  43.                             [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])
  44.  
  45.         B_c = np.block([[0, 0, 0, 0, 0, 0],
  46.                         [0, 0, 0, 0, 0, 0],
  47.                         [0, 0, 0, 0, 0, 0],
  48.                         [0, 0, 0, 0, 0, 0],
  49.                         [0, 0, 0, 0, 0, 0],
  50.                         [0, 0, 0, 0, 0, 0],
  51.                         [I_world @ r_left_skew_symmetric, I_world @ r_right_skew_symmetric],
  52.                         [1/m_value, 0, 0, 1/m_value, 0, 0],
  53.                         [0, 1/m_value, 0, 0, 1/m_value, 0],
  54.                         [0, 0, 1/m_value, 0, 0, 1/m_value],
  55.                         [0, 0, 0, 0, 0, 0]])
  56.  
  57.         A_d, B_d = discretize_ss(A_c, B_c, dt)
  58.        
  59.         P_param[:, 1 + N + (i*n):1 + N + (i*n)+n] = A_d
  60.         P_param[:, 1 + N + n * N + (i*m):1 + N + n * N + (i*m)+m] = B_d
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement