-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathTelemetryDeviceDumper.cpp
665 lines (571 loc) · 23.1 KB
/
TelemetryDeviceDumper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
/*
* Copyright (C) 2006-2021 Istituto Italiano di Tecnologia (IIT)
* All rights reserved.
*
* This software may be modified and distributed under the terms of the
* BSD-3-Clause license. See the accompanying LICENSE file for details.
*/
#include "TelemetryDeviceDumper.h"
#include <array>
#include <algorithm>
#include <cmath>
using namespace yarp::telemetry::experimental;
using namespace yarp::os;
using namespace yarp::dev;
constexpr double period_thread{ 0.010 };
void convertVectorFromDegreesToRadians(std::vector<double>& inVec) {
std::transform(inVec.begin(), inVec.end(), inVec.begin(), [](double el) -> double { return el * M_PI / 180.0; });
}
void addVectorOfStringToProperty(yarp::os::Property& prop, std::string key, std::vector<std::string>& list)
{
prop.addGroup(key);
yarp::os::Bottle& bot = prop.findGroup(key).addList();
for (size_t i = 0; i < list.size(); i++)
{
bot.addString(list[i].c_str());
}
return;
}
bool getConfigParamsAsList(yarp::os::Searchable& config, std::string propertyName, std::vector<std::string>& list)
{
yarp::os::Property prop;
prop.fromString(config.toString().c_str());
yarp::os::Bottle* propNames = prop.find(propertyName).asList();
if (propNames == nullptr)
{
yError() << "telemetryDeviceDumper: Error parsing parameters: \" " << propertyName << " \" should be followed by a list\n";
return false;
}
list.resize(propNames->size());
for (auto elem = 0u; elem < propNames->size(); elem++)
{
list[elem] = propNames->get(elem).asString().c_str();
}
return true;
}
bool getUsedDOFsList(yarp::os::Searchable& config, std::vector<std::string>& usedDOFs)
{
return getConfigParamsAsList(config, "axesNames", usedDOFs);
}
// For now also the period is harcoded, it can be configured
TelemetryDeviceDumper::TelemetryDeviceDumper() : yarp::os::PeriodicThread(period_thread) {
// TODO
}
TelemetryDeviceDumper::~TelemetryDeviceDumper() {
// TODO
}
bool TelemetryDeviceDumper::loadSettingsFromConfig(yarp::os::Searchable& config)
{
yarp::os::Property prop;
prop.fromString(config.toString().c_str());
std::string useJointVelocityOptionName = "logJointVelocity";
if (prop.check(useJointVelocityOptionName.c_str())) {
yWarning() << "telemetryDeviceDumper: logJointVelocity is deprecated, use logIEncoders instead.";
settings.logJointVelocity = prop.find(useJointVelocityOptionName.c_str()).asBool();
}
std::string useJointAccelerationOptionName = "logJointAcceleration";
if (prop.check(useJointAccelerationOptionName.c_str())) {
yWarning() << "telemetryDeviceDumper: logJointAcceleration is deprecated, use logIEncoders instead.";
settings.logJointAcceleration = prop.find(useJointAccelerationOptionName.c_str()).asBool();
}
std::string logAllQuantitiesOptionName = "logAllQuantities";
if (prop.check(logAllQuantitiesOptionName.c_str())) {
settings.logAllQuantities = prop.find(logAllQuantitiesOptionName.c_str()).asBool();
}
std::string logIEncodersOptionName = "logIEncoders";
if (prop.check(logIEncodersOptionName.c_str())) {
settings.logIEncoders = prop.find(logIEncodersOptionName.c_str()).asBool();
}
std::string logITorqueControlOptionName = "logITorqueControl";
if (prop.check(logITorqueControlOptionName.c_str())) {
settings.logITorqueControl = prop.find(logITorqueControlOptionName.c_str()).asBool();
}
std::string logIMotorEncodersOptionName = "logIMotorEncoders";
if (prop.check(logIMotorEncodersOptionName.c_str())) {
settings.logIMotorEncoders = prop.find(logIMotorEncodersOptionName.c_str()).asBool();
}
std::string logIControlModeOptionName = "logIControlMode";
if (prop.check(logIControlModeOptionName.c_str())) {
settings.logIControlMode = prop.find(logIControlModeOptionName.c_str()).asBool();
}
std::string logIInteractionModeOptionName = "logIInteractionMode";
if (prop.check(logIInteractionModeOptionName.c_str())) {
settings.logIInteractionMode = prop.find(logIInteractionModeOptionName.c_str()).asBool();
}
std::string logIPidControlOptionName = "logIPidControl";
if (prop.check(logIPidControlOptionName.c_str())) {
settings.logIPidControl = prop.find(logIPidControlOptionName.c_str()).asBool();
}
std::string logIAmplifierControlOptionName = "logIAmplifierControl";
if (prop.check(logIAmplifierControlOptionName.c_str())) {
settings.logIAmplifierControl = prop.find(logIAmplifierControlOptionName.c_str()).asBool();
}
std::string useRadians = "useRadians";
if (prop.check(useRadians.c_str())) {
settings.useRadians = prop.find(useRadians.c_str()).asBool();
}
std::string saveBufferManagerConfiguration = "saveBufferManagerConfiguration";
if (prop.check(saveBufferManagerConfiguration.c_str())) {
settings.saveBufferManagerConfiguration = prop.find(saveBufferManagerConfiguration.c_str()).asBool();
}
// BufferManager options
std::string json_file = "json_file";
if (prop.check(json_file.c_str()) && prop.find(json_file.c_str()).isString()) {
auto json_path = prop.find(json_file.c_str()).asString();
bool ok = bufferConfigFromJson(m_bufferConfig, json_path);
return ok;
}
else {
std::string experimentName = "experimentName";
if (prop.check(experimentName.c_str()) && prop.find(experimentName.c_str()).isString()) {
m_bufferConfig.filename = prop.find(experimentName.c_str()).asString();
}
else {
yError() << "TelemetryDeviceDumper: missing" << experimentName;
return false;
}
std::string path = "path";
if (prop.check(path.c_str()) && prop.find(path.c_str()).isString()) {
m_bufferConfig.path = prop.find(path.c_str()).asString();
}
std::string n_samples = "n_samples";
if (prop.check(n_samples.c_str()) && prop.find(n_samples.c_str()).isInt32()) {
m_bufferConfig.n_samples = prop.find(n_samples.c_str()).asInt32();
}
else {
yError() << "TelemetryDeviceDumper: missing" << n_samples;
return false;
}
std::string save_periodically = "save_periodically";
if (prop.check(save_periodically.c_str()) && prop.find(save_periodically.c_str()).isBool()) {
m_bufferConfig.save_periodically = prop.find(save_periodically.c_str()).asBool();
}
if (m_bufferConfig.save_periodically) {
std::string save_period = "save_period";
if (prop.check(save_period.c_str()) && prop.find(save_period.c_str()).isFloat64()) {
m_bufferConfig.save_period = prop.find(save_period.c_str()).asFloat64();
}
else {
yError() << "TelemetryDeviceDumper: missing" << save_period;
return false;
}
std::string data_threshold = "data_threshold";
if (prop.check(data_threshold.c_str()) && prop.find(data_threshold.c_str()).isInt32()) {
m_bufferConfig.data_threshold = prop.find(data_threshold.c_str()).asInt32();
}
}
std::string auto_save = "auto_save";
if (prop.check(auto_save.c_str()) && prop.find(auto_save.c_str()).isBool()) {
m_bufferConfig.auto_save = prop.find(auto_save.c_str()).asBool();
}
}
if (!(m_bufferConfig.auto_save || m_bufferConfig.save_periodically)) {
yError() << "TelemetryDeviceDumper: both auto_save and save_periodically are set to false, nothing will be saved.";
return false;
}
return true;
}
bool TelemetryDeviceDumper::open(yarp::os::Searchable& config) {
std::lock_guard<std::mutex> guard(this->deviceMutex);
bool ok;
// Load settings in the class
ok = this->loadSettingsFromConfig(config);
if (!ok)
{
yError() << "telemetryDeviceDumper: Problem in loading settings from config.";
return false;
}
// Open the controlboard remapper
ok = this->openRemapperControlBoard(config);
if (!ok)
{
yError() << "telemetryDeviceDumper: Problem in opening controlboard remapper.";
return false;
}
ok = this->configBufferManager(config);
if (!ok)
{
yError() << "telemetryDeviceDumper: Problem in configuring the buffer manager.";
return false;
}
return true;
}
bool TelemetryDeviceDumper::openRemapperControlBoard(os::Searchable& config)
{
// Pass to the remapper just the relevant parameters (axesList)
yarp::os::Property propRemapper;
propRemapper.put("device", "controlboardremapper");
bool ok = getUsedDOFsList(config, jointNames);
if (!ok) return false;
// Add the joint names to the BufferManager
// Note that this will overwrite what is set from the configuration phase
m_bufferConfig.description_list = jointNames;
addVectorOfStringToProperty(propRemapper, "axesNames", jointNames);
ok = remappedControlBoard.open(propRemapper);
if (!ok)
{
return ok;
}
// View relevant interfaces for the remappedControlBoard
ok = ok && remappedControlBoard.view(remappedControlBoardInterfaces.multwrap);
// TODO: check if it has to be enabled by options
if (settings.logAllQuantities || settings.logIEncoders
|| settings.logJointVelocity || settings.logJointAcceleration ) { // deprecated since v0.1.0
ok = ok && remappedControlBoard.view(remappedControlBoardInterfaces.encs);
}
if (settings.logAllQuantities || settings.logIMotorEncoders) {
ok = ok && remappedControlBoard.view(remappedControlBoardInterfaces.imotenc);
}
if (settings.logAllQuantities || settings.logIPidControl) {
ok = ok && remappedControlBoard.view(remappedControlBoardInterfaces.pid);
}
if (settings.logAllQuantities || settings.logIAmplifierControl) {
ok = ok && remappedControlBoard.view(remappedControlBoardInterfaces.amp);
}
if (settings.logAllQuantities || settings.logIControlMode) {
ok = ok && remappedControlBoard.view(remappedControlBoardInterfaces.cmod);
}
if (settings.logAllQuantities || settings.logIInteractionMode) {
ok = ok && remappedControlBoard.view(remappedControlBoardInterfaces.imod);
}
if (settings.logAllQuantities || settings.logITorqueControl) {
ok = ok && remappedControlBoard.view(remappedControlBoardInterfaces.itrq);
}
if (!ok)
{
yError() << "telemetryDeviceDumper: open impossible to use the necessary interfaces in remappedControlBoard";
return ok;
}
int axes = 0;
ok = ok && remappedControlBoardInterfaces.encs->getAxes(&axes);
if (ok) {
this->resizeBuffers(axes);
}
else {
yError() << "telemetryDeviceDumper: open impossible to use the necessary interfaces in remappedControlBoard";
return ok;
}
return true;
}
bool TelemetryDeviceDumper::attachAllControlBoards(const yarp::dev::PolyDriverList& p_list) {
PolyDriverList controlBoardList;
for (size_t devIdx = 0; devIdx < (size_t)p_list.size(); devIdx++)
{
yarp::dev::IEncoders* pEncs = 0;
if (p_list[devIdx]->poly->view(pEncs))
{
controlBoardList.push(const_cast<PolyDriverDescriptor&>(*p_list[devIdx]));
}
}
// Attach the controlBoardList to the controlBoardRemapper
bool ok = remappedControlBoardInterfaces.multwrap->attachAll(controlBoardList);
if (!ok)
{
yError() << "telemetryDeviceDumper: attachAll in attachAll of the remappedControlBoard";
return false;
}
return true;
}
void TelemetryDeviceDumper::resizeBuffers(int size) {
// Let's resize all, we will see later.
this->jointPos.resize(size);
this->jointVel.resize(size);
this->jointAcc.resize(size);
// TODO see if it has to be enabled by options
this->jointPosErr.resize(size);
this->jointPosRef.resize(size);
this->jointTrqErr.resize(size);
this->jointTrqRef.resize(size);
this->jointPWM.resize(size);
this->jointCurr.resize(size);
this->jointTrq.resize(size);
this->motorEnc.resize(size);
this->motorVel.resize(size);
this->motorAcc.resize(size);
this->controlModes.resize(size);
this->interactionModes.resize(size);
}
bool TelemetryDeviceDumper::configBufferManager(yarp::os::Searchable& conf) {
bool ok{ true };
if (ok && (settings.logIEncoders || settings.logAllQuantities)) {
ok = ok && bufferManager.addChannel({ "encoders", {jointPos.size(), 1} });
}
if (ok && (settings.logJointVelocity || settings.logIEncoders || settings.logAllQuantities)) {
ok = ok && bufferManager.addChannel({ "velocity", {jointVel.size(), 1} });
}
if (ok && (settings.logJointAcceleration || settings.logIEncoders || settings.logAllQuantities)) {
ok = ok && bufferManager.addChannel({ "acceleration", {jointAcc.size(), 1} });
}
// TODO check if it is more convenient having more BM
if (ok && (settings.logIPidControl || settings.logAllQuantities)) {
ok = ok && bufferManager.addChannel({ "position_error", {jointPosErr.size(), 1} });
ok = ok && bufferManager.addChannel({ "position_reference", {jointPosRef.size(), 1} });
ok = ok && bufferManager.addChannel({ "torque_error", {jointTrqErr.size(), 1} });
ok = ok && bufferManager.addChannel({ "torque_reference", {jointTrqRef.size(), 1} });
}
if (ok && (settings.logIAmplifierControl || settings.logAllQuantities)) {
ok = ok && bufferManager.addChannel({ "pwm", {jointPWM.size(), 1} });
ok = ok && bufferManager.addChannel({ "current", {jointCurr.size(), 1} });
}
if (ok && (settings.logITorqueControl || settings.logAllQuantities)) {
ok = ok && bufferManager.addChannel({ "torque", {jointTrq.size(), 1} });
}
if (ok && (settings.logIMotorEncoders || settings.logAllQuantities)) {
ok = ok && bufferManager.addChannel({ "motor_encoder", {motorEnc.size(), 1} });
ok = ok && bufferManager.addChannel({ "motor_velocity", {motorVel.size(), 1} });
ok = ok && bufferManager.addChannel({ "motor_acceleration", {motorAcc.size(), 1} });
}
if (ok && (settings.logIControlMode || settings.logAllQuantities)) {
ok = ok && bufferManager.addChannel({ "control_mode", {controlModes.size(), 1} });
}
if (ok && (settings.logIInteractionMode || settings.logAllQuantities)) {
ok = ok && bufferManager.addChannel({ "interaction_mode", {interactionModes.size(), 1} });
}
ok = ok && bufferManager.configure(m_bufferConfig);
// TODO check if we have nr of channels ~= 0
return ok;
}
bool TelemetryDeviceDumper::attachAll(const yarp::dev::PolyDriverList& device2attach) {
std::lock_guard<std::mutex> guard(this->deviceMutex);
bool ok = true;
ok = ok && this->attachAllControlBoards(device2attach);
if (ok)
{
correctlyConfigured = true;
this->start();
}
return ok;
}
bool TelemetryDeviceDumper::detachAll()
{
std::lock_guard<std::mutex> guard(this->deviceMutex);
correctlyConfigured = false;
if (isRunning())
{
stop();
}
return this->remappedControlBoardInterfaces.multwrap->detachAll();
}
bool TelemetryDeviceDumper::close()
{
correctlyConfigured = false;
remappedControlBoard.close();
bool ok = true;
if (settings.saveBufferManagerConfiguration) {
auto buffConfToSave = bufferManager.getBufferConfig();
ok = bufferConfigToJson(buffConfToSave, buffConfToSave.path + "bufferConfig" + buffConfToSave.filename + ".json");
}
return ok;
}
void TelemetryDeviceDumper::readSensors()
{
bool ok;
// Read encoders
if (settings.logIEncoders || settings.logAllQuantities) {
sensorsReadCorrectly = remappedControlBoardInterfaces.encs->getEncoders(jointPos.data());
if (!sensorsReadCorrectly)
{
yWarning() << "telemetryDeviceDumper warning : joint positions was not readed correctly";
}
else
{
bufferManager.push_back(jointPos, "encoders");
}
}
// At the moment we are assuming that all joints are revolute
if (settings.logJointVelocity || settings.logIEncoders || settings.logAllQuantities)
{
ok = remappedControlBoardInterfaces.encs->getEncoderSpeeds(jointVel.data());
sensorsReadCorrectly = sensorsReadCorrectly && ok;
if (!ok)
{
yWarning() << "telemetryDeviceDumper warning : joint velocities was not readed correctly";
}
else
{
bufferManager.push_back(jointVel , "velocity");
}
}
if (settings.logJointAcceleration || settings.logIEncoders || settings.logAllQuantities)
{
ok = remappedControlBoardInterfaces.encs->getEncoderAccelerations(jointAcc.data());
sensorsReadCorrectly = sensorsReadCorrectly && ok;
if (!ok)
{
yWarning() << "telemetryDeviceDumper warning : joint accelerations was not readed correctly";
}
else
{
bufferManager.push_back(jointAcc, "acceleration");
}
}
// Read PID
if (settings.logIPidControl || settings.logAllQuantities) {
ok = remappedControlBoardInterfaces.pid->getPidErrors(VOCAB_PIDTYPE_POSITION, jointPosErr.data());
sensorsReadCorrectly = sensorsReadCorrectly && ok;
if (!ok)
{
yWarning() << "telemetryDeviceDumper warning : joint position errors was not readed correctly";
}
else
{
bufferManager.push_back(jointPosErr, "position_error");
}
ok = remappedControlBoardInterfaces.pid->getPidReferences(VOCAB_PIDTYPE_POSITION, jointPosRef.data());
sensorsReadCorrectly = sensorsReadCorrectly && ok;
if (!ok)
{
yWarning() << "telemetryDeviceDumper warning : joint position references was not readed correctly";
}
else
{
bufferManager.push_back(jointPosRef, "position_reference");
}
ok = remappedControlBoardInterfaces.pid->getPidErrors(VOCAB_PIDTYPE_TORQUE, jointTrqErr.data());
sensorsReadCorrectly = sensorsReadCorrectly && ok;
if (!ok)
{
yWarning() << "telemetryDeviceDumper warning : joint torque errors was not readed correctly";
}
else
{
bufferManager.push_back(jointPosErr, "torque_error");
}
ok = remappedControlBoardInterfaces.pid->getPidReferences(VOCAB_PIDTYPE_TORQUE, jointTrqRef.data());
sensorsReadCorrectly = sensorsReadCorrectly && ok;
if (!ok)
{
yWarning() << "telemetryDeviceDumper warning : joint torque references was not readed correctly";
}
else
{
bufferManager.push_back(jointTrqRef, "torque_reference");
}
}
// Read amplifier
if (settings.logIAmplifierControl || settings.logAllQuantities) {
for (int j = 0; j < jointPWM.size(); j++)
{
ok &= remappedControlBoardInterfaces.amp->getPWM(j, &jointPWM[j]);
}
sensorsReadCorrectly = sensorsReadCorrectly && ok;
if (!ok)
{
yWarning() << "telemetryDeviceDumper warning : voltage PWM was not readed correctly";
}
else
{
bufferManager.push_back(jointPWM, "pwm");
}
ok = remappedControlBoardInterfaces.amp->getCurrents(jointCurr.data());
sensorsReadCorrectly = sensorsReadCorrectly && ok;
if (!ok)
{
yWarning() << "telemetryDeviceDumper warning : current was not readed correctly";
}
else
{
bufferManager.push_back(jointCurr, "current");
}
}
// Read torque
if (settings.logITorqueControl || settings.logAllQuantities) {
ok = remappedControlBoardInterfaces.itrq->getTorques(jointTrq.data());
sensorsReadCorrectly = sensorsReadCorrectly && ok;
if (!ok)
{
yWarning() << "telemetryDeviceDumper warning : torque was not readed correctly";
}
else
{
bufferManager.push_back(jointTrq, "torque");
}
}
// Read motor
if (settings.logIMotorEncoders || settings.logAllQuantities) {
ok = remappedControlBoardInterfaces.imotenc->getMotorEncoders(motorEnc.data());
sensorsReadCorrectly = sensorsReadCorrectly && ok;
if (!ok)
{
yWarning() << "telemetryDeviceDumper warning : motor encoder was not readed correctly";
}
else
{
bufferManager.push_back(motorEnc, "motor_encoder");
}
ok = remappedControlBoardInterfaces.imotenc->getMotorEncoderSpeeds(motorVel.data());
sensorsReadCorrectly = sensorsReadCorrectly && ok;
if (!ok)
{
yWarning() << "telemetryDeviceDumper warning : motor velocity was not readed correctly";
}
else
{
bufferManager.push_back(motorVel, "motor_velocity");
}
ok = remappedControlBoardInterfaces.imotenc->getMotorEncoderAccelerations(motorAcc.data());
sensorsReadCorrectly = sensorsReadCorrectly && ok;
if (!ok)
{
yWarning() << "telemetryDeviceDumper warning : motor acceleration was not readed correctly";
}
else
{
bufferManager.push_back(motorAcc, "motor_acceleration");
}
}
// Read modes
if (settings.logIControlMode || settings.logAllQuantities) {
for (int i = 0; i < interactionModes.size(); i++)
{
int tmp;
ok &= remappedControlBoardInterfaces.cmod->getControlMode(i, &tmp);
controlModes[i] = (double)tmp;
}
sensorsReadCorrectly = sensorsReadCorrectly && ok;
if (!ok)
{
yWarning() << "telemetryDeviceDumper warning : control modes wa not readed correctly";
}
else
{
bufferManager.push_back(controlModes, "control_mode");
}
}
if (settings.logIInteractionMode || settings.logAllQuantities) {
for (int i = 0; i < interactionModes.size(); i++)
{
yarp::dev::InteractionModeEnum tmp;
ok &= remappedControlBoardInterfaces.imod->getInteractionMode(i, &tmp);
if (!ok) {
break;
}
if (tmp == VOCAB_IM_STIFF) interactionModes[i] = 0.0;
else if (tmp == VOCAB_IM_COMPLIANT) interactionModes[i] = 1.0;
else interactionModes[i] = -1.0;
}
sensorsReadCorrectly = sensorsReadCorrectly && ok;
if (!ok)
{
yWarning() << "telemetryDeviceDumper warning : interaction mode was not readed correctly";
}
else
{
bufferManager.push_back(interactionModes, "interaction_mode");
}
}
if (settings.useRadians) {
// TODO check if it is safe to call transform on empty vectors.
// TODO handle prismatic joints.
convertVectorFromDegreesToRadians(jointPos);
convertVectorFromDegreesToRadians(jointVel);
convertVectorFromDegreesToRadians(jointAcc);
convertVectorFromDegreesToRadians(jointPosErr);
}
}
void TelemetryDeviceDumper::run() {
if (correctlyConfigured) {
readSensors();
}
return;
}