Makani was a project to develop a commercial-scale airborne wind turbine, culminating in a flight test of the Makani M600 off the coast of Norway. All Makani software has now been open-sourced. This repository contains the working Makani flight simulator, controller (autopilot), visualizer, and command center flight monitoring tools. Additionally, almost all avionics firmware is also included, albeit potentially not in a buildable state, due to the removal of some third-party proprietary code. We hope that this code will be inspirational and useful to the kite-based windpower and wider communities.
Find a file
2020-09-12 14:26:04 -07:00
analysis Add copyright headers to crosswind_kinematics 2020-09-10 08:26:31 -07:00
avionics Initial push of Makani open source code. 2020-07-07 11:50:01 -07:00
common Initial push of Makani open source code. 2020-07-07 11:50:01 -07:00
config Initial push of Makani open source code. 2020-07-07 11:50:01 -07:00
control Initial push of Makani open source code. 2020-07-07 11:50:01 -07:00
database Replace GCS bucket with public one. 2020-07-23 14:03:52 -07:00
documentation Update control telemetry users guide. 2020-09-10 13:12:22 -07:00
gs Print webmonitor URL in run_sim 2020-09-12 14:26:04 -07:00
lib Fix install_packages.sh jupyter failure. 2020-09-11 19:37:11 -07:00
nav Initial push of Makani open source code. 2020-07-07 11:50:01 -07:00
sim Initial push of Makani open source code. 2020-07-07 11:50:01 -07:00
system Initial push of Makani open source code. 2020-07-07 11:50:01 -07:00
third_party Initial push of Makani open source code. 2020-07-07 11:50:01 -07:00
third_party_toolchains Initial push of Makani open source code. 2020-07-07 11:50:01 -07:00
tools Replace GCS bucket with public one. 2020-07-23 14:03:52 -07:00
vis Initial push of Makani open source code. 2020-07-07 11:50:01 -07:00
.bazelrc Initial push of Makani open source code. 2020-07-07 11:50:01 -07:00
.bazelversion Initial push of Makani open source code. 2020-07-07 11:50:01 -07:00
.dockerignore Install pip packages during build installation. 2020-07-24 00:37:27 -07:00
.gitignore Remove .pdf from gitignore. 2020-07-10 17:15:53 -07:00
__init__.py Initial push of Makani open source code. 2020-07-07 11:50:01 -07:00
BUILD Initial push of Makani open source code. 2020-07-07 11:50:01 -07:00
CONTRIBUTING.md Initial push of Makani open source code. 2020-07-07 11:50:01 -07:00
docker_build.sh Make docker sh files executable. 2020-09-11 20:27:33 -07:00
docker_run.sh Fix docker_run.sh script. 2020-09-11 20:30:04 -07:00
Dockerfile Replace /path/to/makani with pwd in Dockerfile. 2020-09-10 09:17:56 -07:00
LICENSE Initial push of Makani open source code. 2020-07-07 11:50:01 -07:00
README.md Fix flags for run_sim instructions. 2020-09-12 14:20:59 -07:00
WORKSPACE Initial push of Makani open source code. 2020-07-07 11:50:01 -07:00

Makani

Makani was a project to develop a commercial-scale airborne wind turbine, culminating in a flight test of the Makani M600 off the coast of Norway. All Makani software has now been open-sourced. This repository contains the working Makani flight simulator, controller (autopilot), visualizer, and command center flight monitoring tools. Additionally, almost all avionics firmware is also included, albeit potentially not in a buildable state, due to the removal of some third-party proprietary code. We hope that this code will be inspirational and useful to the kite-based windpower and wider communities.

For more information about Makani, please visit https://x.company/projects/makani/

A brief tour of the code

  • analysis - Miscellaneous analysis scripts. The most important files here are analysis/control/crosswind.py, which generates the gains for the crosswind inner loop controller, and analysis/control/generate_hover_controllers.m, which generates the gains for the hover controller.
  • avionics - Firmware for the winch, ground station, motors, network, servos, batteries, network switches, GPS, strobe lights, etc.
  • control - The hover, transition-in, crosswind, and off-tether flight controllers.
  • common
  • config - A Python-based configuration system produces a JSON dict specifying all system, controller, and simulation parameters. This is translated into a read-only C structure at compile-time.
  • database - Aero tables, Pitot calibration tables, etc.
  • documentation
  • vis - OpenGL-based visualizer that depicts the state of the system during simulation and real flight.

How to build

This code base was originally designed to run on Linux systems running the Debian Stretch distribution. For the convenience of future users, we are shipping this open source release with a script to create the necessary environment within Docker.

Using Debian Stretch natively or as a VM

  1. Run ./lib/scripts/install/install_packages.sh
  2. Run source ~/.bashrc
  3. Run cd ${MAKANI_HOME}
  4. To build everything, run bbuild_x86
  5. To test everything, run btest_all

Using Docker

We have tested the Docker solution in some Linux systems. We also tested it on macOS but we were unable to get the visualizer running due to an issue with libGL (the rest of the simulation software did work).

  1. Run ./docker_build.sh
  2. Run ./docker_run.sh

Inside of docker:

  1. Run cd ${MAKANI_HOME}
  2. To build everything, run bbuild_x86
  3. To test everything, run btest_all

How to run the Makani flight simulator

  1. Run sudo route add -net 239.0.0.0 netmask 255.0.0.0 dev lo
  2. Run cd ${MAKANI_HOME}
  3. Run run_sim -S -M flight

This command will open the visualizer. If running natively or a VM, and have Chrome installed, the webmonitor should open automatically. If not, open http:///localhost:8000 on your browser.

For a full list of available flags when running the simulator, see the file sim/run_sim.py.

Other commands

For a list of preconfigured commands, see lib/scripts/operator and lib/scripts/developer.

How to read the logs

The Control Telemetry Users' guide, included as a PDF with this distribution, gives a full description of log file data structures. Below are examples for how to load and plot log data using Python or MATLAB.

Python

Here's a small example showing how to load an h5 log file in Python and plot a variable (in this case, the kite's altitude). Accessing the log files is made much less painful by enabling tab-completion of telemetry fields; instructions are in lib/python/ipython_completer.py.

import h5py
import pylab

log = h5py.File('20161121-142912-flight01_crosswind.h5', 'r')
c = (log['messages']['kAioNodeControllerA']
        ['kMessageTypeControlTelemetry']['message'])
pylab.plot(c['time'], -c['state_est']['Xg']['z'])
pylab.show()`

Additionally, by starting Python with bazel-bin/lib/bazel/pyembed ipython, you will be able to access some Makani library functions (like DcmToAngle) directly from Python.

You can also explore the field names using .items() or .keys() and .dtype as appropriate:

log.keys()  # Shows [u'bad_packets', u'messages', u'parameters']
log[messages].keys()  # Shows [ukAioNodeBattA', … ]

# The number of messages of this type in the h5 file:
log['messages/kAioNodeBattA/kMessageTypeSlowStatus'].len()

# The first message:
log['messages/kAioNodeBattA/kMessageTypeSlowStatus'][0]

# The nested field names:
log['messages/kAioNodeBattA/kMessageTypeSlowStatus'][0].dtype`

MATLAB

Here's a small example showing three ways to load an h5 log file in MATLAB and plot a variable (in this case, the kite's altitude).

Method 1

A quick way to load a specific telemetry dataset to the workspace using a MATLAB built-in function.

c = h5read('20161121-142912-flight01_crosswind.h5', '/messages/kAioNodeControllerA/kMessageTypeControlTelemetry');
time = c.message.time;
altitude = -c.message.state_est.Xg.z;
figure;
plot(time, altitude)

Method 2

A slower way to load the entire telemetry to the workspace. NOTE: This method only works in MATLAB 2016a and earlier. Find out your MATLAB version by running “ver” on the console. You need the makani repository loaded to your computer.

Open MATLAB and navigate to the following directory on the console:

$MAKANI_HOME/analysis

Run the following script in the MATLAB console to set all relevant paths:

SetMatlab

Now you can run the following code on console to access telemetry data:

log = h5load('20161121-142912-flight01_crosswind.h5');
c = log('/messages/kAioNodeControllerA/kMessageTypeControlTelemetry');
Time = c.message.time;
Altitude = -c.message.state_est.Xg.z
figure;
plot(Time, Altitude)

Method 3

The best of both worlds! A lazy way to loads all datasets quickly. You need the makani repository loaded to your computer.

Open MATLAB and navigate to the following directory on the console:

$MAKANI_HOME/analysis

Run the following script in the MATLAB console to set all relevant paths:

SetMatlab

Now open the H5Plotter (a GUI interface for opening and plotting H5 log data) by running the following in the MATLAB console:

H5Plotter

Load a H5 log file using the Choose button in the top right corner. Once the file is loaded, datasets appear in AIO Nodes panel box. Click on one or more of these nodes to access the corresponding datasets in the AIO Messages panel box. Only datasets common to all selected AIO nodes are shown.

Once you have selected data to plot in the AIO Messages panel box, use the plot button at the bottom right corner to visualize the data. Holding ctrl or shift allows multiple fields to be selected and selecting a node in the tree will plot all data contained beneath that node. Data can also be exported by right clicking.

NOTE: You can plot multiple datasets simultaneously on the same time axes. How many datasets you can plot at the same time is only limited by your machines RAM; be judicious about this.

Matlab Example: Plot roll, pitch, and yaw

Here's a small example that converts the dcm_g2b matrix into Euler angles.

% Read the log file.
filename = '20161121-142912-flight01_crosswind.h5';
c = h5read(filename, ...
    '/messages/kAioNodeControllerA/kMessageTypeControlTelemetry');

% Fetch the dcm_g2b matrix 
dcm_g2b = c.message.state_est.dcm_g2b.d;

% Transpose the dcm_g2b matrix.
dcm_g2b = permute(dcm_g2b, [2 1 3]);

% Compute Euler angles.
[yaw, pitch, roll] = dcm2angle(dcm_g2b, 'ZYX');

% Plot the results.
plot(c.message.time, roll  * 180/pi, '.', ...
     c.message.time, pitch * 180/pi, '.',...
     c.message.time, yaw   * 180/pi, '.')
legend('roll', 'pitch', 'yaw')

ylim([-180 180]);
set(gca, 'YTick', -180:30:180);
grid on;
xlabel('controller time [s]');
ylabel('angle [degrees]');
title(['flight attitude (' filename ')'], 'interpreter', 'none');