geez0x1 / CompliantJointToolbox

Compliant Joint Toolbox (CJT) for MATLAB and Simulink
GNU General Public License v3.0
37 stars 14 forks source link

Stop MATLAB from throwing warnings when delays are zero #59

Closed geez0x1 closed 6 years ago

geez0x1 commented 6 years ago

Implement a similar fix as was done for the input delay (using a subsystem with enable) to avoid MATLAB throwing unnecessary warnings when output delays are zero in the mechanical dynamics block.

To be done when the current unit test issues are sorted out.

geez0x1 commented 6 years ago

Fixed in 7a74d9f137193fed64f6f716693adcef19b3e540.

geez0x1 commented 6 years ago

Unmerging from master through revert because it does in fact change the output somehow. This can be fixed later.

The fix implemented in 7a74d9f137193fed64f6f716693adcef19b3e540 appears to cause algebraic loops. Simulation also slows down significantly, indicating there are some steps being undertaken to solve an algebraic loop.

I have also noticed in other models that simulation time can depend on whether input/output delays are enabled. This requires some more in-depth analysis.

geez0x1 commented 6 years ago

Transplanted throught by @joernmalzahn from another thread:

The warning is issued, because the input delay defaults to 0 sample steps. Would one sample step be a reasonable default value in general? I mean, when we interface the toolbox with hardware through some EtherCAT or whatever, we have this one sample step.

geez0x1 commented 6 years ago

Transplanted comment by @joernmalzahn from another thread:

Ok, this is done. I did the following:

All tests pass, no warnings, output clean

Joint built and written to C:\Users\Jorn\Documents\GitHub\CompliantJointToolbox\build\cjt_Orange_80_6000_full_dyn.m
.-----
EX 02
-----
This example demonstrates the current control of a compliant actuator with locked 
output based on a PI controller with voltage feedforward action.

The model used in this example considers the electrical dynamics.
Joint built and written to C:\Users\Jorn\Documents\GitHub\CompliantJointToolbox\build\example_joint.m
.-----
EX 03
-----
This example demonstrates the torque control of a compliant actuator with locked 
output using a purely integral controller plus a reference feedforward term.

Joint built and written to C:\Users\Jorn\Documents\GitHub\CompliantJointToolbox\build\example_joint.m
.-----
EX 04
-----
This example demonstrates the torque control of a compliant actuator with locked 
output using PID plus a feedforward term.

Joint built and written to C:\Users\Jorn\Documents\GitHub\CompliantJointToolbox\build\example_joint.m
.-----
EX 05
-----
This example demonstrates the torque control of a compliant actuator with locked 
output using a simple PD controller.

Joint built and written to C:\Users\Jorn\Documents\GitHub\CompliantJointToolbox\build\example_joint.m
.-----
EX 06
-----
This example demonstrates the torque control of a compliant actuator with locked 
output using a open-loop disturbance observer, combined with a PD controller with 
feed-forward.

Joint built and written to C:\Users\Jorn\Documents\GitHub\CompliantJointToolbox\build\example_joint.m
.-----
EX 07
-----
This example demonstrates the torque control of a compliant actuator with locked 
output using a open-loop disturbance observer, combined with a PD controller.

Joint built and written to C:\Users\Jorn\Documents\GitHub\CompliantJointToolbox\build\example_joint.m
.-----
EX 08
-----
This example demonstrates the torque control of a compliant actuator with locked 
output using a closed-loop disturbance observer, combined with a PD controller with 
feed-forward.

Joint built and written to C:\Users\Jorn\Documents\GitHub\CompliantJointToolbox\build\example_joint.m
.-----
EX 09
-----
This example demonstrates the torque control of a compliant actuator with locked 
output using a closed-loop disturbance observer, combined with a PD controller.

Joint built and written to C:\Users\Jorn\Documents\GitHub\CompliantJointToolbox\build\example_joint.m
.-----
EX 10
-----
This example demonstrates the open loop torque control of a compliant actuator with locked 
output using a generalized momentum based disturbance observer.

Joint built and written to C:\Users\Jorn\Documents\GitHub\CompliantJointToolbox\build\example_joint.m
.
-----
EX 11
-----
This example demonstrates the torque control of a compliant actuator with locked 
output using a passivity based controller.

Joint built and written to C:\Users\Jorn\Documents\GitHub\CompliantJointToolbox\build\example_joint.m
.-----
EX 12
-----
This example demonstrates the torque control of a compliant actuator with locked 
output using a  a passivity based controller with generalized momentum based 
disturbance observer for friction and ripple compensation.

Joint built and written to C:\Users\Jorn\Documents\GitHub\CompliantJointToolbox\build\example_joint.m
.-----
EX 13
-----
This example demonstrates state estimation using the Kalman estimator block.

Joint built and written to C:\Users\Jorn\Documents\GitHub\CompliantJointToolbox\build\example_joint.m
.-----
EX 14
-----
This example demonstrates state estimation using the Luenberger observer block.

Joint built and written to C:\Users\Jorn\Documents\GitHub\CompliantJointToolbox\build\example_joint.m
.
Done cjtSimulinkLibraryTest
__________

ans = 

  1×14 TestResult array with properties:

    Name
    Passed
    Failed
    Incomplete
    Duration
    Details

Totals:
   14 Passed, 0 Failed, 0 Incomplete.
   268.9236 seconds testing time.

>> save compatible
>> saveCompatible
Library file 'lib/cjt_library_controllers.mdl' is OK.
Library file 'lib/cjt_library_controllers_experimental.mdl' is OK.
Library file 'lib/cjt_library_models.mdl' is OK.
Library file 'lib/cjt_library_observers.mdl' is OK.
Library file 'lib/cjt_library.mdl' is OK.
Library file 'examples/simulink/controlBlockDevelopment_generic.mdl' is OK.
Library file 'examples/simulink/Ex_01_Open_Loop.mdl' is OK.
Library file 'examples/simulink/Ex_02_Current_Control.mdl' is OK.
Library file 'examples/simulink/Ex_03_I_Control_Plus_Feedforward.mdl' is OK.
Library file 'examples/simulink/Ex_04_PD_Control_Plus_Feedforward.mdl' is OK.
Library file 'examples/simulink/Ex_05_PD_Control.mdl' is OK.
Library file 'examples/simulink/Ex_06_PD_Feedforward_OpenLoopDOB.mdl' is OK.
Library file 'examples/simulink/Ex_07_PD_OpenLoopDOB.mdl' is OK.
Library file 'examples/simulink/Ex_08_PD_Feedforward_ClosedLoopDOB.mdl' is OK.
Library file 'examples/simulink/Ex_09_PD_ClosedLoopDOB.mdl' is OK.
Library file 'examples/simulink/Ex_10_Open_Loop_With_Disturbance_Observer.mdl' is OK.
Library file 'examples/simulink/Ex_11_Passivity_Based_Control.mdl' is OK.
Library file 'examples/simulink/Ex_12_Passivity_Based_Control_Plus_Disturbance_Observer.mdl' is OK.
Library file 'examples/simulink/openLoop.mdl' is OK.
Library file 'examples/simulink/openLoop_inputFromFile.mdl' is OK.
Finished. Converted 0 files.
geez0x1 commented 6 years ago

Nice work.

Clever solution to put the memory block in the feed-through path. This ensures it's only used when D != 0, i.e. the zero-inductance electrical dynamics model.