MCPcopy Create free account
hub / github.com/Rhoban/placo / test_expr_t

Method test_expr_t

python/tests/problem_test.py:261–284  ·  view source on GitHub ↗

Testing expr_t, that allows adding constraints that are not aligned with integrator timesteps

(self)

Source from the content-addressed store, hash-verified

259 self.assertRaises(RuntimeError, problem.solve)
260
261 def test_expr_t(self):
262 """
263 Testing expr_t, that allows adding constraints that are not aligned with integrator timesteps
264 """
265 problem = placo.Problem()
266
267 xdd = problem.add_variable(10)
268 integrator = placo.Integrator(xdd, np.array([0.0, 0.0]), 2, 0.1)
269
270 # Adding constraint non aligned with timesteps
271 problem.add_constraint(integrator.expr_t(0.5, 0) == 1.5)
272 problem.add_constraint(integrator.expr_t(0.51, 0) == 2.5)
273
274 for k in range(10):
275 problem.add_limit(integrator.expr(k, 0), np.array([3.0]))
276
277 problem.add_constraint(integrator.expr_t(1.0, 0) == 0.0)
278
279 problem.solve()
280
281 self.assertNumpyEqual(integrator.value(0.0, 0), 0.0)
282 self.assertNumpyEqual(integrator.value(0.5, 0), 1.5)
283 self.assertNumpyEqual(integrator.value(0.51, 0), 2.5)
284 self.assertNumpyEqual(integrator.value(1.0, 0), 0.0)
285
286 def test_integrator_zmp(self):
287 """

Callers

nothing calls this directly

Calls 8

expr_tMethod · 0.95
exprMethod · 0.95
solveMethod · 0.95
assertNumpyEqualMethod · 0.95
ProblemMethod · 0.80
IntegratorMethod · 0.80
add_constraintMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected