MGVehicleSkidFBD.html   (MotionGenesis input/output).
   (1) % MotionGenesis file:  MGVehicleSkidFBD.txt
   (2) % Copyright (c) 2018 Motion Genesis LLC.  All rights reserved.
   (3) % Problem: Analysis of Skidding Vehicle.
   (4) %--------------------------------------------------------------------
   (5) %       Physical declarations.
   (6) NewtonianFrame N        % Newtonian reference frame (ground).
   (7) RigidBody      A        % Vehicle chassis (Ao is center of axle).
   (8) RigidBody      B, C     % Vehicle's rolling wheels.
   (9) Point          BN( B )  % Point of wheel B in contact with N.
   (10) Point          CN( C )  % Point of wheel C in contact with N.
   (11) %--------------------------------------------------------------------
   (12) %       Mathematical declarations (constants and variables).
   (13) Constant  b = 0.75 m    % Distance between Ao and Bcm (or Ao and Ccm).
   (14) Constant  R = 0.35 m    % Wheel radii.
   (15) Constant  a = 1.64 m    % Distance from Ao to Acm (A's mass center).
   (16) Constant  g = 9.8 m/s^2 % Earth's gravitational acceleration.
   (17) Variable  v'            % Ax> measure of Ao's velocity in N.
   (18) Variable  wB'           % Ay> measure of B's angular velocity in A.
   (19) Variable  wC'           % Ay> measure of C's angular velocity in A.
   (20) Variable  theta''       % Vehicle heading angle (car yaw).
   (21) Variable  FBx, FBy      % Rolling contact forces on wheel B (Ax>, Ay> directions).
   (22) Variable  FCx, FCy      % Rolling contact forces on wheel C (Ax>, Ay> directions).
   (23) %--------------------------------------------------------------------
   (24) %       Mass and inertia.
   (25) A.SetMass( mA = 640 kg )
   (26) B.SetMass( m = 30 kg )
   (27) C.SetMass( m )
   (28) A.SetInertia( Acm,    IAxx, IAyy, IAzz = 166.6 kg*m^2)
   (29) B.SetInertia( Bcm, A, K, J = 2.0 kg*m^2, K = 1.0 kg*m^2 )
   (30) C.SetInertia( Ccm, A, K, J, K  )
   (31) %--------------------------------------------------------------------
   (32) %       Rotational kinematics.
   (33) A.RotateZ( N, theta )
-> (34) A_N = [cos(theta), sin(theta), 0;  -sin(theta), cos(theta), 0;  0, 0, 1]
-> (35) w_A_N> = theta'*Az>
-> (36) alf_A_N> = theta''*Az>

   (37) B.SetAngularVelocityAcceleration( A, wB*Ay> )
-> (38) w_B_A> = wB*Ay>
-> (39) w_B_N> = wB*Ay> + theta'*Az>
-> (40) alf_B_A> = wB'*Ay>
-> (41) alf_B_N> = -wB*theta'*Ax> + wB'*Ay> + theta''*Az>

   (42) C.SetAngularVelocityAcceleration( A, wC*Ay> )
-> (43) w_C_A> = wC*Ay>
-> (44) w_C_N> = wC*Ay> + theta'*Az>
-> (45) alf_C_A> = wC'*Ay>
-> (46) alf_C_N> = -wC*theta'*Ax> + wC'*Ay> + theta''*Az>

   (47) %--------------------------------------------------------------------
   (48) %       Translational kinematics.
   (49) Ao.SetVelocityAcceleration( N, v*Ax> )
-> (50) v_Ao_N> = v*Ax>
-> (51) a_Ao_N> = v'*Ax> + v*theta'*Ay>

   (52) Acm.Translate( Ao,  a*Ax> )
-> (53) p_Ao_Acm> = a*Ax>
-> (54) v_Acm_N> = v*Ax> + a*theta'*Ay>
-> (55) a_Acm_N> = (v'-a*theta'^2)*Ax> + (v*theta'+a*theta'')*Ay>

   (56) Bcm.Translate( Ao, -b*Ay> )
-> (57) p_Ao_Bcm> = -b*Ay>
-> (58) v_Bcm_N> = (v+b*theta')*Ax>
-> (59) a_Bcm_N> = (v'+b*theta'')*Ax> + theta'*(v+b*theta')*Ay>

   (60) Ccm.Translate( Ao,  b*Ay> )
-> (61) p_Ao_Ccm> = b*Ay>
-> (62) v_Ccm_N> = (v-b*theta')*Ax>
-> (63) a_Ccm_N> = (v'-b*theta'')*Ax> + theta'*(v-b*theta')*Ay>

   (64) BN.SetPositionVelocity(  Bcm,  -R*Az> )
-> (65) p_Bcm_BN> = -R*Az>
-> (66) v_BN_N> = (v+b*theta'-R*wB)*Ax>

   (67) CN.SetPositionVelocity(  Ccm,  -R*Az> )
-> (68) p_Ccm_CN> = -R*Az>
-> (69) v_CN_N> = (v-R*wC-b*theta')*Ax>

   (70) %--------------------------------------------------------------------
   (71) %       Rolling constraints (relates wB and wC to v and theta').
   (72) RollingConstraint[1] = Dot( BN.GetVelocity(N), Ax> )
-> (73) RollingConstraint[1] = v + b*theta' - R*wB

   (74) RollingConstraint[2] = Dot( CN.GetVelocity(N), Ax> )
-> (75) RollingConstraint[2] = v - R*wC - b*theta'

   (76) SolveDt( RollingConstraint = 0,  wB, wC )
-> (77) wB = (v+b*theta')/R
-> (78) wC = (v-b*theta')/R
-> (79) wB' = (v'+b*theta'')/R
-> (80) wC' = (v'-b*theta'')/R

   (81) %--------------------------------------------------------------------
   (82) %       Add relevant forces (only some of these appear in dynamic equations).
   (83) %       Note: Gravity and normal contact forces do not appear in dynamic.
   (84) System.AddForceGravity( -g*Az> )
-> (85) Force_Acm> = -mA*g*Az>
-> (86) Force_Bcm> = -m*g*Az>
-> (87) Force_Ccm> = -m*g*Az>

   (88) BN.AddForce( FBx*Ax> + FBy*Ay> )
-> (89) Force_BN> = FBx*Ax> + FBy*Ay>

   (90) CN.AddForce( FCx*Ax> + FCy*Ay> )
-> (91) Force_CN> = FCx*Ax> + FCy*Ay>

   (92) %--------------------------------------------------------------------
   (93) %       Form equations of motion via MG road-maps.
   (94) Dynamics[1] = Dot( Ax>,  System(A,B,C).GetDynamics()   )
-> (95) Dynamics[1] = 2*m*v' + mA*(v'-a*theta'^2) - FBx - FCx

   (96) Dynamics[2] = Dot( Az>,  System(A,B,C).GetDynamics(Ao) )
-> (97) Dynamics[2] = b*FCx + IAzz*theta'' + 2*K*theta'' + 2*m*b^2*theta''
        + mA*a*(v*theta'+a*theta'') - b*FBx

   (98) Dynamics[3] = Dot( Ay>,  B.GetDynamics(Bcm) )
-> (99) Dynamics[3] = R*FBx + J*wB'

   (100) Dynamics[4] = Dot( Ay>,  C.GetDynamics(Ccm) )
-> (101) Dynamics[4] = R*FCx + J*wC'

   (102) %--------------------------------------------------------------------
   (103) %       For maximum simplification, solve for FBx, FCx first.
   (104) Solve( Dynamics[3:4] = 0,  FBx, FCx )
-> (105) FBx = -J*wB'/R
-> (106) FCx = -J*wC'/R

   (107) Solve( Dynamics[1:2] = 0,  v',  theta'' )
-> (108) v' = mA*a*theta'^2/(mA+2*m+2*J/R^2)
-> (109) theta'' = -mA*a*v*theta'/(IAzz+2*K+mA*a^2+2*m*b^2+2*J*b^2/R^2)

   (110) %--------------------------------------------------------------------
   (111) %       Differential equations governing x and y.
   (112) Variable x' = Dot( Ao.GetVelocity(N),  Nx> )
-> (113) x' = v*cos(theta)

   (114) Variable y' = Dot( Ao.GetVelocity(N),  Ny> )
-> (115) y' = v*sin(theta)

   (116) %--------------------------------------------------------------------
   (117) %       Integration parameters and initial values.
   (118) Input  tFinal = 1 sec,  tStep = 0.01 sec,  absError = 1.0E-07
   (119) Input  theta = 0 deg,  x = 0 m,  y = 0 m
   (120) Input  theta' = 0.01 rad/sec           % Perturbation in angular rate.
   (121) Input  v = -25 m/s                     % Approximately 55 miles/hour.
   (122) %--------------------------------------------------------------------
   (123) %       List output quantities and solve ODEs.
   (124) Output  t sec,  x m,  y m,  v m/sec,  theta deg,  theta' rad/sec
   (125) ODE()  MGVehicleSkidFBD

   (126) % Plot MGVehicleSkidFBD.1
   (127) %--------------------------------------------------------------------
Saved by Motion Genesis LLC.   Command names and syntax: Copyright (c) 2009-2021 Motion Genesis LLC. All rights reserved.