Skip to content

Commit 22f88dc

Browse files
Feature/update readme (#8)
* resolve compiler warnings and add vscode settings
1 parent df3f221 commit 22f88dc

12 files changed

Lines changed: 82 additions & 65 deletions

File tree

.vscode/c_cpp_properties.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Linux",
5+
"includePath": [
6+
"${workspaceFolder}/**"
7+
],
8+
"defines": [],
9+
"compilerPath": "/usr/bin/clang-14",
10+
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
11+
"cStandard": "c17",
12+
"cppStandard": "c++14",
13+
"intelliSenseMode": "linux-clang-x64"
14+
}
15+
],
16+
"version": 4
17+
}

src/examples/ekf_range_sensor/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ kf::Vector<DIM_Z> covertCartesian2Polar(const kf::Vector<DIM_X> & cartesian);
2525
kf::Matrix<DIM_Z, DIM_Z> calculateJacobianMatrix(const kf::Vector<DIM_X> & vecX);
2626
void executeCorrectionStep();
2727

28-
int main(int argc, char ** argv)
28+
int main()
2929
{
3030
executeCorrectionStep();
3131

src/examples/kf_state_estimation/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static kf::KalmanFilter<DIM_X, DIM_Z> kalmanfilter;
2525
void executePredictionStep();
2626
void executeCorrectionStep();
2727

28-
int main(int argc, char ** argv)
28+
int main()
2929
{
3030
executePredictionStep();
3131
executeCorrectionStep();

src/examples/sr_ukf_linear_function/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ kf::Vector<DIM_X> funcF(const kf::Vector<DIM_X> & x)
2525
return x;
2626
}
2727

28-
int main(int argc, char ** argv)
28+
int main()
2929
{
3030
// example 1
3131
runExample1();

src/examples/test_least_squares/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void runExample2();
2020
void runExample3();
2121
void runExample4();
2222

23-
int main(int argc, char ** argv)
23+
int main()
2424
{
2525
runExample1();
2626
runExample2();

src/examples/ukf_range_sensor/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ kf::Vector<DIM_Z> funcH(const kf::Vector<DIM_X> & x, const kf::Vector<DIM_N> & n
4444
return y;
4545
}
4646

47-
int main(int argc, char ** argv)
47+
int main()
4848
{
4949
// example 1
5050
runExample1();

src/examples/unscented_transform/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ kf::Vector<DIM_2> function2(const kf::Vector<DIM_2> & x)
3737
return y;
3838
}
3939

40-
int main(int argc, char ** argv)
40+
int main()
4141
{
4242
// example 1
4343
runExample1();

src/openkf/kalman_filter/square_root_ukf.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ namespace kf
107107
// y_sigmas = np.zeros((self.dim_x, self.n_sigma))
108108
// for i in range(self.n_sigma):
109109
// y_sigmas[:, i] = f(x_sigmas[:, i])
110-
for (size_t i{ 0 }; i < SIGMA_DIM; ++i)
110+
for (int32_t i{ 0 }; i < SIGMA_DIM; ++i)
111111
{
112112
const Vector<DIM_X> Xi{ util::getColumnAt<DIM_X, SIGMA_DIM>(i, matSigmaX) };
113113
const Vector<DIM_X> Yi{ predictionModelFunc(Xi) }; // y = f(x)
@@ -140,7 +140,7 @@ namespace kf
140140
// y_sigmas[:, i] = f(x_sigmas[:, i])
141141
Matrix<DIM_Z, SIGMA_DIM> matSigmaY;
142142

143-
for (size_t i{ 0 }; i < SIGMA_DIM; ++i)
143+
for (int32_t i{ 0 }; i < SIGMA_DIM; ++i)
144144
{
145145
const Vector<DIM_X> Xi{ util::getColumnAt<DIM_X, SIGMA_DIM>(i, matSigmaX) };
146146
const Vector<DIM_Z> Yi{ measurementModelFunc(Xi) }; // y = f(x)
@@ -217,10 +217,10 @@ namespace kf
217217
// X_0 = \bar{xa}
218218
util::copyToColumn< DIM_X, SIGMA_DIM >(0, sigmaX, vecXk);
219219

220-
for (size_t i{ 0 }; i < DIM_X; ++i)
220+
for (int32_t i{ 0 }; i < DIM_X; ++i)
221221
{
222-
const size_t IDX_1{ i + 1 };
223-
const size_t IDX_2{ i + DIM_X + 1 };
222+
const int32_t IDX_1{ i + 1 };
223+
const int32_t IDX_2{ i + DIM_X + 1 };
224224

225225
util::copyToColumn< DIM_X, SIGMA_DIM >(IDX_1, sigmaX, vecXk);
226226
util::copyToColumn< DIM_X, SIGMA_DIM >(IDX_2, sigmaX, vecXk);
@@ -239,12 +239,12 @@ namespace kf
239239
/// @param sigmaX matrix of sigma points where each column contain single sigma point
240240
/// @param vecX output weighted mean
241241
///
242-
template<size_t DIM>
242+
template<int32_t DIM>
243243
void calculateWeightedMean(const Matrix<DIM, SIGMA_DIM> & sigmaX, Vector<DIM> & vecX)
244244
{
245245
// 1. calculate mean: \bar{y} = \sum_{i_0}^{2n} W[0, i] Y[:, i]
246246
vecX = m_weight0 * util::getColumnAt<DIM, SIGMA_DIM>(0, sigmaX);
247-
for (size_t i{ 1 }; i < SIGMA_DIM; ++i)
247+
for (int32_t i{ 1 }; i < SIGMA_DIM; ++i)
248248
{
249249
vecX += m_weighti * util::getColumnAt<DIM, SIGMA_DIM>(i, sigmaX); // y += W[0, i] Y[:, i]
250250
}
@@ -270,7 +270,7 @@ namespace kf
270270
m_weight0 * (devXi * devYi.transpose())
271271
};
272272

273-
for (size_t i{ 1 }; i < SIGMA_DIM; ++i)
273+
for (int32_t i{ 1 }; i < SIGMA_DIM; ++i)
274274
{
275275
devXi = util::getColumnAt<DIM_X, SIGMA_DIM>(i, sigmaX) - vecX; // X[:, i] - \bar{x}
276276
devYi = util::getColumnAt<DIM_Z, SIGMA_DIM>(i, sigmaY) - vecY; // Y[:, i] - \bar{y}

src/openkf/kalman_filter/unscented_kalman_filter.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ namespace kf
4040
///
4141
void setCovarianceQ(const Matrix<DIM_V, DIM_V> & matQ)
4242
{
43-
const size_t S_IDX{ DIM_X };
44-
const size_t L_IDX{ S_IDX + DIM_V };
43+
const int32_t S_IDX{ DIM_X };
44+
const int32_t L_IDX{ S_IDX + DIM_V };
4545

46-
for (size_t i{ S_IDX }; i < L_IDX; ++i)
46+
for (int32_t i{ S_IDX }; i < L_IDX; ++i)
4747
{
48-
for (size_t j{ S_IDX }; j < L_IDX; ++j)
48+
for (int32_t j{ S_IDX }; j < L_IDX; ++j)
4949
{
5050
m_matPa(i, j) = matQ(i - S_IDX, j - S_IDX);
5151
}
@@ -58,12 +58,12 @@ namespace kf
5858
///
5959
void setCovarianceR(const Matrix<DIM_N, DIM_N> & matR)
6060
{
61-
const size_t S_IDX{ DIM_X + DIM_V };
62-
const size_t L_IDX{ S_IDX + DIM_N };
61+
const int32_t S_IDX{ DIM_X + DIM_V };
62+
const int32_t L_IDX{ S_IDX + DIM_N };
6363

64-
for (size_t i{ S_IDX }; i < L_IDX; ++i)
64+
for (int32_t i{ S_IDX }; i < L_IDX; ++i)
6565
{
66-
for (size_t j{ S_IDX }; j < L_IDX; ++j)
66+
for (int32_t j{ S_IDX }; j < L_IDX; ++j)
6767
{
6868
m_matPa(i, j) = matR(i - S_IDX, j - S_IDX);
6969
}
@@ -105,7 +105,7 @@ namespace kf
105105
// y_sigmas = np.zeros((self.dim_x, self.n_sigma))
106106
// for i in range(self.n_sigma):
107107
// y_sigmas[:, i] = f(xx_sigmas[:, i], xv_sigmas[:, i])
108-
for (size_t i{ 0 }; i < SIGMA_DIM; ++i)
108+
for (int32_t i{ 0 }; i < SIGMA_DIM; ++i)
109109
{
110110
const Vector<DIM_X> sigmaXxi{ util::getColumnAt<DIM_X, SIGMA_DIM>(i, sigmaXx) };
111111
const Vector<DIM_V> sigmaXvi{ util::getColumnAt<DIM_V, SIGMA_DIM>(i, sigmaXv) };
@@ -150,7 +150,7 @@ namespace kf
150150
// for i in range(self.n_sigma) :
151151
// y_sigmas[:, i] = h(xx_sigmas[:, i], xn_sigmas[:, i])
152152
Matrix<DIM_Z, SIGMA_DIM> sigmaY;
153-
for (size_t i{ 0 }; i < SIGMA_DIM; ++i)
153+
for (int32_t i{ 0 }; i < SIGMA_DIM; ++i)
154154
{
155155
const Vector<DIM_X> sigmaXxi{ util::getColumnAt<DIM_X, SIGMA_DIM>(i, sigmaXx) };
156156
const Vector<DIM_N> sigmaXni{ util::getColumnAt<DIM_N, SIGMA_DIM>(i, sigmaXn) };
@@ -194,7 +194,7 @@ namespace kf
194194
///
195195
void updateAugmentedVecX()
196196
{
197-
for (size_t i{ 0 }; i < DIM_X; ++i)
197+
for (int32_t i{ 0 }; i < DIM_X; ++i)
198198
{
199199
m_vecXa[i] = m_vecX[i];
200200
}
@@ -205,9 +205,9 @@ namespace kf
205205
///
206206
void updateAugmentedMatP()
207207
{
208-
for (size_t i{ 0 }; i < DIM_X; ++i)
208+
for (int32_t i{ 0 }; i < DIM_X; ++i)
209209
{
210-
for (size_t j{ 0 }; j < DIM_X; ++j)
210+
for (int32_t j{ 0 }; j < DIM_X; ++j)
211211
{
212212
m_matPa(i, j) = m_matP(i, j);
213213
}
@@ -251,10 +251,10 @@ namespace kf
251251
// X_0 = \bar{xa}
252252
util::copyToColumn< DIM_A, SIGMA_DIM >(0, sigmaXa, vecXa);
253253

254-
for (size_t i{ 0 }; i < DIM_A; ++i)
254+
for (int32_t i{ 0 }; i < DIM_A; ++i)
255255
{
256-
const size_t IDX_1{ i + 1 };
257-
const size_t IDX_2{ i + DIM_A + 1 };
256+
const int32_t IDX_1{ i + 1 };
257+
const int32_t IDX_2{ i + DIM_A + 1 };
258258

259259
util::copyToColumn< DIM_A, SIGMA_DIM >(IDX_1, sigmaXa, vecXa);
260260
util::copyToColumn< DIM_A, SIGMA_DIM >(IDX_2, sigmaXa, vecXa);
@@ -279,7 +279,7 @@ namespace kf
279279
{
280280
// 1. calculate mean: \bar{y} = \sum_{i_0}^{2n} W[0, i] Y[:, i]
281281
vecX = m_weight0 * util::getColumnAt<STATE_DIM, SIGMA_DIM>(0, sigmaX);
282-
for (size_t i{ 1 }; i < SIGMA_DIM; ++i)
282+
for (int32_t i{ 1 }; i < SIGMA_DIM; ++i)
283283
{
284284
vecX += m_weighti * util::getColumnAt<STATE_DIM, SIGMA_DIM>(i, sigmaX); // y += W[0, i] Y[:, i]
285285
}
@@ -288,7 +288,7 @@ namespace kf
288288
Vector<STATE_DIM> devXi{ util::getColumnAt<STATE_DIM, SIGMA_DIM>(0, sigmaX) - vecX }; // Y[:, 0] - \bar{ y }
289289
matPxx = m_weight0 * devXi * devXi.transpose(); // P_0 = W[0, 0] (Y[:, 0] - \bar{y}) (Y[:, 0] - \bar{y})^T
290290

291-
for (size_t i{ 1 }; i < SIGMA_DIM; ++i)
291+
for (int32_t i{ 1 }; i < SIGMA_DIM; ++i)
292292
{
293293
devXi = util::getColumnAt<STATE_DIM, SIGMA_DIM>(i, sigmaX) - vecX; // Y[:, i] - \bar{y}
294294

@@ -318,7 +318,7 @@ namespace kf
318318
m_weight0 * (devXi * devYi.transpose())
319319
};
320320

321-
for (size_t i{ 1 }; i < SIGMA_DIM; ++i)
321+
for (int32_t i{ 1 }; i < SIGMA_DIM; ++i)
322322
{
323323
devXi = util::getColumnAt<DIM_X, SIGMA_DIM>(i, sigmaX) - vecX; // X[:, i] - \bar{x}
324324
devYi = util::getColumnAt<DIM_Z, SIGMA_DIM>(i, sigmaY) - vecY; // Y[:, i] - \bar{y}

src/openkf/kalman_filter/unscented_transform.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
namespace kf
2020
{
21-
template<size_t DIM>
21+
template<int32_t DIM>
2222
class UnscentedTransform
2323
{
2424
public:
25-
static constexpr size_t SIGMA_DIM{ (2 * DIM) + 1 };
25+
static constexpr int32_t SIGMA_DIM{ (2 * DIM) + 1 };
2626

2727
UnscentedTransform() {}
2828
~UnscentedTransform() {}
@@ -45,12 +45,12 @@ namespace kf
4545
updateSigmaPoints(vecX, matPxx, kappa);
4646
}
4747

48-
template<size_t DIM_X>
48+
template<int32_t DIM_X>
4949
void calculateWeightedMeanAndCovariance(const Matrix<DIM_X, SIGMA_DIM> & sigmaX, Vector<DIM_X> & vecX, Matrix<DIM_X, DIM_X> & matPxx)
5050
{
5151
// 1. calculate mean: \bar{y} = \sum_{i_0}^{2n} W[0, i] Y[:, i]
5252
vecX = _weights[0] * util::getColumnAt<DIM_X, SIGMA_DIM>(0, sigmaX);
53-
for (size_t i{ 1 }; i < SIGMA_DIM; ++i)
53+
for (int32_t i{ 1 }; i < SIGMA_DIM; ++i)
5454
{
5555
vecX += _weights[1] * util::getColumnAt<DIM_X, SIGMA_DIM>(i, sigmaX); // y += W[0, i] Y[:, i]
5656
}
@@ -59,7 +59,7 @@ namespace kf
5959
Vector<DIM_X> devXi{ util::getColumnAt<DIM_X, SIGMA_DIM>(0, sigmaX) - vecX }; // Y[:, 0] - \bar{ y }
6060
matPxx = _weights[0] * devXi * devXi.transpose(); // P_0 = W[0, 0] (Y[:, 0] - \bar{y}) (Y[:, 0] - \bar{y})^T
6161

62-
for (size_t i{ 1 }; i < SIGMA_DIM; ++i)
62+
for (int32_t i{ 1 }; i < SIGMA_DIM; ++i)
6363
{
6464
devXi = util::getColumnAt<DIM_X, SIGMA_DIM>(i, sigmaX) - vecX; // Y[:, i] - \bar{y}
6565

@@ -145,10 +145,10 @@ namespace kf
145145
// X_0 = \bar{x}
146146
util::copyToColumn< DIM, SIGMA_DIM >(0, _sigmaX, vecX);
147147

148-
for (size_t i{ 0 }; i < DIM; ++i)
148+
for (int32_t i{ 0 }; i < DIM; ++i)
149149
{
150-
const size_t IDX_1{ i + 1 };
151-
const size_t IDX_2{ i + DIM + 1 };
150+
const int32_t IDX_1{ i + 1 };
151+
const int32_t IDX_2{ i + DIM + 1 };
152152

153153
util::copyToColumn< DIM, SIGMA_DIM >(IDX_1, _sigmaX, vecX);
154154
util::copyToColumn< DIM, SIGMA_DIM >(IDX_2, _sigmaX, vecX);
@@ -168,7 +168,7 @@ namespace kf
168168
template<typename NonLinearFunctionCallback>
169169
void transformSigmaPoints(NonLinearFunctionCallback nonlinearFunction, Matrix<DIM, SIGMA_DIM> & sigmaY)
170170
{
171-
for (size_t i{ 0 }; i < SIGMA_DIM; ++i)
171+
for (int32_t i{ 0 }; i < SIGMA_DIM; ++i)
172172
{
173173
const Vector<DIM> x{ util::getColumnAt<DIM, SIGMA_DIM>(i, _sigmaX) };
174174
const Vector<DIM> y{ nonlinearFunction(x) }; // y = f(x)
@@ -187,7 +187,7 @@ namespace kf
187187
{
188188
// 1. calculate mean: \bar{y} = \sum_{i_0}^{2n} W[0, i] Y[:, i]
189189
vecY = _weights[0] * util::getColumnAt<DIM, SIGMA_DIM>(0, sigmaY);
190-
for (size_t i{ 1 }; i < SIGMA_DIM; ++i)
190+
for (int32_t i{ 1 }; i < SIGMA_DIM; ++i)
191191
{
192192
vecY += _weights[1] * util::getColumnAt<DIM, SIGMA_DIM>(i, sigmaY); // y += W[0, i] Y[:, i]
193193
}
@@ -196,7 +196,7 @@ namespace kf
196196
Vector<DIM> devYi{ util::getColumnAt<DIM, SIGMA_DIM>(0, sigmaY) - vecY }; // Y[:, 0] - \bar{ y }
197197
matPyy = _weights[0] * devYi * devYi.transpose(); // P_0 = W[0, 0] (Y[:, 0] - \bar{y}) (Y[:, 0] - \bar{y})^T
198198

199-
for (size_t i{ 1 }; i < SIGMA_DIM; ++i)
199+
for (int32_t i{ 1 }; i < SIGMA_DIM; ++i)
200200
{
201201
devYi = util::getColumnAt<DIM, SIGMA_DIM>(i, sigmaY) - vecY; // Y[:, i] - \bar{y}
202202

0 commit comments

Comments
 (0)