312 unsigned int numsubstep,
331 ts.
cache = (cache) ? 1 : 0;
333 ts.
numstep = (numsubstep & 0xFF);
334 bool autosubstep = (numsubstep == 0) ?
true :
false;
337 double timesubstep = timestep / numsubstep;
338 double timeleft = timestep;
340 if (timeleft == 0.0) {
342 for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
343 it->second->object->pushCache(ts);
346 for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
347 it->second->task->pushCache(ts);
359 while (numsubstep > 0) {
361 for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
362 Object_struct *os = it->second;
363 if (os->object->
getType() == Object::Controlled) {
365 if (os->constraintrange.
count > 0) {
367 os->constraintrange) = ((
ControlledObject *)(os->object))->getControlOutput();
372 if (os->jointrange.
count > 0) {
374 m_Wq, os->jointrange, os->jointrange) = ((
ControlledObject *)(os->object))->getWq();
377 if (os->object->
getType() == Object::UnControlled &&
388 for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
389 ConstraintSet_struct *cs = it->second;
390 Object_struct *ob1 = cs->object1->second;
391 Object_struct *ob2 = cs->object2->second;
397 getConstraintPose(cs->task, cs, external_pose);
403 project(m_Wy, cs->constraintrange) = (cs->task)->getWy();
407 project(m_Jf, cs->featurerange, cs->featurerange) = cs->task->
getJf();
410 Eigen::Block<e_matrix> Jf_part =
project(m_Jf, cs->featurerange, cs->featurerange);
412 ob1->base->
getPose(ob1->baseFrameIndex) * ob1->object->
getPose(cs->ee1index));
417 project(m_Jf, cs->featurerange, cs->featurerange), m_Uf, m_Sf, m_Vf, m_tempf);
418 for (
unsigned int i = 0; i < 6; ++i)
420 m_Uf.col(i).setConstant(0.0);
422 m_Uf.col(i) *= (1 / m_Sf(i));
423 project(m_Jf_inv, cs->featurerange, cs->featurerange).noalias() = m_Vf * m_Uf.transpose();
428 if (ob1->object->
getType() == Object::Controlled) {
431 ob1->jointrange) = (((
ControlledObject *)(ob1->object))->getJq(cs->ee1index));
433 Eigen::Block<e_matrix> Jq_part =
project(m_Jq, cs->featurerange, ob1->jointrange);
438 project(m_Ju, cs->featurerange, ob1->coordinaterange) = ob1->base->
getJu(
439 ob1->baseFrameIndex);
442 else if (ob1->object->
getType() == Object::UnControlled &&
449 if (ob2->object->
getType() == Object::Controlled) {
453 if (ob1->object == ob2->object) {
459 project(m_Jq, cs->featurerange, ob2->jointrange) -= JqTemp;
462 project(m_Jq, cs->featurerange, ob2->jointrange) = -(
465 Eigen::Block<e_matrix> Jq_part =
project(m_Jq, cs->featurerange, ob2->jointrange);
471 if (ob2->base == ob1->base || ob2->base == ob1->object) {
472 project(m_Ju, cs->featurerange, ob2->coordinaterange) -= ob2->base->
getJu(
473 ob2->baseFrameIndex);
476 project(m_Ju, cs->featurerange, ob2->coordinaterange) = -ob2->base->
getJu(
477 ob2->baseFrameIndex);
481 else if (ob2->object->
getType() == Object::UnControlled &&
483 if (ob2->object == ob1->base || ob2->object == ob1->object) {
484 project(m_Ju, cs->featurerange, ob2->coordinaterange) -=
488 project(m_Ju, cs->featurerange, ob2->coordinaterange) =
495 m_Atemp.noalias() = m_Cf * m_Jf_inv;
496 m_A.noalias() = m_Cq - (m_Atemp * m_Jq);
498 m_B.noalias() = m_Atemp * m_Ju;
499 m_ydot.noalias() += m_B * m_xdot;
503 if (!m_solver->
solve(m_A, m_Wy, m_ydot, m_Wq, m_qdot, nlcoef))
507 for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
508 Object_struct *os = it->second;
509 if (os->object->
getType() == Object::Controlled)
513 for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
514 ConstraintSet_struct *cs = it->second;
515 Object_struct *ob1 = cs->object1->second;
516 Object_struct *ob2 = cs->object2->second;
519 if (ob1->jointrange.
count > 0)
520 external_vel.noalias() += (
project(m_Jq, cs->featurerange, ob1->jointrange) *
521 project(m_qdot, ob1->jointrange));
522 if (ob2->jointrange.
count > 0)
523 external_vel.noalias() += (
project(m_Jq, cs->featurerange, ob2->jointrange) *
524 project(m_qdot, ob2->jointrange));
525 if (ob1->coordinaterange.
count > 0)
526 external_vel.noalias() += (
project(m_Ju, cs->featurerange, ob1->coordinaterange) *
527 project(m_xdot, ob1->coordinaterange));
528 if (ob2->coordinaterange.
count > 0)
529 external_vel.noalias() += (
project(m_Ju, cs->featurerange, ob2->coordinaterange) *
530 project(m_xdot, ob2->coordinaterange));
533 e_vector6 estimated_chidot =
project(m_Jf_inv, cs->featurerange, cs->featurerange) *
542 timesubstep = timeleft;
545 double maxsubstep = nlcoef * m_maxstep;
546 if (maxsubstep < m_minstep)
547 maxsubstep = m_minstep;
548 if (timesubstep > maxsubstep)
549 timesubstep = maxsubstep;
550 for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
551 Object_struct *os = it->second;
552 if (os->object->
getType() == Object::Controlled)
555 for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
556 ConstraintSet_struct *cs = it->second;
560 maxsubstep = 2.0 *
floor(timestep / 2.0 / timesubstep - 0.66666);
561 timesubstep = (maxsubstep < 0.0) ? timestep : timestep / (2.0 + maxsubstep);
562 if (timesubstep >= timeleft - (m_minstep / 2.0)) {
563 timesubstep = timeleft;
569 timeleft -= timesubstep;
572 if (numsubstep > 1) {
585 ObjectMap::iterator it;
588 for (it = objects.begin(); it != objects.end(); ++it) {
590 if (os->object->
getType() == Object::Controlled) {
591 lockCallback.
setRange(os->jointrange);
602 if (!m_solver->
solve(m_A, m_Wy, m_ydot, m_Wq, m_qdot, nlcoef))
607 for (it = objects.begin(); it != objects.end(); ++it) {
609 if (os->object->
getType() == Object::Controlled)
616 for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
620 it->second->object->updated(
false);
623 for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
624 ConstraintSet_struct *cs = it->second;
626 getConstraintPose(cs->task, cs, external_pose);