Exported Functions

Reading config files

KiteUtils.set_data_pathFunction
set_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().

source
KiteUtils.load_settingsFunction
load_settings(project=PROJECT)

Load the project with the given file name.

The project must include the path and the suffix .yaml .

source
KiteUtils.copy_settingsFunction
copy_settings()

Copy the default settings.yaml and system.yaml files to the folder DATAPATH (it will be created if it doesn't exist).

source
KiteUtils.seFunction
se(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.

source
KiteUtils.se_dictFunction
se_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"]

source

Also look at the default example: settings.yaml .

Modify .yaml files

KiteUtils.change_valueFunction
change_value(lines, varname, value::Union{Integer, Float64})

Change the value of a variable in a yaml file for a number.

source
change_value(lines, varname, value::String)

Change the value of a variable in a yaml file.

source
KiteUtils.get_unitFunction
get_unit(lines, key)

Get the unit of a variable in a yaml file. The unit must be defined in square brackets.

source

Creating test data

KiteUtils.demo_stateFunction
demo_state(P, height=6.0, time=0.0; azimuth_north=-pi/2)

Create a demo state with a given height and time. P is the number of tether particles. Kite is parking and aligned with the tether.

Returns a SysState instance.

source
KiteUtils.demo_state_4pFunction
demo_state_4p(P, height=6.0, time=0.0; azimuth_north=-pi/2)

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.

source
KiteUtils.demo_state_4p_3linesFunction
demo_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.

source
KiteUtils.demo_syslogFunction
demo_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.

source
KiteUtils.demo_logFunction
demo_log(P, name="Test_flight"; duration=10)

Create an artifical SysLog struct for demonstration purposes. P is the number of tether particles.

source
KiteUtils.get_particlesFunction
get_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
source

Loading, saving and converting log files

KiteUtils.log!Function
log!(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.

source
KiteUtils.save_logFunction
save_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.

source
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.

source
KiteUtils.import_logFunction
import_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.

Parameters:

  • filename: name of the file without extension.
source
KiteUtils.sys_logFunction
sys_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.

source
Base.getpropertyFunction
Base.getproperty(log::SysLog, sym::Symbol)

Implement the properties x, y and z. They represent the kite position for the 4-point kite model. In addition, implements the properties x1, y1 and z1. They represent the kite position for the 1-point model.

source

The function set_data_path(data_path) can be used to set the directory for the log files.

Rotation matrices and conversions

KiteUtils.calc_orient_rotFunction
calc_orient_rot(x, y, z; viewer=false, ENU=true)

Calculate the rotation matrix based on the kite reference frame, by default passed as ENU (east, north, up), or as NED (north, east, down) if ENU is false. If viewer is true, the rotation matrix is calculated based with respect to the viewer reference frame.

source
KiteUtils.enu2nedFunction
enu2ned(vec::AbstractVector)

Convert a vector from ENU (east, north, up) to NED (north, east, down) reference frame.

source
KiteUtils.ned2enuFunction
ned2enu(vec::AbstractVector)

Convert a vector from NED (north, east, down) to ENU (east, north, up) reference frame.

source
KiteUtils.quat2eulerFunction
quat2euler(q::QuatRotation)
quat2euler(q::AbstractVector)

Convert a quaternion to roll, pitch, and yaw angles in radian. The quaternion can be a 4-element vector (w, i, j, k) or a QuatRotation object.

source
KiteUtils.quat2viewerFunction
quat2viewer(q::QuatRotation)
quat2viewer(rot::AbstractMatrix)
quat2viewer(orient::AbstractVector)

Convert the quaternion q to the viewer reference frame. It can also be passed as a rotation matrix or as 4-element vector [w,i,j,k], where w is the real part and i, j, k are the imaginary parts of the quaternion.

source
KiteUtils.euler2rotFunction
euler2rot(roll, pitch, yaw)

Calculate the rotation matrix based on the roll, pitch, and yaw angles in radian.

source
KiteUtils.rot3dMethod
rot3d(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

source
KiteUtils.rotMethod
rot(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. Assumption: The kite aligns with the apparent wind direction. If used for the model KPS4, pass the vector -x of the kite reference frame instead of v_app.

source

Coordinate system transformations

KiteUtils.fromENU2EGFunction
fromENU2EG(pointENU)

Transform the position of the kite in the East North Up reference frame to the Earth Groundstation (North West Up) reference frame.

source
KiteUtils.fromEG2WFunction
fromEG2W(vector, down_wind_direction = pi/2.0)

Transform a vector (x,y,z) from Earth Groundstation to Wind reference frame.

source
KiteUtils.fromW2SEFunction
fromW2SE(vector, elevation, azimuth)

Transform a (velocity-) vector (x,y,z) from Wind to Small Earth reference frame .

source
KiteUtils.fromKS2EXFunction
fromKS2EX(vector, orientation)

Transform a vector (x,y,z) from KiteSensor to Earth Xsens reference frame.

  • orientation in Euler angles (roll, pitch, yaw)
source
KiteUtils.fromEX2EGFunction
fromEX2EG(vector)

Transform a vector (x,y,z) from EarthXsens to Earth Groundstation reference frame

source

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 asin and acos (safe versions) and the initial kite reference frame.

KiteUtils.calc_headingFunction
calc_heading(orientation, elevation, azimuth; upwind_dir=-pi/2, respos=true)

Calculate the heading angle of the kite in radians. The heading is the direction the nose of the kite is pointing to. The orientation is given in Euler angles, calculated with respect to the North, East, Down reference frame. If respos is true the heading angle is defined in the range of 0 .. 2π, otherwise in the range -π .. π

source
KiteUtils.calc_courseFunction
calc_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 -π .. π
source
KiteUtils.calc_heading_wFunction
calc_heading_w(orientation, down_wind_direction = pi/2.0)

Calculate the heading vector in wind reference frame.

source
KiteUtils.azimuth_eastFunction
azimuth_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: -π .. π.

source
KiteUtils.azimuth_northFunction
azimuth_north(vec)

Calculate the azimuth angle in radian from the kite position in ENU reference frame. Zero north. Positive direction anti-clockwise seen from above. Valid range: -π .. π.

source
KiteUtils.azn2azwFunction
azn2azw(azimuth_north; upwind_dir = -π/2)

Calculate the azimuth in the wind reference frame. The upwind_dir 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.
source
KiteUtils.ground_distFunction
ground_dist(vec)

Calculate the ground distance of the kite from the groundstation based on the kite position (x,y,z, z up).

source
KiteUtils.acos2Function
acos2(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.

source
KiteUtils.asin2Function
asin2(arg)

Calculate the asin 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.

source
KiteUtils.initial_kite_ref_frameFunction
initial_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: (pos_n-2) - (pos_n-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

source

Physical calculations

KiteUtils.calculate_rotational_inertiaFunction
calculate_rotational_inertia(X::Vector, Y::Vector, Z::Vector, M::Vector,  
      around_center_of_mass::Bool=true, rotation_point::Vector=[0, 0, 0])

Calculate the rotational inertia (Ixx, Ixy, Ixz, Iyy, Iyz, Izz) of a collection of point masses around a point. By default this point is the center of mass which will be calculated, but any point can be given to rotation_point.

Parameters:

  • X: x-coordinates of the point masses.
  • Y: y-coordinates of the point masses.
  • Z: z-coordinates of the point masses.
  • M: masses of the point masses.
  • around_center_of_mass: Calculate the rotational inertia around the center of mass?
  • rotation_point: Rotation point used if not rotating around the center of mass.

Returns: The tuple Ixx, Ixy, Ixz, Iyy, Iyz, Izz where:

  • Ixx: rotational inertia around the x-axis.
  • Ixy: rotational inertia around the xy-plane.
  • Ixz: rotational inertia around the xz-plane.
  • Iyy: rotational inertia around the y-axis.
  • Iyz: rotational inertia around the yz-plane.
  • Izz: rotational inertia around the z-axis.
source