From 476a7bccb5aec7f7d74e38494bbb86da2a8566e7 Mon Sep 17 00:00:00 2001 From: Benedikt Wolf Date: Wed, 13 Dec 2023 17:32:32 +0100 Subject: [PATCH] Nasal hitch.nas: Update by D-NXKT and Bea Wolf --- Nasal/towing/hitch.nas | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/Nasal/towing/hitch.nas b/Nasal/towing/hitch.nas index 5456548dc..fc6f6346f 100644 --- a/Nasal/towing/hitch.nas +++ b/Nasal/towing/hitch.nas @@ -2,7 +2,7 @@ # TOWING NASAL CODE # # original version by D-NXKT up to version 30.12.2014 -# updates by Benedikt Wolf and D-NXKT, version 01/2023 +# updates by Bea Wolf and D-NXKT, version 12/2023 # # # Purpose of this routine: @@ -1315,8 +1315,20 @@ var winch = func (open){ if ( winch_hash.clutched.getBoolValue() ) { if( winch_hash.type == 0 ){ - # Concept: force is given - forcetow_N = force_setting; + # Concept: force is conrolled + + towlength_new_m = towlength_m - spoolspeed * delta_t; + delta_towlength_m = distance - towlength_new_m; + var delta_spoolspeed = spool_acceleration * delta_t; + spoolspeed = spoolspeed + delta_spoolspeed ; + if ( spoolspeed > spool_max ) spoolspeed = spool_max; + + if ( delta_towlength_m < 0. ) { + forcetow_N = 0.; + } + else{ + forcetow_N = elastic_constant * delta_towlength_m / towlength_new_m; + } } else if ( winch_hash.type == 1 ){ # Concept: regulate force to reach target speed @@ -1328,13 +1340,12 @@ var winch = func (open){ forcetow_N -= acceleration_N_s * delta_t; } } + # New towlength is distance from hook to winch; previous towlength is stored in winch_hash.towlength_m + towlength_new_m = distance; + delta_towlength_m = -1 * ( distance - towlength_m ); + spoolspeed = delta_towlength_m / delta_t; } - # New towlength is distance from hook to winch; previous towlength is stored in winch_hash.towlength_m - towlength_new_m = distance; - delta_towlength_m = -1 * ( distance - towlength_m ); - spoolspeed = delta_towlength_m / delta_t; - } else { # un-clutched # --- experimental --- # towlength_new_m = towlength_m - spoolspeed * delta_t; @@ -1355,12 +1366,14 @@ var winch = func (open){ spoolspeed = spoolspeed - delta_spoolspeed; if ( spoolspeed < - unspool_max ) spoolspeed = - unspool_max; - - #if ( delta_towlength_m < 0. ) { - # forcetow_N = 0.; - #} + if ( delta_towlength_m < 0. ) { + forcetow_N = 0.; + } + else{ + forcetow_N = elastic_constant * delta_towlength_m / towlength_new_m; + } } - + if ( forcetow_N > max_force_N ) { forcetow_N = max_force_N; var towlength_new_m = distance / ( forcetow_N / elastic_constant + 1. );