319 unsigned int numsubstep,
339 ts.
cache = (cache) ? 1 : 0;
341 ts.
numstep = (numsubstep & 0xFF);
342 bool autosubstep = (numsubstep == 0) ?
true :
false;
343 if (numsubstep < 1) {
346 double timesubstep = timestep / numsubstep;
347 double timeleft = timestep;
349 if (timeleft == 0.0) {
351 for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
352 it->second->object->pushCache(ts);
355 for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
356 it->second->task->pushCache(ts);
368 while (numsubstep > 0) {
370 for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
371 Object_struct *os = it->second;
372 if (os->object->
getType() == Object::Controlled) {
374 if (os->constraintrange.
count > 0) {
376 os->constraintrange) = ((
ControlledObject *)(os->object))->getControlOutput();
381 if (os->jointrange.
count > 0) {
383 m_Wq, os->jointrange, os->jointrange) = ((
ControlledObject *)(os->object))->getWq();
386 if (os->object->
getType() == Object::UnControlled &&
397 for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
398 ConstraintSet_struct *cs = it->second;
399 Object_struct *ob1 = cs->object1->second;
400 Object_struct *ob2 = cs->object2->second;
406 getConstraintPose(cs->task, cs, external_pose);
412 project(m_Wy, cs->constraintrange) = (cs->task)->getWy();
416 project(m_Jf, cs->featurerange, cs->featurerange) = cs->task->
getJf();
419 Eigen::Block<e_matrix> Jf_part =
project(m_Jf, cs->featurerange, cs->featurerange);
421 ob1->base->
getPose(ob1->baseFrameIndex) * ob1->object->
getPose(cs->ee1index));
426 project(m_Jf, cs->featurerange, cs->featurerange), m_Uf, m_Sf, m_Vf, m_tempf);
427 for (
unsigned int i = 0;
i < 6; ++
i)
429 m_Uf.col(
i).setConstant(0.0);
431 m_Uf.col(
i) *= (1 / m_Sf(
i));
432 project(m_Jf_inv, cs->featurerange, cs->featurerange).noalias() = m_Vf * m_Uf.transpose();
437 if (ob1->object->
getType() == Object::Controlled) {
440 ob1->jointrange) = (((
ControlledObject *)(ob1->object))->getJq(cs->ee1index));
442 Eigen::Block<e_matrix> Jq_part =
project(m_Jq, cs->featurerange, ob1->jointrange);
447 project(m_Ju, cs->featurerange, ob1->coordinaterange) = ob1->base->
getJu(
448 ob1->baseFrameIndex);
451 else if (ob1->object->
getType() == Object::UnControlled &&
458 if (ob2->object->
getType() == Object::Controlled) {
462 if (ob1->object == ob2->object) {
468 project(m_Jq, cs->featurerange, ob2->jointrange) -= JqTemp;
471 project(m_Jq, cs->featurerange, ob2->jointrange) = -(
474 Eigen::Block<e_matrix> Jq_part =
project(m_Jq, cs->featurerange, ob2->jointrange);
480 if (ob2->base == ob1->base || ob2->base == ob1->object) {
481 project(m_Ju, cs->featurerange, ob2->coordinaterange) -= ob2->base->
getJu(
482 ob2->baseFrameIndex);
485 project(m_Ju, cs->featurerange, ob2->coordinaterange) = -ob2->base->
getJu(
486 ob2->baseFrameIndex);
490 else if (ob2->object->
getType() == Object::UnControlled &&
492 if (ob2->object == ob1->base || ob2->object == ob1->object) {
493 project(m_Ju, cs->featurerange, ob2->coordinaterange) -=
497 project(m_Ju, cs->featurerange, ob2->coordinaterange) =
504 m_Atemp.noalias() = m_Cf * m_Jf_inv;
505 m_A.noalias() = m_Cq - (m_Atemp * m_Jq);
507 m_B.noalias() = m_Atemp * m_Ju;
508 m_ydot.noalias() += m_B * m_xdot;
512 if (!m_solver->solve(m_A, m_Wy, m_ydot, m_Wq, m_qdot, nlcoef))
516 for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
517 Object_struct *os = it->second;
518 if (os->object->
getType() == Object::Controlled)
522 for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
523 ConstraintSet_struct *cs = it->second;
524 Object_struct *ob1 = cs->object1->second;
525 Object_struct *ob2 = cs->object2->second;
528 if (ob1->jointrange.
count > 0)
529 external_vel.noalias() += (
project(m_Jq, cs->featurerange, ob1->jointrange) *
530 project(m_qdot, ob1->jointrange));
531 if (ob2->jointrange.
count > 0)
532 external_vel.noalias() += (
project(m_Jq, cs->featurerange, ob2->jointrange) *
533 project(m_qdot, ob2->jointrange));
534 if (ob1->coordinaterange.
count > 0)
535 external_vel.noalias() += (
project(m_Ju, cs->featurerange, ob1->coordinaterange) *
536 project(m_xdot, ob1->coordinaterange));
537 if (ob2->coordinaterange.
count > 0)
538 external_vel.noalias() += (
project(m_Ju, cs->featurerange, ob2->coordinaterange) *
539 project(m_xdot, ob2->coordinaterange));
542 e_vector6 estimated_chidot =
project(m_Jf_inv, cs->featurerange, cs->featurerange) *
551 timesubstep = timeleft;
554 double maxsubstep = nlcoef * m_maxstep;
555 if (maxsubstep < m_minstep)
556 maxsubstep = m_minstep;
557 if (timesubstep > maxsubstep)
558 timesubstep = maxsubstep;
559 for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
560 Object_struct *os = it->second;
561 if (os->object->
getType() == Object::Controlled)
564 for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
565 ConstraintSet_struct *cs = it->second;
569 maxsubstep = 2.0 *
floor(timestep / 2.0 / timesubstep - 0.66666);
570 timesubstep = (maxsubstep < 0.0) ? timestep : timestep / (2.0 + maxsubstep);
571 if (timesubstep >= timeleft - (m_minstep / 2.0)) {
572 timesubstep = timeleft;
578 timeleft -= timesubstep;
581 if (numsubstep > 1) {
594 ObjectMap::iterator it;
597 for (it = objects.begin(); it != objects.end(); ++it) {
599 if (os->object->
getType() == Object::Controlled) {
600 lockCallback.
setRange(os->jointrange);
611 if (!m_solver->solve(m_A, m_Wy, m_ydot, m_Wq, m_qdot, nlcoef))
616 for (it = objects.begin(); it != objects.end(); ++it) {
618 if (os->object->
getType() == Object::Controlled)
625 for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
626 it->second->object->updateKinematics(ts);
629 it->second->object->updated(
false);
632 for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
633 ConstraintSet_struct *cs = it->second;
635 getConstraintPose(cs->task, cs, external_pose);