Apache License 2.0

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

深度技术分析:google/makani 项目

项目背景与痛点

Makani 项目旨在开发商用级别的空中风力涡轮机,其最终试验是在挪威海岸进行的 Makani M600 漂浮测试。随着所有相关软件的开源,这个项目可以为飞翼型风力发电设备和更广泛的风力能源开发领域提供宝贵的技术支持。该项目的关键难题是确保在一个高阶复杂、动态变化的环境中进行高效和全面的能源捕获和管理。因此,Makani 需要开发出可靠且高性能的软件架构以实现精准的空中位置控制、数据采集处理和性能优化等任务。

核心技术揭秘

技术架构

Makani 项目的开发涉及飞行模拟器、控制平台(自动驾驶仪)、可视化工具以及飞行监控套件等一系列复杂系统。其关键技术栈涵盖了从嵌入式系统编程到高性能计算模拟等多个层面。

graph TD A[用户指令] --> B[命令中心] B --> C{"模拟器/控制器"} C -->|"模拟器"| D[模拟飞行路径] C -->|"控制器"| E[控制飞行状态] D --> F[生成飞行数据] E --> G[调整飞行轨迹] F --> H[存储飞行数据] G --> H
软件分层设计
  • 命令中心:作为系统的核心,负责调度与管理各项指令。
  • 模拟器:用于仿真飞行器在各类环境中的飞行表现,提供实验性数据。
  • 控制器:基于采集到的数据,优化和调整飞行控制参数,实现自动化的飞行路径规划和自主飞行能力。
  • 数据存储与分析:对飞行过程中产生的海量数据进行存储、归档和初步分析。

这个架构支持了软件系统的可扩展性、可测试性和可维护性,大大降低了系统的总体开发、测试和维护成本。

功能亮点与差异

Makani 项目中最突出的地方在于其控制器对环境变化的适应能力。虽然它依赖的具体第三党库不再提供,但这套系统的核心设计思想和实现原理依然能启发开发者探索高性能、动态的飞行控制算法。此外,通过开放几乎所有硬件和软件的源代码,Makani 为该领域的研究者和实践者提供了一份宝贵的开源模板,促进了社区的创新和技术迭代。

应用场景与落地建议

对于希望开发和测试空中风力发电系统的研究人员和开发团队,Makani 提供了一整套从理论到实践的技术栈。在项目落地过程中,开发团队需要注意模拟环境的调整与真实环境之间的差异,这种差异可能会显著影响实际测试结果的准确性与一致性。另外,由于项目的部分依赖第三方的专有代码,开发人员需要花时间寻找替代方案或重新实现相关功能。

综合评价

Makani 项目通过开放源代码,推动了风力发电技术的进步,然而开发仍不完善,仍需大量开发工作与技术攻关。它的优势在于其复杂的系统设计和精密的控制算法,为飞翼型风力发电系统的研发提供了重要参考。值得指出,项目仍面临诸如部分专有代码缺失等问题,这些技术挑战在未来需要更多开发与技术人员共同努力解决。

关于

GitHub 原始描述(英文)

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.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
2646
价值分
878
活跃状态
归档

语言占比

Assembly
C
C++
CSS
Dockerfile
Emacs Lisp
HTML
Java
JavaScript
Jupyter Notebook
MATLAB
Makefile
Objective-C
Perl
Python
RPC
Roff
SWIG
Shell
Starlark
Vim Script
XC
XS

README

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 [u’kAioNodeBattA', … ]

# 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 machine’s 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');

评论

暂无评论