Skip to content

Commit 666b81d

Browse files
committed
fix CMakeLists and add tests
1 parent 67237dd commit 666b81d

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

ocs2_ipm/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ if(cmake_clang_tools_FOUND)
7373
TARGETS ${PROJECT_NAME}
7474
SOURCE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/test
7575
CT_HEADER_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
76-
CF_FIX
76+
CF_WERROR
7777
)
7878
endif(cmake_clang_tools_FOUND)
7979

ocs2_ipm/test/Exp0Test.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,10 @@ TEST(Exp0Test, Constrained) {
168168
ASSERT_TRUE(umax - u(0) >= 0);
169169
}
170170
}
171+
172+
// solve with shifted horizon
173+
const scalar_array_t shiftTime = {0.05, 0.1, 0.3, 0.5, 0.8, 0.12, 0.16, 0.19};
174+
for (const auto e : shiftTime) {
175+
solver.run(startTime + e, initState, finalTime + e);
176+
}
171177
}

ocs2_ipm/test/Exp1Test.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ TEST(Exp1Test, Constrained) {
197197
ASSERT_TRUE(umax - u(0) >= 0);
198198
}
199199
}
200+
201+
// solve with shifted horizon
202+
const scalar_array_t shiftTime = {0.05, 0.1, 0.3, 0.5, 0.8, 0.12, 0.16, 0.19};
203+
for (const auto e : shiftTime) {
204+
solver.run(startTime + e, initState, finalTime + e);
205+
}
200206
}
201207

202208
TEST(Exp1Test, MixedConstrained) {
@@ -257,4 +263,10 @@ TEST(Exp1Test, MixedConstrained) {
257263
const auto constraintValue = stateInputIneqConstraintCloned->getValue(t, x, u, PreComputation());
258264
ASSERT_TRUE(constraintValue.minCoeff() >= 0.0);
259265
}
266+
267+
// solve with shifted horizon
268+
const scalar_array_t shiftTime = {0.05, 0.1, 0.3, 0.5, 0.8, 0.12, 0.16, 0.19};
269+
for (const auto e : shiftTime) {
270+
solver.run(startTime + e, initState, finalTime + e);
271+
}
260272
}

ocs2_ipm/test/testCircularKinematics.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ TEST(test_circular_kinematics, solve_projected_EqConstraints_IneqConstraints) {
238238
// Feed forward part
239239
ASSERT_TRUE(u.isApprox(primalSolution.controllerPtr_->computeInput(t, x)));
240240
}
241+
242+
// solve with shifted horizon
243+
const scalar_array_t shiftTime = {0.05, 0.1, 0.3, 0.5, 0.8, 0.12, 0.16, 0.19};
244+
for (const auto e : shiftTime) {
245+
solver.run(startTime + e, initState, finalTime + e);
246+
}
241247
}
242248

243249
TEST(test_circular_kinematics, solve_projected_EqConstraints_MixedIneqConstraints) {
@@ -326,10 +332,15 @@ TEST(test_circular_kinematics, solve_projected_EqConstraints_MixedIneqConstraint
326332

327333
// Check Lagrange multipliers
328334
for (int i = 0; i < primalSolution.timeTrajectory_.size() - 1; i++) {
329-
std::cerr << "i: " << i << std::endl;
330335
const auto t = primalSolution.timeTrajectory_[i];
331336
const auto& x = primalSolution.stateTrajectory_[i];
332337
const auto& u = primalSolution.inputTrajectory_[i];
333338
ASSERT_NO_THROW(const auto multiplier = solver.getStateInputEqualityConstraintLagrangian(t, x););
334339
}
340+
341+
// solve with shifted horizon
342+
const scalar_array_t shiftTime = {0.05, 0.1, 0.3, 0.5, 0.8, 0.12, 0.16, 0.19};
343+
for (const auto e : shiftTime) {
344+
solver.run(startTime + e, initState, finalTime + e);
345+
}
335346
}

0 commit comments

Comments
 (0)