YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
jointitem.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 */
6
7#include "jointitem.h"
8#include "ui_jointitem.h"
9
10#include "log.h"
11#include "yarpmotorgui.h"
12
13#include <cmath>
14
15#include <yarp/os/Log.h>
16#include <yarp/os/LogStream.h>
17
18#include <QDebug>
19#include <QKeyEvent>
20
22{
23 ui->sliderTrajectoryPosition->resetTarget();
24 ui->sliderMixedPosition->resetTarget();
25}
26
28{
29 if (this->internalState == Velocity)
30 {
31 velocityTimer.stop();
32 }
33 else if(this->internalState == Pwm)
34 {
35 pwmTimer.stop();
36 }
37 else if(this->internalState == Current)
38 {
39 currentTimer.stop();
40 }
41 else if(this->internalState == Torque)
42 {
43 torqueTimer.stop();
44 }
45 emit homeClicked(this);
46}
47
49{
50 if (this->internalState == Velocity)
51 {
52 velocityTimer.stop();
53 }
54 else if(this->internalState == Pwm)
55 {
56 pwmTimer.stop();
57 }
58 else if(this->internalState == Current)
59 {
60 currentTimer.stop();
61 }
62 else if(this->internalState == Torque)
63 {
64 torqueTimer.stop();
65 }
66 emit runClicked(this);
67}
68
70{
71 if (this->internalState == Velocity)
72 {
73 velocityTimer.stop();
74 }
75 else if(this->internalState == Pwm)
76 {
77 pwmTimer.stop();
78 }
79 else if(this->internalState == Current)
80 {
81 currentTimer.stop();
82 }
83 else if(this->internalState == Torque)
84 {
85 torqueTimer.stop();
86 }
87 emit idleClicked(this);
88}
89
91{
92 emit pidClicked(this);
93}
94
96{
97 QColor output;
98 switch (mode) {
99 case JointItem::Idle:{
100 output = idleColor;
101 break;
102 }
104 output = positionColor;
105 break;
106 }
108 output = positionDirectColor;
109 break;
110 }
111 case JointItem::Mixed:{
112 output = mixedColor;
113 break;
114 }
116 output = velocityColor;
117 break;
118 }
119 case JointItem::Torque:{
120 output = torqueColor;
121 break;
122 }
123 case JointItem::Pwm:{
124 output = pwmColor;
125 break;
126 }
127 case JointItem::Current:{
128 output = currentColor;
129 break;
130 }
131
133 output = disconnectColor;
134 break;
135 }
136 case JointItem::HwFault:{
137 output = hwFaultColor;
138 break;
139 }
141 output = calibratingColor;
142 break;
143 }
145 output = calibratingColor;
146 break;
147 }
149 output = calibratingColor;
150 break;
151 }
152
153 default:
154 output = calibratingColor;
155 break;
156 }
157
158 return output;
159
160}
161
163{
164 QString output;
165 switch (mode) {
166 case JointItem::Idle:{
167 output = "Idle";
168 break;
169 }
171 output = "Position";
172 break;
173 }
175 output = "Position Direct";
176 break;
177 }
178 case JointItem::Mixed:{
179 output = "Mixed";
180 break;
181 }
183 output = "Velocity";
184 break;
185 }
186 case JointItem::Torque:{
187 output = "Torque";
188 break;
189 }
190 case JointItem::Pwm:{
191 output = "PWM";
192 break;
193 }
194 case JointItem::Current:{
195 output = "Current";
196 break;
197 }
198
200 output = "Disconnected";
201 break;
202 }
203 case JointItem::HwFault:{
204 output = "Hardware Fault";
205 break;
206 }
208 output = "Calibrating";
209 break;
210 }
212 output = "Not Configured";
213 break;
214 }
216 output = "Configured";
217 break;
218 }
219
220 default:
221 output = "Unknown";
222 break;
223 }
224
225 return output;
226
227}
228
229void JointItem::updateTrajectoryPositionTarget(double val)
230{
231 ui->sliderTrajectoryPosition->updateSliderTarget(val);
232}
233
234void JointItem::updateMixedPositionTarget(double val)
235{
236 ui->sliderMixedPosition->updateSliderTarget(val);
237}
238
239JointItem::JointItem(int index,QWidget *parent) :
240 QWidget(parent),
241 ui(new Ui::JointItem)
242{
243 ui->setupUi(this);
244 internalState = StateStarting;
245 internalInteraction = InteractionStarting;
246 jointIndex = index;
247 sliderDirectPositionPressed = false;
248 sliderMixedPositionPressed = false;
249 sliderMixedVelocityPressed = false;
250 sliderTrajectoryPositionPressed = false;
251 sliderTrajectoryVelocityPressed = false;
252 sliderTorquePressed = false;
253 sliderPWMPressed = false;
254 sliderCurrentPressed = false;
255 sliderVelocityPressed = false;
256 enableCalib = true;
257 joint_speedVisible = false;
258 joint_motorPositionVisible = false;
259 joint_currentVisible = false;
260 joint_dutyVisible = false;
261 lastVelocity = 0;
262 velocityModeEnabled = false;
263 lastPwm = 0;
264 pwmModeEnabled = false;
265 lastCurrent = 0;
266 currentModeEnabled = false;
267 lastTorque = 0;
268 torqueModeEnabled = false;
269 motionDone = true;
270
271 max_position = 0;
272 min_position = 0;
273 max_velocity = 0;
274 min_velocity = 0;
275 max_trajectory_velocity = 0;
276 max_torque = 0;
277 min_torque = 0;
278 max_current = 0;
279 min_current = 0;
280 ref_torque = 0;
281 ref_pwm = 0;
282 ref_current = 0;
283
284 IDLE = 0;
285 POSITION = 1;
286 POSITION_DIR = 2;
287 MIXED = 3;
288 VELOCITY = 4;
289 TORQUE = 5;
290 PWM = 6;
291 CURRENT = 7;
292 HW_FAULT = 8;
293
294
295
296 connect(ui->comboMode,SIGNAL(currentIndexChanged(int)),this,SLOT(onModeChanged(int)));
297 connect(ui->comboInteraction,SIGNAL(currentIndexChanged(int)),this,SLOT(onInteractionChanged(int)));
298
299 ui->sliderTrajectoryPosition->installEventFilter(this);
300 connect(ui->sliderTrajectoryPosition,SIGNAL(sliderPressed()),this,SLOT(onSliderTrajectoryPositionPressed()));
301 connect(ui->sliderTrajectoryPosition, SIGNAL(sliderReleased()), this, SLOT(onSliderTrajectoryPositionReleased()));
302 ui->sliderTrajectoryPosition->disableClickOutOfHandle=true;
303 ui->sliderTrajectoryPosition->enableViewTargetBox = true;
304 ui->sliderTrajectoryPosition->enableViewTargetValue = false;
305
306 ui->sliderTorqueTorque->installEventFilter(this);
307 connect(ui->sliderTorqueTorque,SIGNAL(sliderPressed()),this,SLOT(onSliderTorquePressed()));
308 connect(ui->sliderTorqueTorque,SIGNAL(sliderReleased()),this,SLOT(onSliderTorqueReleased()));
309 ui->sliderTorqueTorque->disableClickOutOfHandle = true;
310 ui->sliderTorqueTorque->enableViewTargetBox = false;
311 ui->sliderTorqueTorque->enableViewTargetValue = false;
312
313 ui->sliderPWMOutput->installEventFilter(this);
314 connect(ui->sliderPWMOutput, SIGNAL(sliderPressed()), this, SLOT(onSliderPWMPressed()));
315 connect(ui->sliderPWMOutput, SIGNAL(sliderReleased()), this, SLOT(onSliderPWMReleased()));
316 ui->sliderPWMOutput->disableClickOutOfHandle = true;
317 ui->sliderPWMOutput->enableViewTargetBox = false;
318 ui->sliderPWMOutput->enableViewTargetValue = false;
319
320 ui->sliderCurrentOutput->installEventFilter(this);
321 connect(ui->sliderCurrentOutput, SIGNAL(sliderPressed()), this, SLOT(onSliderCurrentPressed()));
322 connect(ui->sliderCurrentOutput, SIGNAL(sliderReleased()), this, SLOT(onSliderCurrentReleased()));
323 ui->sliderCurrentOutput->disableClickOutOfHandle = true;
324 ui->sliderCurrentOutput->enableViewTargetBox = false;
325 ui->sliderCurrentOutput->enableViewTargetValue = false;
326
327 ui->sliderDirectPosition->installEventFilter(this);
328 connect(ui->sliderDirectPosition, SIGNAL(sliderPressed()), this, SLOT(onSliderDirectPositionPressed()));
329 connect(ui->sliderDirectPosition, SIGNAL(sliderReleased()), this, SLOT(onSliderDirectPositionReleased()));
330 ui->sliderDirectPosition->disableClickOutOfHandle = true;
331 ui->sliderDirectPosition->enableViewTargetBox = false;
332 ui->sliderDirectPosition->enableViewTargetValue = false;
333
334 ui->sliderMixedPosition->installEventFilter(this);
335 connect(ui->sliderMixedPosition, SIGNAL(sliderPressed()), this, SLOT(onSliderMixedPositionPressed()));
336 connect(ui->sliderMixedPosition, SIGNAL(sliderReleased()), this, SLOT(onSliderMixedPositionReleased()));
337 ui->sliderMixedPosition->disableClickOutOfHandle = true;
338 ui->sliderMixedPosition->enableViewTargetBox = true;
339 ui->sliderMixedPosition->enableViewTargetValue = false;
340
341 ui->sliderVelocityVelocity->installEventFilter(this);
342 connect(ui->sliderVelocityVelocity,SIGNAL(sliderPressed()),this,SLOT(onSliderVelocityPressed()));
343 connect(ui->sliderVelocityVelocity,SIGNAL(sliderReleased()),this,SLOT(onSliderVelocityReleased()));
344 ui->sliderVelocityVelocity->disableClickOutOfHandle = true;
345 ui->sliderVelocityVelocity->enableViewTargetBox = false;
346 ui->sliderVelocityVelocity->enableViewTargetValue = false;
347
348 ui->sliderTrajectoryVelocity->installEventFilter(this);
349 connect(ui->sliderTrajectoryVelocity, SIGNAL(sliderPressed()), this, SLOT(onSliderTrajectoryVelocityPressed()));
350 connect(ui->sliderTrajectoryVelocity, SIGNAL(sliderReleased()), this, SLOT(onSliderTrajectoryVelocityReleased()));
351 ui->sliderTrajectoryVelocity->disableClickOutOfHandle = true;
352 ui->sliderTrajectoryVelocity->enableViewTargetBox = false;
353 ui->sliderTrajectoryVelocity->enableViewTargetValue = false;
354
355 ui->sliderMixedVelocity->installEventFilter(this);
356 connect(ui->sliderMixedVelocity, SIGNAL(sliderPressed()), this, SLOT(onSliderMixedVelocityPressed()));
357 connect(ui->sliderMixedVelocity, SIGNAL(sliderReleased()), this, SLOT(onSliderMixedVelocityReleased()));
358 ui->sliderMixedVelocity->disableClickOutOfHandle = true;
359 ui->sliderMixedVelocity->enableViewTargetBox = false;
360 ui->sliderMixedVelocity->enableViewTargetValue = false;
361
362 connect(ui->buttonHome,SIGNAL(clicked()),this,SLOT(onHomeClicked()));
363 connect(ui->buttonIdle,SIGNAL(clicked()),this,SLOT(onIdleClicked()));
364 connect(ui->buttonRun,SIGNAL(clicked()),this,SLOT(onRunClicked()));
365 connect(ui->buttonPid,SIGNAL(clicked()),this,SLOT(onPidClicked()));
366 connect(ui->buttonCalib,SIGNAL(clicked()),this,SLOT(onCalibClicked()));
367
368 ui->groupBox->setTitle(QString("JOINT %1 (%2)").arg(index).arg(jointName));
369 // ui->groupBox->setAlignment(Qt::AlignHCenter);
370
371
372
373
374 comboStyle1 = "QComboBox {"
375 "border: 1px solid gray;"
376 "border-radius: 3px;"
377 "padding: 1px 18px 1px 3px;"
378 "min-width: 6em;}"
379 "QComboBox:editable {"
380 "background: white;"
381 "foreground: rgb(35, 38, 41);}"
382 "QComboBox::down-arrow {"
383 "image: url(:/images/downArrow.png);}";
384
385
386 comboStyle2 = "QComboBox:on { "
387 "padding-top: 3px;"
388 "padding-left: 4px;}"
389 "QComboBox::drop-down {"
390 "subcontrol-origin: padding;"
391 "subcontrol-position: top right;"
392 "width: 15px;"
393 "border-left-width: 1px;"
394 "border-left-color: darkgray;"
395 "border-left-style: solid; "
396 "border-top-right-radius: 3px; "
397 "border-bottom-right-radius: 3px;"
398 "background-color: darkgray;}";
399
400
401
402 installFilter();
403
404 ui->comboInteraction->setItemData(0,QColor(Qt::darkGray), Qt::BackgroundRole);
405 ui->comboInteraction->setItemData(1,QColor(0,80,255), Qt::BackgroundRole);
406 ui->comboInteraction->setItemData(1,QColor(35, 38, 41), Qt::ForegroundRole);
407
408 ui->comboMode->setItemData( IDLE, idleColor, Qt::BackgroundRole );
409 ui->comboMode->setItemData( POSITION, positionColor, Qt::BackgroundRole );
410 ui->comboMode->setItemData( POSITION_DIR, positionDirectColor, Qt::BackgroundRole );
411 ui->comboMode->setItemData( MIXED, mixedColor, Qt::BackgroundRole );
412 ui->comboMode->setItemData( VELOCITY, velocityColor, Qt::BackgroundRole );
413 ui->comboMode->setItemData( TORQUE, torqueColor, Qt::BackgroundRole );
414 ui->comboMode->setItemData( PWM, pwmColor, Qt::BackgroundRole );
415 ui->comboMode->setItemData( CURRENT, currentColor, Qt::BackgroundRole);
416
417 ui->comboMode->setItemData( IDLE, QColor(35, 38, 41), Qt::ForegroundRole );
418 ui->comboMode->setItemData( POSITION, QColor(35, 38, 41), Qt::ForegroundRole );
419 ui->comboMode->setItemData( POSITION_DIR, QColor(35, 38, 41), Qt::ForegroundRole );
420 ui->comboMode->setItemData( MIXED, QColor(35, 38, 41), Qt::ForegroundRole );
421 ui->comboMode->setItemData( VELOCITY, QColor(35, 38, 41), Qt::ForegroundRole );
422 ui->comboMode->setItemData( TORQUE, QColor(35, 38, 41), Qt::ForegroundRole );
423 ui->comboMode->setItemData( PWM, QColor(35, 38, 41), Qt::ForegroundRole );
424 ui->comboMode->setItemData( CURRENT, QColor(35, 38, 41), Qt::ForegroundRole );
425
426 ui->comboMode->setItemData( IDLE, Idle, Qt::UserRole);
427 ui->comboMode->setItemData( POSITION, Position, Qt::UserRole );
428 ui->comboMode->setItemData( POSITION_DIR, PositionDirect, Qt::UserRole );
429 ui->comboMode->setItemData( MIXED, Mixed, Qt::UserRole );
430 ui->comboMode->setItemData( VELOCITY, Velocity, Qt::UserRole );
431 ui->comboMode->setItemData( TORQUE, Torque, Qt::UserRole );
432 ui->comboMode->setItemData( PWM, Pwm, Qt::UserRole);
433 ui->comboMode->setItemData( CURRENT, Current, Qt::UserRole);
434
435 setJointInternalState(IDLE);
436
437 ui->stackedWidget->widget(VELOCITY)->setEnabled(false);
438 velocityTimer.setInterval(50);
439 velocityTimer.setSingleShot(false);
440 connect(&velocityTimer,SIGNAL(timeout()),this,SLOT(onVelocityTimer()));
441
442 ui->stackedWidget->widget(PWM)->setEnabled(false);
443 pwmTimer.setInterval(50);
444 pwmTimer.setSingleShot(false);
445 connect(&pwmTimer,SIGNAL(timeout()),this,SLOT(onPwmTimer()));
446
447 ui->stackedWidget->widget(CURRENT)->setEnabled(false);
448 currentTimer.setInterval(50);
449 currentTimer.setSingleShot(false);
450 connect(&currentTimer,SIGNAL(timeout()),this,SLOT(onCurrentTimer()));
451
452 ui->stackedWidget->widget(TORQUE)->setEnabled(false);
453 torqueTimer.setInterval(50);
454 torqueTimer.setSingleShot(false);
455 connect(&torqueTimer,SIGNAL(timeout()),this,SLOT(onTorqueTimer()));
456}
457
458bool JointItem::eventFilter(QObject *obj, QEvent *event)
459{
460 if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
461 auto* keyEvent = static_cast<QKeyEvent *>(event);
462 int key = keyEvent->key();
463 if(key == Qt::Key_Left || key == Qt::Key_Right || key == Qt::Key_Up ||
464 key == Qt::Key_Down || key == Qt::Key_PageUp || key == Qt::Key_PageDown){
465
466 //SliderWithTarget *slider=0;
467 QSlider* slider = nullptr;
468
469 if(obj == ui->sliderTrajectoryPosition){
470 slider = ui->sliderTrajectoryPosition;
471 if(keyEvent->type() == QEvent::KeyPress){
472 onSliderTrajectoryPositionPressed();
473 }
474 if(keyEvent->type() == QEvent::KeyRelease){
475 onSliderTrajectoryPositionReleased();
476 }
477 }
478 if(obj == ui->sliderTrajectoryVelocity){
479 slider = ui->sliderTrajectoryVelocity;
480 if (keyEvent->type() == QEvent::KeyPress){
481 onSliderTrajectoryVelocityPressed();
482 }
483 if (keyEvent->type() == QEvent::KeyRelease){
484 onSliderTrajectoryVelocityReleased();
485 }
486 }
487 if(obj == ui->sliderDirectPosition){
488 slider = ui->sliderDirectPosition;
489 if(keyEvent->type() == QEvent::KeyPress){
490 onSliderDirectPositionPressed();
491 }
492 if(keyEvent->type() == QEvent::KeyRelease){
493 onSliderDirectPositionReleased();
494 }
495 }
496 if(obj == ui->sliderMixedPosition){
497 slider = ui->sliderMixedPosition;
498 if(keyEvent->type() == QEvent::KeyPress){
499 onSliderMixedPositionPressed();
500 }
501 if(keyEvent->type() == QEvent::KeyRelease){
502 onSliderMixedPositionReleased();
503 }
504 }
505 if(obj == ui->sliderMixedVelocity){
506 slider = ui->sliderMixedVelocity;
507 }
508 if(obj == ui->sliderTorqueTorque){
509 slider = ui->sliderTorqueTorque;
510 if(keyEvent->type() == QEvent::KeyPress){
511 onSliderTorquePressed();
512 }
513 if(keyEvent->type() == QEvent::KeyRelease){
514 onSliderTorqueReleased();
515 }
516 }
517 if (obj == ui->sliderPWMOutput){
518 slider = ui->sliderPWMOutput;
519 if(keyEvent->type() == QEvent::KeyPress){
520 onSliderPWMPressed();
521 }
522 if(keyEvent->type() == QEvent::KeyRelease){
523 onSliderPWMReleased();
524 }
525 }
526 if (obj == ui->sliderCurrentOutput){
527 slider = ui->sliderCurrentOutput;
528 if (keyEvent->type() == QEvent::KeyPress){
529 onSliderCurrentPressed();
530 }
531 if (keyEvent->type() == QEvent::KeyRelease){
532 onSliderCurrentReleased();
533 }
534 }
535 if(obj == ui->sliderVelocityVelocity){
536 slider = ui->sliderVelocityVelocity;
537 if(keyEvent->type() == QEvent::KeyPress){
538 onSliderVelocityPressed();
539 }
540 if(keyEvent->type() == QEvent::KeyRelease){
541 onSliderVelocityReleased();
542 }
543 }
544
545 if (slider == nullptr) {
546 return false;
547 }
548
549
550 if(keyEvent->type() == QEvent::KeyPress){
551 if(key == Qt::Key_Left || key == Qt::Key_Down){
552 slider->setValue(slider->value() - 1);
553 }
554 if(key == Qt::Key_Right || key == Qt::Key_Up){
555 slider->setValue(slider->value() + 1);
556 }
557 if(key == Qt::Key_PageUp){
558 slider->setValue(slider->value() + 10);
559 }
560 if(key == Qt::Key_PageDown){
561 slider->setValue(slider->value() - 10);
562 }
563 }
564
565
566 return true;
567 }
568 return QObject::eventFilter(obj, event);
569
570 } else {
571 // standard event processing
572 return QObject::eventFilter(obj, event);
573 }
574}
575
577{
578 velocityModeEnabled = control;
579 ui->stackedWidget->widget(VELOCITY)->setEnabled(velocityModeEnabled);
580 if(ui->stackedWidget->currentIndex() == VELOCITY && velocityModeEnabled){
581 velocityTimer.start();
582 }
583}
584
586{
587 ui->stackedWidget->widget(MIXED)->setEnabled(control);
588}
589
591{
592 ui->stackedWidget->widget(POSITION_DIR)->setEnabled(control);
593}
594
596{
597 pwmModeEnabled = control;
598 ui->stackedWidget->widget(PWM)->setEnabled(pwmModeEnabled);
599 if(ui->stackedWidget->currentIndex() == PWM && pwmModeEnabled)
600 {
601 pwmTimer.start();
602 }
603}
604
606{
607 currentModeEnabled = control;
608 ui->stackedWidget->widget(CURRENT)->setEnabled(currentModeEnabled);
609 if(ui->stackedWidget->currentIndex() == CURRENT && currentModeEnabled)
610 {
611 currentTimer.start();
612 }
613}
614
616{
617 torqueModeEnabled = control;
618 ui->stackedWidget->widget(TORQUE)->setEnabled(torqueModeEnabled);
619 if(ui->stackedWidget->currentIndex() == TORQUE && torqueModeEnabled)
620 {
621 torqueTimer.start();
622 }
623}
624
626{
627 ui->sliderTrajectoryPosition->enableViewTargetBox = visible;
628 ui->sliderMixedPosition->enableViewTargetBox = visible;
629}
630
632{
633 ui->sliderTrajectoryPosition->enableViewTargetValue = visible;
634 ui->sliderMixedPosition->enableViewTargetValue = visible;
635}
636
638{
639 QString pos_metric_revolute("deg");
640 QString trq_metric_revolute("Nm");
641 QString trq_metric_revolute_title("Torque:");
642 QString vel_metric_revolute("deg/s");
643 QString pos_metric_prism("m");
644 QString trq_metric_prism("N");
645 QString trq_metric_prism_title("Force:");
646 QString vel_metric_prism("m/s");
647
649 {
650 ui->labelIdlevelUnits->setText(vel_metric_revolute);
651 ui->labelPositionvelUnits->setText(vel_metric_revolute);
652 ui->labelPositionDirvelUnits->setText(vel_metric_revolute);
653 ui->labelMixedvelUnits->setText(vel_metric_revolute);
654 ui->labelTorquevelUnits->setText(vel_metric_revolute);
655 ui->labelPWMvelUnits->setText(vel_metric_revolute);
656 ui->labelCurrentvelUnits->setText(vel_metric_revolute);
657 ui->labelVelocityvelUnits->setText(vel_metric_revolute);
658
659 ui->labelIdleTorque->setText(trq_metric_revolute_title);
660 ui->labelPositionTorque->setText(trq_metric_revolute_title);
661 ui->labelPositionDirTorque->setText(trq_metric_revolute_title);
662 ui->labelMixedTorque->setText(trq_metric_revolute_title);
663 ui->labelTorqueTorque->setText(trq_metric_revolute_title);
664 ui->labelPWMTorque->setText(trq_metric_revolute_title);
665 ui->labelCurrentTorque->setText(trq_metric_revolute_title);
666 ui->labelVelocityTorque->setText(trq_metric_revolute_title);
667
668 ui->labelIdleposUnits->setText(pos_metric_revolute);
669 ui->labelPositionposUnits->setText(pos_metric_revolute);
670 ui->labelPositionDirposUnits->setText(pos_metric_revolute);
671 ui->labelMixedposUnits->setText(pos_metric_revolute);
672 ui->labelTorqueposUnits->setText(pos_metric_revolute);
673 ui->labelPWMposUnits->setText(pos_metric_revolute);
674 ui->labelCurrentposUnits->setText(pos_metric_revolute);
675 ui->labelVelocityposUnits->setText(pos_metric_revolute);
676 ui->labelFaultposUnits->setText(pos_metric_revolute);
677
678 //ui->labelIdleMotorPosUnits->setText(pos_metric_revolute);
679 //ui->labelFaultMotorPosUnits->setText(pos_metric_revolute);
680
681 ui->labelIdletrqUnits->setText(trq_metric_revolute);
682 ui->labelPositiontrqUnits->setText(trq_metric_revolute);
683 ui->labelPositionDirtrqUnits->setText(trq_metric_revolute);
684 ui->labelMixedtrqUnits->setText(trq_metric_revolute);
685 ui->labelTorquetrqUnits->setText(trq_metric_revolute);
686 ui->labelPWMtrqUnits->setText(trq_metric_revolute);
687 ui->labelCurrenttrqUnits->setText(pos_metric_revolute);
688 ui->labelVelocitytrqUnits->setText(trq_metric_revolute);
689 }
691 {
692 ui->labelIdlevelUnits->setText(vel_metric_prism);
693 ui->labelPositionvelUnits->setText(vel_metric_prism);
694 ui->labelPositionDirvelUnits->setText(vel_metric_prism);
695 ui->labelMixedvelUnits->setText(vel_metric_prism);
696 ui->labelTorquevelUnits->setText(vel_metric_prism);
697 ui->labelPWMvelUnits->setText(vel_metric_prism);
698 ui->labelCurrentvelUnits->setText(vel_metric_prism);
699 ui->labelVelocityvelUnits->setText(vel_metric_prism);
700
701 ui->labelIdleTorque->setText(trq_metric_prism_title);
702 ui->labelPositionTorque->setText(trq_metric_prism_title);
703 ui->labelPositionDirTorque->setText(trq_metric_prism_title);
704 ui->labelMixedTorque->setText(trq_metric_prism_title);
705 ui->labelTorqueTorque->setText(trq_metric_prism_title);
706 ui->labelPWMTorque->setText(trq_metric_prism_title);
707 ui->labelCurrentTorque->setText(trq_metric_prism_title);
708 ui->labelVelocityTorque->setText(trq_metric_prism_title);
709
710 ui->labelIdleposUnits->setText(pos_metric_prism);
711 ui->labelPositionposUnits->setText(pos_metric_prism);
712 ui->labelPositionDirposUnits->setText(pos_metric_prism);
713 ui->labelMixedposUnits->setText(pos_metric_prism);
714 ui->labelTorqueposUnits->setText(pos_metric_prism);
715 ui->labelPWMposUnits->setText(pos_metric_prism);
716 ui->labelCurrentposUnits->setText(pos_metric_prism);
717 ui->labelVelocityposUnits->setText(pos_metric_prism);
718 ui->labelFaultposUnits->setText(pos_metric_prism);
719
720 //ui->labelIdleMotorPosUnits->setText(pos_metric_prism);
721 //ui->labelFaultMotorPosUnits->setText(pos_metric_prism);
722
723 ui->labelIdletrqUnits->setText(trq_metric_prism);
724 ui->labelPositiontrqUnits->setText(trq_metric_prism);
725 ui->labelPositionDirtrqUnits->setText(trq_metric_prism);
726 ui->labelMixedtrqUnits->setText(trq_metric_prism);
727 ui->labelTorquetrqUnits->setText(trq_metric_prism);
728 ui->labelPWMtrqUnits->setText(trq_metric_prism);
729 ui->labelCurrenttrqUnits->setText(trq_metric_prism);
730 ui->labelVelocitytrqUnits->setText(trq_metric_prism);
731 }
732 else
733 {
734 yFatal("Unspecified joint type");
735 }
736}
737
739{
740 joint_motorPositionVisible = visible;
741 ui->editIdleMotorPos->setVisible(visible);
742 ui->editPositionMotorPos->setVisible(visible);
743 ui->editPositionDirMotorPos->setVisible(visible);
744 ui->editMixedMotorPos->setVisible(visible);
745 ui->editTorqueMotorPos->setVisible(visible);
746 ui->editPWMMotorPos->setVisible(visible);
747 ui->editCurrentMotorPos->setVisible(visible);
748 ui->editVelocityMotorPos->setVisible(visible);
749 ui->editFaultMotorPos->setVisible(visible);
750
751 ui->labelIdleMotorPos->setVisible(visible);
752 ui->labelPositionMotorPos->setVisible(visible);
753 ui->labelPositionDirMotorPos->setVisible(visible);
754 ui->labelMixedMotorPos->setVisible(visible);
755 ui->labelTorqueMotorPos->setVisible(visible);
756 ui->labelPWMMotorPos->setVisible(visible);
757 ui->labelCurrentMotorPos->setVisible(visible);
758 ui->labelVelocityMotorPos->setVisible(visible);
759 ui->labelFaultMotorPos->setVisible(visible);
760
761 ui->labelIdleMotorPosUnits->setVisible(visible);
762 ui->labelPositionMotorPosUnits->setVisible(visible);
763 ui->labelPositionDirMotorPosUnits->setVisible(visible);
764 ui->labelMixedMotorPosUnits->setVisible(visible);
765 ui->labelTorqueMotorPosUnits->setVisible(visible);
766 ui->labelPWMMotorPosUnits->setVisible(visible);
767 ui->labelCurrentMotorPosUnits->setVisible(visible);
768 ui->labelVelocityMotorPosUnits->setVisible(visible);
769 ui->labelFaultMotorPosUnits->setVisible(visible);
770
771 if (!visible) {
772 ui->editIdleMotorPos->setMinimumHeight(0);
773 ui->editPositionMotorPos->setMinimumHeight(0);
774 ui->editPositionDirMotorPos->setMinimumHeight(0);
775 ui->editMixedMotorPos->setMinimumHeight(0);
776 ui->editTorqueMotorPos->setMinimumHeight(0);
777 ui->editPWMMotorPos->setMinimumHeight(0);
778 ui->editCurrentMotorPos->setMinimumHeight(0);
779 ui->editVelocityMotorPos->setMinimumHeight(0);
780 ui->editFaultMotorPos->setMinimumHeight(0);
781
782 ui->labelPositionMotorPos->setMinimumHeight(0);
783 ui->labelPositionMotorPosUnits->setMinimumHeight(0);
784 ui->labelPositionDirMotorPos->setMinimumHeight(0);
785 ui->labelPositionDirMotorPosUnits->setMinimumHeight(0);
786 ui->labelMixedMotorPos->setMinimumHeight(0);
787 ui->labelMixedMotorPosUnits->setMinimumHeight(0);
788 ui->labelTorqueMotorPos->setMinimumHeight(0);
789 ui->labelTorqueMotorPosUnits->setMinimumHeight(0);
790 ui->labelPWMMotorPos->setMinimumHeight(0);
791 ui->labelPWMMotorPosUnits->setMinimumHeight(0);
792 ui->labelCurrentMotorPos->setMinimumHeight(0);
793 ui->labelCurrentMotorPosUnits->setMinimumHeight(0);
794 ui->labelVelocityMotorPos->setMinimumHeight(0);
795 ui->labelVelocityMotorPosUnits->setMinimumHeight(0);
796 ui->labelIdleMotorPos->setMinimumHeight(0);
797 ui->labelIdleMotorPosUnits->setMinimumHeight(0);
798 ui->labelFaultMotorPos->setMinimumHeight(0);
799 ui->labelFaultMotorPosUnits->setMinimumHeight(0);
800 }
801 else {
802 ui->editIdleMotorPos->setMinimumHeight(20);
803 ui->editPositionMotorPos->setMinimumHeight(20);
804 ui->editPositionDirMotorPos->setMinimumHeight(20);
805 ui->editMixedMotorPos->setMinimumHeight(20);
806 ui->editTorqueMotorPos->setMinimumHeight(20);
807 ui->editPWMMotorPos->setMinimumHeight(20);
808 ui->editCurrentMotorPos->setMinimumHeight(20);
809 ui->editVelocityMotorPos->setMinimumHeight(20);
810 ui->editFaultMotorPos->setMinimumHeight(20);
811
812 ui->labelPositionMotorPos->setMinimumHeight(20);
813 ui->labelPositionMotorPosUnits->setMinimumHeight(20);
814 ui->labelPositionDirMotorPos->setMinimumHeight(20);
815 ui->labelPositionDirMotorPosUnits->setMinimumHeight(20);
816 ui->labelMixedMotorPos->setMinimumHeight(20);
817 ui->labelMixedMotorPosUnits->setMinimumHeight(20);
818 ui->labelTorqueMotorPos->setMinimumHeight(20);
819 ui->labelTorqueMotorPosUnits->setMinimumHeight(20);
820 ui->labelPWMMotorPos->setMinimumHeight(20);
821 ui->labelPWMMotorPosUnits->setMinimumHeight(20);
822 ui->labelCurrentMotorPos->setMinimumHeight(20);
823 ui->labelCurrentMotorPosUnits->setMinimumHeight(20);
824 ui->labelVelocityMotorPos->setMinimumHeight(20);
825 ui->labelVelocityMotorPosUnits->setMinimumHeight(20);
826 ui->labelIdleMotorPos->setMinimumHeight(20);
827 ui->labelIdleMotorPosUnits->setMinimumHeight(20);
828 ui->labelFaultMotorPos->setMinimumHeight(20);
829 ui->labelFaultMotorPosUnits->setMinimumHeight(20);
830 }
831}
832
834{
835 joint_dutyVisible = visible;
836 //ui->editIdleDuty->setVisible(visible);
837 //ui->editPositionDuty->setVisible(visible);
838 //ui->editPositionDirDuty->setVisible(visible);
839 // ui->editMixedDuty->setVisible(visible);
840 ui->editTorqueDuty->setVisible(visible);
841 ui->editCurrentDuty->setVisible(visible);
842 //ui->editPWMDuty->setVisible(visible);
843 //ui->editDutyDuty->setVisible(visible);
844 //ui->editVelocityDuty->setVisible(visible);
845
846 //ui->labelIdleDuty->setVisible(visible);
847 //ui->labelIdleDutyUnits->setVisible(visible);
848 //ui->labelPositionDuty->setVisible(visible);
849 //ui->labelPositionDutyUnits->setVisible(visible);
850 //ui->labelPositionDirDuty->setVisible(visible);
851 //ui->labelPositionDirDutyUnits->setVisible(visible);
852 //ui->labelMixedDuty->setVisible(visible);
853 //ui->labelMixedDutyUnits->setVisible(visible);
854 ui->labelTorqueDuty->setVisible(visible);
855 ui->labelTorqueDutyUnits->setVisible(visible);
856 //ui->labelPWMDuty->setVisible(visible);
857 ui->labelCurrentDuty->setVisible(visible);
858 //ui->labelPWMDutyUnits->setVisible(visible);
859 ui->labelCurrentDutyUnits->setVisible(visible);
860 //ui->labelVelocityDuty->setVisible(visible);
861 //ui->labelVelocityDutyUnits->setVisible(visible);
862
863
864 if (!visible) {
865 //ui->editIdleDuty->setMinimumHeight(0);
866 //ui->editPositionDuty->setMinimumHeight(0);
867 //ui->editPositionDirDuty->setMinimumHeight(0);
868 //ui->editMixedDuty->setMinimumHeight(0);
869 //ui->editTorqueDuty->setMinimumHeight(0);
870 //ui->editPWMDuty->setMinimumHeight(0);
871 //ui->editDutyDuty->setMinimumHeight(0);
872 //ui->editVelocityDuty->setMinimumHeight(0);
873
874 //ui->labelPositionDuty->setMinimumHeight(0);
875 //ui->labelPositionDutyUnits->setMinimumHeight(0);
876 //ui->labelPositionDirDuty->setMinimumHeight(0);
877 //ui->labelPositionDirDutyUnits->setMinimumHeight(0);
878 //ui->labelMixedDuty->setMinimumHeight(0);
879 //ui->labelMixedDutyUnits->setMinimumHeight(0);
880 ui->labelTorqueDuty->setMinimumHeight(0);
881 ui->labelTorqueDutyUnits->setMinimumHeight(0);
882 //ui->labelPWMDuty->setMinimumHeight(0);
883 //ui->labelPWMDutyUnits->setMinimumHeight(0);
884 ui->labelCurrentDuty->setMinimumHeight(0);
885 ui->labelCurrentDutyUnits->setMinimumHeight(0);
886 //ui->labelVelocityDuty->setMinimumHeight(0);
887 //ui->labelVelocityDutyUnits->setMinimumHeight(0);
888 //ui->labelIdleDuty->setMinimumHeight(0);
889 //ui->labelIdleDutyUnits->setMinimumHeight(0);
890 }
891 else {
892 //ui->editIdleDuty->setMinimumHeight(20);
893 //ui->editPositionDuty->setMinimumHeight(20);
894 //ui->editPositionDirDuty->setMinimumHeight(20);
895 //ui->editMixedDuty->setMinimumHeight(20);
896 ui->editTorqueDuty->setMinimumHeight(20);
897 //ui->editPWMDuty->setMinimumHeight(20);
898 ui->editCurrentDuty->setMinimumHeight(20);
899 //ui->editVelocityDuty->setMinimumHeight(20);
900
901 //ui->labelPositionDuty->setMinimumHeight(20);
902 //ui->labelPositionDutyUnits->setMinimumHeight(20);
903 //ui->labelPositionDirDuty->setMinimumHeight(20);
904 //ui->labelPositionDirDutyUnits->setMinimumHeight(20);
905 //ui->labelMixedDuty->setMinimumHeight(20);
906 //ui->labelMixedDutyUnits->setMinimumHeight(20);
907 ui->labelTorqueDuty->setMinimumHeight(20);
908 ui->labelTorqueDutyUnits->setMinimumHeight(20);
909 //ui->labelPWMDuty->setMinimumHeight(20);
910 //ui->labelPWMDutyUnits->setMinimumHeight(20);
911 ui->labelCurrentDuty->setMinimumHeight(20);
912 ui->labelCurrentDutyUnits->setMinimumHeight(20);
913 //ui->labelVelocityDuty->setMinimumHeight(20);
914 //ui->labelVelocityDutyUnits->setMinimumHeight(20);
915 //ui->labelIdleDuty->setMinimumHeight(20);
916 //ui->labelIdleDutyUnits->setMinimumHeight(20);
917 }
918}
919
921{
922 joint_currentVisible = visible;
923 ui->editIdleCurrent->setVisible(visible);
924 ui->editPositionCurrent->setVisible(visible);
925 ui->editPositionDirCurrent->setVisible(visible);
926 ui->editMixedCurrent->setVisible(visible);
927 ui->editTorqueCurrent->setVisible(visible);
928 ui->editPWMCurrent->setVisible(visible);
929 //ui->editCurrentCurrent->setVisible(visible);
930 ui->editVelocityCurrent->setVisible(visible);
931
932 ui->labelIdleCurrent->setVisible(visible);
933 ui->labelIdleCurrentUnits->setVisible(visible);
934 ui->labelPositionCurrent->setVisible(visible);
935 ui->labelPositionCurrentUnits->setVisible(visible);
936 ui->labelPositionDirCurrent->setVisible(visible);
937 ui->labelPositionDirCurrentUnits->setVisible(visible);
938 ui->labelMixedCurrent->setVisible(visible);
939 ui->labelMixedCurrentUnits->setVisible(visible);
940 ui->labelTorqueCurrent->setVisible(visible);
941 ui->labelTorqueCurrentUnits->setVisible(visible);
942 ui->labelPWMCurrent->setVisible(visible);
943 //ui->labelCurrentCurrent->setVisible(visible);
944 ui->labelPWMCurrentUnits->setVisible(visible);
945 //ui->labelCurrentCurrentUnits->setVisible(visible);
946 ui->labelVelocityCurrent->setVisible(visible);
947 ui->labelVelocityCurrentUnits->setVisible(visible);
948
949
950 if (!visible) {
951 ui->editIdleCurrent->setMinimumHeight(0);
952 ui->editPositionCurrent->setMinimumHeight(0);
953 ui->editPositionDirCurrent->setMinimumHeight(0);
954 ui->editMixedCurrent->setMinimumHeight(0);
955 ui->editTorqueCurrent->setMinimumHeight(0);
956 ui->editPWMCurrent->setMinimumHeight(0);
957 //ui->editCurrentCurrent->setMinimumHeight(0);
958 ui->editVelocityCurrent->setMinimumHeight(0);
959
960 ui->labelPositionCurrent->setMinimumHeight(0);
961 ui->labelPositionCurrentUnits->setMinimumHeight(0);
962 ui->labelPositionDirCurrent->setMinimumHeight(0);
963 ui->labelPositionDirCurrentUnits->setMinimumHeight(0);
964 ui->labelMixedCurrent->setMinimumHeight(0);
965 ui->labelMixedCurrentUnits->setMinimumHeight(0);
966 ui->labelTorqueCurrent->setMinimumHeight(0);
967 ui->labelTorqueCurrentUnits->setMinimumHeight(0);
968 ui->labelPWMCurrent->setMinimumHeight(0);
969 ui->labelPWMCurrentUnits->setMinimumHeight(0);
970 //ui->labelCurrentCurrent->setMinimumHeight(0);
971 //ui->labelCurrentCurrentUnits->setMinimumHeight(0);
972 ui->labelVelocityCurrent->setMinimumHeight(0);
973 ui->labelVelocityCurrentUnits->setMinimumHeight(0);
974 ui->labelIdleCurrent->setMinimumHeight(0);
975 ui->labelIdleCurrentUnits->setMinimumHeight(0);
976 }
977 else {
978 ui->editIdleCurrent->setMinimumHeight(20);
979 ui->editPositionCurrent->setMinimumHeight(20);
980 ui->editPositionDirCurrent->setMinimumHeight(20);
981 ui->editMixedCurrent->setMinimumHeight(20);
982 ui->editTorqueCurrent->setMinimumHeight(20);
983 ui->editPWMCurrent->setMinimumHeight(20);
984 //ui->editCurrentCurrent->setMinimumHeight(20);
985 ui->editVelocityCurrent->setMinimumHeight(20);
986
987 ui->labelPositionCurrent->setMinimumHeight(20);
988 ui->labelPositionCurrentUnits->setMinimumHeight(20);
989 ui->labelPositionDirCurrent->setMinimumHeight(20);
990 ui->labelPositionDirCurrentUnits->setMinimumHeight(20);
991 ui->labelMixedCurrent->setMinimumHeight(20);
992 ui->labelMixedCurrentUnits->setMinimumHeight(20);
993 ui->labelTorqueCurrent->setMinimumHeight(20);
994 ui->labelTorqueCurrentUnits->setMinimumHeight(20);
995 ui->labelPWMCurrent->setMinimumHeight(20);
996 ui->labelPWMCurrentUnits->setMinimumHeight(20);
997 //ui->labelCurrentCurrent->setMinimumHeight(20);
998 //ui->labelCurrentCurrentUnits->setMinimumHeight(20);
999 ui->labelVelocityCurrent->setMinimumHeight(20);
1000 ui->labelVelocityCurrentUnits->setMinimumHeight(20);
1001 ui->labelIdleCurrent->setMinimumHeight(20);
1002 ui->labelIdleCurrentUnits->setMinimumHeight(20);
1003 }
1004}
1005
1007{
1008 joint_speedVisible = visible;
1009 ui->editIdleSpeed->setVisible(visible);
1010 ui->editPositionSpeed->setVisible(visible);
1011 ui->editPositionDirSpeed->setVisible(visible);
1012 ui->editMixedSpeed->setVisible(visible);
1013 ui->editTorqueSpeed->setVisible(visible);
1014 ui->editPWMSpeed->setVisible(visible);
1015 ui->editCurrentSpeed->setVisible(visible);
1016 ui->editVelocitySpeed->setVisible(visible);
1017
1018 ui->labelIdleSpeed->setVisible(visible);
1019 ui->labelIdlevelUnits->setVisible(visible);
1020 ui->labelPositionSpeed->setVisible(visible);
1021 ui->labelPositionvelUnits->setVisible(visible);
1022 ui->labelPositionDirSpeed->setVisible(visible);
1023 ui->labelPositionDirvelUnits->setVisible(visible);
1024 ui->labelMixedSpeed->setVisible(visible);
1025 ui->labelMixedvelUnits->setVisible(visible);
1026 ui->labelTorqueSpeed->setVisible(visible);
1027 ui->labelTorquevelUnits->setVisible(visible);
1028 ui->labelPWMSpeed->setVisible(visible);
1029 ui->labelCurrentSpeed->setVisible(visible);
1030 ui->labelPWMvelUnits->setVisible(visible);
1031 ui->labelCurrentvelUnits->setVisible(visible);
1032 ui->labelVelocitySpeed->setVisible(visible);
1033 ui->labelVelocityvelUnits->setVisible(visible);
1034
1035
1036 if(!visible){
1037 ui->editIdleSpeed->setMinimumHeight(0);
1038 ui->editPositionSpeed->setMinimumHeight(0);
1039 ui->editPositionDirSpeed->setMinimumHeight(0);
1040 ui->editMixedSpeed->setMinimumHeight(0);
1041 ui->editTorqueSpeed->setMinimumHeight(0);
1042 ui->editPWMSpeed->setMinimumHeight(0);
1043 ui->editCurrentSpeed->setMinimumHeight(0);
1044 ui->editVelocitySpeed->setMinimumHeight(0);
1045
1046 ui->labelPositionSpeed->setMinimumHeight(0);
1047 ui->labelPositionvelUnits->setMinimumHeight(0);
1048 ui->labelPositionDirSpeed->setMinimumHeight(0);
1049 ui->labelPositionDirvelUnits->setMinimumHeight(0);
1050 ui->labelMixedSpeed->setMinimumHeight(0);
1051 ui->labelMixedvelUnits->setMinimumHeight(0);
1052 ui->labelTorqueSpeed->setMinimumHeight(0);
1053 ui->labelTorquevelUnits->setMinimumHeight(0);
1054 ui->labelPWMSpeed->setMinimumHeight(0);
1055 ui->labelPWMvelUnits->setMinimumHeight(0);
1056 ui->labelCurrentSpeed->setMinimumHeight(0);
1057 ui->labelCurrentvelUnits->setMinimumHeight(0);
1058 ui->labelVelocitySpeed->setMinimumHeight(0);
1059 ui->labelVelocityvelUnits->setMinimumHeight(0);
1060 ui->labelIdleSpeed->setMinimumHeight(0);
1061 ui->labelIdlevelUnits->setMinimumHeight(0);
1062 }else{
1063 ui->editIdleSpeed->setMinimumHeight(20);
1064 ui->editPositionSpeed->setMinimumHeight(20);
1065 ui->editPositionDirSpeed->setMinimumHeight(20);
1066 ui->editMixedSpeed->setMinimumHeight(20);
1067 ui->editTorqueSpeed->setMinimumHeight(20);
1068 ui->editPWMSpeed->setMinimumHeight(20);
1069 ui->editCurrentSpeed->setMinimumHeight(20);
1070 ui->editVelocitySpeed->setMinimumHeight(20);
1071
1072 ui->labelPositionSpeed->setMinimumHeight(20);
1073 ui->labelPositionvelUnits->setMinimumHeight(20);
1074 ui->labelPositionDirSpeed->setMinimumHeight(20);
1075 ui->labelPositionDirvelUnits->setMinimumHeight(20);
1076 ui->labelMixedSpeed->setMinimumHeight(20);
1077 ui->labelMixedvelUnits->setMinimumHeight(20);
1078 ui->labelTorqueSpeed->setMinimumHeight(20);
1079 ui->labelTorquevelUnits->setMinimumHeight(20);
1080 ui->labelPWMSpeed->setMinimumHeight(20);
1081 ui->labelPWMvelUnits->setMinimumHeight(20);
1082 ui->labelCurrentSpeed->setMinimumHeight(20);
1083 ui->labelCurrentvelUnits->setMinimumHeight(20);
1084 ui->labelVelocitySpeed->setMinimumHeight(20);
1085 ui->labelVelocityvelUnits->setMinimumHeight(20);
1086 ui->labelIdleSpeed->setMinimumHeight(20);
1087 ui->labelIdlevelUnits->setMinimumHeight(20);
1088 }
1089}
1090
1092{
1093 double positionSliderStep = 1 / (fabs(min_position - max_position) / 100.0);
1094 ui->sliderMixedPosition->setSliderStep(positionSliderStep);
1095 ui->sliderTrajectoryPosition->setSliderStep(positionSliderStep);
1096 ui->sliderDirectPosition->setSliderStep(positionSliderStep);
1097 ui->sliderMixedPosition->setIsDouble(true);
1098 ui->sliderTrajectoryPosition->setIsDouble(true);
1099 ui->sliderDirectPosition->setIsDouble(true);
1100 int sliderMin = min_position*positionSliderStep;
1101 int sliderMax = max_position*positionSliderStep;
1102 ui->sliderMixedPosition->setRange(sliderMin, sliderMax);
1103 ui->sliderTrajectoryPosition->setRange(sliderMin, sliderMax);
1104 ui->sliderDirectPosition->setRange(sliderMin, sliderMax);
1105 ui->sliderMixedPosition->resetTarget();
1106 ui->sliderTrajectoryPosition->resetTarget();
1107 ui->sliderDirectPosition->resetTarget();
1108}
1109
1111{
1112 double positionSliderStep = 1 / value;
1113 ui->sliderMixedPosition->setSliderStep(positionSliderStep);
1114 ui->sliderTrajectoryPosition->setSliderStep(positionSliderStep);
1115 ui->sliderDirectPosition->setSliderStep(positionSliderStep);
1116 ui->sliderMixedPosition->setIsDouble(true);
1117 ui->sliderTrajectoryPosition->setIsDouble(true);
1118 ui->sliderDirectPosition->setIsDouble(true);
1119 int sliderMin = min_position*positionSliderStep;
1120 int sliderMax = max_position*positionSliderStep;
1121 ui->sliderMixedPosition->setRange(sliderMin, sliderMax);
1122 ui->sliderTrajectoryPosition->setRange(sliderMin, sliderMax);
1123 ui->sliderDirectPosition->setRange(sliderMin, sliderMax);
1124 ui->sliderMixedPosition->resetTarget();
1125 ui->sliderTrajectoryPosition->resetTarget();
1126 ui->sliderDirectPosition->resetTarget();
1127}
1128
1130{
1131 ui->sliderMixedPosition->number_of_decimals=num;
1132 ui->sliderTrajectoryPosition->number_of_decimals = num;
1133 ui->sliderDirectPosition->number_of_decimals = num;
1134 ui->sliderMixedPosition->number_of_decimals = num;
1135 ui->sliderTrajectoryPosition->number_of_decimals = num;
1136 ui->sliderDirectPosition->number_of_decimals = num;
1137}
1138
1140{
1141 if (fabs(max_position - min_position) < 1.0)
1142 {
1143 yError("Unable to set integer position slider");
1144 return;
1145 }
1146 double positionSliderStep = 1;
1147 ui->sliderMixedPosition->setSliderStep(positionSliderStep);
1148 ui->sliderTrajectoryPosition->setSliderStep(positionSliderStep);
1149 ui->sliderDirectPosition->setSliderStep(positionSliderStep);
1150 ui->sliderMixedPosition->setIsDouble(false);
1151 ui->sliderTrajectoryPosition->setIsDouble(false);
1152 ui->sliderDirectPosition->setIsDouble(false);
1153 int sliderMin = min_position;
1154 int sliderMax = max_position;
1155 ui->sliderMixedPosition->setRange(sliderMin, sliderMax);
1156 ui->sliderTrajectoryPosition->setRange(sliderMin, sliderMax);
1157 ui->sliderDirectPosition->setRange(sliderMin, sliderMax);
1158 ui->sliderMixedPosition->resetTarget();
1159 ui->sliderTrajectoryPosition->resetTarget();
1160 ui->sliderDirectPosition->resetTarget();
1161}
1162
1164{
1165 double velocitySliderStep = 1 / (fabs(-max_velocity - max_velocity) / 100.0); //note that we are using -max_velocity
1166 ui->sliderVelocityVelocity->setSliderStep(velocitySliderStep);
1167 ui->sliderVelocityVelocity->setIsDouble(true);
1168 int sliderMin = -max_velocity*velocitySliderStep; //note that we are using -max_velocity
1169 int sliderMax = max_velocity*velocitySliderStep;
1170 ui->sliderVelocityVelocity->setRange(sliderMin, sliderMax);
1171 int v = ui->sliderVelocityVelocity->value();
1172 if (v > sliderMax) {}
1173 if (v < sliderMin) {}
1174 setRefVelocitySpeed(ref_speed);
1175}
1176
1178{
1179 double velocitySliderStep = 1 / value;
1180 ui->sliderVelocityVelocity->setSliderStep(velocitySliderStep);
1181 ui->sliderVelocityVelocity->setIsDouble(true);
1182 int sliderMin = -max_velocity*velocitySliderStep; //note that we are using -max_velocity
1183 int sliderMax = max_velocity*velocitySliderStep;
1184 ui->sliderVelocityVelocity->setRange(sliderMin, sliderMax);
1185 int v = ui->sliderVelocityVelocity->value();
1186 if (v > sliderMax) {}
1187 if (v < sliderMin) {}
1188 setRefVelocitySpeed(ref_speed);
1189}
1190
1192{
1193 if (fabs(max_velocity) < 1.0)
1194 {
1195 yError("Unable to set integer velocity slider");
1196 return;
1197 }
1198 double velocitySliderStep = 1;
1199 ui->sliderVelocityVelocity->setSliderStep(velocitySliderStep);
1200 ui->sliderVelocityVelocity->setIsDouble(false);
1201 int sliderMin = -max_velocity; //note that we are using -max_velocity
1202 int sliderMax = max_velocity;
1203 ui->sliderVelocityVelocity->setRange(sliderMin, sliderMax);
1204 int v = ui->sliderVelocityVelocity->value();
1205 if (v > sliderMax) {}
1206 if (v < sliderMin) {}
1207 setRefVelocitySpeed(ref_speed);
1208}
1209
1211{
1212 double torqueSliderStep = 1 / (fabs(-max_torque - max_torque) / 100.0); //note that we are using -max_velocity
1213 ui->sliderTorqueTorque->setSliderStep(torqueSliderStep);
1214 ui->sliderTorqueTorque->setIsDouble(true);
1215 int sliderMin = -max_torque*torqueSliderStep; //note that we are using -max_torque
1216 int sliderMax = max_torque*torqueSliderStep;
1217 ui->sliderTorqueTorque->setRange(sliderMin, sliderMax);
1218 int v = ui->sliderTorqueTorque->value();
1219 if (v > sliderMax) {}
1220 if (v < sliderMin) {}
1221 setRefTorque(ref_torque);
1222}
1223
1225{
1226 double torqueSliderStep = 1 / value;
1227 ui->sliderTorqueTorque->setSliderStep(torqueSliderStep);
1228 ui->sliderTorqueTorque->setIsDouble(true);
1229 int sliderMin = -max_torque*torqueSliderStep; //note that we are using -max_torque
1230 int sliderMax = max_torque*torqueSliderStep;
1231 ui->sliderTorqueTorque->setRange(sliderMin, sliderMax);
1232 int v = ui->sliderTorqueTorque->value();
1233 if (v > sliderMax) {}
1234 if (v < sliderMin) {}
1235 setRefTorque(ref_torque);
1236}
1237
1239{
1240 if (fabs(max_torque) < 1.0)
1241 {
1242 yError("Unable to set integer torque slider");
1243 return;
1244 }
1245 double torqueSliderStep = 1;
1246 ui->sliderTorqueTorque->setSliderStep(torqueSliderStep);
1247 ui->sliderTorqueTorque->setIsDouble(false);
1248 int sliderMin = -max_torque; //note that we are using -max_torque
1249 int sliderMax = max_torque;
1250 ui->sliderTorqueTorque->setRange(sliderMin, sliderMax);
1251 int v = ui->sliderTorqueTorque->value();
1252 if (v > sliderMax) {}
1253 if (v < sliderMin) {}
1254 setRefTorque(ref_torque);
1255}
1256
1258{
1259 double currentSliderStep = 1 / (fabs(-max_current - max_current) / 100.0); //note that we are using -max_velocity
1260 ui->sliderCurrentOutput->setSliderStep(currentSliderStep);
1261 ui->sliderCurrentOutput->setIsDouble(true);
1262 int sliderMin = -max_current*currentSliderStep; //note that we are using -max_current
1263 int sliderMax = max_current*currentSliderStep;
1264 ui->sliderCurrentOutput->setRange(sliderMin, sliderMax);
1265 int v = ui->sliderCurrentOutput->value();
1266 if (v > sliderMax) {}
1267 if (v < sliderMin) {}
1268 setRefCurrent(ref_current);
1269}
1270
1272{
1273 double currentSliderStep = 1 / value;
1274 ui->sliderCurrentOutput->setSliderStep(currentSliderStep);
1275 ui->sliderCurrentOutput->setIsDouble(true);
1276 int sliderMin = -max_current*currentSliderStep; //note that we are using -max_current
1277 int sliderMax = max_current*currentSliderStep;
1278 ui->sliderCurrentOutput->setRange(sliderMin, sliderMax);
1279 int v = ui->sliderCurrentOutput->value();
1280 if (v > sliderMax) {}
1281 if (v < sliderMin) {}
1282 setRefCurrent(ref_current);
1283}
1284
1286{
1287 if (fabs(max_velocity) < 1.0)
1288 {
1289 yError("Unable to set integer velocity slider");
1290 return;
1291 }
1292 double currentSliderStep = 1;
1293 ui->sliderCurrentOutput->setSliderStep(currentSliderStep);
1294 ui->sliderCurrentOutput->setIsDouble(false);
1295 int sliderMin = -max_current; //note that we are using -max_current
1296 int sliderMax = max_current;
1297 ui->sliderCurrentOutput->setRange(sliderMin, sliderMax);
1298 int v = ui->sliderCurrentOutput->value();
1299 if (v > sliderMax) {}
1300 if (v < sliderMin) {}
1301 setRefCurrent(ref_current);
1302}
1303
1305{
1306 double trajectoryVelocitySliderStep = 1 / (fabs(0 - max_trajectory_velocity) / 100.0); //note that we are using 0
1307 ui->sliderTrajectoryVelocity->setSliderStep(trajectoryVelocitySliderStep);
1308 ui->sliderTrajectoryVelocity->setIsDouble(true);
1309 int sliderMin = 0 * trajectoryVelocitySliderStep; //note that we are using 0
1310 int sliderMax = max_trajectory_velocity*trajectoryVelocitySliderStep;
1311 ui->sliderTrajectoryVelocity->setRange(sliderMin, sliderMax);
1312 int v = ui->sliderTrajectoryVelocity->value();
1313 if (v > sliderMax) {}
1314 if (v < sliderMin) {}
1315 setRefTrajectorySpeed(ref_trajectory_velocity);
1316}
1317
1319{
1320 double trajectoryVelocitySliderStep = 1 / value;
1321 ui->sliderTrajectoryVelocity->setSliderStep(trajectoryVelocitySliderStep);
1322 ui->sliderTrajectoryVelocity->setIsDouble(true);
1323 int sliderMin = 0 * trajectoryVelocitySliderStep; //note that we are using 0
1324 int sliderMax = max_trajectory_velocity*trajectoryVelocitySliderStep;
1325 ui->sliderTrajectoryVelocity->setRange(sliderMin, sliderMax);
1326 int v = ui->sliderTrajectoryVelocity->value();
1327 if (v > sliderMax) {}
1328 if (v < sliderMin) {}
1329 setRefTrajectorySpeed(ref_trajectory_velocity);
1330}
1331
1333{
1334 int sliderMin = 0; //note that we are using 0
1335 int sliderMax = max_trajectory_velocity;
1336 double trajectoryVelocitySliderStep = 1;
1337 ui->sliderTrajectoryVelocity->setSliderStep(trajectoryVelocitySliderStep);
1338 ui->sliderTrajectoryVelocity->setRange(sliderMin, sliderMax);
1339 ui->sliderTrajectoryVelocity->setIsDouble(false);
1340 int v = ui->sliderTrajectoryVelocity->value();
1341 if (v > sliderMax) {}
1342 if (v < sliderMin) {}
1343 setRefTrajectorySpeed(ref_trajectory_velocity);
1344}
1345
1348 bool enable_calib_all)
1349{
1350 Q_UNUSED(debug_param_enabled);
1351 Q_UNUSED(speedview_param_enabled);
1352
1353 enableCalib = enable_calib_all;
1354 if (!enable_calib_all){
1355 ui->buttonCalib->setEnabled(false);
1356 }
1357
1358 connect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(onStackedWidgetChanged(int)));
1359}
1360
1362{
1363 disconnect(ui->comboMode,SIGNAL(currentIndexChanged(int)),this,SLOT(onModeChanged(int)));
1364 disconnect(ui->comboInteraction,SIGNAL(currentIndexChanged(int)),this,SLOT(onInteractionChanged(int)));
1365
1366 disconnect(ui->sliderTrajectoryPosition,SIGNAL(sliderPressed()),this,SLOT(onSliderTrajectoryPositionPressed()));
1367 disconnect(ui->sliderTrajectoryPosition,SIGNAL(sliderReleased()),this,SLOT(onSliderTrajectoryPositionReleased()));
1368
1369 disconnect(ui->sliderTorqueTorque,SIGNAL(sliderPressed()),this,SLOT(onSliderTorquePressed()));
1370 disconnect(ui->sliderTorqueTorque,SIGNAL(sliderReleased()),this,SLOT(onSliderTorqueReleased()));
1371
1372 disconnect(ui->sliderPWMOutput, SIGNAL(sliderPressed()), this, SLOT(onSliderPWMPressed()));
1373 disconnect(ui->sliderPWMOutput, SIGNAL(sliderReleased()), this, SLOT(onSliderPWMReleased()));
1374
1375 disconnect(ui->sliderCurrentOutput, SIGNAL(sliderPressed()), this, SLOT(onSliderCurrentPressed()));
1376 disconnect(ui->sliderCurrentOutput, SIGNAL(sliderReleased()), this, SLOT(onSliderCurrentPressed()));
1377
1378 disconnect(ui->sliderDirectPosition, SIGNAL(sliderPressed()), this, SLOT(onSliderDirectPositionPressed()));
1379 disconnect(ui->sliderDirectPosition, SIGNAL(sliderReleased()), this, SLOT(onSliderDirectPositionReleased()));
1380
1381 disconnect(ui->sliderMixedPosition,SIGNAL(sliderPressed()),this,SLOT(onSliderMixedPositionPressed()));
1382 disconnect(ui->sliderMixedPosition,SIGNAL(sliderReleased()),this,SLOT(onSliderMixedPositionReleased()));
1383
1384 disconnect(ui->sliderTrajectoryVelocity, SIGNAL(sliderPressed()), this, SLOT(onSliderTrajectoryVelocityPressed()));
1385 disconnect(ui->sliderMixedVelocity, SIGNAL(sliderReleased()), this, SLOT(onSliderMixedVelocityReleased()));
1386
1387 disconnect(ui->buttonHome,SIGNAL(clicked()),this,SLOT(onHomeClicked()));
1388 disconnect(ui->buttonIdle,SIGNAL(clicked()),this,SLOT(onIdleClicked()));
1389 disconnect(ui->buttonRun,SIGNAL(clicked()),this,SLOT(onRunClicked()));
1390 disconnect(ui->buttonPid,SIGNAL(clicked()),this,SLOT(onPidClicked()));
1391 disconnect(ui->buttonCalib,SIGNAL(clicked()),this,SLOT(onCalibClicked()));
1392 delete ui;
1393}
1394
1396{
1397 return jointIndex;
1398}
1399
1400void JointItem::installFilter()
1401{
1402 auto* filter = new WheelEventFilter();
1403 filter->setParent(this);
1404 ui->comboMode->installEventFilter(filter);
1405 ui->comboInteraction->installEventFilter(filter);
1406
1407 ui->sliderMixedPosition->installEventFilter(filter);
1408 ui->sliderMixedVelocity->installEventFilter(filter);
1409 ui->sliderDirectPosition->installEventFilter(filter);
1410 ui->sliderTrajectoryPosition->installEventFilter(filter);
1411 ui->sliderTrajectoryVelocity->installEventFilter(filter);
1412 ui->sliderTorqueTorque->installEventFilter(filter);
1413}
1414
1415
1416void JointItem::onStackedWidgetChanged(int index)
1417{
1418 if(index == VELOCITY)
1419 {
1420 if(velocityModeEnabled)
1421 {
1422 velocityTimer.start();
1423 }
1424 }
1425 else if(index == PWM)
1426 {
1427 if(pwmModeEnabled)
1428 {
1429 pwmTimer.start();
1430 }
1431 }
1432 else if(index == CURRENT)
1433 {
1434 if(currentModeEnabled)
1435 {
1436 currentTimer.start();
1437 }
1438 }
1439 else if(index == TORQUE)
1440 {
1441 if(torqueModeEnabled)
1442 {
1443 torqueTimer.start();
1444 }
1445 }
1446 else
1447 {
1448 if(velocityModeEnabled)
1449 {
1450 velocityTimer.stop();
1451 lastVelocity = 0;
1452 updateSliderVelocity(0);
1453 }
1454 if(pwmModeEnabled)
1455 {
1456 pwmTimer.stop();
1457 lastPwm = 0;
1458 updateSliderPWM(0);
1459 }
1460 if(currentModeEnabled)
1461 {
1462 currentTimer.stop();
1463 lastCurrent = 0;
1464 updateSliderCurrent(0);
1465 }
1466 if(torqueModeEnabled)
1467 {
1468 torqueTimer.stop();
1469 lastTorque = 0;
1470 updateSliderTorque(0);
1471 }
1472 }
1473}
1474
1475void JointItem::onModeChanged(int index)
1476{
1477 // Stop all timers, the correct one will be enabled by onStackedWidgetChanged()
1478 velocityTimer.stop();
1479 pwmTimer.stop();
1480 currentTimer.stop();
1481 torqueTimer.stop();
1482 Q_UNUSED(index);
1483 int mode = ui->comboMode->currentData(Qt::UserRole).toInt();
1484 emit changeMode(mode,this);
1485}
1486
1487
1488void JointItem::onInteractionChanged(int index)
1489{
1490 emit changeInteraction(index,this);
1491}
1492
1493void JointItem::setJointName(QString name)
1494{
1495 jointName = name;
1496}
1497
1499{
1500 return jointName;
1501}
1502
1503void JointItem::onSliderVelocityPressed()
1504{
1505 sliderVelocityPressed = true;
1506}
1507
1508void JointItem::onSliderVelocityReleased()
1509{
1510 lastVelocity = (double)ui->sliderVelocityVelocity->value() / ui->sliderVelocityVelocity->getSliderStep();
1511 sliderVelocityPressed = false;
1512}
1513
1514void JointItem::onSliderMixedVelocityPressed()
1515{
1516 sliderMixedVelocityPressed = true;
1517}
1518
1519void JointItem::onSliderMixedVelocityReleased()
1520{
1521 lastVelocity = ui->sliderMixedVelocity->value();
1522
1523 if (ui->sliderMixedVelocity->getIsDouble())
1524 {
1525 double val = ui->sliderMixedVelocity->value();
1526 emit sliderMixedVelocityCommand(val / ui->sliderMixedVelocity->getSliderStep(), jointIndex);
1527 }
1528 else
1529 {
1530 emit sliderMixedVelocityCommand(ui->sliderMixedVelocity->value(), jointIndex);
1531 }
1532
1533 sliderMixedVelocityPressed = false;
1534}
1535
1536
1537void JointItem::onVelocityTimer()
1538{
1539 if(velocityModeEnabled)
1540 {
1541 emit sliderVelocityCommand(lastVelocity,jointIndex);
1542 }
1543}
1544
1545void JointItem::onPwmTimer()
1546{
1547 if(pwmModeEnabled)
1548 {
1549 emit sliderPWMCommand(lastPwm,jointIndex);
1550 }
1551}
1552
1553void JointItem::onCurrentTimer()
1554{
1555 if(currentModeEnabled)
1556 {
1557 emit sliderCurrentCommand(lastCurrent,jointIndex);
1558 }
1559}
1560
1561void JointItem::onTorqueTimer()
1562{
1563 if(torqueModeEnabled)
1564 {
1565 emit sliderTorqueCommand(lastTorque, jointIndex);
1566 }
1567}
1568
1569void JointItem::onSliderTrajectoryPositionPressed()
1570{
1571 sliderTrajectoryPositionPressed = true;
1572}
1573
1574void JointItem::onSliderTrajectoryPositionReleased()
1575{
1576 if (ui->sliderTrajectoryPosition->getIsDouble())
1577 {
1578 double val = ui->sliderTrajectoryPosition->value();
1579 emit sliderTrajectoryPositionCommand(val / ui->sliderTrajectoryPosition->getSliderStep(), jointIndex);
1580 updateTrajectoryPositionTarget(val / ui->sliderTrajectoryPosition->getSliderStep());
1581 }
1582 else
1583 {
1584 double val = ui->sliderTrajectoryPosition->value();
1585 emit sliderTrajectoryPositionCommand(val, jointIndex);
1586 updateTrajectoryPositionTarget(val);
1587 }
1588 sliderTrajectoryPositionPressed = false;
1589 motionDone = false;
1590}
1591
1592void JointItem::onSliderMixedPositionPressed()
1593{
1594 sliderMixedPositionPressed = true;
1595}
1596
1597void JointItem::onSliderMixedPositionReleased()
1598{
1599 if (ui->sliderMixedPosition->getIsDouble())
1600 {
1601 double val = ui->sliderMixedPosition->value();
1602 emit sliderMixedPositionCommand(val / ui->sliderMixedPosition->getSliderStep(), jointIndex);
1603 updateMixedPositionTarget(val / ui->sliderMixedPosition->getSliderStep());
1604 }
1605 else
1606 {
1607 double val = ui->sliderMixedPosition->value();
1608 emit sliderMixedPositionCommand(val, jointIndex);
1609 updateMixedPositionTarget(val);
1610 }
1611
1612 sliderMixedPositionPressed = false;
1613 motionDone = false;
1614}
1615
1616void JointItem::onSliderDirectPositionPressed()
1617{
1618 sliderDirectPositionPressed = true;
1619}
1620
1621void JointItem::onSliderDirectPositionReleased()
1622{
1623 double ref_direct_position = (double)ui->sliderDirectPosition->value() / ui->sliderDirectPosition->getSliderStep();
1624 emit sliderDirectPositionCommand(ref_direct_position, jointIndex);
1625 sliderDirectPositionPressed = false;
1626 motionDone = false;
1627}
1628
1629void JointItem::onSliderTrajectoryVelocityPressed()
1630{
1631 sliderTrajectoryVelocityPressed = true;
1632}
1633
1634void JointItem::onSliderTrajectoryVelocityReleased()
1635{
1636 ref_trajectory_velocity = (double)ui->sliderTrajectoryVelocity->value() / ui->sliderTrajectoryVelocity->getSliderStep();
1637 emit sliderTrajectoryVelocityCommand(ref_trajectory_velocity, jointIndex);
1638 sliderTrajectoryVelocityPressed = false;
1639}
1640
1641void JointItem::onSliderPWMPressed()
1642{
1643 sliderPWMPressed = true;
1644}
1645
1646void JointItem::onSliderPWMReleased()
1647{
1648 lastPwm = (double)ui->sliderPWMOutput->value() / ui->sliderPWMOutput->getSliderStep();
1649 sliderPWMPressed = false;
1650}
1651
1652void JointItem::onSliderCurrentPressed()
1653{
1654 sliderCurrentPressed = true;
1655}
1656
1657void JointItem::onSliderCurrentReleased()
1658{
1659 lastCurrent = (double)ui->sliderCurrentOutput->value() / ui->sliderCurrentOutput->getSliderStep();
1660 sliderCurrentPressed = false;
1661}
1662
1663void JointItem::onSliderTorquePressed()
1664{
1665 sliderTorquePressed = true;
1666}
1667
1668void JointItem::onSliderTorqueReleased()
1669{
1670 lastTorque = (double)ui->sliderTorqueTorque->value() / ui->sliderTorqueTorque->getSliderStep();
1671 sliderTorquePressed = false;
1672}
1673
1674
1676{
1677 //this function is mainly used used by the sequencer
1678 double pos = (double)ui->sliderTrajectoryPosition->value() / ui->sliderTrajectoryPosition->getSliderStep();
1679 if (fabs(pos) < 1e-6) {
1680 pos = 0;
1681 }
1682 return pos;
1683}
1684
1686{
1687 //this function is mainly used used by the sequencer
1688 double vel = (double)ui->sliderTrajectoryVelocity->value() / ui->sliderTrajectoryVelocity->getSliderStep();
1689 if (fabs(vel) < 1e-6) {
1690 vel = 0;
1691 }
1692 return vel;
1693}
1694
1696{
1697 motionDone = done;
1698 int index = ui->stackedWidget->currentIndex();
1699 if (index == POSITION) {
1700 if(!done){
1701 ui->editPositionJointPos->setStyleSheet("background-color: rgb(255, 38, 41); color: rgb(35, 38, 41);");
1702 }else{
1703 ui->editPositionJointPos->setStyleSheet("background-color: rgb(255, 255, 255); color: rgb(35, 38, 41);");
1704 }
1705 } else if (index == POSITION_DIR) {
1706 if(!done){
1707 ui->editPositionDirJointPos->setStyleSheet("background-color: rgb(255, 38, 41); color: rgb(35, 38, 41);");
1708 }else{
1709 ui->editPositionDirJointPos->setStyleSheet("background-color: rgb(255, 255, 255); color: rgb(35, 38, 41);");
1710 }
1711 } else if (index == MIXED) {
1712 if(!done){
1713 ui->editMixedJointPos->setStyleSheet("background-color: rgb(255, 38, 41); color: rgb(35, 38, 41);");
1714 }else{
1715 ui->editMixedJointPos->setStyleSheet("background-color: rgb(255, 255, 255); color: rgb(35, 38, 41);");
1716 }
1717 }
1718}
1719
1720void JointItem::updateSliderPosition(SliderWithTarget *slider, double val)
1721{
1722 if(sliderTrajectoryPositionPressed ||
1723 sliderMixedPositionPressed ||
1724 sliderDirectPositionPressed)
1725 {
1726 return;
1727 }
1728
1729 /*
1730 //@@@checkme
1731 if (motionDone == false)
1732 {
1733 return;
1734 }*/
1735 slider->setValue(val);
1736}
1737
1738void JointItem::updateSliderVelocity(double val)
1739{
1740 if (sliderVelocityPressed)
1741 {
1742 return;
1743 }
1744 ui->sliderVelocityVelocity->setValue(val);
1745}
1746
1747void JointItem::updateSliderPWM(double val)
1748{
1749 if (sliderPWMPressed) {
1750 return;
1751 }
1752 ui->sliderPWMOutput->setValue(val);
1753}
1754
1755void JointItem::updateSliderCurrent(double val)
1756{
1757 if (sliderCurrentPressed) {
1758 return;
1759 }
1760 ui->sliderCurrentOutput->setValue(val);
1761}
1762
1763void JointItem::updateJointFault(int i, std::string message)
1764{
1765 ui->labelFaultCodeEntry->setText(QString::fromStdString(std::to_string(i)));
1766 ui->labelFaultMessageEntry->setText(QString::fromStdString(message));
1767}
1768
1769void JointItem::updateSliderTorque(double val)
1770{
1771 if(sliderTorquePressed){
1772 return;
1773 }
1774 ui->sliderTorqueTorque->setValue(val);
1775}
1776
1777void JointItem::updateSliderTrajectoryVelocity(double val)
1778{
1779 if (sliderTrajectoryVelocityPressed){
1780 return;
1781 }
1782 ui->sliderTrajectoryVelocity->setValue(val);
1783}
1784
1785void JointItem::setRefPWM(double pwmValue)
1786{
1787 if(sliderPWMPressed){
1788 return;
1789 }
1790 if(ui->stackedWidget->currentIndex() == PWM){
1791 updateSliderPWM(pwmValue);
1792 QString sVal;
1793 sVal = QString("%L1").arg(pwmValue, 0, 'f', 3);
1794 ui->editPWMDuty->setText(sVal);
1795 }
1796}
1797
1798void JointItem::setRefCurrent(double currentValue)
1799{
1800 if (sliderCurrentPressed){
1801 return;
1802 }
1803 if (ui->stackedWidget->currentIndex() == CURRENT){
1804 updateSliderCurrent(currentValue);
1805 QString sVal;
1806 sVal = QString("%L1").arg(currentValue, 0, 'f', 3);
1807 ui->editCurrentCurrent->setText(sVal);
1808 }
1809}
1810
1812{
1813 QString sVal;
1814 if (ui->sliderTrajectoryPosition->getIsDouble())
1815 {
1816 double pos = val;
1817 sVal = QString("%L1").arg(pos, 0, 'f', 3);
1818 }
1819 else
1820 {
1821 double pos = floor(val * 10) / 10;
1822 sVal = QString("%1").arg(pos);
1823 }
1824
1825 if(ui->stackedWidget->currentIndex() == IDLE){
1826 ui->editIdleJointPos->setText(sVal);
1827 }
1828
1829 if (ui->stackedWidget->currentIndex() == HW_FAULT) {
1830 ui->editFaultJointPos->setText(sVal);
1831 }
1832
1833 if(ui->stackedWidget->currentIndex() == POSITION){
1834 ui->editPositionJointPos->setText(sVal);
1835 updateSliderPosition(ui->sliderTrajectoryPosition, val);
1836 }
1837
1838 if(ui->stackedWidget->currentIndex() == POSITION_DIR){
1839 ui->editPositionDirJointPos->setText(sVal);
1840 updateSliderPosition(ui->sliderDirectPosition, val);
1841 }
1842
1843 if(ui->stackedWidget->currentIndex() == MIXED){
1844 ui->editMixedJointPos->setText(sVal);
1845 updateSliderPosition(ui->sliderMixedPosition, val);
1846 }
1847
1848 if(ui->stackedWidget->currentIndex() == VELOCITY){
1849 ui->editVelocityJointPos->setText(sVal);
1850
1851 }
1852 if(ui->stackedWidget->currentIndex() == TORQUE){
1853 ui->editTorqueJointPos->setText(sVal);
1854 }
1855 if(ui->stackedWidget->currentIndex() == PWM){
1856 ui->editPWMJointPos->setText(sVal);
1857 }
1858 if (ui->stackedWidget->currentIndex() == CURRENT){
1859 ui->editCurrentJointPos->setText(sVal);
1860 }
1861
1862}
1863
1865{
1866 if(ui->stackedWidget->currentIndex() == TORQUE){
1867 updateSliderTorque(val);
1868 ref_torque = val;
1869 }
1870}
1871
1873{
1874 if (ui->stackedWidget->currentIndex() == VELOCITY){
1875 updateSliderVelocity(val);
1876 ref_speed = val;
1877 }
1878}
1879
1881{
1882 if (ui->stackedWidget->currentIndex() == POSITION){
1883 updateSliderTrajectoryVelocity(val);
1884 ref_trajectory_velocity = val;
1885
1886 if (val < 0.001)
1887 {
1888 ui->groupBox_12->setStyleSheet("background-color:orange; color: rgb(35, 38, 41);");
1889 ui->groupBox_12->setTitle("Velocity is ZERO!");
1890 }
1891 else
1892 {
1893 ui->groupBox_12->setStyleSheet("background-color:transparent; color: rgb(35, 38, 41);");
1894 ui->groupBox_12->setTitle("Velocity");
1895 }
1896 }
1897}
1898
1900{
1901 if (ui->stackedWidget->currentIndex() == POSITION){
1902 updateTrajectoryPositionTarget(val);
1903 }
1904}
1905
1906void JointItem::setTorque(double val)
1907{
1908 QString sVal = QString("%L1").arg(val,0,'f',3);
1909
1910 if(ui->stackedWidget->currentIndex() == IDLE){
1911 ui->editIdleTorque->setText(sVal);
1912 }
1913
1914 if(ui->stackedWidget->currentIndex() == POSITION){
1915 ui->editPositionTorque->setText(sVal);
1916 }
1917
1918 if(ui->stackedWidget->currentIndex() == POSITION_DIR){
1919 ui->editPositionDirTorque->setText(sVal);
1920 }
1921
1922 if(ui->stackedWidget->currentIndex() == MIXED){
1923 ui->editMixedTorque->setText(sVal);
1924 }
1925
1926 if(ui->stackedWidget->currentIndex() == VELOCITY){
1927 ui->editVelocityTorque->setText(sVal);
1928 }
1929 if(ui->stackedWidget->currentIndex() == TORQUE){
1930 ui->editTorqueTorque->setText(sVal);
1931 }
1932 if(ui->stackedWidget->currentIndex() == PWM){
1933 ui->editPWMTorque->setText(sVal);
1934 }
1935 if (ui->stackedWidget->currentIndex() == CURRENT){
1936 ui->editCurrentTorque->setText(sVal);
1937 }
1938}
1939
1941{
1942 if (!joint_motorPositionVisible){
1943 return;
1944 }
1945
1946 double mot = val;
1947 QString sVal = QString("%1").arg(mot, 0, 'f', 1);
1948
1949 if (ui->stackedWidget->currentIndex() == HW_FAULT) {
1950 ui->editFaultMotorPos->setText(sVal);
1951 }
1952
1953 if (ui->stackedWidget->currentIndex() == IDLE){
1954 ui->editIdleMotorPos->setText(sVal);
1955 }
1956
1957 if (ui->stackedWidget->currentIndex() == POSITION){
1958 ui->editPositionMotorPos->setText(sVal);
1959 }
1960
1961 if (ui->stackedWidget->currentIndex() == POSITION_DIR) {
1962 ui->editPositionDirMotorPos->setText(sVal);
1963 }
1964
1965 if (ui->stackedWidget->currentIndex() == MIXED) {
1966 ui->editMixedMotorPos->setText(sVal);
1967 }
1968
1969 if (ui->stackedWidget->currentIndex() == VELOCITY) {
1970 ui->editVelocityMotorPos->setText(sVal);
1971 }
1972
1973 if (ui->stackedWidget->currentIndex() == TORQUE) {
1974 ui->editTorqueMotorPos->setText(sVal);
1975 }
1976
1977 if (ui->stackedWidget->currentIndex() == PWM) {
1978 ui->editPWMMotorPos->setText(sVal);
1979 }
1980
1981 if (ui->stackedWidget->currentIndex() == CURRENT) {
1982 ui->editCurrentMotorPos->setText(sVal);
1983 }
1984}
1985
1987{
1988 if (!joint_dutyVisible) {
1989 return;
1990 }
1991
1992 double mot = val;
1993 QString sVal = QString("%1").arg(mot, 0, 'f', 1);
1994
1995 //if (ui->stackedWidget->currentIndex() == IDLE) {
1996 // ui->editIdleDuty->setText(sVal);
1997 //}
1998
1999 //if (ui->stackedWidget->currentIndex() == POSITION) {
2000 // ui->editPositionDuty->setText(sVal);
2001 //}
2002
2003 //if (ui->stackedWidget->currentIndex() == POSITION_DIR) {
2004 // ui->editPositionDirDuty->setText(sVal);
2005 //}
2006
2007 //if (ui->stackedWidget->currentIndex() == MIXED) {
2008 // ui->editMixedDuty->setText(sVal);
2009 //}
2010
2011 //if (ui->stackedWidget->currentIndex() == VELOCITY) {
2012 // ui->editVelocityDuty->setText(sVal);
2013 //}
2014
2015 if (ui->stackedWidget->currentIndex() == TORQUE) {
2016 ui->editTorqueDuty->setText(sVal);
2017 }
2018
2019 if (ui->stackedWidget->currentIndex() == PWM) {
2020 ui->editPWMDuty->setText(sVal);
2021 }
2022
2023 if (ui->stackedWidget->currentIndex() == CURRENT) {
2024 ui->editCurrentDuty->setText(sVal);
2025 }
2026}
2027
2028void JointItem::setSpeed(double meas)
2029{
2030 if (!joint_speedVisible){
2031 return;
2032 }
2033 //TODO
2034
2035 double speed = meas;
2036 QString sVal = QString("%1").arg(speed,0,'f',1);
2037
2038 if(ui->stackedWidget->currentIndex() == IDLE){
2039 ui->editIdleSpeed->setText(sVal);
2040 }
2041
2042 if(ui->stackedWidget->currentIndex() == POSITION){
2043 ui->editPositionSpeed->setText(sVal);
2044 }
2045
2046 if(ui->stackedWidget->currentIndex() == POSITION_DIR){
2047 ui->editPositionDirSpeed->setText(sVal);
2048 }
2049
2050 if(ui->stackedWidget->currentIndex() == MIXED){
2051 ui->editMixedSpeed->setText(sVal);
2052 }
2053
2054 if(ui->stackedWidget->currentIndex() == VELOCITY){
2055 if(!sliderVelocityPressed){
2056 ui->editVelocitySpeed->setText(sVal);
2057 //updateSlider(ui->sliderVelocityVelocity,ui->labelVelocityVelocity,val);
2058 }
2059 }
2060 if(ui->stackedWidget->currentIndex() == TORQUE){
2061 ui->editTorqueSpeed->setText(sVal);
2062 //updateSliderTorque(val);
2063 }
2064 if(ui->stackedWidget->currentIndex() == PWM){
2065 ui->editPWMSpeed->setText(sVal);
2066 }
2067 if (ui->stackedWidget->currentIndex() == CURRENT){
2068 ui->editCurrentSpeed->setText(sVal);
2069 }
2070
2071}
2072
2073void JointItem::setCurrent(double meas)
2074{
2075 if (!joint_currentVisible) {
2076 return;
2077 }
2078 //TODO
2079
2080 double current = meas;
2081 QString sVal = QString("%1").arg(current, 0, 'f', 3);
2082
2083 if (ui->stackedWidget->currentIndex() == IDLE) {
2084 ui->editIdleCurrent->setText(sVal);
2085 }
2086
2087 if (ui->stackedWidget->currentIndex() == POSITION) {
2088 ui->editPositionCurrent->setText(sVal);
2089 }
2090
2091 if (ui->stackedWidget->currentIndex() == POSITION_DIR) {
2092 ui->editPositionDirCurrent->setText(sVal);
2093 }
2094
2095 if (ui->stackedWidget->currentIndex() == MIXED) {
2096 ui->editMixedCurrent->setText(sVal);
2097 }
2098
2099 if (ui->stackedWidget->currentIndex() == VELOCITY) {
2100 ui->editVelocityCurrent->setText(sVal);
2101 }
2102 if (ui->stackedWidget->currentIndex() == TORQUE) {
2103 ui->editTorqueCurrent->setText(sVal);
2104 }
2105 if (ui->stackedWidget->currentIndex() == PWM) {
2106 ui->editPWMCurrent->setText(sVal);
2107 }
2108 if (ui->stackedWidget->currentIndex() == CURRENT) {
2109 ui->editCurrentCurrent->setText(sVal);
2110 }
2111
2112}
2113
2114
2115
2116
2117void JointItem::setJointInternalInteraction(int interaction)
2118{
2119 disconnect(ui->comboInteraction,SIGNAL(currentIndexChanged(int)),this,SLOT(onInteractionChanged(int)));
2120 ui->comboInteraction->setCurrentIndex(interaction);
2121 connect(ui->comboInteraction,SIGNAL(currentIndexChanged(int)),this,SLOT(onInteractionChanged(int)));
2122}
2123
2124void JointItem::setJointInternalState(int mode)
2125{
2126 disconnect(ui->comboMode,SIGNAL(currentIndexChanged(int)),this,SLOT(onModeChanged(int)));
2127 ui->comboMode->setCurrentIndex(mode);
2128 connect(ui->comboMode,SIGNAL(currentIndexChanged(int)),this,SLOT(onModeChanged(int)));
2129
2130 ui->stackedWidget->setCurrentIndex(mode);
2131 if(ui->stackedWidget->widget(mode)){
2132 QVariant variant = ui->comboMode->itemData(mode,Qt::BackgroundRole);
2133 QColor c;
2134 switch(internalState)
2135 {
2136 case Disconnected:
2137 c = disconnectColor;
2138 break;
2139 case HwFault:
2140 ui->groupBox->setTitle(QString("JOINT %1 (%2) - HARDWARE FAULT").arg(jointIndex).arg(jointName));
2141 ui->stackedWidget->setEnabled(false);
2142 //ui->buttonsContainer->setEnabled(false);
2143 ui->buttonHome->setEnabled(false);
2144 ui->buttonCalib->setEnabled(false);
2145 ui->buttonRun->setEnabled(false);
2146 ui->comboMode->setEnabled(false);
2147 ui->comboInteraction->setEnabled(false);
2148 ui->buttonIdle->setEnabled(true);
2149 ui->buttonPid->setEnabled(true);
2150 c = hwFaultColor;
2151 break;
2152 case Unknown:
2153 case NotConfigured:
2154 case Configured:
2155 case CalibDone:
2156 case Calibrating:
2157 c = calibratingColor;
2158 break;
2159
2160 default:{
2161 enableAll();
2162 c = variant.value<QColor>();
2163 if(ui->groupBox->title() != QString("JOINT %1 (%2)").arg(jointIndex).arg(jointName))
2164 {
2165 ui->groupBox->setTitle(QString("JOINT %1 (%2)").arg(jointIndex).arg(jointName));
2166 }
2167 ui->stackedWidget->setEnabled(true);
2168 ui->buttonsContainer->setEnabled(true);
2169 break;
2170 }
2171 }
2172
2173 setStyleSheet(QString("font: 8pt; background-color: rgb(%1,%2,%3); color: rgb(35, 38, 41);").arg(c.red()).arg(c.green()).arg(c.blue()));
2174 }
2175}
2176
2178{
2179 if(internalInteraction == interaction){
2180 return;
2181 }
2182
2183 internalInteraction = interaction;
2184
2185 switch (internalInteraction) {
2186 case Stiff:
2187 setJointInternalInteraction(STIFF);
2188 break;
2189 case COMPLIANT:
2190 setJointInternalInteraction(COMPLIANT);
2191 break;
2192 default:
2193 break;
2194 }
2195}
2196
2197
2199{
2200 if(internalState == newState){
2201 return;
2202 }
2203
2204 internalState = newState;
2205
2206 switch (internalState) {
2207 case Unknown:{
2208 ui->groupBox->setTitle(QString("JOINT %1 (%2) - UNKNOWN").arg(jointIndex).arg(jointName));
2209 ui->stackedWidget->setEnabled(false);
2210 ui->buttonsContainer->setEnabled(false);
2211
2212 int index = ui->stackedWidget->currentIndex();
2213 if(ui->stackedWidget->widget(index)){
2214 QColor c = calibratingColor;
2215 setStyleSheet(QString("font: 8pt; background-color: rgb(%1,%2,%3); color: rgb(35, 38, 41);").arg(c.red()).arg(c.green()).arg(c.blue()));
2216 }
2217 break;
2218 }
2219 case Configured:{
2220 ui->groupBox->setTitle(QString("JOINT %1 (%2) - CONFIGURED").arg(jointIndex).arg(jointName));
2221 ui->stackedWidget->setEnabled(true);
2222 ui->buttonsContainer->setEnabled(true);
2223
2224 int index = ui->stackedWidget->currentIndex();
2225 if(ui->stackedWidget->widget(index)){
2226 QColor c = calibratingColor;
2227 setStyleSheet(QString("font: 8pt; background-color: rgb(%1,%2,%3); color: rgb(35, 38, 41);").arg(c.red()).arg(c.green()).arg(c.blue()));
2228 }
2229 break;
2230 }
2231
2232 case NotConfigured:{
2233 ui->groupBox->setTitle(QString("JOINT %1 (%2) - NOT CONFIGURED").arg(jointIndex).arg(jointName));
2234 ui->stackedWidget->setEnabled(false);
2235 //activating only calib button
2236 if(enableCalib)
2237 {
2238
2239 ui->buttonsContainer->setEnabled(true);
2240 ui->buttonIdle->setEnabled(false);
2241 ui->buttonPid->setEnabled(true);
2242 ui->buttonHome->setEnabled(false);
2243 ui->buttonCalib->setEnabled(true);
2244 ui->buttonRun->setEnabled(false);
2245 ui->comboMode->setEnabled(false);
2246 ui->comboInteraction->setEnabled(false);
2247 }
2248 //nothing must be activated
2249 else
2250 {
2251 ui->buttonsContainer->setEnabled(false);
2252 }
2253
2254 int index = ui->stackedWidget->currentIndex();
2255 if(ui->stackedWidget->widget(index)){
2256 QColor c = calibratingColor;
2257 setStyleSheet(QString("font: 8pt; background-color: rgb(%1,%2,%3); color: rgb(35, 38, 41);").arg(c.red()).arg(c.green()).arg(c.blue()));
2258 }
2259 break;
2260 }
2261
2262 case CalibDone:{
2263 ui->groupBox->setTitle(QString("JOINT %1 (%2) - CALIBRATING DONE").arg(jointIndex).arg(jointName));
2264 ui->stackedWidget->setEnabled(true);
2265 ui->buttonsContainer->setEnabled(true);
2266
2267 int index = ui->stackedWidget->currentIndex();
2268 if(ui->stackedWidget->widget(index)){
2269 QColor c = calibratingColor;
2270 setStyleSheet(QString("font: 8pt; background-color: rgb(%1,%2,%3); color: rgb(35, 38, 41);").arg(c.red()).arg(c.green()).arg(c.blue()));
2271 }
2272 break;
2273 }
2274 case Calibrating:{
2275 ui->groupBox->setTitle(QString("JOINT %1 (%2) - CALIBRATING").arg(jointIndex).arg(jointName));
2276 ui->stackedWidget->setEnabled(false);
2277 ui->buttonsContainer->setEnabled(false);
2278
2279 int index = ui->stackedWidget->currentIndex();
2280 if(ui->stackedWidget->widget(index)){
2281 QColor c = calibratingColor;
2282 setStyleSheet(QString("font: 8pt; background-color: rgb(%1,%2,%3); color: rgb(35, 38, 41);").arg(c.red()).arg(c.green()).arg(c.blue()));
2283 }
2284 break;
2285 }
2286 case HwFault:{
2287 setJointInternalState(HW_FAULT);
2288 break;
2289 }
2290 case Disconnected:{
2291 ui->groupBox->setTitle(QString("JOINT %1 (%2) - DISCONNECTED").arg(jointIndex).arg(jointName));
2292 ui->stackedWidget->setEnabled(false);
2293 ui->buttonsContainer->setEnabled(false);
2294
2295 int index = ui->stackedWidget->currentIndex();
2296 if(ui->stackedWidget->widget(index)){
2297 QColor c = disconnectColor;
2298 setStyleSheet(QString("font: 8pt; background-color: rgb(%1,%2,%3); color: rgb(35, 38, 41);").arg(c.red()).arg(c.green()).arg(c.blue()));
2299 }
2300 break;
2301 }
2302 case Idle:{
2303 setJointInternalState(IDLE);
2304 break;
2305 }
2306 case Position:{
2307 setJointInternalState(POSITION);
2308 break;
2309 }
2310 case PositionDirect:{
2311 setJointInternalState(POSITION_DIR);
2312 break;
2313 }
2314 case Mixed:{
2315 setJointInternalState(MIXED);
2316 break;
2317 }
2318 case Velocity:{
2319 setJointInternalState(VELOCITY);
2320 break;
2321 }
2322 case Torque:{
2323 setJointInternalState(TORQUE);
2324 break;
2325 }
2326 case Pwm:{
2327 setJointInternalState(PWM);
2328 break;
2329 }
2330 case Current:{
2331 setJointInternalState(CURRENT);
2332 break;
2333 }
2334 default:
2335 break;
2336 }
2337
2338}
2339
2340void JointItem::enableAll()
2341{
2342 ui->stackedWidget->setEnabled(true);
2343 ui->buttonsContainer->setEnabled(true);
2344 ui->buttonIdle->setEnabled(true);
2345 ui->buttonPid->setEnabled(true);
2346 ui->buttonHome->setEnabled(true);
2347 if(enableCalib){
2348 ui->buttonCalib->setEnabled(true);
2349 }
2350 ui->buttonRun->setEnabled(true);
2351 ui->comboMode->setEnabled(true);
2352 ui->comboInteraction->setEnabled(true);
2353
2354}
2355
2356void JointItem::setPWMRange(double min, double max)
2357{
2358 ui->sliderPWMOutput->setRange(min,max);
2359}
2360
2361void JointItem::setCurrentRange(double min, double max)
2362{
2363 if (min < max)
2364 {
2365 min_current = min;
2366 max_current = max;
2367 }
2368 else
2369 {
2370 //Error
2371 }
2372 ui->sliderCurrentOutput->setRange(min, max);
2373}
2374
2375void JointItem::setPositionRange(double min, double max)
2376{
2377 min_position = 1;
2378 max_position = 2;
2379 if(min < max)
2380 {
2381 min_position = min;
2382 max_position = max;
2383 }
2384 else
2385 {
2386 //Error
2387 }
2388}
2389
2390void JointItem::setVelocityRange(double min, double max)
2391{
2392 min_velocity = -100;
2393 max_velocity = 100;
2394 if (min < max)
2395 {
2396 min_velocity = min;
2397 max_velocity = max;
2398 }
2399 else
2400 {
2401 //Error
2402 }
2403}
2404
2406{
2407 max_trajectory_velocity = 100;
2408 if (max >= 0)
2409 {
2410 max_trajectory_velocity = max;
2411 }
2412 else
2413 {
2414 //Error
2415 }
2416}
2417
2419{
2420 max_torque = 5;
2421 if (max >= 0)
2422 {
2423 max_torque = max;
2424 }
2425 else
2426 {
2427 //Error
2428 }
2429}
2430
2431void JointItem::onCalibClicked()
2432{
2433 if (this->internalState == Velocity)
2434 {
2435 velocityTimer.stop();
2436 }
2437 else if(this->internalState == Pwm)
2438 {
2439 pwmTimer.stop();
2440 }
2441 else if(this->internalState == Current)
2442 {
2443 currentTimer.stop();
2444 }
2445 else if(this->internalState == Torque)
2446 {
2447 torqueTimer.stop();
2448 }
2449 emit calibClicked(this);
2450}
2451
2452void JointItem::onHomeClicked()
2453{
2454 home();
2455}
2456
2457void JointItem::onIdleClicked()
2458{
2459 idle();
2460}
2461
2462void JointItem::onRunClicked()
2463{
2464 run();
2465}
2466
2467void JointItem::onPidClicked()
2468{
2469 showPID();
2470}
2471
2473{
2474 ui->sliderMixedPosition->setEnabled(false);
2475 ui->sliderMixedVelocity->setEnabled(false);
2476 ui->sliderPWMOutput->setEnabled(false);
2477 ui->sliderCurrentOutput->setEnabled(false);
2478 ui->sliderDirectPosition->setEnabled(false);
2479 ui->sliderTrajectoryPosition->setEnabled(false);
2480 ui->sliderTrajectoryVelocity->setEnabled(false);
2481 ui->sliderTorqueTorque->setEnabled(false);
2482
2483}
2484
2486{
2487 ui->sliderMixedPosition->setEnabled(true);
2488 ui->sliderMixedVelocity->setEnabled(true);
2489 ui->sliderPWMOutput->setEnabled(true);
2490 ui->sliderCurrentOutput->setEnabled(true);
2491 ui->sliderDirectPosition->setEnabled(true);
2492 ui->sliderTrajectoryPosition->setEnabled(true);
2493 ui->sliderTrajectoryVelocity->setEnabled(true);
2494 ui->sliderTorqueTorque->setEnabled(true);
2495}
2496
2497
2498bool WheelEventFilter::eventFilter(QObject *obj, QEvent *event)
2499{
2500 if (event->type() == QEvent::Wheel) {
2501 return true;
2502 } else {
2503 // standard event processing
2504 return QObject::eventFilter(obj, event);
2505 }
2506}
#define yError(...)
Definition Log.h:361
#define yFatal(...)
Definition Log.h:382
int SIGNAL(int pid, int signum)
void setMotorPosition(double meas)
void viewPositionTargetValue(bool)
void setVelocityRange(double min, double max)
void setDutyVisible(bool)
void sequenceActivated()
void enableTrajectoryVelocitySliderDoubleAuto()
void updateJointFault(int i, std::string message)
void enableControlPositionDirect(bool control)
void enableVelocitySliderDoubleAuto()
void setCurrentsVisible(bool)
void setUnits(yarp::dev::JointTypeEnum t)
static QColor GetModeColor(JointState mode)
Definition jointitem.cpp:95
void setPositionRange(double min, double max)
void enableControlMixed(bool control)
void setRefTrajectoryPosition(double ref)
void sliderVelocityCommand(double val, int jointIndex)
void resetTarget()
Definition jointitem.cpp:21
void enablePositionSliderDoubleValue(double value)
void sliderCurrentCommand(double val, int jointIndex)
void enableCurrentSliderDoubleValue(double value)
void viewPositionTargetBox(bool)
void setJointState(JointState)
void enableControlPWM(bool control)
void disablePositionSliderDouble()
void disableCurrentSliderDouble()
void enableTorqueSliderDoubleValue(double value)
void homeClicked(JointItem *joint)
void setPosition(double val)
void sliderPWMCommand(double val, int jointIndex)
void setRefVelocitySpeed(double ref)
static QString GetModeString(JointState mode)
void sliderTrajectoryPositionCommand(double val, int jointIndex)
void setCurrentRange(double min, double max)
void setJointName(QString name)
void pidClicked(JointItem *joint)
QString getJointName()
void setPWMRange(double min, double max)
void updateMotionDone(bool done)
void setRefCurrent(double ref)
@ InteractionStarting
Definition jointitem.h:35
double getTrajectoryVelocityValue()
void setTrajectoryVelocityRange(double max)
void setSpeed(double val)
void enableCurrentSliderDoubleAuto()
bool eventFilter(QObject *obj, QEvent *event) override
int getJointIndex()
void sliderMixedPositionCommand(double val, int jointIndex)
void sliderDirectPositionCommand(double val, int jointIndex)
void disableTrajectoryVelocitySliderDouble()
void setJointInteraction(JointInteraction interaction)
void calibClicked(JointItem *joint)
void runClicked(JointItem *joint)
void setMotorPositionVisible(bool)
void enableControlVelocity(bool control)
void setDutyCycles(double duty)
double getTrajectoryPositionValue()
void setCurrent(double meas)
void setRefTrajectorySpeed(double ref)
void idle()
Definition jointitem.cpp:69
void disableVelocitySliderDouble()
void sliderTrajectoryVelocityCommand(double val, int jointIndex)
void setRefPWM(double ref)
void run()
Definition jointitem.cpp:48
void sliderTorqueCommand(double val, int jointIndex)
void enableControlCurrent(bool control)
void enableTrajectoryVelocitySliderDoubleValue(double value)
void setEnabledOptions(bool debug_param_enabled, bool speedview_param_enabled, bool enable_calib_all)
void sequenceStopped()
void changeMode(int mode, JointItem *joint)
void enableTorqueSliderDoubleAuto()
void setSpeedVisible(bool)
void showPID()
Definition jointitem.cpp:90
void home()
Definition jointitem.cpp:27
JointItem(int index, QWidget *parent=0)
void setNumberOfPositionSliderDecimals(size_t num)
@ PositionDirect
Definition jointitem.h:33
@ Disconnected
Definition jointitem.h:34
@ StateStarting
Definition jointitem.h:34
@ Calibrating
Definition jointitem.h:34
@ NotConfigured
Definition jointitem.h:34
void enableVelocitySliderDoubleValue(double value)
void enablePositionSliderDoubleAuto()
void disableTorqueSliderDouble()
void enableControlTorque(bool control)
void setTorque(double meas)
void sliderMixedVelocityCommand(double val, int jointIndex)
void idleClicked(JointItem *joint)
void setTorqueRange(double max)
void setRefTorque(double ref)
void changeInteraction(int interaction, JointItem *joint)
void setValue(double val)
bool eventFilter(QObject *obj, QEvent *event) override
bool speedview_param_enabled
Definition main.cpp:35
bool debug_param_enabled
Definition main.cpp:34
bool enable_calib_all
Definition main.cpp:36
#define STIFF
Definition jointitem.h:25
#define COMPLIANT
Definition jointitem.h:26
Definition aboutdlg.h:11
@ VOCAB_JOINTTYPE_REVOLUTE
Definition IAxisInfo.h:24
@ VOCAB_JOINTTYPE_PRISMATIC
Definition IAxisInfo.h:25
const QColor idleColor
const QColor disconnectColor
const QColor hwFaultColor
const QColor torqueColor
const QColor positionColor
const QColor pwmColor
const QColor positionDirectColor
const QColor mixedColor
const QColor velocityColor
const QColor calibratingColor
const QColor currentColor