@@ -75,6 +75,13 @@ const AP_Param::GroupInfo TetherSim::var_info[] = {
75
75
// @User: Advanced
76
76
AP_GROUPINFO (" SPGCNST" , 6 , TetherSim, tether_spring_constant, 100 ),
77
77
78
+ // @Param: DMPCNST
79
+ // @DisplayName: Tether Damping Constant
80
+ // @Description: Damping constant for the tether to simulate resistance based on change in stretch
81
+ // @Range: 0 255
82
+ // @User: Advanced
83
+ AP_GROUPINFO (" DMPCNST" , 7 , TetherSim, tether_damping_constant, 10 ),
84
+
78
85
AP_GROUPEND
79
86
};
80
87
@@ -266,33 +273,40 @@ void TetherSim::update_tether_force(const Location& veh_pos, float dt)
266
273
// Calculate the stretch beyond the maximum length
267
274
float stretch = MAX (tether_length - max_line_length, 0 .0f );
268
275
269
- // Apply a spring-like penalty force proportional to the stretch
270
- float penalty_force_magnitude = tether_spring_constant * stretch;
276
+ // Calculate the stretch rate beyond the maximum length
277
+ float stretch_rate = (stretch - prev_stretch)/dt;
278
+
279
+ // Apply a spring and damping penalty force proportional to the stretch
280
+ float penalty_force_magnitude = tether_spring_constant * stretch + tether_damping_constant * stretch_rate;
271
281
272
282
// Direction of force is along the tether, pulling toward the anchor
273
- veh_forces_ef = tether_vector.normalized () * penalty_force_magnitude;
283
+ veh_forces_teth = tether_vector.normalized () * penalty_force_magnitude;
274
284
275
285
GCS_SEND_TEXT (MAV_SEVERITY_WARNING, " Tether: Exceeded maximum length." );
276
286
277
- return ;
278
- }
287
+ prev_stretch = stretch;
279
288
280
- if (tether_stuck) {
289
+ } else if (tether_stuck) {
281
290
282
291
// Calculate the stretch beyond the maximum length
283
292
float stretch = MAX (tether_length - tether_not_stuck_length, 0 .0f );
284
293
294
+ // Calculate the stretch rate beyond the maximum length
295
+ float stretch_rate = (stretch - prev_stretch)/dt;
296
+
285
297
// Apply a spring-like penalty force proportional to the stretch
286
- float penalty_force_magnitude = tether_spring_constant * stretch;
298
+ float penalty_force_magnitude = tether_spring_constant * stretch + tether_damping_constant * stretch_rate ;
287
299
288
300
// Direction of force is directly along the tether, towards the tether anchor point
289
- veh_forces_ef = tether_vector.normalized () * penalty_force_magnitude;
301
+ veh_forces_teth = tether_vector.normalized () * penalty_force_magnitude;
290
302
291
303
GCS_SEND_TEXT (MAV_SEVERITY_WARNING, " Tether: Stuck." );
292
304
293
- return ;
305
+ prev_stretch = stretch;
306
+
294
307
} else {
295
308
tether_not_stuck_length = tether_length;
309
+ veh_forces_teth.zero ();
296
310
}
297
311
298
312
// Step 3: Calculate the weight of the tether being lifted
@@ -302,8 +316,8 @@ void TetherSim::update_tether_force(const Location& veh_pos, float dt)
302
316
// Step 4: Calculate the tension force
303
317
Vector3f tension_force_NED = tether_vector.normalized () * tether_weight_force;
304
318
305
- // Step 5: Apply the force to the vehicle
306
- veh_forces_ef = tension_force_NED;
319
+ // Step 5: Apply the total force to the vehicle
320
+ veh_forces_ef = veh_forces_teth + tension_force_NED;
307
321
}
308
322
309
323
#endif
0 commit comments