Free Electron
MountSystem.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __tire_MountSystem_h__
8 #define __tire_MountSystem_h__
9 
10 #include "solve/solve.h"
11 
12 namespace fe
13 {
14 namespace ext
15 {
16 
17 /// @brief Tire to Rig Connection
18 class MountSystem :
19  virtual public Stepper,
20  public Initialize<MountSystem>
21 {
22  public:
23  struct Mount
24  {
25  WeakRecord m_r_mount;
26  WeakRecord m_r_rig;
27  WeakRecord m_r_tire;
28  };
29  MountSystem(void)
30  {
31  }
32  void initialize(void) {}
33 virtual void compile(const t_note_id &a_note_id)
34  {
35  sp<Scope> spScope = m_rg_dataset->scope();
36 
37  if(!spScope.isValid()) { return; }
38 
39  enforce<AsTire,AsTireLive>(m_rg_dataset);
40 
41  m_asRig.bind(spScope);
42  m_asTireLive.bind(spScope);
43  m_asMount.bind(spScope);
44 
45  AsTire asTire(spScope);
46 
47  RecordDictionary<AsRig> rd_rigs(m_rg_dataset);
48  RecordDictionary<AsTire> rd_tires(m_rg_dataset);
49 
50  std::vector<Record> mounts;
51  m_asMount.filter(mounts, m_rg_dataset);
52 
53  for(unsigned int i_mount = 0; i_mount < mounts.size(); i_mount++)
54  {
55  Record &r_mount = mounts[i_mount];
56  Mount mount;
57  mount.m_r_mount = r_mount;
58  mount.m_r_rig = rd_rigs[m_asMount.rig(r_mount)];
59  mount.m_r_tire = rd_tires[m_asMount.tire(r_mount)];
60  if( mount.m_r_rig.isValid() &&
61  mount.m_r_tire.isValid() &&
62  m_asRig.check(mount.m_r_rig) &&
63  m_asTireLive.check(mount.m_r_tire))
64  {
65  m_mounts.push_back(mount);
66  }
67  }
68 
69  }
70  void step(t_moa_real a_dt)
71  {
72  for(unsigned int i_mount = 0; i_mount < m_mounts.size(); i_mount++)
73  {
74  WeakRecord &r_rig = m_mounts[i_mount].m_r_rig;
75  WeakRecord &r_tire = m_mounts[i_mount].m_r_tire;
76  WeakRecord &r_mount = m_mounts[i_mount].m_r_mount;
77 
78  t_moa_real alpha = m_asRig.alpha(r_rig)*pi/180.0;
79  t_moa_v3 vel;
80  vel[0] = m_asRig.velocity(r_rig) * cos(alpha);
81  vel[1] = m_asRig.velocity(r_rig) * sin(alpha)
82  * cos(m_asRig.inclination(r_rig));
83  vel[2] = m_asRig.pnt_velocity(r_rig)[2];
84 
85  setIdentity(m_asTireLive.transform(r_tire));
86  translate(m_asTireLive.transform(r_tire),
87  m_asRig.location(r_rig));
88  rotate(m_asTireLive.transform(r_tire),
89  m_asRig.inclination(r_rig), e_xAxis);
90  invert(m_asMount.transform_inv(r_mount),
91  m_asTireLive.transform(r_tire));
92 
93  vel = rotateVector<3, t_moa_real>(
94  m_asMount.transform_inv(r_mount),vel);
95  m_asTireLive.velocity(r_tire) = vel;
96  t_moa_v3 angular_velocity = t_moa_v3(0,m_asRig.kappa(r_rig),0);
97  if(m_asRig.free_wheel(r_rig)) { angular_velocity[1] += vel[0] /
98  m_asTireLive.radius(r_tire); }
99  m_asTireLive.angular_velocity(r_tire) = angular_velocity;
100  }
101  accumulate();
102  }
103  void accumulate(void)
104  {
105  for(unsigned int i_mount = 0; i_mount < m_mounts.size(); i_mount++)
106  {
107  WeakRecord &r_rig = m_mounts[i_mount].m_r_rig;
108  WeakRecord &r_tire = m_mounts[i_mount].m_r_tire;
109  WeakRecord &r_mount = m_mounts[i_mount].m_r_mount;
110 
111  t_moa_v3 rig_space_F = rotateVector<3, t_moa_real>
112  (m_asTireLive.transform(r_tire),
113  m_asTireLive.force(r_tire));
114  t_moa_v3 rig_space_M = rotateVector<3, t_moa_real>
115  (m_asTireLive.transform(r_tire),
116  m_asTireLive.moment(r_tire));
117 
118  m_asRig.force_accum(r_rig).add(rig_space_F);
119  m_asRig.moment_accum(r_rig).add(rig_space_M);
120  }
121  }
122 
123  std::vector<Mount> m_mounts;
124  AsRigLive m_asRig;
125  AsTireLive m_asTireLive;
126  AsMount m_asMount;
127 };
128 
129 } /* namespace ext */
130 } /* namespace fe */
131 
132 #endif /* __tire_MountSystem_h__ */
133 
134 
Tire Test Rig Live.
Definition: tireAS.h:206
Tire.
Definition: tireAS.h:36
kernel
Definition: namespace.dox:3
Matrix< 4, 4, T > & invert(Matrix< 4, 4, T > &a_inverted, const Matrix< 4, 4, T > &a_matrix)
4x4 full matrix inversion
Definition: Matrix.h:1033
Time Stepping System.
Definition: Stepper.h:15
Per-class participation in the Initialized <> mechanism.
Definition: Initialized.h:117
virtual void compile(const t_note_id &a_note_id)
Compile internal structure for dataset.
Definition: MountSystem.h:33
void step(t_moa_real a_dt)
Move system forward in time by a timestep.
Definition: MountSystem.h:70
Run Time Single Contact Tire Model.
Definition: tireAS.h:49
Tire to Rig Connection.
Definition: MountSystem.h:18
Reference to an instance of a Layout.
Definition: RecordSB.h:35
Non-persistent reference to an instance of a Layout.
Definition: WeakRecordSB.h:17
Rig to Tire mount.
Definition: tireAS.h:89