@@ -36,7 +36,7 @@ export Settings, SysState, SysLog, Logger, MyFloat
36
36
import Base. length
37
37
export demo_state, demo_syslog, demo_log, load_log, save_log, export_log # functions for logging
38
38
export log!, syslog, length
39
- export demo_state_4p, initial_kite_ref_frame # functions for four point kite model
39
+ export demo_state_4p, demo_state_4p_3lines, initial_kite_ref_frame # functions for four point and three line kite
40
40
export rot, rot3d, ground_dist, calc_elevation, azimuth_east, acos2 # geometric functions
41
41
export fromEG2W, fromENU2EG,fromW2SE, fromKS2EX, fromEX2EG # reference frame transformations
42
42
export calc_azimuth, calc_heading_w, calc_heading, calc_course # geometric functions
@@ -305,6 +305,38 @@ function get_particles(height_k, height_b, width, m_k, pos_pod= [ 75., 0., 129.9
305
305
[zeros (3 ), pos0, pos_A, pos_kite, pos_C, pos_D] # 0, p7, p8, p9, p10, p11
306
306
end
307
307
308
+
309
+ """
310
+ Calculate the initial positions of the particels representing
311
+ a 4-point 3 line kite.
312
+ """
313
+ function get_particles_3l (width, radius, middle_length, tip_length, bridle_center_distance, pos_kite = [ 75. , 0. , 129.90381057 ],
314
+ vec_c= [- 15. , 0. , - 25.98076211 ], v_app= [10.4855 , 0 , - 3.08324 ])
315
+ # inclination angle of the kite; beta = atan(-pos_kite[2], pos_kite[1]) ???
316
+ beta = pi / 2.0
317
+
318
+ e_z = normalize (vec_c) # vec_c is the direction of the last two particles
319
+ e_y = normalize (cross (v_app, e_z))
320
+ e_x = normalize (cross (e_y, e_z))
321
+
322
+ α_0 = pi / 2 - width/ 2 / radius
323
+ α_c = α_0 + width* (- 2 * tip_length + sqrt (2 * middle_length^ 2 + 2 * tip_length^ 2 ))/ (4 * (middle_length - tip_length)) / radius
324
+ α_d = π - α_c
325
+
326
+ E = pos_kite
327
+ E_c = pos_kite + e_z * (- bridle_center_distance + radius) # E at center of circle on which the kite shape lies
328
+ C = E_c + e_y* cos (α_c)* radius - e_z* sin (α_c)* radius
329
+ D = E_c + e_y* cos (α_d)* radius - e_z* sin (α_d)* radius
330
+
331
+ length (α) = α < π/ 2 ?
332
+ (tip_length + (middle_length- tip_length)* α* radius/ (0.5 * width)) :
333
+ (tip_length + (middle_length- tip_length)* (π- α)* radius/ (0.5 * width))
334
+ P_c = (C+ D). / 2
335
+ A = P_c - e_x* (length (α_c)* (3 / 4 - 1 / 4 ))
336
+
337
+ [E, C, D, A] # important to have the order E = 1, C = 2, D = 3, A = 4
338
+ end
339
+
308
340
"""
309
341
demo_state_4p(P, height=6.0, time=0.0)
310
342
@@ -356,6 +388,77 @@ function demo_state_4p(P, height=6.0, time=0.0)
356
388
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )
357
389
end
358
390
391
+ """
392
+ demo_state_4p_3lines(P, height=6.0, time=0.0)
393
+
394
+ Create a demo state, using the 4 point kite model with a given height and time. P is the number of tether particles.
395
+
396
+ Returns a SysState instance.
397
+ """
398
+ function demo_state_4p_3lines (P, height= 6.0 , time= 0.0 )
399
+ num_A = P
400
+ num_D = P- 1
401
+ num_C = P- 2
402
+ num_E = P- 3
403
+ pos = zeros (SVector{P, MVector{3 , Float64}})
404
+ # ground points
405
+ [pos[i] .= [0.0 , 0.0 , 0.0 ] for i in 1 : 3 ]
406
+
407
+ # middle tether
408
+ sin_el, cos_el = sin (deg2rad (se (). elevation)), cos (deg2rad (se (). elevation))
409
+ for (i, j) in enumerate (range (6 , step= 3 , length= se (). segments))
410
+ radius = i * (se (). l_tether/ se (). segments)
411
+ pos[j] .= [cos_el* radius, 0.0 , sin_el* radius]
412
+ end
413
+
414
+ # kite points
415
+ vec_c = pos[num_E- 3 ] - pos[num_E]
416
+ E, C, D, A = get_particles_3l (se (). width, se (). radius, se (). middle_length, se (). tip_length, se (). bridle_center_distance, pos[num_E], vec_c)
417
+ pos[num_A] .= A
418
+ pos[num_C] .= C
419
+ pos[num_D] .= [pos[num_C][1 ], - pos[num_C][2 ], pos[num_C][3 ]]
420
+
421
+ # build tether connection points
422
+ e_z = normalize (vec_c)
423
+ distance_c_l = 0.5 # distance between c and left steering line
424
+ pos[num_E- 2 ] .= pos[num_C] + e_z .* (distance_c_l)
425
+ pos[num_E- 1 ] .= pos[num_E- 2 ] .* [1.0 , - 1.0 , 1.0 ]
426
+
427
+ # build left and right tether points
428
+ for (i, j) in enumerate (range (4 , step= 3 , length= se (). segments- 1 ))
429
+ pos[j] .= pos[num_E- 2 ] ./ se (). segments .* i
430
+ pos[j+ 1 ] .= [pos[j][1 ], - pos[j][2 ], pos[j][3 ]]
431
+ end
432
+
433
+ X = zeros (P)
434
+ Y = zeros (P)
435
+ Z = zeros (P)
436
+ for (i, p) in enumerate (pos)
437
+ # println("pos ", pos)
438
+ X[i] = p[1 ]
439
+ Y[i] = p[2 ]
440
+ Z[i] = p[3 ]
441
+ end
442
+ # println("X ", X)
443
+ pos_centre = 0.5 * (C + D)
444
+ delta = E - pos_centre
445
+ z = normalize (delta)
446
+ y = normalize (C - D)
447
+ x = y × z
448
+ pos_before = pos[num_E] + z
449
+
450
+ rotation = rot (pos[num_E], pos_before, - x)
451
+ q = QuatRotation (rotation)
452
+ orient = MVector {4, Float32} (Rotations. params (q))
453
+ elevation = calc_elevation ([X[end ], 0.0 , Z[end ]])
454
+ vel_kite= zeros (3 )
455
+ t_sim = 0.014
456
+ sys_state = 0
457
+ e_mech = 0
458
+ return SysState {P} (time, t_sim, sys_state, e_mech, orient, elevation,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,vel_kite, X, Y, Z,
459
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )
460
+ end
461
+
359
462
"""
360
463
demo_syslog(P, name="Test flight"; duration=10)
361
464
0 commit comments