ReflexCombination.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package RobotComponents::ArmarXObjects::ReflexCombination
17 * @author [Author Name] ( [Author Email] )
18 * @date 2016
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#include "ReflexCombination.h"
24
26
27
28using namespace armarx;
29
30void
32{
33 usingProxy(getProperty<std::string>("KinematicUnitName").getValue());
34 usingProxy(getProperty<std::string>("RobotStateName").getValue());
35 offeringTopic(getProperty<std::string>("DebugObserverName").getValue());
36 usingProxy(getProperty<std::string>("ImageSourceSelectionName").getValue());
37
38 offeringTopic("DebugDrawerUpdates");
39
40
41 usingTopic(getProperty<std::string>("RobotNodeSetName").getValue() + "State");
42 usingTopic("IMUValues");
43 usingTopic("PlatformState");
44 usingTopic("HeadIKUnitTopic");
45 usingTopic("OpticalFlowTopic");
46 usingTopic("OpticalFlowOKRTopic");
47 //usingTopic("TrackingErrorTopic");
48
49 armar4 = !(getProperty<std::string>("KinematicUnitName").getValue().find("Armar3") == 0);
50
51 headIKName = getProperty<std::string>("HeadIKName").getValue();
52
53 if (armar4)
54 {
55 eye_pitch_left = "EyeL_1_joint";
56 eye_pitch_right = "EyeR_1_joint";
57 eye_yaw_left = "EyeL_2_joint";
58 eye_yaw_right = "EyeR_2_joint";
59 neck_roll = "Neck_2_joint";
60 }
61 else
62 {
63 eye_pitch_left = "Cameras";
64 eye_yaw_left = "Eye_Left";
65 eye_yaw_right = "Eye_Right";
66 neck_roll = "Neck_2_Roll";
67
68 headJointNames = {
69 "Neck_1_Pitch", neck_roll, "Neck_3_Yaw", eye_pitch_left, eye_yaw_right, eye_yaw_left};
70 }
71
72 velocityBased = getProperty<bool>("VelocityBasedControl").getValue();
73 neckPerturbation = getProperty<bool>("NeckPerturbation").getValue();
74
75 if (getProperty<bool>("reafferenceCombination").getValue())
76 {
77 combinationMethod = Reafference;
78 }
79 else
80 {
81 combinationMethod = WeightedSum;
82 }
83
84 ARMARX_LOG << "Velocity based: " << velocityBased;
85
86 vorWeight = getProperty<float>("VOR").getValue();
87 okrWeight = getProperty<float>("OKR").getValue();
88 jointIKWeight = getProperty<float>("JointIK").getValue();
89
90
91 kp = getProperty<float>("kp").getValue();
92 ki = getProperty<float>("ki").getValue();
93 kd = getProperty<float>("kd").getValue();
94
95 vor = new VOR(5);
96 vor->setJointNames(eye_pitch_left, eye_pitch_right, eye_yaw_left, eye_yaw_right, neck_roll);
97 vor->setBools(armar4, velocityBased);
98 vor->setPIDValues(kp, ki, kd);
99
100 jointIK = new FeedforwardReflex(7);
101 jointIK->setBools(armar4, velocityBased);
102
103 okr = new OKR(10);
104 okr->setJointNames(eye_pitch_left, eye_pitch_right, eye_yaw_left, eye_yaw_right, neck_roll);
105 okr->setBools(armar4, velocityBased);
106 okr->setPIDValues(kp, ki, kd);
107
108
109 execCombineReflexesTask = new PeriodicTask<ReflexCombination>(
110 this, &ReflexCombination::combineReflexes, 5, false, "ReflexCombinationTask");
111 execCombineReflexesTask->setDelayWarningTolerance(2);
112
113
114 // Filters initialization
115
116 int sampling_size = 20;
117 IMU_GyroFilters["X"] = new armarx::filters::MedianFilter(sampling_size);
118 IMU_GyroFilters["X"]->update(0, new Variant((float)0.0));
119 IMU_GyroFilters["Y"] = new armarx::filters::MedianFilter(sampling_size);
120 IMU_GyroFilters["Y"]->update(0, new Variant((float)0.0));
121 IMU_GyroFilters["Z"] = new armarx::filters::MedianFilter(sampling_size);
122 IMU_GyroFilters["Z"]->update(0, new Variant((float)0.0));
123
124 double frequency = 10.; // cut off frequency
125 int sampleRate = 100;
126 double resonance = 1.0; // should be between 0.1 and sqrt(2)
127
128 std::map<std::string, float> filterProperties{{"minSampleTimeDelta", 100 * 1000.0}};
129
130 for (auto& joint_name : headJointNames)
131 {
132
133 VelocityFilters[joint_name] = new armarx::filters::DerivationFilter();
134 VelocityFilters[joint_name]->setProperties(filterProperties);
135 VelocityFilters[joint_name]->update(0, new Variant((double)0.0));
136
137 PreVelocityFilters[joint_name] =
138 new armarx::filters::ButterworthFilter(frequency, sampleRate, Lowpass, resonance);
139 PreVelocityFilters[joint_name]->setInitialValue(0.);
140 PreVelocityFilters[joint_name]->update(0, new Variant((double)0.0));
141 }
142
143 frequency = 5.0;
144 sampleRate = 100;
145 resonance = 1.0;
146 FlowFilters["X"] =
147 new armarx::filters::ButterworthFilter(frequency, sampleRate, Lowpass, resonance);
148 FlowFilters["X"]->setInitialValue(0.);
149 FlowFilters["X"]->update(0, new Variant((float)0.0));
150 FlowFilters["Y"] =
151 new armarx::filters::ButterworthFilter(frequency, sampleRate, Lowpass, resonance);
152 FlowFilters["Y"]->setInitialValue(0.);
153 FlowFilters["Y"]->update(0, new Variant((float)0.0));
154
155
156 t_init = armarx::TimeUtil::GetTime().toMilliSecondsDouble() / 1000.;
157}
158
159void
161{
163 getProperty<std::string>("KinematicUnitName").getValue());
164 robotStateComponent = getProxy<RobotStateComponentInterfacePrx>(
165 getProperty<std::string>("RobotStateName").getValue());
166
168 getProperty<std::string>("DebugObserverName").getValue());
169 imageSourceSelection = getProxy<ImageSourceSelectionInterfacePrx>(
170 getProperty<std::string>("ImageSourceSelectionName").getValue());
171
172 drawer = getTopic<DebugDrawerInterfacePrx>("DebugDrawerUpdates");
173
174
175 std::string nodeSetName = getProperty<std::string>("RobotNodeSetName").getValue();
176
177 jointIK->setRobot(nodeSetName, headIKName, robotStateComponent);
178
179
180 FramedPosePtr dummy = new FramedPose();
181
182 ARMARX_LOG << "Armar4: " << armar4;
183
184 updateWeights(vorWeight, okrWeight, jointIKWeight);
185
186 if ((combinationMethod == Reafference) && !jointIKEnabled)
187 {
188 ARMARX_WARNING << "Reafference combination cannot work without IK method enabled. Setting "
189 "to weighted sum imnstead";
190 combinationMethod = WeightedSum;
191 }
192
193 execCombineReflexesTask->start();
194}
195
196void
198{
199 execCombineReflexesTask->stop();
200}
201
202void
204{
205 delete vor;
206 delete jointIK;
207 delete okr;
208}
209
216
217void
219 float okrWeight,
220 float jointIKWeight,
221 const Ice::Current& c)
222{
223
224
225 ARMARX_LOG << "new reflex weights vor:" << vorWeight << " okr:" << okrWeight
226 << " jointik:" << jointIKWeight;
227
228
229 StringVariantBaseMap debugValues;
230 debugValues["reflexes_vor"] = new Variant(vorWeight);
231 debugValues["reflexes_okr"] = new Variant(okrWeight);
232 debugValues["reflexes_ik"] = new Variant(jointIKWeight);
233
234 debugObserver->setDebugChannel("ReflexCombination", debugValues);
235
236
237 std::scoped_lock lock(mutex);
238
239 this->vorWeight = vorWeight;
240 this->okrWeight = okrWeight;
241 this->jointIKWeight = jointIKWeight;
242
243 vorEnabled = (vorWeight > 0);
244 jointIKEnabled = (jointIKWeight > 0);
245 okrEnabled = (okrWeight > 0);
246
247 ARMARX_LOG << "enabled reflexes vor:" << vorEnabled << " okr:" << okrEnabled
248 << " jointik:" << jointIKEnabled;
249
250 vor->setEnabled(vorEnabled);
251 okr->setEnabled(okrEnabled);
252 jointIK->setEnabled(jointIKEnabled);
253
254 ARMARX_LOG << "reflexes enabled.";
255}
256
257void
258ReflexCombination::setReafferenceMethod(bool isReafference, const Ice::Current& c)
259{
260 if (isReafference)
261 {
262 this->combinationMethod = Reafference;
263 }
264 else
265 {
266 this->combinationMethod = WeightedSum;
267 }
268}
269
270void
271ReflexCombination::combineReflexes()
272{
273 std::scoped_lock lock(mutex);
274
275 if (!(vorEnabled || jointIKEnabled || okrEnabled))
276 {
278 << "at least one reflex must be enabled to stabilize the gaze!";
279 return;
280 }
281
282 if (newHeadTarget)
283 {
284 ARMARX_LOG << deactivateSpam(1) << "waiting for new head position";
285 return;
286 }
287
288 // lock.unlock();
289
290 NameValueMap resultJointValues;
291 NameControlModeMap controlModes;
292
293 std::map<std::string, float> weights;
294 std::map<std::string, float> jointValuesIK = jointIK->getJoints();
295 std::map<std::string, float> jointValuesVOR = vor->getJoints();
296 std::map<std::string, float> jointValuesOKR = okr->getJoints();
297
298
299 // logging to debug observed via single channel using the map
300 StringVariantBaseMap mapValues;
301 mapValues["optFlow_predX"] = new Variant(jointIK->optFlow_pred[0]);
302 mapValues["optFlow_predY"] = new Variant(jointIK->optFlow_pred[1]);
303 mapValues["meanOptFlow_pred"] = new Variant((float)jointIK->mean_optFl_pred);
304 mapValues["imu_gyro_predX"] = new Variant(jointIK->gyroscopeRotation_pred[0]);
305 mapValues["imu_gyro_predY"] = new Variant(jointIK->gyroscopeRotation_pred[1]);
306 mapValues["imu_gyro_predZ"] = new Variant(jointIK->gyroscopeRotation_pred[2]);
307 mapValues["vel_filtered"] = new Variant(VelocityFilters[eye_yaw_left]->getValue()->getDouble());
308 mapValues["flow_filteredX"] = new Variant(FlowFilters["X"]->getValue()->getDouble());
309 mapValues["flow_filteredY"] = new Variant(FlowFilters["Y"]->getValue()->getDouble());
310 mapValues["imu_filteredX"] = new Variant(IMU_GyroFilters["X"]->getValue()->getFloat());
311 mapValues["imu_filteredY"] = new Variant(IMU_GyroFilters["Y"]->getValue()->getFloat());
312 mapValues["imu_filteredZ"] = new Variant(IMU_GyroFilters["Z"]->getValue()->getFloat());
313 debugObserver->setDebugChannel("ForwardPredictor", mapValues);
314
315 /*
316
317 for (auto & r : reflexes)
318 {
319 float w = r.second->getWeight();
320
321 for (auto & kv : r.second->getJoints())
322 {
323 if (!resultJointValues.count(kv.first))
324 {
325 resultJointValues[kv.first] = 0;
326 weights[kv.first] = 0;
327 }
328 resultJointValues[kv.first] += w * kv.second;
329 weights[kv.first] += w;
330 }
331 }
332
333 */
334
335
336 // Add up references of each reflexes
337
338 for (auto& kv : jointValuesIK)
339 {
340 if (!resultJointValues.count(kv.first))
341 {
342 resultJointValues[kv.first] = 0;
343 weights[kv.first] = 0;
344 }
345 resultJointValues[kv.first] += jointIKWeight * kv.second;
346 weights[kv.first] += jointIKWeight;
347 }
348
349 for (auto& kv : jointValuesVOR)
350 {
351 if (!resultJointValues.count(kv.first))
352 {
353 resultJointValues[kv.first] = 0;
354 weights[kv.first] = 0;
355 }
356 resultJointValues[kv.first] += vorWeight * kv.second;
357 weights[kv.first] += vorWeight;
358 }
359
360 for (auto& kv : jointValuesOKR)
361 {
362 if (!resultJointValues.count(kv.first))
363 {
364 resultJointValues[kv.first] = 0;
365 weights[kv.first] = 0;
366 }
367 resultJointValues[kv.first] += okrWeight * kv.second;
368 weights[kv.first] += okrWeight;
369 //ARMARX_LOG << "okr vel " << kv.first << "= " << kv.second;
370 }
371
372
373 if (combinationMethod == WeightedSum)
374 {
375 // normalize joint ref
376 for (auto& kv : weights)
377 {
378 resultJointValues[kv.first] = resultJointValues[kv.first] / kv.second;
379 }
380 }
381
382 // send command to controller
383 if (resultJointValues.empty())
384 {
385 return;
386 }
387
388
389 // set the unset velocities to 0
390 if (velocityBased)
391 {
392 for (auto const& headJoint : headJointNames)
393 {
394 if (resultJointValues.find(headJoint) == resultJointValues.end())
395 {
396 resultJointValues[headJoint] = 0.;
397 }
398 }
399 }
400
401 // position tracking to keep eyes parrallel (necessary for stereo calibration)
402 if (velocityBased)
403 {
404 try
405 {
406 double kp = 5.;
407 resultJointValues["Eye_Left"] =
408 resultJointValues["Eye_Right"] +
409 kp * (PreVelocityFilters["Eye_Right"]->getValue()->getDouble() -
410 PreVelocityFilters["Eye_Left"]->getValue()->getDouble());
411 }
412 catch (...)
413 {
414 }
415 }
416
417 for (auto& kv : resultJointValues)
418 {
419 if (velocityBased)
420 {
421 controlModes[kv.first] = eVelocityControl;
422 }
423 else
424 {
425 controlModes[kv.first] = ePositionControl;
426 }
427 }
428
429 if (neckPerturbation && velocityBased)
430 {
431 controlModes["Neck_3_Yaw"] = eVelocityControl;
432 resultJointValues["Neck_3_Yaw"] =
433 4. * cos((armarx::TimeUtil::GetTime().toMilliSecondsDouble() / 1000. - t_init));
434 }
435
436 try
437 {
438 // ARMARX_LOG << deactivateSpam(1) << resultJointValues;
439 //ARMARX_IMPORTANT_S << "joint vel reflex comb" << resultJointValues;
440
441 StringVariantBaseMap debugValues;
442
443 for (auto& kv : resultJointValues)
444 {
445 debugValues[kv.first] = new Variant(kv.second);
446 }
447
448 debugObserver->setDebugChannel("ReflexCombination", debugValues);
449
450
451 StringVariantBaseMap debugValuesIK;
452 for (auto& kv : jointValuesIK)
453 {
454 debugValuesIK[kv.first] = new Variant(kv.second);
455 }
456 debugObserver->setDebugChannel("ReflexCombinationIK", debugValuesIK);
457
458 StringVariantBaseMap debugValuesOKR;
459 for (auto& kv : jointValuesOKR)
460 {
461 debugValuesOKR[kv.first] = new Variant(kv.second);
462 }
463 debugObserver->setDebugChannel("ReflexCombinationOKR", debugValuesOKR);
464
465 StringVariantBaseMap debugValuesVOR;
466 for (auto& kv : jointValuesVOR)
467 {
468 debugValuesVOR[kv.first] = new Variant(kv.second);
469 }
470 debugObserver->setDebugChannel("ReflexCombinationVOR", debugValuesVOR);
471
472 kinUnitPrx->switchControlMode(controlModes);
473 if (velocityBased)
474 {
475 kinUnitPrx->setJointVelocities(resultJointValues);
476 }
477 else
478 {
479 kinUnitPrx->setJointAngles(resultJointValues);
480 }
481 }
482 catch (...)
483 {
484 ARMARX_IMPORTANT << "Setting joint values failed!";
485 }
486}
487
488void
489ReflexCombination::reportPlatformVelocity(Ice::Float currentPlatformVelocityX,
490 Ice::Float currentPlatformVelocityY,
491 Ice::Float currentPlatformVelocityRotation,
492 const Ice::Current& c)
493{
494 if (jointIKEnabled)
495 {
496 //jointIK->reportPlatformVelocity(currentPlatformVelocityX, currentPlatformVelocityY, currentPlatformVelocityRotation);
497 }
498}
499
500void
502 Ice::Long timestamp,
503 bool,
504 const Ice::Current&)
505{
506}
507
508void
510 Ice::Long timestamp,
511 bool valueChanged,
512 const Ice::Current& c)
513{
514 std::scoped_lock lock(mutex);
515
516 NameValueMap tmp = values;
517
518 if (newHeadTarget)
519 {
520 float offset = 0.1f;
521 bool jointAnglesReached = true;
522 for (std::pair<std::string, Ice::Float> joint : targetJointAngles)
523 {
524 jointAnglesReached &= (tmp[joint.first] >= (joint.second - offset));
525 jointAnglesReached &= (tmp[joint.first] <= (joint.second + offset));
526 }
527
528 if (jointAnglesReached)
529 {
530 newHeadTarget = false;
531
532 ARMARX_LOG << deactivateSpam(1) << "new head target reached";
533
534 if (vorEnabled)
535 {
536 vor->start();
537 }
538
539
540 if (jointIKEnabled)
541 {
542 jointIK->start();
543 }
544 if (okrEnabled)
545 {
546 okr->start();
547 }
548 }
549 else
550 {
551 return;
552 }
553 }
554
555 if (vorEnabled)
556 {
557 vor->reportJointAngles(values, valueChanged, c);
558 }
559 if (jointIKEnabled)
560 {
561 jointIK->reportJointAngles(values, valueChanged, c);
562 }
563 if (okrEnabled)
564 {
565 okr->reportJointAngles(values, valueChanged, c);
566 }
567
568 // velocity estimation from position (velocity sensing not working in mca)
569 for (auto& joint_name : headJointNames)
570 {
571 PreVelocityFilters[joint_name]->update(timestamp, new Variant(tmp[joint_name]));
572 VelocityFilters[joint_name]->update(
573 timestamp, new Variant(PreVelocityFilters[joint_name]->getValue()->getDouble()));
574 }
575}
576
577void
579 Ice::Long timestamp,
580 bool valueChanged,
581 const Ice::Current& c)
582{
583
584 std::scoped_lock lock(mutex);
585 NameValueMap velocities_filtered(velocities);
586 for (auto& joint_name : headJointNames)
587 {
588 if (velocities_filtered.count(joint_name))
589 {
590 velocities_filtered[joint_name] = VelocityFilters[joint_name]->getValue()->getDouble();
591 }
592 }
593
594
595 if (vorEnabled)
596 {
597 vor->reportJointVelocities(velocities_filtered, valueChanged, c);
598 }
599 if (jointIKEnabled)
600 {
601 jointIK->reportJointVelocities(velocities_filtered, valueChanged, c);
602 }
603 if (okrEnabled)
604 {
605 if (combinationMethod == Reafference && jointIKEnabled)
606 {
607 velocities_filtered[eye_yaw_left] =
608 0.; // no need of removing self induced velocities as already removed by the prediction
609 velocities_filtered[eye_yaw_right] = 0.;
610 velocities_filtered[eye_pitch_left] = 0.;
611 }
612 okr->reportJointVelocities(velocities_filtered, valueChanged, timestamp, c);
613 }
614}
615
616void
618 Ice::Long timestamp,
619 bool,
620 const Ice::Current&)
621{
622}
623
624void
626 Ice::Long timestamp,
627 bool,
628 const Ice::Current&)
629{
630}
631
632void
634 Ice::Long timestamp,
635 bool,
636 const Ice::Current&)
637{
638}
639
640void
642 Ice::Long timestamp,
643 bool,
644 const Ice::Current&)
645{
646}
647
648void
650 Ice::Long timestamp,
651 bool,
652 const Ice::Current&)
653{
654}
655
656void
658 Ice::Float y,
659 Ice::Float deltaT,
660 Ice::Long timestamp,
661 const Ice::Current& c)
662{
663
664 std::scoped_lock lock(mutex);
665
666 FlowFilters["X"]->update(timestamp, new Variant(x));
667 FlowFilters["Y"]->update(timestamp, new Variant(y));
668
669 double x_flow, y_flow;
670
671 x_flow = FlowFilters["X"]->getValue()->getDouble();
672 y_flow = FlowFilters["Y"]->getValue()->getDouble();
673
674 // no filtering
675 //x_flow = x;
676 //y_flow = y;
677
678 if (combinationMethod == Reafference && jointIKEnabled)
679 {
680 x_flow -= jointIK->optFlow_pred[0];
681 y_flow -= jointIK->optFlow_pred[1];
682
683 if (fabs(x_flow) < 0.04)
684 {
685 x_flow = 0.;
686 }
687 }
688
689 if (okrEnabled)
690 {
691 okr->reportNewOpticalFlow(x_flow, y_flow, deltaT, timestamp);
692 }
693}
694
695void
696armarx::ReflexCombination::reportHeadTargetChanged(const NameValueMap& targetJointAngles,
697 const FramedPositionBasePtr& targetPosition,
698 const Ice::Current&)
699{
700
701 std::scoped_lock lock(mutex);
702
703 newHeadTarget = true;
704 this->targetJointAngles = targetJointAngles;
705
706 ARMARX_INFO << " new head target " << targetPosition->output();
707
708 if (jointIKEnabled)
709 {
710 jointIK->stop();
711 }
712 jointIK->reportHeadTargetChanged(targetJointAngles, targetPosition);
713
714 if (vorEnabled)
715 {
716 vor->stop();
717 }
718 if (okrEnabled)
719 {
720 okr->stop();
721 }
722}
723
724void
726 const std::string& name,
727 const IMUData& values,
728 const TimestampBasePtr& timestamp,
729 const Ice::Current& c)
730{
731
732
733 std::scoped_lock lock(mutex);
734
735 /*
736 Eigen::Quaternionf qTemp = Eigen::Quaternionf(values.orientationQuaternion[0], values.orientationQuaternion[1], values.orientationQuaternion[2], values.orientationQuaternion[3]);
737 Eigen::Vector3f rpy = quaternionToRPY(qTemp);
738 ARMARX_LOG << deactivateSpam(1) << "RPY: " << rpy[0] << " " << rpy[1] << " " << rpy[2];
739 ARMARX_LOG << deactivateSpam(1) << "Quat: " << qTemp.w() << " " << qTemp.x() << " " << qTemp.y() << " " << qTemp.z();
740 */
741 if (IMU_GyroFilters["X"] && IMU_GyroFilters["Y"] && IMU_GyroFilters["Z"])
742 {
743 IMU_GyroFilters["X"]->update(timestamp->timestamp,
744 new Variant((float)values.gyroscopeRotation[0]));
745 IMU_GyroFilters["Y"]->update(timestamp->timestamp,
746 new Variant((float)values.gyroscopeRotation[1]));
747 IMU_GyroFilters["Z"]->update(timestamp->timestamp,
748 new Variant((float)values.gyroscopeRotation[2]));
749 }
750
751 IMUData values2 = values;
752
753 if (IMU_GyroFilters["X"] && IMU_GyroFilters["Y"] && IMU_GyroFilters["Z"])
754 {
755 values2.gyroscopeRotation[0] = IMU_GyroFilters["X"]->getValue()->getFloat();
756 values2.gyroscopeRotation[1] = IMU_GyroFilters["Y"]->getValue()->getFloat();
757 values2.gyroscopeRotation[2] = IMU_GyroFilters["Z"]->getValue()->getFloat();
758 }
759
760 if (combinationMethod == Reafference && jointIKEnabled)
761 {
762 values2.gyroscopeRotation[0] -= jointIK->gyroscopeRotation_pred[0];
763 values2.gyroscopeRotation[1] -= jointIK->gyroscopeRotation_pred[1];
764 values2.gyroscopeRotation[2] -= jointIK->gyroscopeRotation_pred[2];
765
766 if (fabs(values2.gyroscopeRotation[2]) < 0.04)
767 {
768 values2.gyroscopeRotation[2] = 0.;
769 }
770 }
771
772 if (vorEnabled)
773 {
774 vor->reportSensorValues(values2);
775 }
776}
777
778void
779armarx::ReflexCombination::setImageQuality(float quality)
780{
781 Ice::StringSeq imageSources = getProperty<Ice::StringSeq>("ImageProviders");
782 ARMARX_CHECK_GREATER_EQUAL(imageSources.size(), 2) << imageSources;
783 if (quality > 0.7)
784 {
785 imageSourceSelection->setImageSource(imageSources[1], 100000000);
786 }
787 else
788 {
789 imageSourceSelection->setImageSource(imageSources[0], 100000000);
790 }
791}
792
793void
795 Ice::Float pixelY,
796 Ice::Float angleX,
797 Ice::Float angleY,
798 const Ice::Current&)
799{
800 okr->reportNewTrackingError(pixelX, pixelY, angleX, angleY);
801}
802
803void
805 Ice::Float,
806 Ice::Float,
807 const Ice::Current&)
808{
809}
std::string timestamp()
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Definition Logging.cpp:75
constexpr T c
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
Property< PropertyType > getProperty(const std::string &name)
The FramedPose class.
Definition FramedPose.h:281
SpamFilterDataPtr deactivateSpam(float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
disables the logging for the current line for the given amount of seconds.
Definition Logging.cpp:99
void offeringTopic(const std::string &name)
Registers a topic for retrival after initialization.
TopicProxyType getTopic(const std::string &name)
Returns a proxy of the specified topic.
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
The periodic task executes one thread method repeatedly using the time period specified in the constr...
void reportHeadTargetChanged(const NameValueMap &targetJointAngles, const FramedPositionBasePtr &targetPosition, const Ice::Current &c=Ice::emptyCurrent) override
void setReafferenceMethod(bool isReafference, const Ice::Current &c=Ice::emptyCurrent) override
void reportSensorValues(const std::string &device, const std::string &name, const IMUData &values, const TimestampBasePtr &timestamp, const Ice::Current &c=Ice::emptyCurrent) override
void reportJointMotorTemperatures(const NameValueMap &, Ice::Long timestamp, bool, const Ice::Current &c=Ice::emptyCurrent) override
void updateWeights(float vor, float okr, float jointIK, const Ice::Current &c=Ice::emptyCurrent) override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void reportControlModeChanged(const NameControlModeMap &, Ice::Long timestamp, bool, const Ice::Current &c=Ice::emptyCurrent) override
void reportJointAccelerations(const NameValueMap &, Ice::Long timestamp, bool, const Ice::Current &c=Ice::emptyCurrent) override
void reportJointVelocities(const NameValueMap &values, Ice::Long timestamp, bool valueChanged, const Ice::Current &c=Ice::emptyCurrent) override
void reportJointTorques(const NameValueMap &, Ice::Long timestamp, bool, const Ice::Current &c=Ice::emptyCurrent) override
void reportPlatformOdometryPose(Ice::Float, Ice::Float, Ice::Float, const Ice::Current &) override
void reportNewTrackingError(Ice::Float pixelX, Ice::Float pixelY, Ice::Float angleX, Ice::Float angleY, const Ice::Current &) override
void reportNewOpticalFlow(Ice::Float, Ice::Float, Ice::Float, Ice::Long, const Ice::Current &) override
void reportJointCurrents(const NameValueMap &, Ice::Long timestamp, bool, const Ice::Current &c=Ice::emptyCurrent) override
void reportPlatformVelocity(Ice::Float currentPlatformVelocityX, Ice::Float currentPlatformVelocityY, Ice::Float currentPlatformVelocityRotation, const Ice::Current &c=Ice::emptyCurrent) override
void reportJointAngles(const NameValueMap &values, Ice::Long timestamp, bool valueChanged, const Ice::Current &c=Ice::emptyCurrent) override
void reportJointStatuses(const NameStatusMap &, Ice::Long timestamp, bool, const Ice::Current &c=Ice::emptyCurrent) override
static IceUtil::Time GetTime(TimeMode timeMode=TimeMode::VirtualTime)
Get the current time.
Definition TimeUtil.cpp:42
The Variant class is described here: Variants.
Definition Variant.h:224
The DerivationFilter calculates the derivate of a datafield.
The MedianFilter class provides an implementation for a median for datafields of type float,...
#define ARMARX_CHECK_GREATER_EQUAL(lhs, rhs)
This macro evaluates whether lhs is greater or equal (>=) rhs and if it turns out to be false it will...
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193
#define ARMARX_LOG
Definition Logging.h:165
T getValue(nlohmann::json &userConfig, nlohmann::json &defaultConfig, const std::string &entryName)
Definition utils.h:80
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::map< std::string, VariantBasePtr > StringVariantBaseMap
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
IceInternal::Handle< FramedPose > FramedPosePtr
Definition FramedPose.h:272