gwnavruntime/pathfollower/avoidanceconfig.h Source File

avoidanceconfig.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 // primary contact: LAPA - secondary contact: NOBODY
8 #ifndef Navigation_AvoidanceConfig_H
9 #define Navigation_AvoidanceConfig_H
10 
11 
14 
15 
16 namespace Kaim
17 {
18 
19 class AvoidanceCapConfig
20 {
22 
23 public:
24  AvoidanceCapConfig() { SetDefaults(); }
25  void SetDefaults();
26  bool operator==(const AvoidanceCapConfig& other) const;
27  bool operator!=(const AvoidanceCapConfig& other) const { return !operator==(other); }
28 
29 public:
32  bool m_capAvoidanceAngleChange;
33 
36  bool m_capAvoidanceSpeedChange;
37 
40  KyFloat32 m_maxAngularVelocityChange;
41 
44  KyFloat32 m_maxLinearSpeedChange;
45 };
46 
47 
48 class AvoidanceContactSolverConfig
49 {
51 
52 public:
53  AvoidanceContactSolverConfig() { SetDefaults(); }
54  void SetDefaults();
55  bool operator==(const AvoidanceContactSolverConfig& other) const;
56  bool operator!=(const AvoidanceContactSolverConfig& other) const { return !operator==(other); }
57 
58 public:
59 
62  bool m_enableSoftContactSolver;
63 
66  bool m_enableBypassContactOverTime;
67 
70  KyFloat32 m_contactBypassingTimeLimit;
71 
74  KyFloat32 m_contactBypassingRatio;
75 };
76 
77 
78 class AvoidanceUtilityFunctionConfig
79 {
81 
82 public:
83  AvoidanceUtilityFunctionConfig() { SetDefaults(); }
84  void SetDefaults();
85  bool operator==(const AvoidanceUtilityFunctionConfig& other) const;
86  bool operator!=(const AvoidanceUtilityFunctionConfig& other) const { return !operator==(other); }
87 
88 public:
91  KyFloat32 m_avoidanceAngleSpan;
92 
95  KyUInt32 m_avoidanceSampleCount;
96 
99  KyFloat32 m_avoidanceInfluence;
100 
103  KyFloat32 m_desiredVelocityInfluence;
104 
107  KyFloat32 m_previousVelocityInfluence;
108 };
109 
111 class AvoidanceConfig
112 {
113  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_Bot)
114 
115 public:
116  AvoidanceConfig() { SetDefaults(); }
117  void SetDefaults();
118 
119  bool operator==(const AvoidanceConfig& other) const;
120  bool operator!=(const AvoidanceConfig& other) const { return !operator==(other); }
121 
122 public:
123 
124  // -------- Avoidance Capabilities ---------
125 
129  bool m_enableSlowingDown;
130 
131 
135  bool m_enableStop;
136 
140 
144 
145 
149 
153 
156  KyFloat32 m_forcePassageTimeLimit;
157 
158 
159  // -------- Avoidance output computation config ---------
168 
170  AvoidanceUtilityFunctionConfig m_utilityFunctionConfig;
171 
173  AvoidanceCapConfig m_capConfig;
174 
176  AvoidanceContactSolverConfig m_contactSolverConfig;
177 };
178 
180 KY_INLINE void AvoidanceCapConfig::SetDefaults()
181 {
182  m_capAvoidanceAngleChange = true;
183  m_capAvoidanceSpeedChange = false;
184  m_maxAngularVelocityChange = 360.0f;
185  m_maxLinearSpeedChange = 8.0f;
186 }
187 
188 KY_INLINE bool AvoidanceCapConfig::operator==(const AvoidanceCapConfig& other) const
189 {
190  return m_capAvoidanceAngleChange == other.m_capAvoidanceAngleChange
191  && m_capAvoidanceSpeedChange == other.m_capAvoidanceSpeedChange
192  && m_maxAngularVelocityChange == other.m_maxAngularVelocityChange
193  && m_maxLinearSpeedChange == other.m_maxLinearSpeedChange;
194 
195 }
196 
197 KY_INLINE void AvoidanceUtilityFunctionConfig::SetDefaults()
198 {
199  m_avoidanceAngleSpan = 90.0f;
200  m_avoidanceSampleCount = 20;
201 
202  m_avoidanceInfluence = 0.8f;
203  m_desiredVelocityInfluence = 0.15f;
204  m_previousVelocityInfluence = 0.05f;
205 }
206 
207 KY_INLINE bool AvoidanceUtilityFunctionConfig::operator==(const AvoidanceUtilityFunctionConfig& other) const
208 {
209  return m_avoidanceAngleSpan == other.m_avoidanceAngleSpan
210  && m_avoidanceSampleCount == other.m_avoidanceSampleCount
211  && m_avoidanceInfluence == other.m_avoidanceInfluence
212  && m_desiredVelocityInfluence == other.m_desiredVelocityInfluence
213  && m_previousVelocityInfluence == other.m_previousVelocityInfluence;
214 }
215 
216 
217 KY_INLINE void AvoidanceContactSolverConfig::SetDefaults()
218 {
219  m_enableSoftContactSolver = false;
220  m_enableBypassContactOverTime = false;
221  m_contactBypassingTimeLimit = 1.0f;
222  m_contactBypassingRatio = 0.9f;
223 }
224 KY_INLINE bool AvoidanceContactSolverConfig::operator==(const AvoidanceContactSolverConfig& other) const
225 {
226  return m_enableSoftContactSolver == other.m_enableSoftContactSolver
227  && m_enableBypassContactOverTime == other.m_enableBypassContactOverTime
228  && m_contactBypassingTimeLimit == other.m_contactBypassingTimeLimit
229  && m_contactBypassingRatio == other.m_contactBypassingRatio;
230 }
231 
232 
233 KY_INLINE void AvoidanceConfig::SetDefaults()
234 {
235  m_enableSlowingDown = false;
236 
237  m_enableStop = true;
238  m_stopCollisionTime = 0.25f;
239  m_stopWaitTime = 0.2f;
240 
241  m_enableForcePassage = true;
243  m_forcePassageTimeLimit = 0.5f;
244 
246  m_safetyDistance = 0.1f;
247  m_utilityFunctionConfig.SetDefaults();
248  m_capConfig.SetDefaults();
249  m_contactSolverConfig.SetDefaults();
250 }
251 KY_INLINE bool AvoidanceConfig::operator==(const AvoidanceConfig& other) const
252 {
253  return m_enableSlowingDown == other.m_enableSlowingDown
254 
255  && m_enableStop == other.m_enableStop
256  && m_stopCollisionTime == other.m_stopCollisionTime
257  && m_stopWaitTime == other.m_stopWaitTime
258 
259  && m_enableForcePassage == other.m_enableForcePassage
260  && m_waitPassageTimeLimit == other.m_waitPassageTimeLimit
261  && m_forcePassageTimeLimit == other.m_forcePassageTimeLimit
262 
263  && m_minimalTimeToCollision == other.m_minimalTimeToCollision
264  && m_safetyDistance == other.m_safetyDistance
265  && m_utilityFunctionConfig == other.m_utilityFunctionConfig
266  && m_capConfig == other.m_capConfig
267  && m_contactSolverConfig == other.m_contactSolverConfig;
268 }
269 
270 } // namespace Kaim
271 
272 #endif // Navigation_AvoidanceComputerConfig_H
Set of parameters used to configure AvoidanceComputer.
Definition: avoidanceconfig.h:117
bool m_enableSlowingDown
If set to true, velocity candidates with reduced speed will be considered; else only velocity candida...
Definition: avoidanceconfig.h:141
AvoidanceCapConfig m_capConfig
Cap changes in the avoidance output velocity.
Definition: avoidanceconfig.h:189
KyFloat32 m_waitPassageTimeLimit
If m_enableForcePassage is true, passage is forced for at most m_forcePassageTimeLimit seconds only a...
Definition: avoidanceconfig.h:164
KyFloat32 m_stopWaitTime
If the entity stopped, wait stopWaitTime seconds before moving again.
Definition: avoidanceconfig.h:155
KyFloat32 m_minimalTimeToCollision
If an obstacle may collide another one in m_minimalTimeToCollision seconds, take it into account for ...
Definition: avoidanceconfig.h:179
bool m_enableStop
If set to true, null velocity candidate will be considered; else the AvoidanceSolver will never consi...
Definition: avoidanceconfig.h:147
Definition: gamekitcrowddispersion.h:20
KyFloat32 m_safetyDistance
Safety distance around collider to avoid moving too close.
Definition: avoidanceconfig.h:183
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
AvoidanceContactSolverConfig m_contactSolverConfig
Soft-Physics Contact Solver config.
Definition: avoidanceconfig.h:192
KyFloat32 m_stopCollisionTime
If a collision cannot be avoided in less that stopCollisionTime seconds, the entity will stop...
Definition: avoidanceconfig.h:151
AvoidanceUtilityFunctionConfig m_utilityFunctionConfig
Various parameters of the utility function defining how candidate velocities for avoidance are scored...
Definition: avoidanceconfig.h:186
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
bool m_enableForcePassage
If set to true, solutions with collisions are allowed if no other solutions are found after a while...
Definition: avoidanceconfig.h:160
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43