本文整理汇总了C++中StatesTrajectory::isCompatibleWith方法的典型用法代码示例。如果您正苦于以下问题:C++ StatesTrajectory::isCompatibleWith方法的具体用法?C++ StatesTrajectory::isCompatibleWith怎么用?C++ StatesTrajectory::isCompatibleWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StatesTrajectory
的用法示例。
在下文中一共展示了StatesTrajectory::isCompatibleWith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testIntegrityChecks
void testIntegrityChecks() {
Model arm26("arm26.osim");
const auto& s26 = arm26.initSystem();
Model gait2354("gait2354_simbody.osim");
const auto& s2354 = gait2354.initSystem();
// TODO add models with events, unilateral constraints, etc.
// Times are nondecreasing.
{
StatesTrajectory states;
auto state0(s26);
state0.setTime(0.5);
auto state1(s26);
state1.setTime(0.6);
states.append(state0);
states.append(state1);
SimTK_TEST(states.isConsistent());
SimTK_TEST(states.isNondecreasingInTime());
SimTK_TEST(states.hasIntegrity());
// Users should never do this const cast; it's just for the sake of
// the test.
const_cast<SimTK::State*>(&states[1])->setTime(0.2);
SimTK_TEST(states.isConsistent());
SimTK_TEST(!states.isNondecreasingInTime());
SimTK_TEST(!states.hasIntegrity());
}
// Consistency and compatibility with a model.
{
StatesTrajectory states;
// An empty trajectory is consistent.
SimTK_TEST(states.isConsistent());
// A length-1 trajectory is consistent.
states.append(s26);
SimTK_TEST(states.isConsistent());
// This trajectory is compatible with the arm26 model.
SimTK_TEST(states.isCompatibleWith(arm26));
// Not compatible with gait2354 model.
// Ensures a lower-dimensional trajectory can't pass for a higher
// dimensional model.
SimTK_TEST(!states.isCompatibleWith(gait2354));
// The checks still work with more than 1 state.
states.append(s26);
states.append(s26);
SimTK_TEST(states.isNondecreasingInTime());
SimTK_TEST(states.isConsistent());
SimTK_TEST(states.hasIntegrity());
SimTK_TEST(states.isCompatibleWith(arm26));
SimTK_TEST(!states.isCompatibleWith(gait2354));
}
{
StatesTrajectory states;
states.append(s2354);
// Reverse of the previous check; to ensure that a larger-dimensional
// trajectory can't pass for the smaller dimensional model.
SimTK_TEST(states.isCompatibleWith(gait2354));
SimTK_TEST(!states.isCompatibleWith(arm26));
// Check still works with more than 1 state.
states.append(s2354);
states.append(s2354);
SimTK_TEST(states.isNondecreasingInTime());
SimTK_TEST(states.isConsistent());
SimTK_TEST(states.hasIntegrity());
SimTK_TEST(states.isCompatibleWith(gait2354));
SimTK_TEST(!states.isCompatibleWith(arm26));
}
{
// Cannot append inconsistent states.
StatesTrajectory states;
states.append(s26);
SimTK_TEST_MUST_THROW_EXC(states.append(s2354),
StatesTrajectory::InconsistentState);
// Same check, but swap the models.
StatesTrajectory states2;
states2.append(s2354);
SimTK_TEST_MUST_THROW_EXC(states2.append(s26),
StatesTrajectory::InconsistentState);
}
// TODO Show weakness of the test: two models with the same number of Q's, U's,
// and Z's both pass the check.
}