Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.91 KB | None | 0 0
  1. function [Fjx,Fjy, Fm] = BioM(aa, ak, aw, as, H, M, mobj)
  2. %initial
  3. g = 9.81;
  4. %object position
  5. x = 0.25;
  6. y = 0.5;
  7. %angles
  8. aground = 180*pi/180;
  9. aankle = aa*pi/180;
  10. aknee = ak*pi/180;
  11. awaist = aw*pi/180;
  12. ashoulder = as*pi/180;
  13. %lengths;
  14. lfeet = (0.152)*H;
  15. hfeet = (0.039)*H;
  16. llegs = (0.285-0.039)*H;
  17. lthighs = 0.245*H;
  18. ltnh = (0.818-0.53)*H;
  19. lua = 0.186*H;
  20. lfah = (0.145+0.108/2)*H;
  21. %mass
  22. mfeet = 0.0145*2*M;
  23. mlegs = 0.0465*2*M;
  24. mthighs = 0.1*2*M;
  25. mtnh = 0.578*M;
  26. mua = 0.028*2*M;
  27. mfah = 0.022*2*M;
  28. msum = mfeet+mlegs+mthighs+mtnh+mua+mfah+mobj;
  29. %Weight matrix
  30. Wmfeet = [0; -mfeet*g; 0];
  31. Wmlegs = [0; -mlegs*g; 0];
  32. Wmthighs = [0; -mthighs*g; 0];
  33. Wmtnh = [0; -mtnh*g; 0];
  34. Wmua = [0; -mua*g; 0];
  35. Wmfah = [0; -mfah*g; 0];
  36. Wmsum = [0; -msum*g; 0];
  37. %Weight
  38. Wfeet = mfeet*g;
  39. Wlegs = mlegs*g;
  40. Wthighs = mthighs*g;
  41. Wtnh = mtnh*g;
  42. Wua = mua*g;
  43. Wfah = mfah*g;
  44. Wsum = msum*g;
  45. %center of gravity
  46. cgfeet = 0.095*H;
  47. cglegs = 0.139*H;
  48. cgthighs = 0.139*H;
  49. %NOTE - the root is defined as the pelvis. Once we pass the hip, swap from distal to proximal.
  50. cgtnh = 0.190*H;
  51. cgua = 0.081*H;
  52. cgfah = 0.099*H;
  53. cgobj = x;
  54. %Normal force
  55. FN = [0; Wsum; 0];
  56. rFN = [-0.5*0.152*H 0 0];
  57. %Location of Normal force on the feet [m]
  58. lN = (Wfeet*cgfeet + Wlegs*cglegs + Wthighs*cgthighs + Wtnh*cgtnh + Wua*cgua + Wfah*cgfah + mobj*g*cgobj)./FN;
  59. %Set up the rotation matrices
  60. Rground = [cos(aground) -sin(aground) 0 0; sin(aground) cos(aground) 0 0; 0 0 1 0; 0 0 0 1];
  61. Rankle = [cos(aankle) -sin(aankle) 0 0; sin(aankle) cos(aankle) 0 0; 0 0 1 0; 0 0 0 1];
  62. Rknee = [cos(aknee) -sin(aknee) 0 0; sin(aknee) cos(aknee) 0 0; 0 0 1 0; 0 0 0 1];
  63. Rwaist = [cos(awaist) -sin(awaist) 0 0; sin(awaist) cos(awaist) 0 0; 0 0 1 0; 0 0 0 1];
  64. Rshoulder = [cos(ashoulder) -sin(ashoulder) 0 0; sin(ashoulder) cos(ashoulder) 0 0; 0 0 1 0; 0 0 0 1];
  65. %Set up the lengths
  66. Lfeet = [1 0 0 lfeet; 0 1 0 -hfeet; 0 0 1 0; 0 0 0 1];
  67. Llegs = [1 0 0 llegs; 0 1 0 0; 0 0 1 0; 0 0 0 1];
  68. Lthighs = [1 0 0 lthighs; 0 1 0 0; 0 0 1 0; 0 0 0 1];
  69. Ltnh = [1 0 0 ltnh; 0 1 0 0; 0 0 1 0; 0 0 0 1];
  70. Lua = [1 0 0 lua; 0 1 0 0; 0 0 1 0; 0 0 0 1];
  71. Lfah = [1 0 0 lfah; 0 1 0 0; 0 0 1 0; 0 0 0 1];
  72. %Create secondary link matrices for the distance to the CG on each link.
  73. Lfeetcg = [1 0 0 cgfeet; 0 1 0 0; 0 0 1 0; 0 0 0 1];
  74. Llegscg = [1 0 0 cglegs; 0 1 0 0; 0 0 1 0; 0 0 0 1];
  75. Lthighscg = [1 0 0 cgthighs; 0 1 0 0; 0 0 1 0; 0 0 0 1];
  76. Ltnhcg = [1 0 0 cgtnh; 0 1 0 0; 0 0 1 0; 0 0 0 1];
  77. Luacg = [1 0 0 cgua; 0 1 0 0; 0 0 1 0; 0 0 0 1];
  78. Lfahcg = [1 0 0 cgfah; 0 1 0 0; 0 0 1 0; 0 0 0 1];
  79. %Displacement of x value for each segment
  80. Tfeet = (Rground * Lfeet);
  81. Tlegs = (Rground*Lfeet*Rankle*Llegs);
  82. Tthighs = (Rground*Lfeet*Rankle*Llegs*Rknee*Lthighs);
  83. Ttnh = (Rground*Lfeet*Rankle*Llegs*Rknee*Lthighs*Rwaist*Ltnh);
  84. Tua = (Rground*Lfeet*Rankle*Llegs*Rknee*Lthighs*Rwaist*Ltnh*Rshoulder*Lua);
  85. Tfah = (Rground*Lfeet*Rankle*Llegs*Rknee*Lthighs*Rwaist*Ltnh*Rshoulder*Lua*Lfah);
  86. Tobj = (Rground*Lfeet*Rankle*Llegs*Rknee*Lthighs*Rwaist*Ltnh*Rshoulder*Lua*Lfah);
  87. %Calculate the x value of displacement for each CG
  88. Tfeetcg = (Rground * Lfeetcg);
  89. Tlegscg = (Rground*Lfeet*Rankle*Llegscg);
  90. Tthighscg = (Rground*Lfeet*Rankle*Llegs*Rknee*Lthighscg);
  91. Ttnhcg = (Rground*Lfeet*Rankle*Llegs*Rknee*Lthighs*Rwaist*Ltnhcg);
  92. Tuacg = (Rground*Lfeet*Rankle*Llegs*Rknee*Lthighs*Rwaist*Ltnh*Rshoulder*Luacg);
  93. Tfahcg = (Rground*Lfeet*Rankle*Llegs*Rknee*Lthighs*Rwaist*Ltnh*Rshoulder*Lua*Lfahcg);
  94. Tobj = (Rground*Lfeet*Rankle*Llegs*Rknee*Lthighs*Rwaist*Ltnh*Rshoulder*Lua*Lfah);
  95. %Define vectors from the origin (where we will take the moments) to the CGs and the object.
  96. rfeetcg = [Tfeetcg(1, 4), Tfeetcg(2, 4), 0];
  97. rlegscg = [Tlegscg(1, 4), Tlegscg(2, 4), 0];
  98. rthighscg = [Tthighscg(1, 4), Tthighscg(2, 4), 0];
  99. rtnhcg = [Ttnhcg(1, 4), Ttnhcg(2, 4), 0];
  100. ruacg = [Tuacg(1, 4), Tuacg(2, 4), 0];
  101. rfahcg = [Tfahcg(1, 4), Tfahcg(2, 4), 0];
  102. robj = [Tobj(1, 4), Tobj(2, 4), 0];
  103. %Define unit vectors
  104. Lerectorspinaeproximal = [1 0 0 0; 0 1 0 0.05*ltnh; 0 0 1 0; 0 0 0 1];
  105. Lerectorspinaedistal = [1 0 0 0.8*ltnh; 0 1 0 0; 0 0 1 0; 0 0 0 1];
  106. Terectorspinaeproximal = (Rground*Lfeet*Rankle*Llegs*Rknee*Lthighs*Rwaist*Lerectorspinaeproximal);
  107. Terectorspinaedistal = (Rground*Lfeet*Rankle*Llegs*Rknee*Lthighs*Rwaist*Lerectorspinaedistal);
  108. %now move to the spine
  109. %Swapped definition of proximal and distal as we move away from the hips
  110. Fmdir = [Terectorspinaedistal(1,4)-Terectorspinaeproximal(1,4) Terectorspinaedistal(2,4)- Terectorspinaeproximal(2,4) 0];
  111. Fmdir = Fmdir/norm(Fmdir);
  112. rFm = [Terectorspinaeproximal(1,4) Terectorspinaeproximal(2,4) 0];
  113. rthighs = [Tthighscg(1,4) Tthighscg(2,4) 0];
  114. msum = (cross(rfeetcg,Wmfeet)+cross(rlegscg,Wmlegs)+cross(rthighscg,Wmthighs)+cross(rFN,FN)); msum = msum(3);
  115. RHS = [0; mfeet*g+mlegs*g+mthighs*g-(M+mobj)*g; -msum];
  116. Fmmom = cross(rFm, Fmdir);
  117. LHS = [1 0 Fmdir(1); 0 1 Fmdir(2); -rthighs(2) rthighs(1) Fmmom(3)];
  118. soln = inv(LHS)*RHS;
  119. Fjx = soln([1]);
  120. Fjy = soln([2]);
  121. Fm = soln([3]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement