gwnavruntime/pathfollower/avoidanceconfig.h Source File

avoidanceconfig.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
8 
11 
12 namespace Kaim
13 {
14 
15 class AvoidanceCapConfig
16 {
18 
19 public:
20  AvoidanceCapConfig() { SetDefaults(); }
21  void SetDefaults();
22  bool operator==(const AvoidanceCapConfig& other) const;
23  bool operator!=(const AvoidanceCapConfig& other) const { return !operator==(other); }
24 
25 public:
28  bool m_capAvoidanceAngleChange;
29 
32  bool m_capAvoidanceSpeedChange;
33 
36  KyFloat32 m_maxAngularVelocityChange;
37 
40  KyFloat32 m_maxLinearSpeedChange;
41 };
42 
43 
44 class AvoidanceContactSolverConfig
45 {
47 
48 public:
49  // ------------------------------ Functions -----------------------------
50  AvoidanceContactSolverConfig() { SetDefaults(); }
51  void SetDefaults();
52  bool operator==(const AvoidanceContactSolverConfig& other) const;
53  bool operator!=(const AvoidanceContactSolverConfig& other) const { return !operator==(other); }
54 
57  bool m_enableSoftContactSolver;
58 
61  bool m_enableBypassContactOverTime;
62 
65  KyFloat32 m_contactBypassingTimeLimit;
66 
69  KyFloat32 m_contactBypassingRatio;
70 };
71 
72 
73 class AvoidanceUtilityFunctionConfig
74 {
76 
77 public:
78  AvoidanceUtilityFunctionConfig() { SetDefaults(); }
79  void SetDefaults();
80  bool operator==(const AvoidanceUtilityFunctionConfig& other) const;
81  bool operator!=(const AvoidanceUtilityFunctionConfig& other) const { return !operator==(other); }
82 
83 public:
86  KyFloat32 m_avoidanceAngleSpan;
87 
90  KyUInt32 m_avoidanceSampleCount;
91 
94  KyFloat32 m_avoidanceInfluence;
95 
98  KyFloat32 m_desiredVelocityInfluence;
99 
102  KyFloat32 m_previousVelocityInfluence;
103 };
104 
107 {
108  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_Bot)
109 
110 public:
111  AvoidanceConfig() { SetDefaults(); }
112  void SetDefaults();
113 
114  bool operator==(const AvoidanceConfig& other) const;
115  bool operator!=(const AvoidanceConfig& other) const { return !operator==(other); }
116 
117 public:
118 
119  // -------- Avoidance Capabilities ---------
120 
125 
130 
134 
138 
139 
143 
147 
151 
152 
153  // -------- Avoidance output computation config ---------
154 
158 
162 
164  AvoidanceUtilityFunctionConfig m_utilityFunctionConfig;
165 
167  AvoidanceCapConfig m_capConfig;
168 
170  AvoidanceContactSolverConfig m_contactSolverConfig;
171 };
172 
173 
174 KY_INLINE void AvoidanceCapConfig::SetDefaults()
175 {
176  m_capAvoidanceAngleChange = true;
177  m_capAvoidanceSpeedChange = false;
178  m_maxAngularVelocityChange = 360.0f;
179  m_maxLinearSpeedChange = 8.0f;
180 }
181 
182 KY_INLINE bool AvoidanceCapConfig::operator==(const AvoidanceCapConfig& other) const
183 {
184  return m_capAvoidanceAngleChange == other.m_capAvoidanceAngleChange
185  && m_capAvoidanceSpeedChange == other.m_capAvoidanceSpeedChange
186  && m_maxAngularVelocityChange == other.m_maxAngularVelocityChange
187  && m_maxLinearSpeedChange == other.m_maxLinearSpeedChange;
188 
189 }
190 
191 KY_INLINE void AvoidanceUtilityFunctionConfig::SetDefaults()
192 {
193  m_avoidanceAngleSpan = 90.0f;
194  m_avoidanceSampleCount = 20;
195 
196  m_avoidanceInfluence = 0.8f;
197  m_desiredVelocityInfluence = 0.15f;
198  m_previousVelocityInfluence = 0.05f;
199 }
200 
201 KY_INLINE bool AvoidanceUtilityFunctionConfig::operator==(const AvoidanceUtilityFunctionConfig& other) const
202 {
203  return m_avoidanceAngleSpan == other.m_avoidanceAngleSpan
204  && m_avoidanceSampleCount == other.m_avoidanceSampleCount
205  && m_avoidanceInfluence == other.m_avoidanceInfluence
206  && m_desiredVelocityInfluence == other.m_desiredVelocityInfluence
207  && m_previousVelocityInfluence == other.m_previousVelocityInfluence;
208 }
209 
210 
211 KY_INLINE void AvoidanceContactSolverConfig::SetDefaults()
212 {
213  m_enableSoftContactSolver = false;
214  m_enableBypassContactOverTime = false;
215  m_contactBypassingTimeLimit = 1.0f;
216  m_contactBypassingRatio = 0.9f;
217 }
218 KY_INLINE bool AvoidanceContactSolverConfig::operator==(const AvoidanceContactSolverConfig& other) const
219 {
220  return m_enableSoftContactSolver == other.m_enableSoftContactSolver
221  && m_enableBypassContactOverTime == other.m_enableBypassContactOverTime
222  && m_contactBypassingTimeLimit == other.m_contactBypassingTimeLimit
223  && m_contactBypassingRatio == other.m_contactBypassingRatio;
224 }
225 
226 
227 KY_INLINE void AvoidanceConfig::SetDefaults()
228 {
229  m_enableSlowingDown = false;
230 
231  m_enableStop = true;
232  m_stopCollisionTime = 0.25f;
233  m_stopWaitTime = 0.2f;
234 
235  m_enableForcePassage = true;
238 
240  m_safetyDistance = 0.1f;
241  m_utilityFunctionConfig.SetDefaults();
242  m_capConfig.SetDefaults();
243  m_contactSolverConfig.SetDefaults();
244 }
245 KY_INLINE bool AvoidanceConfig::operator==(const AvoidanceConfig& other) const
246 {
247  return m_enableSlowingDown == other.m_enableSlowingDown
248 
249  && m_enableStop == other.m_enableStop
250  && m_stopCollisionTime == other.m_stopCollisionTime
251  && m_stopWaitTime == other.m_stopWaitTime
252 
253  && m_enableForcePassage == other.m_enableForcePassage
254  && m_waitPassageTimeLimit == other.m_waitPassageTimeLimit
255  && m_forcePassageTimeLimit == other.m_forcePassageTimeLimit
256 
257  && m_minimalTimeToCollision == other.m_minimalTimeToCollision
258  && m_safetyDistance == other.m_safetyDistance
259  && m_utilityFunctionConfig == other.m_utilityFunctionConfig
260  && m_capConfig == other.m_capConfig
261  && m_contactSolverConfig == other.m_contactSolverConfig;
262 }
263 
264 } // namespace Kaim
265 
Set of parameters used to configure AvoidanceComputer.
Definition: avoidanceconfig.h:106
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
bool m_enableSlowingDown
If set to true, velocity candidates with reduced speed will be considered; else only velocity candida...
Definition: avoidanceconfig.h:124
AvoidanceCapConfig m_capConfig
Cap changes in the avoidance output velocity.
Definition: avoidanceconfig.h:167
KyFloat32 m_waitPassageTimeLimit
If m_enableForcePassage is true, passage will be forced after m_waitPassageTimeLimit seconds...
Definition: avoidanceconfig.h:146
KyFloat32 m_stopWaitTime
If the entity stopped, wait stopWaitTime seconds before moving again.
Definition: avoidanceconfig.h:137
KyFloat32 m_minimalTimeToCollision
If an obstacle may collide another one in m_minimalTimeToCollision seconds, take it into account for ...
Definition: avoidanceconfig.h:157
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
bool m_enableStop
If set to true, null velocity candidate will be considered; else the AvoidanceSolver will never consi...
Definition: avoidanceconfig.h:129
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
KyFloat32 m_safetyDistance
Safety distance around collider to avoid moving too close.
Definition: avoidanceconfig.h:161
AvoidanceContactSolverConfig m_contactSolverConfig
Soft-Physics Contact Solver config.
Definition: avoidanceconfig.h:170
KyFloat32 m_stopCollisionTime
If a collision cannot be avoided in less that stopCollisionTime seconds, the entity will stop...
Definition: avoidanceconfig.h:133
AvoidanceUtilityFunctionConfig m_utilityFunctionConfig
Various parameters of the utility function defining how candidate velocities for avoidance are scored...
Definition: avoidanceconfig.h:164
KyFloat32 m_forcePassageTimeLimit
If m_enableForcePassage is true, passage is forced for at most m_forcePassageTimeLimit seconds only a...
Definition: avoidanceconfig.h:150
bool m_enableForcePassage
If set to true, solutions with collisions are allowed if no other solutions are found after a while...
Definition: avoidanceconfig.h:142
float KyFloat32
float
Definition: types.h:32