Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desired torque decimals are not displayed in the motorgui if the torque control mode is set #3118

Open
LoreMoretti opened this issue Jun 26, 2024 · 7 comments

Comments

@LoreMoretti
Copy link

Describe the bug
I noticed that the desired torque are treated as integer in the motorgui
To Reproduce
Start the motorgui and set on joint in torque
Expected behavior
It would be nice to have three decimal as the position control
Screenshots
image

Configuration (please complete the following information):

  • OS:
  • yarp version:
  • compiler:

Additional context
cc @GiulioRomualdi

@GiulioRomualdi
Copy link
Member

yarp version: YARP version 3.9.0+8-20240206.2+git27242fd41

@GiulioRomualdi
Copy link
Member

If someone can point me the code I should check I can try to fix it

@traversaro
Copy link
Member

If someone can point me the code I should check I can try to fix it

I guess somewhere around

void JointItem::enableTorqueSliderDoubleValue(double value)
{
double torqueSliderStep = 1 / value;
ui->sliderTorqueTorque->setSliderStep(torqueSliderStep);
ui->sliderTorqueTorque->setIsDouble(true);
int sliderMin = -max_torque*torqueSliderStep; //note that we are using -max_torque
int sliderMax = max_torque*torqueSliderStep;
ui->sliderTorqueTorque->setRange(sliderMin, sliderMax);
int v = ui->sliderTorqueTorque->value();
if (v > sliderMax) {}
if (v < sliderMin) {}
setRefTorque(ref_torque);
}
void JointItem::disableTorqueSliderDouble()
{
if (fabs(max_torque) < 1.0)
{
yError("Unable to set integer torque slider");
return;
}
double torqueSliderStep = 1;
ui->sliderTorqueTorque->setSliderStep(torqueSliderStep);
ui->sliderTorqueTorque->setIsDouble(false);
int sliderMin = -max_torque; //note that we are using -max_torque
int sliderMax = max_torque;
ui->sliderTorqueTorque->setRange(sliderMin, sliderMax);
int v = ui->sliderTorqueTorque->value();
if (v > sliderMax) {}
if (v < sliderMin) {}
setRefTorque(ref_torque);
}
.

@traversaro
Copy link
Member

Reading the code, I guess there is already a similar functionality if you go in Slider ---> Torque Options.

@traversaro
Copy link
Member

Screenshot 2024-06-26 202353

@GiulioRomualdi
Copy link
Member

Cool! Still, according to your picture, the number of slider decimal digits seems to be available oly for position control

@GiulioRomualdi
Copy link
Member

So I checked the code and there are three possible solutions:

The easiest solution

Modify the following line

int number_of_decimals = 0;

intermediate solution

add a function to change the slide for the torque (and velocity at this point) and modify

void PartItem::onSetVelSliderOptionPI(int mode, double step)

and

   void PartItem::onSetTrqSliderOptionPI(int mode, double step)

to set the decimal number to an hardcoded value

complex solution

modify the GUI and all the signal slots to have the possibility to set the number of digits. Indeed they are set only for position control in

void JointItem::setNumberOfPositionSliderDecimals(size_t num)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants