Page 1 of 1

Control strategy 4 implementation

Posted: Thu Oct 01, 2020 10:19 am
by QiangPITT
1. I checked the control section, and I am wondering what is the basic Matlab API example for strategy 4? I know there is an example zip folder on the website for x-series_actuator, but could you please tell me if I need to modify the code inside to realize the strategy 4?

2. strategy 4 is specifically for trajectory and velocity tracking as I think. Could you please tell me if you have done some impedance control or admittance control with the X-series motor? If so, could you please share some Matlab code with me?

3. Can I increase the feedback frequency? How to set this parameter, in Scope or Matlab command?

Re: Control strategy 4 implementation

Posted: Thu Oct 01, 2020 10:07 pm
by dave_rollinson
Qiang,

To address your questions, I'm assuming you're running the latest version of the hebi-matlab-examples repository on Github. For working with single actuators, the best place to start is with the basic examples for the X-Series actuators.
1. I checked the control section, and I am wondering what is the basic Matlab API example for strategy 4? I know there is an example zip folder on the website for x-series_actuator, but could you please tell me if I need to modify the code inside to realize the strategy 4?
The best practice is to make a Gains XML File for your work and set it every time you run your code. An example of doing this in the Matlab API can be found here. The gains format is cross-API, so your settings can be easily loaded into the other APIs if you wind up switching later on.

I've noticed now that the example gains file in the matlab examples is for Strategy 3. Sorry, we will fix this shortly. Since your actuators are X8-16s (the example is for an X5-1), you'll want the default gains for that model, which you can find here.

2. Strategy 4 is specifically for trajectory and velocity tracking as I think. Could you please tell me if you have done some impedance control or admittance control with the X-series motor? If so, could you please share some Matlab code with me?
All the strategies can be used with trajectory tracking, or individually for position / velocity / torque, or any combination of the two.

By my (probably limited) understanding, Strategy 4 is doing impedance control at the joint level based on commanded positions. The P and D gains are a spring and damper based on the actuator position that commands a torque to the inner torque loop. In addition to the position P and D parameters, you might find it useful to increase the P gain on effort (torque) if you would like the actuator to be more responsive.

You can also implement impedance control yourself at the API level and command efforts to the actuator. In terms of admittance control, we would do this at the API level, but we don't have any examples.

3. Can I increase the feedback frequency? How to set this parameter, in Scope or Matlab command?
Yes, in the Matlab API you can call HebiGroup.setFeedbackFrequency(). There are similar calls in the other APIs. For reference the full API documentation for the latest version 1.7.3 can be found here, and also by typing "help hebi" in Matlab.

In Scope there is a slider at the top that controls the feedback frequency for plotting. This also controls the feedback frequency when you take logs from Scope.

Since the actuators are already doing realtime control at the joint level at 1 kHz, we have found that there isn't much benefit from running faster than ~200 Hz at the API level. But feel free to explore. From Windows, you can reliably get feedback and send commands up to about 600 Hz, and on macOS and Linux you can get all the way up to 1 kHz.

Hope this helps,
-Dave

Re: Control strategy 4 implementation

Posted: Tue Oct 06, 2020 7:50 pm
by QiangPITT
:D :D :D Those replies are really helpful.
Thank you so much.

Re: Control strategy 4 implementation

Posted: Tue Jan 26, 2021 12:18 am
by QiangPITT
All the strategies can be used with trajectory tracking, or individually for position / velocity / torque, or any combination of the two.

By my (probably limited) understanding, Strategy 4 is doing impedance control at the joint level based on commanded positions. The P and D gains are a spring and damper based on the actuator position that commands a torque to the inner torque loop. In addition to the position P and D parameters, you might find it useful to increase the P gain on effort (torque) if you would like the actuator to be more responsive.

You can also implement impedance control yourself at the API level and command efforts to the actuator.
Thanks a lot for these suggestions. I did try using the Scope to reduce the PD gains to zero for position control under strategy 4, and also increase the P gain for effort control, although the impedance did reduce, there was still some impedance when I rotated the motor and when P gain for effort control increases to around 3, the motor was shaking either I was rotating it or not.
Would you please give me some suggestions for further reduce the impedance and make it more compliant while get rid of the shaking?

I really appreciate your help.

--Qiang

Re: Control strategy 4 implementation

Posted: Tue Jan 26, 2021 8:02 am
by dave_rollinson
Setting the P or D gains too high on the effort loop (or any of the others) will cause shaking / buzzing due to sensor noise. If you want to more fully remove impedance from the effort/torque loop, you can lower the P/D gains, and instead use the integral I-term, Ki (units of PWM / Nm Error * sec). This will make the motion of the actuator much more fluid, but too much of it will cause overshoot in torque, just like it does with other controllers. There also a saturation term, I-Clamp (units of PWM), that can be tuned to prevent integral windup and overshoot.

When tuning these gains and control parameters viewing the tracking of the effort commands and feedback live in Scope is very useful. To increase the time resolution on the plots and better see what's going on during tuning it may also help to increase the the Plot Frequency in Scope from the default 100 Hz to something higher, like ~300 Hz.

Hope this help,
-Dave