@@ -70,17 +70,29 @@ class TrackFitterUKFBase {
7070 float32_t m_weightC0;
7171 // / Unscented transform weight for the other sigma points
7272 float32_t m_weighti;
73- // / Kappa parameter for sigma point calculation
74- float32_t m_kappa{ 3 - DIM_A };
73+ // / Lambda parameter for sigma point calculation
74+ float32_t m_lambda{ 0 };
7575
7676public:
77- TrackFitterUKFBase () { updateWeights ( ); }
77+ TrackFitterUKFBase () { setParameters ( 1 , 2 , 0 ); }
7878 ~TrackFitterUKFBase () = default ;
7979
80- void setKappa (float32_t kappa)
80+ /* *
81+ * @brief Set the weights used to calculate sigma points.
82+ */
83+ void setParameters (float alpha, float beta, float kappa)
8184 {
82- m_kappa = kappa; // Set the kappa parameter for sigma point calculation
83- updateWeights (); // Update the weights based on the new kappa value
85+ static_assert (DIM_A > 0 , " DIM_A is Zero which leads to numerical issue." );
86+
87+ m_lambda = alpha * alpha * (DIM_A + kappa) - DIM_A;
88+ float32_t denoTerm = m_lambda + static_cast <float32_t >(DIM_A);
89+
90+ m_weightM0 = m_lambda / denoTerm;
91+ m_weightC0 = m_weightM0 + (1 .0F - alpha * alpha + beta); // Weight for the mean sigma point in covariance
92+ m_weighti = 0 .5F / denoTerm;
93+ LOG (info) << " Mean weight " << m_weightM0;
94+ LOG (info) << " Cov weight: " << m_weightC0;
95+ LOG (info) << " Shared weight: " << m_weighti;
8496 }
8597
8698 /* *
@@ -200,24 +212,6 @@ class TrackFitterUKFBase {
200212 }
201213
202214protected:
203- /* *
204- * @brief Set the weights used to calculate sigma points.
205- */
206- void updateWeights ()
207- {
208- static_assert (DIM_A > 0 , " DIM_A is Zero which leads to numerical issue." );
209-
210- constexpr float alpha = 1.0 ; // Scaling parameter, set to 1 to match orig
211- constexpr float beta = 2.0 ; // Optimal for Gaussian distributions
212-
213- float lambda{alpha * alpha * (DIM_A + m_kappa) - DIM_A}; // Lambda parameter for sigma points
214- // lambda = m_kappa
215- const float32_t denoTerm{lambda + static_cast <float32_t >(DIM_A)};
216-
217- m_weightM0 = lambda / denoTerm;
218- m_weightC0 = m_weightM0 + (1 .0F - alpha * alpha + beta); // Weight for the mean sigma point in covariance
219- m_weighti = 0 .5F / denoTerm;
220- }
221215 /* *
222216 * @brief Add state vector and state covariance matrix to the augmented state vector covariance matrix.
223217 */
@@ -328,7 +322,7 @@ class TrackFitterUKFBase {
328322 Matrix<STATE_DIM, SIGMA_DIM>
329323 calculateSigmaPoints (const Vector<STATE_DIM> &vecXa, const Matrix<STATE_DIM, STATE_DIM> &matPa)
330324 {
331- const float32_t scalarMultiplier{std::sqrt (STATE_DIM + m_kappa )}; // sqrt(n + \kappa)
325+ const float32_t scalarMultiplier{std::sqrt (STATE_DIM + m_lambda )}; // sqrt(n + \kappa)
332326
333327 Eigen::LLT<Matrix<STATE_DIM, STATE_DIM>> lltOfPa = calculateCholesky<STATE_DIM>(matPa);
334328
@@ -447,6 +441,7 @@ class TrackFitterUKF : public TrackFitterUKFBase<6, 3, 1, 3> {
447441 using EigenVectorDimX = std::vector<Vector<TF_DIM_X>, Eigen::aligned_allocator<Vector<TF_DIM_X>>>;
448442 using VectorEigenMatDimX =
449443 std::vector<Matrix<TF_DIM_X, TF_DIM_X>, Eigen::aligned_allocator<Matrix<TF_DIM_X, TF_DIM_X>>>;
444+
450445 // vectors to hold the information needed for smoothing the UKF
451446 EigenVectorDimX m_vecXPredHist; // / @brief History of predicted state vectors at k+1
452447 VectorEigenMatDimX m_matPPredHist; // / @brief History of predicted state covariances at k+1
0 commit comments