Exported Functions
Reading config files
KiteUtils.set_data_path
— Functionset_data_path(data_path="")
Set the directory for log and config files.
If called without argument, use the data path of the package to obtain the default settings when calling se().
KiteUtils.load_settings
— Functionload_settings(project=PROJECT)
Load the project with the given file name.
The project must include the path and the suffix .yaml .
KiteUtils.update_settings
— Functionupdate_settings()
Re-read the settings from a previously loaded project. Returns the new settings.
KiteUtils.copy_settings
— Functioncopy_settings()
Copy the default settings.yaml and system.yaml files to the folder DATAPATH (it will be created if it doesn't exist).
KiteUtils.se
— Functionse(project=PROJECT)
Getter function for the Settings
struct.
The settings.yaml file to load is determined by the content active PROJECT, which defaults to system.yaml
. The project file must be located in the directory specified by the variable DATA_PATH
.
KiteUtils.se_dict
— Functionse_dict()
Getter function for the dictionary, representing the settings.yaml file.
Access to the dict is much slower than access to the setting struct, but more flexible.
Usage example: z0 = se_dict()["environment"]["z0"]
Also look at the default example: settings.yaml .
Creating test data
KiteUtils.demo_state
— Functiondemo_state(P, height=6.0, time=0.0)
Create a demo state with a given height and time. P is the number of tether particles.
Returns a SysState instance.
KiteUtils.demo_state_4p
— Functiondemo_state_4p(P, height=6.0, time=0.0)
Create a demo state, using the 4 point kite model with a given height and time. P is the number of tether particles.
Returns a SysState instance.
KiteUtils.demo_state_4p_3lines
— Functiondemo_state_4p_3lines(P, height=6.0, time=0.0)
Create a demo state, using the 4 point kite model with a given height and time. P is the number of middle tether particles.
Returns a SysState instance.
KiteUtils.demo_syslog
— Functiondemo_syslog(P, name="Test flight"; duration=10)
Create a demo flight log with given name [String] and duration [s] as StructArray. P is the number of tether particles.
KiteUtils.demo_log
— Functiondemo_log(P, name="Test_flight"; duration=10)
Create an artifical SysLog struct for demonstration purposes. P is the number of tether particles.
KiteUtils.get_particles
— Functionget_particles(height_k, height_b, width, m_k, pos_pod= [ 75., 0., 129.90381057], vec_c=[-15., 0., -25.98076211],
v_app=[10.4855, 0, -3.08324])
Calculate the initial positions of the particels representing a 4-point kite, connected to a kite control unit (KCU).
Parameters:
- height_k: height of the kite itself, not above ground [m]
- height_b: height of the bridle [m]
- width: width of the kite [m]
- mk: relative nose distance
- pos_pod: position of the control pod
- vec_c: vector of the last tether segment
KiteUtils.get_particles_3l
— FunctionCalculate the initial positions of the particels representing a 4-point 3 line kite.
Loading, saving and converting log files
KiteUtils.log!
— Functionlog!(logger::Logger, state::SysState)
Log a state in a logger object. Do nothing if the preallocated size would be exceeded. Returns the current number of elements of the log.
KiteUtils.load_log
— Functionload_log(filename::String; path="")
Read a log file that was saved as .arrow file.
KiteUtils.save_log
— Functionsave_log(logger::Logger, name="sim_log", compress=true;
path="",
colmeta = Dict(:var_01 => ["name" => "var_01"],
:var_02 => ["name" => "var_02"],
:var_03 => ["name" => "var_03"],
:var_04 => ["name" => "var_04"],
:var_05 => ["name" => "var_05"],
:var_06 => ["name" => "var_06"],
:var_07 => ["name" => "var_07"],
:var_08 => ["name" => "var_08"],
:var_09 => ["name" => "var_09"],
:var_10 => ["name" => "var_10"],
:var_11 => ["name" => "var_11"],
:var_12 => ["name" => "var_12"],
:var_13 => ["name" => "var_13"],
:var_14 => ["name" => "var_14"],
:var_15 => ["name" => "var_15"],
:var_16 => ["name" => "var_16"]
))
Save a fligh log from a logger as .arrow file. By default lz4 compression is used, if you use false as second parameter no compression is used.
save_log(flight_log::SysLog, compress=true; path="")
Save a fligh log of type SysLog as .arrow file. By default lz4 compression is used, if you use false as second parameter no compression is used.
KiteUtils.import_log
— Functionimport_log(filename)
Read a .csv file with a flight log and return a SysLog object. The columns var_01
to var_05
must exists, the rest are optional.
- filename: name of the file without extension.
KiteUtils.export_log
— Functionexport_log(flight_log; path="")
Save a fligh log of type SysLog as .csv file.
KiteUtils.sys_log
— Functionsys_log(logger::Logger, name="sim_log";
colmeta = Dict(:var_01 => ["name" => "var_01"],
:var_02 => ["name" => "var_02"],
:var_03 => ["name" => "var_03"],
:var_04 => ["name" => "var_04"],
:var_05 => ["name" => "var_05"],
:var_06 => ["name" => "var_06"],
:var_07 => ["name" => "var_07"],
:var_08 => ["name" => "var_08"],
:var_09 => ["name" => "var_09"],
:var_10 => ["name" => "var_10"],
:var_11 => ["name" => "var_11"],
:var_12 => ["name" => "var_12"],
:var_13 => ["name" => "var_13"],
:var_14 => ["name" => "var_14"],
:var_15 => ["name" => "var_15"],
:var_16 => ["name" => "var_16"]
))
Converts the data of a Logger object into a SysLog object, containing a StructArray, a name and the column meta data.
The function set_data_path(data_path)
can be used to set the directory for the log files.
Rotation matrices
KiteUtils.rot3d
— Methodrot3d(ax, ay, az, bx, by, bz)
Calculate the rotation matrix that needs to be applied on the reference frame (ax, ay, az) to match the reference frame (bx, by, bz). All parameters must be 3-element vectors. Both refrence frames must be orthogonal, all vectors must already be normalized.
Source: TRIAD_Algorithm
KiteUtils.rot
— Methodrot(pos_kite, pos_before, v_app)
Calculate the rotation matrix of the kite based on the position of the last two tether particles and the apparent wind speed vector.
Coordinate system transformations
KiteUtils.fromENU2EG
— FunctionfromENU2EG(pointENU)
Transform the position of the kite in the East North Up reference frame to the Earth Groundstation (North West Up) reference frame.
KiteUtils.fromEG2W
— FunctionfromEG2W(vector, down_wind_direction = pi/2.0)
Transform a vector (x,y,z) from Earth Groundstation to Wind reference frame.
KiteUtils.fromW2SE
— FunctionfromW2SE(vector, elevation, azimuth)
Transform a (velocity-) vector (x,y,z) from Wind to Small Earth reference frame .
KiteUtils.fromKS2EX
— FunctionfromKS2EX(vector, orientation)
Transform a vector (x,y,z) from KiteSensor to Earth Xsens reference frame.
- orientation in Euler angles (roll, pitch, yaw)
KiteUtils.fromEX2EG
— FunctionfromEX2EG(vector)
Transform a vector (x,y,z) from EarthXsens to Earth Groundstation reference frame
Geometric calculations
Calculate the elevation angle, the azimuth angle and the ground distance based on the kite position. In addition, calculate the heading angle, the heading vector, the arc cos (safe version) and the initial kite reference frame.
KiteUtils.calc_elevation
— Functioncalc_elevation(vec)
Calculate the elevation angle in radian from the kite position.
KiteUtils.calc_azimuth
— Functioncalc_azimuth(azimuth_north, up_wind_direction = -π/2)
Calculate the azimuth in the wind reference frame. The upwinddirection is the direction the wind is coming from Zero is at north; clockwise positive. Default: Wind from west.
Returns:
- Angle in radians. Zero straight downwind. Positive direction clockwise seen from above.
- Valid range: -pi .. pi.
KiteUtils.calc_heading
— Functioncalc_heading(orientation, down_wind_direction = pi/2.0, respos=true)
Calculate the heading angle of the kite in radians. The heading is the direction the nose of the kite is pointing to. If respos is true the heading angle is defined in the range of 0 .. 2π, otherwise in the range -π .. π
KiteUtils.calc_course
— Functioncalc_course(velocityENU, elevation, azimuth, down_wind_direction = π/2, respos=true)
Calculate the course angle in radian.
- velocityENU: Kite velocity in EastNorthUp reference frame
- downwinddirection: The direction the wind is going to; zero at north; clockwise positive from above; default: going to east.
- respos: If true, the result is in the range 0 .. 2π, otherwis -π .. π
KiteUtils.calc_heading_w
— Functioncalc_heading_w(orientation, down_wind_direction = pi/2.0)
Calculate the heading vector in wind reference frame.
KiteUtils.azimuth_east
— Functionazimuth_east(vec)
Calculate the azimuth angle in radian from the kite position in ENU reference frame. Zero east. Positive direction clockwise seen from above. Valid range: -π .. π.
KiteUtils.ground_dist
— Functionground_dist(vec)
Calculate the ground distance of the kite from the groundstation based on the kite position (x,y,z, z up).
KiteUtils.acos2
— Functionacos2(arg)
Calculate the acos of arg, but allow values slightly above one and below minus one to avoid exceptions in case of rounding errors. Returns an angle in radian.
KiteUtils.initial_kite_ref_frame
— Functioninitial_kite_ref_frame(vec_c, v_app)
Calculate the initial orientation of the kite based on the last tether segment and the apparent wind speed.
Parameters:
vec_c
: (posn-2) - (posn-1) n: number of particles without the three kite particles that do not belong to the main thether (P1, P2 and P3).- v_app: vector of the apparent wind speed
Returns: x, y, z: the unit vectors of the kite reference frame in the ENU reference frame