Kinovarobotics / Kinova-kortex2_Gen3_G3L

Code examples and API documentation for KINOVA® KORTEX™ robotic arms
https://www.kinovarobotics.com/
Other
117 stars 87 forks source link

Unable to perform Joint Torque Control without the internal Velocity Loop #114

Closed proyan closed 1 year ago

proyan commented 2 years ago

Description

Hi

I am trying to perform Joint Torque Control without the internal Velocity control loop. From https://github.com/Kinovarobotics/kortex/issues/77, I understand that there are two avenues I could have pursued, both are currently blocked by Kinova: 1) Choosing JOINT_TORQUE_HIGH_VELOCITY mode, which has been declared buggy (It has been so long since the bug was mentioned, is there any timeline for the fix?) 2) Converting the transfer function for velocity loop from ClosedLoop to OpenLoop by using SetControlLoopParameters. However, it appears that this is not available to the end-user.

My main question is: a) Is there any other option that I am missing here, that might help in disabling the velocity loop. b) What the timeline for the bugfix on (1), or additional support on (2) might be from Kinova side?

Thanks for the support, Rohan

Version

Using version 2.3.0

Steps to reproduce

Related to https://github.com/Kinovarobotics/kortex/issues/77 and https://github.com/Kinovarobotics/kortex/issues/110#issuecomment-1170026070

Code example

Code sample to set velocity Kaz values to zero:

 224 void KinovaDriver::clearVelocityLoopKaz(int actuator_id) {                                                                                                                                                    
 225     auto control_loop_selection = k_api::ActuatorConfig::ControlLoopSelection::JOINT_VELOCITY;                                                                                                                
 226     auto loop_selection = k_api::ActuatorConfig::LoopSelection();                                                                                                                                             
 227     loop_selection.set_loop_selection(control_loop_selection);                                                                                                                                                
 228     auto control_loop_parameters = actuator_config_->GetControlLoopParameters(loop_selection, actuator_id);                                                                                                   
 229                                                                                                                                                                                                               
 230     // Set kaz values to zero.                                                                                                                                                                                
 231     for(int i =0; i< 5; i++) {                                                                                                                                                                                
 232       control_loop_parameters.set_kaz(i, 0.0F);                                                                                                                                                               
 233     }                                                                                                                                                                                                         
 234     actuator_config_->SetControlLoopParameters(control_loop_parameters, actuator_id);                                                                                                                         
 235                                                                                                                                                                                                               
 236     usleep(1500000);                                                                                                                                                                                          
 237                                                                                                                                                                                                               
 238     for(int i =0; i< 5; i++) {                                                                                                                                                                                
 239       std::cout << "Get Control Loop actuator #" << actuator_id << " kaz #" << i << ": "                                                                                                                      
 240                 << actuator_config_->GetControlLoopParameters(loop_selection, actuator_id).kaz(i)                                                                                                             
 241                 << std::endl;                                                                                                                                                                                 
 242     }                                                                                                                                                                                                         
 243 }                                                                                                                                                                                                             

This results in an error as described in https://github.com/Kinovarobotics/kortex/issues/77#issuecomment-953801439 (Error sub type=SUB_ERROR_NONE => <srv: 10, fct: 15, msgType: 3>)

Expected behavior

Either point (1) or point (2) should provide a relief, but both seem to be blocked.

proyan commented 2 years ago

Edit: After looking at https://github.com/Kinovarobotics/kortex/issues/77#issuecomment-957563316, I changed the ControlLoopSelection to MOTOR_VELOCITY, and I was able to change the transfer function (atleast see updated values through GetControlLoopParameters).

Could you please explain whether this update is permanent, or do the coefficients reset to initial values automatically? After setting the ControlLoopParameters for MOTOR_VELOCITY, I checked through GetControlLoopParameters, and the coefficients were set to new values. However, when I called this function again after the experiment, the coefficients for some motors were still reset to new values, and some were back to initial values. Is that expected behavior? Thanks

felixmaisonneuve commented 2 years ago

Hi @proyan,

I do not have an answer for you since I do not understand all this stuff. I will find the adequate person and will get back to you once I get the answer.

I do not know how long it will take so I apologize in advance for any additionnal delay.

Best, Felix

proyan commented 2 years ago

Thanks for the response @felixmaisonneuve.

Along with the above information, would it be possible to get by mail the control loop information for the different Modes (as you mentioned in this comment https://github.com/Kinovarobotics/kortex/issues/77#issuecomment-951428855)? We would like to have a lower level view of the control loops in different modes as well, and currently all our information comes from issue #77. Looking forward, Best, Rohan

felixmaisonneuve commented 2 years ago

Sure, send me an email at fmaisonneuve@kinova.ca and I will send you the control loop diagrams.

Also, changing Control loop parameters should not be persistant. They should reset to the default values once the actuator (the arm) has been turned off. The way I understand it, you are changing the coefficients and, without powering off the arm, some of them are changing back to the default values after only sleeping for 1.5s. Is that correct or are you doing something else at the same time? I will try to test this this week and see if I can reproduce it. This would be a bug.

Best, Felix

proyan commented 2 years ago

The way I understand it, you are changing the coefficients and, without powering off the arm, some of them are changing back to the default values after only sleeping for 1.5s. Is that correct or are you doing something else at the same time? I will try to test this this week and see if I can reproduce it. This would be a bug.

I noted this behaviour between two separate experiments, and not immediately after 1.5s. The sequence I saw was: 1) getparameters -> param_orig 2) myparams -> setparams 3) wait 1.5s 4) getparameters -> param_new (matches myparams) 5) run experiment I did the above sequence for two different experiments, but I don't remember if the robot was turned off in between. I'll confirm on my side, please confirm on your side as well.

felixmaisonneuve commented 1 year ago

Hi @proyan,

I am cleaning up opened issue and I just Realized I never got back to you about this. When I tested it, ControlLoopParameters will stay the same until you reboot the arm. If you set some parameters on an actuator, they shouldn't change back to the default values by themselves during operation. However, these parameters are not persistant when you reboot the arm. Every time you power off the arm, you have to manually set them back.

Best, Felix

felixmaisonneuve commented 1 year ago

TORQUE_HIGH_VELOCITY was fixed in the newest KortexAPI 2.6.0 release (SWU 2.5.2) and it is now possible to send torque commands in that mode.

Closing this issue