Linux系统下搭建PX4/Pixhawk原生固件编译环境

2023-05-16

对于新版本的固件V1.11.3,在pixhawk官网可以找到开发环境的搭建,这里把开发环境链接贴出来:https://docs.px4.io/master/zh/dev_setup/dev_env_linux_ubuntu.html
但是新版本的代码过于复杂,有时候想要学习代码可以下载老版本的代码,但是经过实验发现,搭建好的新版本的环境编译老版本的代码经常出错,因此将自己实验过程中出现的一些错误总结下来:
1.下载代码的时候,不要直接git clone 要指定版本信息,如下所示:

git clone -b v1.8.2 https://github.com.cnpmjs.org/PX4/PX4-Autopilot.git

这里我指定了版本信息是v1.8.2,同时可以发现我的网页并没有直接使用github,而是使用的国内的镜像.cnpmjs.org,这样下载起来代码会快10倍左右。
2. 下载好代码,大概两分钟左右,使用指令git submodule update --init --recursive更新子模块,但是这里的子模块也是使用的github上的资源,下载起来超级慢,两三天都有可能,因此我们修改.gitmodules文件,这是一个隐藏文件,打开PX4-Autopilot文件夹,单击CTRL+H,就可以显示隐藏文件,讲隐藏文件里面的github.com全部修改成github.com.cnpmjs.org,这样就可以换成国内的镜像,如下所示:

[submodule "mavlink/include/mavlink/v2.0"]
	path = mavlink/include/mavlink/v2.0
	url = https://github.com.cnpmjs.org/mavlink/c_library_v2.git
	branch = master
[submodule "src/modules/uavcan/libuavcan"]
	path = src/modules/uavcan/libuavcan
	url = https://github.com.cnpmjs.org/UAVCAN/libuavcan.git
	branch = master
[submodule "msg/tools/genmsg"]
	path = msg/tools/genmsg
	url = https://github.com.cnpmjs.org/ros/genmsg.git
	branch = indigo-devel
[submodule "msg/tools/gencpp"]
	path = msg/tools/gencpp
	url = https://github.com.cnpmjs.org/ros/gencpp.git
	branch = indigo-devel
[submodule "Tools/jMAVSim"]
	path = Tools/jMAVSim
	url = https://github.com.cnpmjs.org/PX4/jMAVSim.git
	branch = master
[submodule "Tools/sitl_gazebo"]
	path = Tools/sitl_gazebo
	url = https://github.com.cnpmjs.org/PX4/sitl_gazebo.git
	branch = master
[submodule "src/lib/matrix"]
	path = src/lib/matrix
	url = https://github.com.cnpmjs.org/PX4/Matrix.git
	branch = master
[submodule "src/lib/DriverFramework"]
	path = src/lib/DriverFramework
	url = https://github.com.cnpmjs.org/PX4/DriverFramework.git
	branch = master
[submodule "src/lib/ecl"]
	path = src/lib/ecl
	url = https://github.com.cnpmjs.org/PX4/ecl.git
	branch = master
[submodule "cmake/cmake_hexagon"]
	path = cmake/cmake_hexagon
	url = https://github.com.cnpmjs.org/ATLFlight/cmake_hexagon.git
	branch = master
[submodule "src/drivers/gps/devices"]
	path = src/drivers/gps/devices
	url = https://github.com.cnpmjs.org/PX4/GpsDrivers.git
	branch = master
[submodule "src/modules/micrortps_bridge/micro-CDR"]
	path = src/modules/micrortps_bridge/micro-CDR
	url = https://github.com.cnpmjs.org/eProsima/micro-CDR.git
	branch = master
[submodule "platforms/nuttx/NuttX/nuttx"]
	path = platforms/nuttx/NuttX/nuttx
	url = https://github.com.cnpmjs.org/PX4-NuttX/nuttx.git
	branch = px4_firmware_nuttx-7.22+
[submodule "platforms/nuttx/NuttX/apps"]
	path = platforms/nuttx/NuttX/apps
	url = https://github.com.cnpmjs.org/PX4-NuttX/apps.git
	branch = px4_firmware_nuttx-7.22+
[submodule "cmake/configs/uavcan_board_ident"]
	path = cmake/configs/uavcan_board_ident
	url = https://github.com.cnpmjs.org/PX4/uavcan_board_ident.git
	branch = master

3.更换以后,这时候会在更新子模块的时候出现一些错误,比如无法克隆等或者长时间没有进展,这个时候只需要按CTRL+Z终止下载,将下载有错误或停止的文件夹删除,之后重新下载即可。
4.下载完成以后,大概需要10分钟时间(非常快了),我们在固件的根目录打开终端,使用指令make px4fmu-v2_default(1.8版本一下,新版本的指令不是这个,具体看官网)编译。
5.此时出现错误error: expected initializer before '_PARAMS' extern double atan _PARAMS((double)); ^~~~~~~这种原因可能是因为GCC版本不对的原因,但是我们有解决办法,打开根目录,进入到src->include中,创建一个新的文件叫_ansi.h文件,里面填写如下:

/* Provide support for both ANSI and non-ANSI environments.  */

/* Some ANSI environments are "broken" in the sense that __STDC__ cannot be
   relied upon to have it's intended meaning.  Therefore we must use our own
   concoction: _HAVE_STDC.  Always use _HAVE_STDC instead of __STDC__ in newlib
   sources!
   To get a strict ANSI C environment, define macro __STRICT_ANSI__.  This will
   "comment out" the non-ANSI parts of the ANSI header files (non-ANSI header
   files aren't affected).  */

#ifndef	_ANSIDECL_H_
#define	_ANSIDECL_H_

#include <newlib.h>
#include <sys/config.h>

/* First try to figure out whether we really are in an ANSI C environment.  */
/* FIXME: This probably needs some work.  Perhaps sys/config.h can be
   prevailed upon to give us a clue.  */

#ifdef __STDC__
#define _HAVE_STDC
#endif

#ifdef _HAVE_STDC
#define	_PTR		void *
#define	_AND		,
#define	_NOARGS		void
#define	_CONST		const
#define	_VOLATILE	volatile
#define	_SIGNED		signed
#define	_DOTS		, ...
#define _VOID void
#ifdef __CYGWIN__
#define	_EXFUN(name, proto)		__cdecl name proto
#define	_EXPARM(name, proto)		(* __cdecl name) proto
#else
#define	_EXFUN(name, proto)		name proto
#define _EXPARM(name, proto)		(* name) proto
#endif
#define	_DEFUN(name, arglist, args)	name(args)
#define	_DEFUN_VOID(name)		name(_NOARGS)
#define _CAST_VOID (void)
#ifndef _LONG_DOUBLE
#define _LONG_DOUBLE long double
#endif
#ifndef _PARAMS
#define _PARAMS(paramlist)		paramlist
#endif
#else	
#define	_PTR		char *
#define	_AND		;
#define	_NOARGS
#define	_CONST
#define	_VOLATILE
#define	_SIGNED
#define	_DOTS
#define _VOID void
#define	_EXFUN(name, proto)		name()
#define	_DEFUN(name, arglist, args)	name arglist args;
#define	_DEFUN_VOID(name)		name()
#define _CAST_VOID
#define _LONG_DOUBLE double
#ifndef _PARAMS
#define _PARAMS(paramlist)		()
#endif
#endif

/* Support gcc's __attribute__ facility.  */

#ifdef __GNUC__
#define _ATTRIBUTE(attrs) __attribute__ (attrs)
#else
#define _ATTRIBUTE(attrs)
#endif

/*  ISO C++.  */

#ifdef __cplusplus
#if !(defined(_BEGIN_STD_C) && defined(_END_STD_C))
#ifdef _HAVE_STD_CXX
#define _BEGIN_STD_C namespace std { extern "C" {
#define _END_STD_C  } }
#else
#define _BEGIN_STD_C extern "C" {
#define _END_STD_C  }
#endif
#endif
#else
#define _BEGIN_STD_C
#define _END_STD_C
#endif

#endif /* _ANSIDECL_H_ */

即可。
6.继续编译,此时又会碰到一个错误converting a packed 'flash_entry_header_t' {aka 'struct flash_entry_header_t'} pointer (alignment 1) to a 'uint32_t' {aka 'unsigned int'} pointer (alignment 4) may result in an unaligned pointer value [-Werror=address-of-packed-member],我们同样有解决办法,打开根目录,进入到cmake->common,打开px4_base.cmake,搜索werror,找到他,把他所在行删除即可,如下图所示:
在这里插入图片描述
7.之后就可以编译成功!(其余的一些小错误都可以直接搜到哦,下载之前一定记得系统快照以防万一!!!)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Linux系统下搭建PX4/Pixhawk原生固件编译环境 的相关文章

随机推荐

  • Vicon轨迹topic转tum格式

    rostopic span class token function echo span span class token operator span xx gt gt xx span class token punctuation spa
  • Realsense d435i启动双目并关闭IR结构光(保证管用)

    想要采集一些双目的数据 上手了一下实验室闲置的stereolab zed2 xff0c 发现连官网都上不去 xff0c 而且环境配置麻烦的要死 xff0c 遂放弃 想起手里还有一个d435i也可以开双目 xff0c 果然还是realsens
  • 读取rosbag中的IMU信息并转为tum格式的csv和txt

    rostopic span class token operator span b xx span class token punctuation span bag span class token operator span p span
  • git中常用命令

    span class token number 1 span 安装 xff1a GitLens span class token number 2 span 快捷键打开终端 xff1a ctrl span class token opera
  • 镜像tag、push、pull、load等相关操作

    一 本身PaaS环境不能访问外网的操作 1 首先准备好镜像tar包 xff0c 上传到镜像服务器的 root目录下 执行命令为 xff1a docker load i 镜像 tar xff0c 如图所示 2 给镜像重新打上标记 xff0c
  • SNMPv3实验与报文分析

    一 SNMPv3工作原理 1 1 SNMPv3工作模式 SNMPv3采用客户机 服务器模式 如下图1所示 由图可知SNMP管理站可向代理发送普通请求 如GetRequest GetNextRequest等 xff0c 代理收到请求之后返回一
  • ACLLib图形库的基本使用

    ACLLib图形库的基本使用 使用环境 xff1a Dev C 43 43 5 7 1ACLLib图形库的下载 xff1a github上ACLLib的下载链接打开Dev C 43 43 xff0c 新建项目 xff0c 自定义你的文件名称
  • HBase Java Api

    任务目标 1 了解HBase语言的基本语法 2 了解HBase开发的原理 3 了解HBase Java API的使用 相关知识 HBase与Hadoop一样 xff0c 都是用Java编写的 xff0c 所以HBase对Java支持是必须的
  • 浅谈jQuery属性获取

    浅谈jQuery的属性获取 基本标签设置与基本css xff0c 附图下所示 上述代码如下图 xff1a 一 js的一些属性获取 1 var div 61 document getElementById first 这时候找到第一个div
  • 使用RGB-D摄像机的机器人目标跟踪和避障控制设计

    Control Design for Robotic Human Following and Obstacle Avoidance Using an RGB D Camera 摘要1 介绍2 系统总体架构3 算法介绍3 1 用户识别和定位3
  • Linux网络编程之PHP聊天室Workerman-chat

    云服务器上搭建 34 PHP聊天室框架 34 一 简介 xff1a 在服务器上搭建PHP聊天室框架 workerman chat 具体步骤 1 准备云服务器 购买阿里云服务器 可选购买其他云服务器 xff0c 如 xff1a 腾讯云 华为云
  • keil 下载安装 保姆级教程

    一 前言 最近被安排开发一个单片机的项目 xff0c 回头想了一下 xff0c 自己上次弄单片机的时候 xff0c 还都是在大学期间 xff0c 到现在也有三四年没有碰过了 xff0c 大部分的知识点都忘了 xff0c 所以又重新的把以前的
  • 从CSDN博客下载的图片如何无损去水印

    如果你想下载别人CSDN博客文章中很好看的图片 xff0c 但却有水印 想要下载去水印的图片 xff0c 可以先鼠标右击该图片 xff0c 选择复制图片地址 https img blog csdnimg cn 202009161408079
  • 不要再使用 Gitee 当图床了,官方已经开启防盗链了

    如果你正在使用或打算使用 Gitee 作为图床 xff0c 那么请不要这么做或打消该念头 近日 xff0c Gitee 官方已经开启防盗链 正在使用 Gitee 当图床的小伙伴或许已经发现所有的图片都已经变成了 Gitee 的 Logo 了
  • 基于BP神经网络的人脸朝向识别

    一 数字图像处理 1 1 问题假设 所给的全部人脸图像都未出现损坏等问题 xff1b 人脸的朝向仅分为5类 xff1a 左 中左 中间 中右 右 xff0c 其他朝向不予考虑 xff1b 对于题目中所给的人脸图像 xff0c 不考虑人脸的复
  • ::在c++中的意思

    在c 43 43 中 一 作用域符号 xff1a xff1a 前面是类名称 xff0c 后面一般是该类的成员名称 例类A中包含member1 A member1 二 全局作用域符号 用于区分全局变量和局部变量 xff1a xff1a cha
  • linux下cannot execute binary file: Exec format error解决办法

    对于linux下cannot execute binary file Exec format error明确说明是执行文件格式错误 xff0c 可能情况 xff1a 1 使用错误的命令 xff0c 如gcc c hello c o hell
  • PX4/Pixhawk---uORB深入理解和应用(最新版)

    1 简介 ps 第1章简介是参考 uORB深入理解和应用 1 1 PX4 Pixhawk的软件体系结构 PX4 Pixhawk的软件体系结构主要被分为四个层次 xff0c 这可以让我们更好的理解PX4 Pixhawk的软件架构和运作 xff
  • 深拷贝和浅拷贝的区别

    1 简单理解 深拷贝和浅拷贝最根本的区别在于是否真正获取一个对象的复制实体 xff0c 而不是引用 假设B复制了A xff0c 修改A的时候 xff0c 看B是否发生变化 xff1a 如果B跟着也变了 xff0c 说明是浅拷贝 xff0c
  • Linux系统下搭建PX4/Pixhawk原生固件编译环境

    对于新版本的固件V1 11 3 在pixhawk官网可以找到开发环境的搭建 xff0c 这里把开发环境链接贴出来 xff1a https docs px4 io master zh dev setup dev env linux ubunt