当前位置: 首页 > news >正文

Quadrotor-NMPC-Control 开源项目复现与问题记录

ACADOS NMPC Quadrotor Position Control Demo

四旋翼高速NMPC控制 ACADOS


项目环境配置流程如下:

git clone https://github.com/LGQWakkk/Quadrotor-NMPC-Control.git

cd Quadrotor-NMPC-Control

conda activate mujo  # my conda env

安装 ACADOS

ACADOS 是一个复杂的优化工具,需要手动编译和安装。以下是安装步骤:

git clone https://github.com/acados/acados.git

cd acados

mkdir -p build
cd build
cmake ..
make install

如果 cmake .. 遇到如下报错:

cmake ..
-- Build type is Release
-- ACADOS_WITH_OPENMP: OFF
CMake Error at external/CMakeLists.txt:48 (add_subdirectory):
The source directory

TEXT

/home/hjx/hjx_file/MuJoCo/Quadrotor-NMPC-Control/acados/external/blasfeo

does not contain a CMakeLists.txt file.

CMake Error at external/CMakeLists.txt:61 (add_subdirectory):
The source directory

TEXT

/home/hjx/hjx_file/MuJoCo/Quadrotor-NMPC-Control/acados/external/hpipm

does not contain a CMakeLists.txt file.

--
-- Target: BLASFEO is X64_AUTOMATIC, HPIPM is X64_AUTOMATIC
-- Linear algebra: HIGH_PERFORMANCE
-- Octave MEX (OFF)
-- System name:version Linux:5.15.0-131-generic
-- Build type is Release
-- Installation directory is /home/hjx/hjx_file/MuJoCo/Quadrotor-NMPC-Control/acados
-- OpenMP parallelization is OFF

-- Configuring incomplete, errors occurred!
See also "/home/hjx/hjx_file/MuJoCo/Quadrotor-NMPC-Control/acados/build/CMakeFiles/CMakeOutput.log".

从 CMake 错误信息来看,问题是由于 blasfeo 和 hpipm 子模块缺失导致的。这些子模块是 ACADOS 的核心依赖项,通常通过 Git 子模块初始化来获取。以下是解决此问题的详细步骤:

初始化 Git 子模块

ACADOS 使用 Git 子模块来管理依赖项(如 blasfeo 和 hpipm)。如果子模块未初始化,CMake 将无法找到相关的 CMakeLists.txt 文件。

进入 ACADOS 目录

cd /home/hjx/hjx_file/MuJoCo/Quadrotor-NMPC-Control/acados

初始化子模块

运行以下命令初始化子模块:

git submodule update --init --recursive

检查子模块是否成功初始化

确保 blasfeo 和 hpipm 目录已正确下载:

ls external/blasfeo
ls external/hpipm

重新运行 CMake

子模块初始化完成后,重新运行 CMake:

mkdir -p build
cd build
cmake ..

检查依赖项

确保已安装所有依赖项。在 Ubuntu 上,可以运行以下命令安装依赖:

sudo apt-get install cmake build-essential gcc g++ gfortran

编译 ACADOS

CMake 配置成功后,编译 ACADOS:

make install

检查 libacados.so 是否生成

编译完成后,检查 libacados.so 是否生成:

ls /home/hjx/hjx_file/MuJoCo/Quadrotor-NMPC-Control/acados/lib/libacados.so

设置环境变量

确保 LD_LIBRARY_PATH 包含 libacados.so 的路径。运行以下命令:

export LD_LIBRARY_PATH=/home/hjx/hjx_file/MuJoCo/Quadrotor-NMPC-Control/acados/lib:$LD_LIBRARY_PATH

注意在.bashrc文件中添加:

# ACADOS
export ACADOS_SOURCE_DIR=/home/hjx/hjx_file/MuJoCo/Quadrotor-NMPC-Control/acados
export LD_LIBRARY_PATH=/home/hjx/hjx_file/MuJoCo/Quadrotor-NMPC-Control/acados/lib:$LD_LIBRARY_PATH

最后安装 Python 接口

进入 acados_template 目录,安装 Python 接口:

cd /home/hjx/hjx_file/MuJoCo/Quadrotor-NMPC-Control/acados/interfaces/acados_template

conda activate mujo
pip install .

OK,到这里环境配置完成!

下面开始运行对应的demo文件:main.py (注意在终端运行)

python main.py

初次运行应该会遇到如下的提示:

hovor speed: 15.777730167256925 krpm
field AcadosOcpDims.N has been migrated to AcadosOcpOptions.N_horizon. setting AcadosOcpOptions.N_horizon = N. For future comppatibility, please use AcadosOcpOptions.N_horizon directly.

Tera template render executable not found, while looking in path:
/home/hjx/hjx_file/MuJoCo/Quadrotor-NMPC-Control/acados/bin/t_renderer
In order to be able to render the templates, you need to download the tera renderer binaries from:
https://github.com/acados/tera_renderer/releases

Do you wish to set up Tera renderer automatically?
y/N? (press y to download tera or any key for manual installation)

问题是由于 t_renderer 未找到导致的。t_renderer 是 ACADOS 用于渲染模板的工具,缺失时会影响代码生成。因此只要在运行窗口处输入 “y” 即可

最终的main.py文件运行无误后,会出现如下的界面:

说明项目代码运行成功!!!


参考:

GitHub - LGQWakkk/Quadrotor-NMPC-Control: 四旋翼高速NMPC控制 ACADOS

http://www.dtcms.com/a/54959.html

相关文章:

  • 03.06 QT
  • ComfyUI进阶教程核心要点与详解
  • 多模态模型在做选择题时,如何设置Prompt,如何精准定位我们需要的选项
  • 【Kubernetes 指南】基础入门——Kubernetes 基本概念(四)
  • Python在DevOps中的应用:自动化CI/CD管道的实现
  • 【电控笔记z29】扰动估测器DOB估测惯量J-摩擦系数B
  • 私有云基础架构与运维(一)
  • Mybatis中的设计模式
  • SpringBoot+Vue 多模块(子父工程)项目的注册登录及增删改查
  • 软件工程画图题
  • leetcode202 快乐数 哈希结构 集合
  • Ubuntu 安装docker docker-compose
  • 颠覆传统软件测试!Browser Use WebUI+DeepSeek:软件测试行业的革命性突破
  • 深入剖析Android Service:原理、生命周期与实战应用
  • Python中判断静态方法的六种方式
  • 物联网系统搭建
  • 【橘子golang】从golang来谈闭包
  • 【五.LangChain技术与应用】【29.LangChain Agent小案例1:智能代理的实战应用】
  • 6. 机器人实现远程遥控(具身智能机器人套件)
  • 【JAVA架构师成长之路】【持久层】第5集:PreparedStatement防SQL注入
  • 计算机数据库三级刷题总结(博主89分已过,总结的内容分享)
  • Linux 开发工具
  • 学习使用ESP8266进行MQTT通信并在网页上可视化显示
  • VEC系列-RabbitMQ 入门笔记
  • 三款好用远程终端软件
  • FPGA时序约束的几种方法
  • MAVEN手动配置(阿里云)全教程
  • 【Linux———信号精讲】
  • DELETE/ UPDATE/ INSERT 语句会自动加锁
  • HarmonyOS:基于hmrouter实现Page的生命周期监听