Blender V5.0
Scene.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Ruben Smits
2 *
3 * SPDX-License-Identifier: LGPL-2.1-or-later */
4
8
9#include "Scene.hpp"
10#include "ControlledObject.hpp"
12#include <cstdio>
13
14namespace iTaSC {
15
17 private:
18 Scene *m_scene;
19 Range m_qrange;
20
21 public:
22 SceneLock(Scene *scene) : m_scene(scene), m_qrange(0, 0)
23 {
24 }
25 virtual ~SceneLock()
26 {
27 }
28
29 void setRange(Range &range)
30 {
31 m_qrange = range;
32 }
33 // lock a joint, no need to update output
34 virtual void lockJoint(unsigned int q_nr, unsigned int ndof)
35 {
36 q_nr += m_qrange.start;
37 project(m_scene->m_Wq, Range(q_nr, ndof), m_qrange).setZero();
38 }
39 // lock a joint and update output in view of reiteration
40 virtual void lockJoint(unsigned int q_nr, unsigned int ndof, double *qdot)
41 {
42 q_nr += m_qrange.start;
43 project(m_scene->m_Wq, Range(q_nr, ndof), m_qrange).setZero();
44 // update the output vector so that the movement of this joint will be
45 // taken into account and we can put the joint back in its initial position
46 // which means that the jacobian doesn't need to be changed
47 for (unsigned int i = 0; i < ndof; ++i, ++q_nr) {
48 m_scene->m_ydot -= m_scene->m_A.col(q_nr) * qdot[i];
49 }
50 }
51};
52
54 : m_A(),
55 m_B(),
56 m_Atemp(),
57 m_Wq(),
58 m_Jf(),
59 m_Jq(),
60 m_Ju(),
61 m_Cf(),
62 m_Cq(),
63 m_Jf_inv(),
64 m_Vf(),
65 m_Uf(),
66 m_Wy(),
67 m_ydot(),
68 m_qdot(),
69 m_xdot(),
70 m_Sf(),
71 m_tempf(),
72 m_ncTotal(0),
73 m_nqTotal(0),
74 m_nuTotal(0),
75 m_nsets(0),
76 m_solver(NULL),
77 m_cache(NULL)
78{
79 m_minstep = 0.01;
80 m_maxstep = 0.06;
81}
82
84{
85 ConstraintMap::iterator constraint_it;
86 while ((constraint_it = constraints.begin()) != constraints.end()) {
87 delete constraint_it->second;
88 constraints.erase(constraint_it);
89 }
90 ObjectMap::iterator object_it;
91 while ((object_it = objects.begin()) != objects.end()) {
92 delete object_it->second;
93 objects.erase(object_it);
94 }
95}
96
97bool Scene::setParam(SceneParam paramId, double value)
98{
99 switch (paramId) {
100 case MIN_TIMESTEP:
101 m_minstep = value;
102 break;
103 case MAX_TIMESTEP:
104 m_maxstep = value;
105 break;
106 default:
107 return false;
108 }
109 return true;
110}
111
112bool Scene::addObject(const std::string &name,
113 Object *object,
114 UncontrolledObject *base,
115 const std::string &baseFrame)
116{
117 // finalize the object before adding
118 if (!object->finalize()) {
119 return false;
120 }
121 // Check if Object is controlled or uncontrolled.
122 if (object->getType() == Object::Controlled) {
123 int baseFrameIndex = base->addEndEffector(baseFrame);
124 if (baseFrameIndex < 0)
125 return false;
126 std::pair<ObjectMap::iterator, bool> result;
127 if (base->getNrOfCoordinates() == 0) {
128 // base is fixed object, no coordinate range
129 result = objects.insert(ObjectMap::value_type(
130 name,
131 new Object_struct(object,
132 base,
133 baseFrameIndex,
134 Range(m_nqTotal, object->getNrOfCoordinates()),
135 Range(m_ncTotal, ((ControlledObject *)object)->getNrOfConstraints()),
136 Range(0, 0))));
137 }
138 else {
139 // base is a moving object, must be in list already
140 ObjectMap::iterator base_it;
141 for (base_it = objects.begin(); base_it != objects.end(); base_it++) {
142 if (base_it->second->object == base)
143 break;
144 }
145 if (base_it == objects.end())
146 return false;
147 result = objects.insert(ObjectMap::value_type(
148 name,
149 new Object_struct(object,
150 base,
151 baseFrameIndex,
152 Range(m_nqTotal, object->getNrOfCoordinates()),
153 Range(m_ncTotal, ((ControlledObject *)object)->getNrOfConstraints()),
154 base_it->second->coordinaterange)));
155 }
156 if (!result.second) {
157 return false;
158 }
159 m_nqTotal += object->getNrOfCoordinates();
160 m_ncTotal += ((ControlledObject *)object)->getNrOfConstraints();
161 return true;
162 }
163 if (object->getType() == Object::UnControlled) {
164 if ((WorldObject *)base != &Object::world)
165 return false;
166 std::pair<ObjectMap::iterator, bool> result = objects.insert(
167 ObjectMap::value_type(name,
168 new Object_struct(object,
169 base,
170 0,
171 Range(0, 0),
172 Range(0, 0),
173 Range(m_nuTotal, object->getNrOfCoordinates()))));
174 if (!result.second)
175 return false;
176 m_nuTotal += object->getNrOfCoordinates();
177 return true;
178 }
179 return false;
180}
181
182bool Scene::addConstraintSet(const std::string &name,
183 ConstraintSet *task,
184 const std::string &object1,
185 const std::string &object2,
186 const std::string &ee1,
187 const std::string &ee2)
188{
189 // Check if objects exist:
190 ObjectMap::iterator object1_it = objects.find(object1);
191 ObjectMap::iterator object2_it = objects.find(object2);
192 if (object1_it == objects.end() || object2_it == objects.end()) {
193 return false;
194 }
195 int ee1_index = object1_it->second->object->addEndEffector(ee1);
196 int ee2_index = object2_it->second->object->addEndEffector(ee2);
197 if (ee1_index < 0 || ee2_index < 0) {
198 return false;
199 }
200 std::pair<ConstraintMap::iterator, bool> result = constraints.insert(ConstraintMap::value_type(
201 name,
202 new ConstraintSet_struct(task,
203 object1_it,
204 ee1_index,
205 object2_it,
206 ee2_index,
207 Range(m_ncTotal, task->getNrOfConstraints()),
208 Range(6 * m_nsets, 6))));
209 if (!result.second) {
210 return false;
211 }
212 m_ncTotal += task->getNrOfConstraints();
213 m_nsets += 1;
214 return true;
215}
216
217bool Scene::addSolver(Solver *_solver)
218{
219 if (m_solver == NULL) {
220 m_solver = _solver;
221 return true;
222 }
223 else
224 return false;
225}
226
227bool Scene::addCache(Cache *_cache)
228{
229 if (m_cache == NULL) {
230 m_cache = _cache;
231 return true;
232 }
233 else
234 return false;
235}
236
237bool Scene::initialize()
238{
239
240 // prepare all matrices:
241 if (m_ncTotal == 0 || m_nqTotal == 0 || m_nsets == 0) {
242 return false;
243 }
244
245 m_A = e_zero_matrix(m_ncTotal, m_nqTotal);
246 if (m_nuTotal > 0) {
247 m_B = e_zero_matrix(m_ncTotal, m_nuTotal);
248 m_xdot = e_zero_vector(m_nuTotal);
249 m_Ju = e_zero_matrix(6 * m_nsets, m_nuTotal);
250 }
251 m_Atemp = e_zero_matrix(m_ncTotal, 6 * m_nsets);
252 m_ydot = e_zero_vector(m_ncTotal);
253 m_qdot = e_zero_vector(m_nqTotal);
254 m_Wq = e_zero_matrix(m_nqTotal, m_nqTotal);
255 m_Wy = e_zero_vector(m_ncTotal);
256 m_Jq = e_zero_matrix(6 * m_nsets, m_nqTotal);
257 m_Jf = e_zero_matrix(6 * m_nsets, 6 * m_nsets);
258 m_Jf_inv = m_Jf;
259 m_Cf = e_zero_matrix(m_ncTotal, m_Jf.rows());
260 m_Cq = e_zero_matrix(m_ncTotal, m_nqTotal);
261
262 bool result = true;
263 // finalize all objects
264 for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
265 Object_struct *os = it->second;
266
267 os->object->initCache(m_cache);
268 if (os->constraintrange.count > 0)
269 project(m_Cq,
270 os->constraintrange,
271 os->jointrange) = (((ControlledObject *)(os->object))->getCq());
272 }
273
274 m_ytask.resize(m_ncTotal);
275 bool toggle = true;
276 int count = 0;
277 // Initialize all ConstraintSets:
278 for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
279 // Calculate the external pose:
280 ConstraintSet_struct *cs = it->second;
281 Frame external_pose;
282 getConstraintPose(cs->task, cs, external_pose);
283 result &= cs->task->initialise(external_pose);
284 cs->task->initCache(m_cache);
285 for (int i = 0; i < cs->constraintrange.count; i++, count++) {
286 m_ytask[count] = toggle;
287 }
288 toggle = !toggle;
289 project(m_Cf, cs->constraintrange, cs->featurerange) = cs->task->getCf();
290 }
291
292 if (m_solver != NULL) {
293 m_solver->init(m_nqTotal, m_ncTotal, m_ytask);
294 }
295 else {
296 return false;
297 }
298
299 return result;
300}
301
302bool Scene::getConstraintPose(ConstraintSet *constraint, void *_param, KDL::Frame &_pose)
303{
304 // function called from constraint when they need to get the external pose
305 ConstraintSet_struct *cs = (ConstraintSet_struct *)_param;
306 // verification, the pointer MUST match
307 assert(constraint == cs->task);
308 Object_struct *ob1 = cs->object1->second;
309 Object_struct *ob2 = cs->object2->second;
310 // Calculate the external pose:
311 _pose =
312 (ob1->base->getPose(ob1->baseFrameIndex) * ob1->object->getPose(cs->ee1index)).Inverse() *
313 (ob2->base->getPose(ob2->baseFrameIndex) * ob2->object->getPose(cs->ee2index));
314 return true;
315}
316
317bool Scene::update(double timestamp,
318 double timestep,
319 unsigned int numsubstep,
320 bool reiterate,
321 bool cache,
322 bool interpolate)
323{
324 // we must have valid timestep and timestamp
325 if (timestamp < KDL::epsilon || timestep < 0.0) {
326 return false;
327 }
328 Timestamp ts;
329 ts.realTimestamp = timestamp;
330 // initially we start with the full timestep to allow velocity estimation over the full interval
331 ts.realTimestep = timestep;
333 ts.substep = 0;
334 // for reiteration don't load cache
335 // reiteration=additional iteration with same timestamp if application finds the convergence not
336 // good enough
337 ts.reiterate = (reiterate) ? 1 : 0;
338 ts.interpolate = (interpolate) ? 1 : 0;
339 ts.cache = (cache) ? 1 : 0;
340 ts.update = 1;
341 ts.numstep = (numsubstep & 0xFF);
342 bool autosubstep = (numsubstep == 0) ? true : false;
343 if (numsubstep < 1) {
344 numsubstep = 1;
345 }
346 double timesubstep = timestep / numsubstep;
347 double timeleft = timestep;
348
349 if (timeleft == 0.0) {
350 // this special case correspond to a request to cache data
351 for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
352 it->second->object->pushCache(ts);
353 }
354 // Update the Constraints
355 for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
356 it->second->task->pushCache(ts);
357 }
358 return true;
359 }
360
361 // double maxqdot; // UNUSED
362 e_scalar nlcoef;
363 SceneLock lockCallback(this);
364 Frame external_pose;
365 bool locked;
366
367 // initially we keep timestep unchanged so that update function compute the velocity over
368 while (numsubstep > 0) {
369 // get objects
370 for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
371 Object_struct *os = it->second;
372 if (os->object->getType() == Object::Controlled) {
373 ((ControlledObject *)(os->object))->updateControlOutput(ts);
374 if (os->constraintrange.count > 0) {
375 project(m_ydot,
376 os->constraintrange) = ((ControlledObject *)(os->object))->getControlOutput();
377 project(m_Wy, os->constraintrange) = ((ControlledObject *)(os->object))->getWy();
378 // project(m_Cq,os->constraintrange,os->jointrange) =
379 // (((ControlledObject*)(os->object))->getCq());
380 }
381 if (os->jointrange.count > 0) {
382 project(
383 m_Wq, os->jointrange, os->jointrange) = ((ControlledObject *)(os->object))->getWq();
384 }
385 }
386 if (os->object->getType() == Object::UnControlled &&
387 ((UncontrolledObject *)os->object)->getNrOfCoordinates() != 0) {
388 ((UncontrolledObject *)(os->object))->updateCoordinates(ts);
389 if (!ts.substep) {
390 // velocity of uncontrolled object remains constant during substepping
391 project(m_xdot, os->coordinaterange) = ((UncontrolledObject *)(os->object))->getXudot();
392 }
393 }
394 }
395
396 // get new Constraints values
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;
401
402 if (ob1->base->updated() || ob1->object->updated() || ob2->base->updated() ||
403 ob2->object->updated()) {
404 // the object from which the constraint depends have changed position
405 // recompute the constraint pose
406 getConstraintPose(cs->task, cs, external_pose);
407 cs->task->initialise(external_pose);
408 }
409 cs->task->updateControlOutput(ts);
410 project(m_ydot, cs->constraintrange) = cs->task->getControlOutput();
411 if (!ts.substep || cs->task->substep()) {
412 project(m_Wy, cs->constraintrange) = (cs->task)->getWy();
413 // project(m_Cf,cs->constraintrange,cs->featurerange)=cs->task->getCf();
414 }
415
416 project(m_Jf, cs->featurerange, cs->featurerange) = cs->task->getJf();
417 // std::cout << "Jf = " << Jf << std::endl;
418 // Transform the reference frame of this jacobian to the world reference frame
419 Eigen::Block<e_matrix> Jf_part = project(m_Jf, cs->featurerange, cs->featurerange);
420 changeBase(Jf_part,
421 ob1->base->getPose(ob1->baseFrameIndex) * ob1->object->getPose(cs->ee1index));
422 // std::cout << "Jf_w = " << Jf << std::endl;
423
424 // calculate the inverse of Jf
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)
428 if (m_Sf(i) < KDL::epsilon)
429 m_Uf.col(i).setConstant(0.0);
430 else
431 m_Uf.col(i) *= (1 / m_Sf(i));
432 project(m_Jf_inv, cs->featurerange, cs->featurerange).noalias() = m_Vf * m_Uf.transpose();
433
434 // Get the robotjacobian associated with this constraintset
435 // Each jacobian is expressed in robot base frame => convert to world reference
436 // and negate second robot because it is taken reversed when closing the loop:
437 if (ob1->object->getType() == Object::Controlled) {
438 project(m_Jq,
439 cs->featurerange,
440 ob1->jointrange) = (((ControlledObject *)(ob1->object))->getJq(cs->ee1index));
441 // Transform the reference frame of this jacobian to the world reference frame:
442 Eigen::Block<e_matrix> Jq_part = project(m_Jq, cs->featurerange, ob1->jointrange);
443 changeBase(Jq_part, ob1->base->getPose(ob1->baseFrameIndex));
444 // if the base of this object is moving, get the Ju part
445 if (ob1->base->getNrOfCoordinates() != 0) {
446 // Ju is already computed for world reference frame
447 project(m_Ju, cs->featurerange, ob1->coordinaterange) = ob1->base->getJu(
448 ob1->baseFrameIndex);
449 }
450 }
451 else if (ob1->object->getType() == Object::UnControlled &&
452 ((UncontrolledObject *)ob1->object)->getNrOfCoordinates() != 0) {
453 // object1 is uncontrolled moving object
454 project(m_Ju,
455 cs->featurerange,
456 ob1->coordinaterange) = ((UncontrolledObject *)ob1->object)->getJu(cs->ee1index);
457 }
458 if (ob2->object->getType() == Object::Controlled) {
459 // Get the robotjacobian associated with this constraintset
460 // process a special case where object2 and object1 are equal but using different end
461 // effector
462 if (ob1->object == ob2->object) {
463 // we must create a temporary matrix
464 e_matrix JqTemp(((ControlledObject *)(ob2->object))->getJq(cs->ee2index));
465 // Transform the reference frame of this jacobian to the world reference frame:
466 changeBase(JqTemp, ob2->base->getPose(ob2->baseFrameIndex));
467 // subtract in place
468 project(m_Jq, cs->featurerange, ob2->jointrange) -= JqTemp;
469 }
470 else {
471 project(m_Jq, cs->featurerange, ob2->jointrange) = -(
472 ((ControlledObject *)(ob2->object))->getJq(cs->ee2index));
473 // Transform the reference frame of this jacobian to the world reference frame:
474 Eigen::Block<e_matrix> Jq_part = project(m_Jq, cs->featurerange, ob2->jointrange);
475 changeBase(Jq_part, ob2->base->getPose(ob2->baseFrameIndex));
476 }
477 if (ob2->base->getNrOfCoordinates() != 0) {
478 // if base is the same as first object or first object base,
479 // that portion of m_Ju has been set already => subtract inplace
480 if (ob2->base == ob1->base || ob2->base == ob1->object) {
481 project(m_Ju, cs->featurerange, ob2->coordinaterange) -= ob2->base->getJu(
482 ob2->baseFrameIndex);
483 }
484 else {
485 project(m_Ju, cs->featurerange, ob2->coordinaterange) = -ob2->base->getJu(
486 ob2->baseFrameIndex);
487 }
488 }
489 }
490 else if (ob2->object->getType() == Object::UnControlled &&
491 ((UncontrolledObject *)ob2->object)->getNrOfCoordinates() != 0) {
492 if (ob2->object == ob1->base || ob2->object == ob1->object) {
493 project(m_Ju, cs->featurerange, ob2->coordinaterange) -=
494 ((UncontrolledObject *)ob2->object)->getJu(cs->ee2index);
495 }
496 else {
497 project(m_Ju, cs->featurerange, ob2->coordinaterange) =
498 -((UncontrolledObject *)ob2->object)->getJu(cs->ee2index);
499 }
500 }
501 }
502
503 // Calculate A
504 m_Atemp.noalias() = m_Cf * m_Jf_inv;
505 m_A.noalias() = m_Cq - (m_Atemp * m_Jq);
506 if (m_nuTotal > 0) {
507 m_B.noalias() = m_Atemp * m_Ju;
508 m_ydot.noalias() += m_B * m_xdot;
509 }
510
511 // Call the solver with A, Wq, Wy, ydot to solver qdot:
512 if (!m_solver->solve(m_A, m_Wy, m_ydot, m_Wq, m_qdot, nlcoef))
513 // this should never happen
514 return false;
515 // send result to the objects
516 for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
517 Object_struct *os = it->second;
518 if (os->object->getType() == Object::Controlled)
519 ((ControlledObject *)(os->object))->setJointVelocity(project(m_qdot, os->jointrange));
520 }
521 // compute the constraint velocity
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;
526 // Calculate the twist of the world reference frame due to the robots (Jq*qdot+Ju*chiudot):
527 e_vector6 external_vel = e_zero_vector(6);
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));
540 // the twist caused by the constraint must be opposite because of the closed loop
541 // estimate the velocity of the joints using the inverse jacobian
542 e_vector6 estimated_chidot = project(m_Jf_inv, cs->featurerange, cs->featurerange) *
543 (-external_vel);
544 cs->task->setJointVelocity(estimated_chidot);
545 }
546
547 if (autosubstep) {
548 // automatic computing of substep based on maximum joint change
549 // and joint limit gain variation
550 // We will pass the joint velocity to each object and they will recommend a maximum timestep
551 timesubstep = timeleft;
552 // get armature max joint velocity to estimate the maximum duration of integration
553 // maxqdot = m_qdot.cwise().abs().maxCoeff(); // UNUSED
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)
562 ((ControlledObject *)(os->object))->getMaxTimestep(timesubstep);
563 }
564 for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
565 ConstraintSet_struct *cs = it->second;
566 cs->task->getMaxTimestep(timesubstep);
567 }
568 // use substep that are even dividers of timestep for more regularity
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;
573 numsubstep = 1;
574 timeleft = 0.;
575 }
576 else {
577 numsubstep = 2;
578 timeleft -= timesubstep;
579 }
580 }
581 if (numsubstep > 1) {
582 ts.substep = 1;
583 }
584 else {
585 // set substep to false for last iteration so that controlled output
586 // can be updated in updateKinematics() and model_update)() before next call to
587 // Secne::update()
588 ts.substep = 0;
589 }
590 // change timestep so that integration is done correctly
591 ts.realTimestep = timesubstep;
592
593 do {
594 ObjectMap::iterator it;
595 Object_struct *os;
596 locked = false;
597 for (it = objects.begin(); it != objects.end(); ++it) {
598 os = it->second;
599 if (os->object->getType() == Object::Controlled) {
600 lockCallback.setRange(os->jointrange);
601 if (((ControlledObject *)os->object)->updateJoint(ts, lockCallback)) {
602 // this means one of the joint was locked and we must rerun
603 // the solver to update the remaining joints
604 locked = true;
605 break;
606 }
607 }
608 }
609 if (locked) {
610 // Some rows of m_Wq have been cleared so that the corresponding joint will not move
611 if (!m_solver->solve(m_A, m_Wy, m_ydot, m_Wq, m_qdot, nlcoef))
612 // this should never happen
613 return false;
614
615 // send result to the objects
616 for (it = objects.begin(); it != objects.end(); ++it) {
617 os = it->second;
618 if (os->object->getType() == Object::Controlled)
619 ((ControlledObject *)(os->object))->setJointVelocity(project(m_qdot, os->jointrange));
620 }
621 }
622 } while (locked);
623
624 // Update the Objects
625 for (ObjectMap::iterator it = objects.begin(); it != objects.end(); ++it) {
626 it->second->object->updateKinematics(ts);
627 // mark this object not updated since the constraint will be updated anyway
628 // this flag is only useful to detect external updates
629 it->second->object->updated(false);
630 }
631 // Update the Constraints
632 for (ConstraintMap::iterator it = constraints.begin(); it != constraints.end(); ++it) {
633 ConstraintSet_struct *cs = it->second;
634 // Calculate the external pose:
635 getConstraintPose(cs->task, cs, external_pose);
636 cs->task->modelUpdate(external_pose, ts);
637 // update the constraint output and cache
638 cs->task->updateKinematics(ts);
639 }
640 numsubstep--;
641 }
642 return true;
643}
644
645} // namespace iTaSC
represents a frame transformation in 3D space (rotation + translation)
Definition frames.hpp:526
Frame Inverse() const
Gives back inverse transformation of a Frame.
Definition frames.hpp:432
virtual const e_matrix6 & getJf() const
virtual double getMaxTimestep(double &timestep)
virtual bool initialise(KDL::Frame &init_pose)
virtual void initCache(Cache *_cache)=0
void substep(bool _substep)
virtual void modelUpdate(KDL::Frame &_external_pose, const Timestamp &timestamp)
virtual void updateKinematics(const Timestamp &timestamp)=0
virtual void setJointVelocity(const e_vector chidot_in)
virtual void updateControlOutput(const Timestamp &timestamp)=0
virtual const e_matrix & getCf() const
virtual unsigned int getNrOfConstraints()
virtual const e_vector & getControlOutput() const
virtual ObjectType getType()
Definition Object.hpp:42
virtual bool finalize()
Definition Object.hpp:37
bool updated()
Definition Object.hpp:47
virtual int addEndEffector(const std::string &)
Definition Object.hpp:36
virtual void initCache(Cache *)=0
virtual unsigned int getNrOfCoordinates()
Definition Object.hpp:43
virtual const KDL::Frame & getPose(const unsigned int end_effector=0)
Definition Object.hpp:38
SceneLock(Scene *scene)
Definition Scene.cpp:22
virtual ~SceneLock()
Definition Scene.cpp:25
virtual void lockJoint(unsigned int q_nr, unsigned int ndof, double *qdot)
Definition Scene.cpp:40
void setRange(Range &range)
Definition Scene.cpp:29
virtual void lockJoint(unsigned int q_nr, unsigned int ndof)
Definition Scene.cpp:34
friend class SceneLock
Definition Scene.hpp:25
virtual const e_matrix & getJu(unsigned int frameIndex) const
virtual unsigned int getNrOfCoordinates()
#define e_vector6
#define e_scalar
#define e_zero_vector
#define e_zero_matrix
#define e_matrix
#define assert(assertion)
#define floor
int count
double epsilon
default precision while comparing with Equal(..,..) functions. Initialized at 0.0000001.
Definition utility.cpp:22
int svd_eigen_HH(const Eigen::MatrixBase< MatrixA > &A, Eigen::MatrixBase< MatrixUV > &U, Eigen::MatrixBase< VectorS > &S, Eigen::MatrixBase< MatrixUV > &V, Eigen::MatrixBase< VectorS > &tmp, int maxiter=150)
void setCacheTimestamp(Timestamp &timestamp)
Definition Cache.hpp:52
static int changeBase(Eigen::MatrixBase< Derived > &J, const Frame &T)
Eigen::Block< MatrixType > project(MatrixType &m, Range r)
const char * name
Scene(const SceneParams &params, Device *device)
Definition scene.cpp:40
bool update(Progress &progress)
Definition scene.cpp:623
~Scene() override
Definition scene.cpp:83
unsigned int interpolate
Definition Cache.hpp:45
double realTimestep
Definition Cache.hpp:38
unsigned int cache
Definition Cache.hpp:43
double realTimestamp
Definition Cache.hpp:37
unsigned int reiterate
Definition Cache.hpp:42
unsigned int substep
Definition Cache.hpp:41
unsigned int numstep
Definition Cache.hpp:40
unsigned int update
Definition Cache.hpp:44
i
Definition text_draw.cc:230