Home > Resources > MBDyn Examples > 20. Toy Car Jump
MBDyn Examples

20. Toy Car Jump

Animation





Input File

rolling_car_2d_jump.mbd
# rolling_car_2d_jump.mbd

#-----------------------------------------------------------------------------
# [Data Block]

begin: data;
   problem: initial value;
end: data;

#-----------------------------------------------------------------------------
# [ Block]

begin: initial value;
   initial time:   0.;
   final time:     1.4;
   time step:      1.e-4;
   max iterations: 10;
   tolerance:      1.e-6;
end: initial value;

#-----------------------------------------------------------------------------
# [Control Data Block]

begin: control data;
   skip initial joint assembly;
   output frequency: 50;
   structural nodes: 8;
   rigid bodies:     3;
   joints:           11;
   forces:           2;
   gravity;
end: control data;

#-----------------------------------------------------------------------------
# Design Variables
set: real L = 0.1;  # [m]    Wheel Base
set: real M = 0.1;  # [kg]   Mass
set: real D = 0.05; # [m]    Chassis Height
set: real K = 100.; # [N/m]  Spring Rate
set: real C = 1;    # [Ns/m] Shock Absorber

set: real Kc = 5000.; # [N/m]  Contact Stiffness
set: real Ec = 1.2;   # [-]    Contact Stiffness Exponent
set: real Cc = 0.01;  # [Ns/m] Contact Damping
set: real Dc = 0.0001;# [m]    Contact Damping Activation Depth

set: real Delta_Road = 0.0001; #[m] 

#-----------------------------------------------------------------------------
# Intermediate Variables
set: real I = M*L^2./12.; # Moment of Inertia of Chassis

#-----------------------------------------------------------------------------
# Reference Labels
set: integer Ref_RearWheel = 1;

# Node Labels
set: integer NoSta_Ground     = 1;
set: integer NoDyn_Chassis    = 2;
set: integer NoDyn_FrontWheel = 3;
set: integer NoDyn_RearWheel  = 4;
set: integer NoDyn_Road1      = 5;
set: integer NoDyn_Road2      = 6;

set: integer NoDum_FrontWheel = 7;
set: integer NoDum_RearWheel  = 8;

# Body Labels
set: integer Body_Chassis    = 1;
set: integer Body_FrontWheel = 2;
set: integer Body_RearWheel  = 3;

# Joint Labels
set: integer JoClamp_Ground             = 1;
set: integer JoInp_Ground_Chassis       = 2;
set: integer JoRevrot_Ground_Chassis    = 3;
set: integer JoInlin_Chassis_FrontWheel = 4;
set: integer JoPrism_Chassis_FrontWheel = 5;
set: integer JoDfmd_Chassis_FrontWheel  = 6;
set: integer JoInlin_Chassis_RearWheel  = 7;
set: integer JoPrism_Chassis_RearWheel  = 8;
set: integer JoDfmd_Chassis_RearWheel   = 9;
set: integer JoTotp_Road1               = 10;
set: integer JoTotp_Road2               = 11;

# Force Labels
set: integer FoStrin_Normal_FrontWheel_Road1 = 1;
set: integer FoStrin_Normal_RearWheel_Road2  = 2;

#-----------------------------------------------------------------------------
# Scalar Functions
include: "sf_cubstep.sub";
include: "sf_Fun_Road_Jump.sub";
   
#-----------------------------------------------------------------------------
# Intermediate Variables
set: real Road1_Height_Ini = model::sf::Fun_Road(L);
set: real Road2_Height_Ini = model::sf::Fun_Road(0.);
set: real Road1_Angle_Ini  = atan((model::sf::Fun_Road(L+Delta_Road)-model::sf::Fun_Road(L))/Delta_Road);
set: real Road2_Angle_Ini  = atan((model::sf::Fun_Road(Delta_Road)-model::sf::Fun_Road(0.))/Delta_Road);

#-----------------------------------------------------------------------------
# References
reference: Ref_RearWheel,
   0., 0., Road2_Height_Ini, # absolute position
   eye,                      # absolute orientation
   null,                     # absolute velocity
   null;                     # absolute angular velocity
      
#-----------------------------------------------------------------------------
# [Nodes Block]

begin: nodes;

   #-----------------------------------------------------------------------------
   # Nodes
   structural: NoSta_Ground, static,
      null, # absolute position
      eye,  # absolute orientation
      null, # absolute velocity
      null; # absolute angular velocity
      
   structural: NoDyn_Chassis, dynamic,
      reference, Ref_RearWheel, L/2., 0., D,          # absolute position
      reference, Ref_RearWheel, euler, pi/2., 0., 0., # absolute orientation
      reference, Ref_RearWheel, null,                 # absolute velocity
      reference, Ref_RearWheel, null;                 # absolute angular velocity
      
   structural: NoDyn_FrontWheel, dynamic,
      reference, Ref_RearWheel, L, 0., 0., # absolute position
      reference, Ref_RearWheel, eye,       # absolute orientation
      reference, Ref_RearWheel, null,      # absolute velocity
      reference, Ref_RearWheel, null;      # absolute angular velocity
      
   structural: NoDyn_RearWheel, dynamic,
      reference, Ref_RearWheel, null, # absolute position
      reference, Ref_RearWheel, eye,  # absolute orientation
      reference, Ref_RearWheel, null, # absolute velocity
      reference, Ref_RearWheel, null; # absolute angular velocity
      
   structural: NoDyn_Road1, dynamic,
      L, 0., Road1_Height_Ini,         # absolute position
      euler, 0., -Road1_Angle_Ini, 0., # absolute orientation
      null,                            # absolute velocity
      null;                            # absolute angular velocity
      
   structural: NoDyn_Road2, dynamic,
      0., 0., Road2_Height_Ini,        # absolute position
      euler, 0., -Road2_Angle_Ini, 0., # absolute orientation
      null,                            # absolute velocity
      null;                            # absolute angular velocity
      
   structural: NoDum_FrontWheel, dummy, NoDyn_FrontWheel,
      relative frame, NoDyn_Road1;
      
   structural: NoDum_RearWheel, dummy, NoDyn_RearWheel,
      relative frame, NoDyn_Road2;
   
end: nodes;
   
#-----------------------------------------------------------------------------
# Plugin Variables
set: [node, DX1, NoDyn_FrontWheel, structural, string="X[1]"];
set: [node, DX2, NoDyn_RearWheel, structural, string="X[1]"];

set: [node, DZ1_Dum, NoDum_FrontWheel, structural, string="X[3]"];
set: [node, DZ2_Dum, NoDum_RearWheel, structural, string="X[3]"];

set: [node, VZ1_Dum, NoDum_FrontWheel, structural, string="XP[3]"];
set: [node, VZ2_Dum, NoDum_RearWheel, structural, string="XP[3]"];

#-----------------------------------------------------------------------------
# [Elements Block]

begin: elements;

   #-----------------------------------------------------------------------------
   # Bodies

   body: Body_Chassis, NoDyn_Chassis,
      M,               # mass
      null,            # relative center of mass
      diag, 1., 1., I; # inertia matrix
      
   body: Body_FrontWheel, NoDyn_FrontWheel,
      1.e-6,                     # mass
      null,                      # relative center of mass
      diag, 1.e-9, 1.e-9, 1.e-9; # inertia matrix
    
   body: Body_RearWheel, NoDyn_RearWheel,
      1.e-6,                     # mass
      null,                      # relative center of mass
      diag, 1.e-9, 1.e-9, 1.e-9; # inertia matrix
      
   #-----------------------------------------------------------------------------
   # Joints 
   joint: JoClamp_Ground,
      clamp,
         NoSta_Ground,
            position, node,
            orientation, node;

   joint: JoInp_Ground_Chassis,
      in plane,
         NoSta_Ground,
            null,       # relative plane position
            0., 1., 0., # relative normal direction
         NoDyn_Chassis;

   joint: JoRevrot_Ground_Chassis,
      revolute rotation,
         NoSta_Ground,
            hinge,
               euler, pi/2., 0, 0., # relative orientation matrix
         NoDyn_Chassis;
         
   joint: JoInlin_Chassis_FrontWheel, 
      in line,
         NoDyn_Chassis,
            reference, Ref_RearWheel, L, 0., D, # relative line position
            reference, Ref_RearWheel, eye,      # relative line orientation
         NoDyn_FrontWheel;

   joint: JoPrism_Chassis_FrontWheel,
      prismatic,
         NoDyn_Chassis,
            hinge, reference, global, eye, # relative orientation matrix
         NoDyn_FrontWheel;
         
   joint: JoDfmd_Chassis_FrontWheel,
      deformable displacement joint,
         NoDyn_Chassis,
            reference, Ref_RearWheel, L, 0., D,   # relative offset
            hinge, reference, Ref_RearWheel, eye, # relative orientation matrix
         NoDyn_FrontWheel, 
            null,                                 # relative offset
         linear viscoelastic isotropic,
            K,    # stiffness
            C,    # viscosity coefficient
         prestrain, single, 0., 0., -1, const, D;
         
   joint: JoInlin_Chassis_RearWheel, 
      in line,
         NoDyn_Chassis,
            reference, Ref_RearWheel, 0., 0., D, # relative line position
            reference, Ref_RearWheel, eye,       # relative line orientation
         NoDyn_RearWheel;

   joint: JoPrism_Chassis_RearWheel,
      prismatic,
         NoDyn_Chassis,
            hinge, reference, global, eye, # relative orientation matrix
         NoDyn_RearWheel;
         
   joint: JoDfmd_Chassis_RearWheel,
      deformable displacement joint,
         NoDyn_Chassis,
            reference, Ref_RearWheel, 0., 0., D,  # relative offset
            hinge, reference, Ref_RearWheel, eye, # relative orientation matrix
         NoDyn_RearWheel, 
            null,                                 # relative offset
         linear viscoelastic isotropic,
            K,    # stiffness
            C,    # viscosity coefficient
         prestrain, single, 0., 0., -1, const, D;

   joint: JoTotp_Road1,
      total pin joint,
         NoDyn_Road1,
            position, null, # relative offset
            position, null, # absolute position
         position constraint,
            active, active, active,
            component,
               string, "DX1",
               null,
               string, "model::sf::Fun_Road(DX1)",
         orientation constraint,
            active, active, active,
            single, 0., 1., 0,
               string, "-atan((model::sf::Fun_Road(DX1+Delta_Road)\
                                 -model::sf::Fun_Road(DX1))/Delta_Road)";
               
   joint: JoTotp_Road2,
      total pin joint,
         NoDyn_Road2,
            position, null, # relative offset
            position, null, # absolute position
         position constraint,
            active, active, active,
            component,
               string, "DX2",
               const, 0.,
               string, "model::sf::Fun_Road(DX2)",
         orientation constraint,
            active, active, active,
            single, 0., 1., 0,
               string, "-atan((model::sf::Fun_Road(DX2+Delta_Road)\
                                -model::sf::Fun_Road(DX2))/Delta_Road)";
         
   #-----------------------------------------------------------------------------
   # Forces      
   force: FoStrin_Normal_FrontWheel_Road1,
      follower internal,
         NoDyn_Road1,
            position, null, # relative arm
         NoDyn_FrontWheel,
            position, null, # relative arm
         single, 0., 0., -1.,
            string, "max(0,Kc*sign(0-DZ1_Dum)*abs(0-DZ1_Dum)^Ec\
                           -Cc*VZ1_Dum*model::sf::cubstep((0-DZ1_Dum)/Dc))"; # force value
                           
   force: FoStrin_Normal_RearWheel_Road2,
      follower internal,
         NoDyn_Road2,
            position, null, # relative arm
         NoDyn_RearWheel,
            position, null, # relative arm
         single, 0., 0., -1.,
            string, "max(0,Kc*sign(0-DZ2_Dum)*abs(0-DZ2_Dum)^Ec\
                           -Cc*VZ2_Dum*model::sf::cubstep((0-DZ2_Dum)/Dc))"; # force value
                                
   #-----------------------------------------------------------------------------
   # Gravity 
   gravity: 0., 0., -1., const, 9.81;

end: elements;

Subfiles

sf_cubstep.sub
# sf_cubstep.sub

scalar function: "cubstep",
   cubicspline, do not extrapolate,
      -0.03, 0.00,
      -0.02, 0.00,
      -0.01, 0.00,
       0.00, 0.00,
       1.00, 1.00,
       1.01, 1.00,
       1.02, 1.00,
       1.03, 1.00;

sf_Fun_Road_Jump.sub
# sf_Fun_Road_Jump.sub

scalar function: "Fun_Road",
   cubicspline, do not extrapolate,
  0.0000000e+000,  4.0000000e-001,
  1.0000000e-002,  3.9990131e-001,
  2.0000000e-002,  3.9960535e-001,
  3.0000000e-002,  3.9911239e-001,
  4.0000000e-002,  3.9842294e-001,
  5.0000000e-002,  3.9753767e-001,
  6.0000000e-002,  3.9645745e-001,
  7.0000000e-002,  3.9518335e-001,
  8.0000000e-002,  3.9371663e-001,
  9.0000000e-002,  3.9205874e-001,
  1.0000000e-001,  3.9021130e-001,
  1.1000000e-001,  3.8817615e-001,
  1.2000000e-001,  3.8595530e-001,
  1.3000000e-001,  3.8355093e-001,
  1.4000000e-001,  3.8096541e-001,
  1.5000000e-001,  3.7820130e-001,
  1.6000000e-001,  3.7526134e-001,
  1.7000000e-001,  3.7214841e-001,
  1.8000000e-001,  3.6886559e-001,
  1.9000000e-001,  3.6541611e-001,
  2.0000000e-001,  3.6180340e-001,
  2.1000000e-001,  3.5803100e-001,
  2.2000000e-001,  3.5410265e-001,
  2.3000000e-001,  3.5002221e-001,
  2.4000000e-001,  3.4579373e-001,
  2.5000000e-001,  3.4142136e-001,
  2.6000000e-001,  3.3690942e-001,
  2.7000000e-001,  3.3226237e-001,
  2.8000000e-001,  3.2748480e-001,
  2.9000000e-001,  3.2258141e-001,
  3.0000000e-001,  3.1755705e-001,
  3.1000000e-001,  3.1241668e-001,
  3.2000000e-001,  3.0716536e-001,
  3.3000000e-001,  3.0180828e-001,
  3.4000000e-001,  2.9635073e-001,
  3.5000000e-001,  2.9079810e-001,
  3.6000000e-001,  2.8515586e-001,
  3.7000000e-001,  2.7942958e-001,
  3.8000000e-001,  2.7362491e-001,
  3.9000000e-001,  2.6774758e-001,
  4.0000000e-001,  2.6180340e-001,
  4.1000000e-001,  2.5579822e-001,
  4.2000000e-001,  2.4973798e-001,
  4.3000000e-001,  2.4362865e-001,
  4.4000000e-001,  2.3747626e-001,
  4.5000000e-001,  2.3128689e-001,
  4.6000000e-001,  2.2506665e-001,
  4.7000000e-001,  2.1882166e-001,
  4.8000000e-001,  2.1255810e-001,
  4.9000000e-001,  2.0628215e-001,
  5.0000000e-001,  2.0000000e-001,
  5.1000000e-001,  1.9371785e-001,
  5.2000000e-001,  1.8744190e-001,
  5.3000000e-001,  1.8117834e-001,
  5.4000000e-001,  1.7493335e-001,
  5.5000000e-001,  1.6871311e-001,
  5.6000000e-001,  1.6252374e-001,
  5.7000000e-001,  1.5637135e-001,
  5.8000000e-001,  1.5026202e-001,
  5.9000000e-001,  1.4420178e-001,
  6.0000000e-001,  1.3819660e-001,
  6.1000000e-001,  1.3225242e-001,
  6.2000000e-001,  1.2637509e-001,
  6.3000000e-001,  1.2057042e-001,
  6.4000000e-001,  1.1484414e-001,
  6.5000000e-001,  1.0920190e-001,
  6.6000000e-001,  1.0364927e-001,
  6.7000000e-001,  9.8191717e-002,
  6.8000000e-001,  9.2834641e-002,
  6.9000000e-001,  8.7583324e-002,
  7.0000000e-001,  8.2442950e-002,
  7.1000000e-001,  7.7418589e-002,
  7.2000000e-001,  7.2515202e-002,
  7.3000000e-001,  6.7737627e-002,
  7.4000000e-001,  6.3090579e-002,
  7.5000000e-001,  5.8578644e-002,
  7.6000000e-001,  5.4206275e-002,
  7.7000000e-001,  4.9977786e-002,
  7.8000000e-001,  4.5897351e-002,
  7.9000000e-001,  4.1968998e-002,
  8.0000000e-001,  3.8196601e-002,
  8.1000000e-001,  3.4583885e-002,
  8.2000000e-001,  3.1134415e-002,
  8.3000000e-001,  2.7851595e-002,
  8.4000000e-001,  2.4738664e-002,
  8.5000000e-001,  2.1798695e-002,
  8.6000000e-001,  1.9034590e-002,
  8.7000000e-001,  1.6449075e-002,
  8.8000000e-001,  1.4044703e-002,
  8.9000000e-001,  1.1823846e-002,
  9.0000000e-001,  9.7886967e-003,
  9.1000000e-001,  7.9412629e-003,
  9.2000000e-001,  6.2833678e-003,
  9.3000000e-001,  4.8166476e-003,
  9.4000000e-001,  3.5425499e-003,
  9.5000000e-001,  2.4623319e-003,
  9.6000000e-001,  1.5770597e-003,
  9.7000000e-001,  8.8760708e-004,
  9.8000000e-001,  3.9465431e-004,
  9.9000000e-001,  9.8687927e-005,
  1.0000000e+000,  0.0000000e+000,
  1.0100000e+000,  9.8687927e-005,
  1.0200000e+000,  3.9465431e-004,
  1.0300000e+000,  8.8760708e-004,
  1.0400000e+000,  1.5770597e-003,
  1.0500000e+000,  2.4623319e-003,
  1.0600000e+000,  3.5425499e-003,
  1.0700000e+000,  4.8166476e-003,
  1.0800000e+000,  6.2833678e-003,
  1.0900000e+000,  7.9412629e-003,
  1.1000000e+000,  9.7886967e-003,
  1.1100000e+000,  1.1823846e-002,
  1.1200000e+000,  1.4044703e-002,
  1.1300000e+000,  1.6449075e-002,
  1.1400000e+000,  1.9034590e-002,
  1.1500000e+000,  2.1798695e-002,
  1.1600000e+000,  2.4738664e-002,
  1.1700000e+000,  2.7851595e-002,
  1.1800000e+000,  3.1134415e-002,
  1.1900000e+000,  3.4583885e-002,
  1.2000000e+000,  3.8196601e-002,
  1.2100000e+000,  4.1968998e-002,
  1.2200000e+000,  4.5897351e-002,
  1.2300000e+000,  4.9977786e-002,
  1.2400000e+000,  5.4206275e-002,                                
  1.2500000e+000,  5.8578644e-002,
  1.2600000e+000,  6.3090579e-002,
  1.2700000e+000,  6.7737627e-002,
  1.2800000e+000,  7.2515202e-002,
  1.2900000e+000,  7.7418589e-002,
  1.3000000e+000,  8.2442950e-002,
  1.3100000e+000,  8.2442950e-002,
  1.3200000e+000,  6.9561239e-002,
  1.3300000e+000,  4.1221475e-002,
  1.3400000e+000,  1.2881711e-002,
  1.3500000e+000,  0.0000000e+000,
  1.3600000e+000,  0.0000000e+000,
  1.3700000e+000,  0.0000000e+000,
  1.3800000e+000,  0.0000000e+000,
  1.3900000e+000,  0.0000000e+000,
  1.4000000e+000,  0.0000000e+000,
  1.4100000e+000,  0.0000000e+000,
  1.4200000e+000,  0.0000000e+000,
  1.4300000e+000,  0.0000000e+000,
  1.4400000e+000,  0.0000000e+000,
  1.4500000e+000,  0.0000000e+000,
  1.4600000e+000,  0.0000000e+000,
  1.4700000e+000,  0.0000000e+000,
  1.4800000e+000,  0.0000000e+000,
  1.4900000e+000,  0.0000000e+000,
  1.5000000e+000,  0.0000000e+000,
  2.0000000e+000,  0.0000000e+000;
Sponsor Link