PX4和Airsim通信操作流程

2023-05-16

坑真几把多

先在Windows上安装UE4和Airsim不再赘述,官网都有

虚拟机或其他计算机安装好ubuntu并安装PX4

1、安装PX4的ROS相关包(mavros)

1、第一种:

进入官网安装ROS相关包(也就是mavros)

Ubuntu LTS/Debian Linux 的开发环境 | PX4 自动驾驶用户指南https://docs.px4.io/main/zh/dev_setup/dev_env_linux_ubuntu.html

要安装工具链:(这个会直接克隆PX4)

git clone https://github.com/PX4/PX4-Autopilot.git --recursive

运行 bash 脚本 

bash ./PX4-Autopilot/Tools/setup/ubuntu.sh

完事,重新启动计算机。

2、第二种,更好的方法(上面那种办法还要克隆一次PX4很烦,这个办法仅可用于Ubuntu18.04)

#!/bin/bash

## Bash script for setting up ROS Melodic (with Gazebo 9) development environment for PX4 on Ubuntu LTS (18.04).
## It installs the common dependencies for all targets (including Qt Creator)
##
## Installs:
## - Common dependencies libraries and tools as defined in `ubuntu_sim_common_deps.sh`
## - ROS Melodic (including Gazebo9)
## - MAVROS

if [[ $(lsb_release -sc) == *"xenial"* ]]; then
  echo "OS version detected as $(lsb_release -sc) (16.04)."
  echo "ROS Melodic requires at least Ubuntu 18.04."
  echo "Exiting ...."
  return 1;
fi

echo "Downloading dependent script 'ubuntu_sim_common_deps.sh'"
# Source the ubuntu_sim_common_deps.sh script directly from github
common_deps=$(wget https://raw.githubusercontent.com/PX4/Devguide/master/build_scripts/ubuntu_sim_common_deps.sh -O -)
wget_return_code=$?
# If there was an error downloading the dependent script, we must warn the user and exit at this point.
if [[ $wget_return_code -ne 0 ]]; then echo "Error downloading 'ubuntu_sim_common_deps.sh'. Sorry but I cannot proceed further :("; exit 1; fi
# Otherwise source the downloaded script.
. <(echo "${common_deps}")

# ROS Melodic
## Gazebo simulator dependencies
sudo apt-get install protobuf-compiler libeigen3-dev libopencv-dev -y

## ROS Gazebo: http://wiki.ros.org/melodic/Installation/Ubuntu
## Setup keys
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
## For keyserver connection problems substitute hkp://pgp.mit.edu:80 or hkp://keyserver.ubuntu.com:80 above.
sudo apt-get update
## Get ROS/Gazebo
sudo apt install ros-melodic-desktop-full -y
## Initialize rosdep
sudo rosdep init
rosdep update
## Setup environment variables
rossource="source /opt/ros/melodic/setup.bash"
if grep -Fxq "$rossource" ~/.bashrc; then echo ROS setup.bash already in .bashrc;
else echo "$rossource" >> ~/.bashrc; fi
eval $rossource

## Install rosinstall and other dependencies
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential -y



# MAVROS: https://dev.px4.io/en/ros/mavros_installation.html
## Install dependencies
sudo apt-get install python-catkin-tools python-rosinstall-generator -y

## Create catkin workspace
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin init
wstool init src


## Install MAVLink
###we use the Kinetic reference for all ROS distros as it's not distro-specific and up to date
rosinstall_generator --rosdistro kinetic mavlink | tee /tmp/mavros.rosinstall

## Build MAVROS
### Get source (upstream - released)
rosinstall_generator --upstream mavros | tee -a /tmp/mavros.rosinstall

### Setup workspace & install deps
wstool merge -t src /tmp/mavros.rosinstall
wstool update -t src
if ! rosdep install --from-paths src --ignore-src -y; then
    # (Use echo to trim leading/trailing whitespaces from the unsupported OS name
    unsupported_os=$(echo $(rosdep db 2>&1| grep Unsupported | awk -F: '{print $2}'))
    rosdep install --from-paths src --ignore-src --rosdistro melodic -y --os ubuntu:bionic
fi

if [[ ! -z $unsupported_os ]]; then
    >&2 echo -e "\033[31mYour OS ($unsupported_os) is unsupported. Assumed an Ubuntu 18.04 installation,"
    >&2 echo -e "and continued with the installation, but if things are not working as"
    >&2 echo -e "expected you have been warned."
fi

#Install geographiclib
sudo apt install geographiclib-tools -y
echo "Downloading dependent script 'install_geographiclib_datasets.sh'"
# Source the install_geographiclib_datasets.sh script directly from github
install_geo=$(wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh -O -)
wget_return_code=$?
# If there was an error downloading the dependent script, we must warn the user and exit at this point.
if [[ $wget_return_code -ne 0 ]]; then echo "Error downloading 'install_geographiclib_datasets.sh'. Sorry but I cannot proceed further :("; exit 1; fi
# Otherwise source the downloaded script.
sudo bash -c "$install_geo"

## Build!
catkin build
## Re-source environment to reflect new packages/build environment
catkin_ws_source="source ~/catkin_ws/devel/setup.bash"
if grep -Fxq "$catkin_ws_source" ~/.bashrc; then echo ROS catkin_ws setup.bash already in .bashrc;
else echo "$catkin_ws_source" >> ~/.bashrc; fi
eval $catkin_ws_source

 新建一个文件,把这段粘贴到里边,后缀为.sh

运行

bash ./xxx.sh

 等待即可

 2、安装PX4(科学上网诶)如果前一步用的第一种方法就可以跳过下面代码的克隆源码阶段

mkdir -p PX4
cd PX4
git clone https://github.com/PX4/PX4-Autopilot.git --recursive  #(用的第一种可以跳过)
bash ./PX4-Autopilot/Tools/setup/ubuntu.sh --no-nuttx --no-sim-tools
cd PX4-Autopilot

并从 Releases · PX4/PX4-Autopilot · GitHub 中找到最新的稳定版本,并查看与该版本匹配的源代码,例如:

git checkout v1.12.3

完事之后更新一下子模块,我就出了问题shift!!

git submodule update --init --recursive

然后用j8来make他

make px4_sitl_default none_iris -j8

就安装好PX4了

运行上面那条指令出现

 就是PX4已经运行了。

注意:

<span style="color:#404040"><span style="background-color:#fcfcfc"><code class="language-shell"> *******************************************************************************
 *   IF YOU DID NOT CHANGE THIS FILE (OR YOU DON'T KNOW WHAT A SUBMODULE IS):  *
 *   Hit 'u' and <ENTER> to update ALL submodules and resolve this.            *
 *   (performs git submodule sync --recursive                                  *
 *    and git submodule update --init --recursive )                            *
 *******************************************************************************</code></span></span>

每次看到此提示时,请在键盘上键入“u”。还有一个是输入“y”的,自己看着来吧,我没截图。

3、设置Windows环境下的Airsim的设置settings.json

1、Windows:

在   C:\Users\DELL\Documents\AirSim  这里

{
    "SettingsVersion": 1.2,
    "SimMode": "Multirotor",
    "ClockType": "SteppableClock",
    "Vehicles": {
        "PX4": {
            "VehicleType": "PX4Multirotor",
            "UseSerial": false,
            "LockStep": true,
            "UseTcp": true,
            "TcpPort": 4560,
            "ControlIp": "remote",
            "ControlPortLocal": 14540,
            "ControlPortRemote": 14580,
            "LocalHostIp": "192.168.1.12",
            "Sensors":{
                "Barometer":{
                    "SensorType": 1,
                    "Enabled": true,
                    "PressureFactorSigma": 0.0001825
                }
            },
            "Parameters": {
                "NAV_RCL_ACT": 0,
                "NAV_DLL_ACT": 0,
                "COM_OBL_ACT": 1,
                "LPE_LAT": 47.641468,
                "LPE_LON": -122.140165
            }
        }
    }
}

LocalHostIp是Windows本机的IP哦

完事了打开我的电脑的防火墙

 打开高级设置

 然后新建一个TCP4560端口

 

 懂得都懂了

完事之后可以去查看一下TCP端口打开没有

进入CMD输入

netstat -ano

 打开Airsim环境收听4560端口消息。就能看到了

 当我建立链接也就是我在PX4端和Airsim链接他就显示连接状态如上图

2、Ubuntu

虚拟机的话弄成桥接模式嗷(其他不懂行不行反正我也懒得尝试)

 双系统或者其它非虚拟机可能要手动一下IP,反正能ping上都好说。

进.bashrc里操作一下,把Windows的IP输入进去保存

export PX4_SIM_HOST_ADDR=192.168.1.12

 然后source一下它

source ~/.bashrc

 这样就拿捏了

4、运行PX4建立链接

1、Windows:

UE4和Airsim这边先运行

2、Ubuntu:

先cpdd到PX4的文件夹里

cd PX4/PX4-Autopilot

 然后就可以用你强大的CPU的j8来make它了(编译过了不用你的j8也行)

make px4_sitl_default none_iris

5、这样就完了

然后Airsim也显示连接成功,PX4会返回一些消息

 这就是链接成功了。

接下来它就听你的了,想干嘛就干嘛,也可以用ROS来教育教育它。嘿嘿嘿。

还有什么后续再补充,有什么漏的我可能也忘了。

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

PX4和Airsim通信操作流程 的相关文章

  • 用matlab处理px4日志的转换方法

    px4 v1 8 2的版本可以选择用sdlog2模块记录日志 xff0c 通过QGC地面站下载的日志格式为 ulg xff0c 将下载成功的 ulg扩展名改为 bin xff0c 然后用MP地面站 数据闪存日志 创建matlab文件 xff
  • PX4与TX2通信

    PX4与TX2通信以及相关数据的获取 目录 1 PX4硬件接口 2 TELEM1 2接口线序 3 PX4与TX2通信 PX4 IO口定义 xff1a PX4硬件 xff1a 4 通信测试 5 RTPS 43 ROS Jetson TX2终端
  • 编译PX4固件

    PX4编译 文章目录 PX4编译疑难杂症bug1bug2catkin build isolated 官方脚本Step1Step2 安装常用依赖Step3 创建并运行脚本Step4 补全代码子模块Step5 验证仿真 官方offboard 例
  • Ubuntu20.04+MAVROS+PX4+Gazebo保姆级安装教程

    Ubuntu20 04 43 MAVROS 43 PX4 43 Gazebo 安装PX4步骤安装MAVROS安装QGCPX4仿真 安装PX4步骤 从github上clone源码 span class token function git s
  • PX4+Offboard模式+代码控制无人机起飞(Gazebo)

    参考PX4自动驾驶用户指南 https docs px4 io main zh ros mavros offboard cpp html 我的另一篇博客写了 键盘控制PX4无人机飞行 PX4无人机 键盘控制飞行代码 可以先借鉴本篇博客 xf
  • Ubuntu下构建PX4软件

    本搭建过程基于http dev px4 io starting building html xff0c 希望大家互相交流学习 原文 xff1a Building PX4 Software xff08 构建PX4软件 xff09 PX4 ca
  • px4 avoidance笔记

    最近在用px4官方的avoidance代码跑硬件避障 xff0c 官方介绍了只要生成符合sensor msgs PointCloud2点云信息就能使用 xff0c 因此为了应用长基线双目 xff0c 没有使用realsense的相机 xff
  • 初学PX4之环境搭建

    文章转自 xff1a http www jianshu com p 36dac548106b 前言 前段时间linux崩溃了 xff0c 桌面进去后只有背景 xff0c 折腾好久没搞定 xff0c 为了节省时间索性重装了系统 xff0c 同
  • PX4 ---- Mixer

    文章目录 Mixer 混合控制 作用输入输出装载混控文件MAVROS代码解析总结示例MAINAUX Mixer 混合控制 作用 经过位置控制和姿态控制后 xff0c 控制量通过 actuator controls发布 xff0c 其中 co
  • PX4模块设计之一:SITL & HITL模拟框架

    PX4模块设计之一 xff1a SITL amp HITL模拟框架 1 模拟框架1 1 SITL模拟框架1 2 HITL模拟框架 2 模拟器类型3 MAVLink API4 总结 基于PX4开源软件框架简明简介的框架设计 xff0c 逐步分
  • PX4模块设计之四:MAVLink简介

    PX4模块设计之四 xff1a MAVLink简介 1 MAVLink PX4 应用简介2 MAVLink v2 0新特性3 MAVLink协议版本4 MAVLink通信协议帧4 1 MAVLink v1 0 帧格式4 2 MAVLink
  • PX4模块设计之五:自定义MAVLink消息

    PX4模块设计之五 xff1a 自定义MAVLink消息 1 MAVLink Dialects1 1 PX4 Dialects1 2 Paprazzi Dialects1 3 MAVLink XML File Format 2 添加自定义M
  • PX4模块设计之十八:Logger模块

    PX4模块设计之十八 xff1a Logger模块 1 Logger模块简介2 模块入口函数2 1 主入口logger main2 2 自定义子命令Logger custom command2 3 日志主题uORB注册 3 重要实现函数3
  • PX4模块设计之三十一:ManualControl模块

    PX4模块设计之三十一 xff1a ManualControl模块 1 ManualControl模块简介2 模块入口函数2 1 主入口manual control main2 2 自定义子命令custom command 3 Manual
  • PX4模块设计之四十三:icm20689模块

    PX4模块设计之四十三 xff1a icm20689模块 1 icm20689模块简介2 模块入口函数2 1 主入口icm20689 main2 2 自定义子命令custom command2 3 模块状态print status 重载 3
  • PX4-4-任务调度

    PX4所有的功能都封装在独立的模块中 xff0c uORB是任务间数据交互和同步的工具 xff0c 而管理和调度每个任务 xff0c PX4也提供了一套很好的机制 xff0c 这一篇我们分享PX4的任务调度机制 我们以PX4 1 11 3版
  • 【px4】运行mavsdk中的offboard example

    运行MAVSDK中的offboard例子时无人机不执行 想控制无人机前后左右移动 xff0c 在按照官方教程实现offboard 插件的时候 发现用action插件能正常起飞和降落 但是一旦执行到offboard的插件代码的时候就会自动降落
  • PX4飞控之自主返航(RTL)控制逻辑

    本文基于PX4飞控1 5 5版本 xff0c 分析导航模块中自护返航模式的控制逻辑和算法 自主返航模式和导航中的其他模式一样 xff0c 在Navigator main函数中一旦触发case vehicle status s NAVIGAT
  • PX4飞控的PPM接收机

    xff08 一 xff09 原理图 xff1a PX4飞控的PPM输入捕获由协处理器完成 xff0c 接在A8引脚 xff0c 对应Timer1的通道1 xff08 二 xff09 PPM协议 xff1a PPM的每一帧数据间隔为20ms
  • 无人机PX4使用动捕系统mocap的位置实现控制+MAVROS

    动捕系统Optitrack xff0c 有很高的定位精度 xff0c 能够给无人机提供比较精确的位置信息 xff0c 因此如果实验室有条件 xff0c 都可以买一套动捕系统 动捕系统的原理 xff1a 光学式动作捕捉依靠一整套精密而复杂的光

随机推荐

  • 什么是耦合、解耦

    一 耦合 1 耦合是指两个或两个以上的体系或两种运动形式间通过相互作用而彼此影响以至联合起来的现象 2 在软件工程中 xff0c 对象之间的耦合度就是对象之间的依赖性 对象之间的耦合越高 xff0c 维护成本越高 xff0c 因此对象的设计
  • ERROR! Session/line number was not unique in database. History logging moved to new session 178

    原来的代码 xff1a MODEL NAME 61 39 ssd mobilenet v1 coco 2017 11 17 39 载入训练好的pb模型 detection graph 61 tf Graph with detection g
  • 基于px4的hc-sr04-pwm超声波模块的驱动开发

    一直想实现无人的避障功能 xff0c 但是px4源生代码又不支持避障 xff0c 所以只能自己动手写 避障的基础条件还是获取距离数据 xff0c 超声波模块就是最熟悉也是最简单的模块了 px4源生代码也支持了几种超声波模块 xff0c 但是
  • px4最新版commander代码分析

    commander位于Firmware src modules commander文件夹中 该部分主要负责对地面站 遥控器以及其它部分发布的cmd命令 xff0c 包括vehicle command VEHICLE CMD DO SET M
  • SMPL模型进阶

    SMPL模型是一种参数化人体模型 xff0c 是马普所提出的一种人体建模方法 xff0c 该方法可以进行任意的人体建模和动画驱动 这种方法与传统的LBS的最大的不同在于其提出的人体姿态影像体表形貌的方法 xff0c 这种方法可以模拟人的肌肉
  • px4最新版navigation代码分析

    navigation部分位于代码Firmware navigator文件夹中 其中不仅仅包含navigator的代码 xff0c 最主要的9种不同的飞行模式的代码 xff0c 它们针对不同的飞行模式计算出不同的期望的位置 xff0c 即po
  • 基于最新版本px4的takeoff代码分析

    takeoff是px4的一种飞行模式 xff0c 跟之前分析的lotier部分是一种类型 takeoff模式也是由navigator部分进行调用的 xff0c 所以也就印证了上一篇说navigator相当于一个分发器的说法 各种飞行模式实际
  • Nuttx移植到S5PV210

    最近没有分析飞控的代码 xff0c 转而研究Nuttx实时操作系统的移植 入门一个操作的移植还是挺有难度的 xff0c 首先代码的框架能理清楚就很不容易了 xff0c 尤其是Nuttx这种相对小众的操作系统 xff0c 参考资料比较少 xf
  • 基于最新版PX4-Autopilot的follow_target代码分析

    快有半年没更博客了 最近加班比较多 xff0c 而且一直想研究研究ROS那块 xff0c 但是学到的又不足以写出博客 xff0c 也就一直没更新 最近接了一个目标跟踪的二次开发的活 xff0c 需求就是根据挂载摄像头传回来的与识别的目标的角
  • PX4-Autopilot的串口读写驱动程序开发

    最近突然感觉 xff0c 能把开发程序的流程写清楚比开发程序本身还困难 xff0c 所以之前写的文章都是毫无章法 xff0c 想到哪写到哪 xff0c 努力改变中 之前开发了超声波测量距离的驱动 xff0c 实质是px4的IO口操作 本次的
  • px4的IO固件升级代码分析

    很多时候都在看fmu的代码 xff0c 很少看io的代码 一个原因是io的功能简单 xff0c 代码少 xff0c 然后是io的功能一般都是通过fmu实现的 出于好奇 xff0c 最近分析了下io的固件升级的过程 首先 xff0c io和f
  • 你对自己做的项目感兴趣吗

    一家公司 主要是开发OA的 xff0c 大家知道OA的简单含义是办公自动化系统 用途是利用信息化系统帮助企业或者政府单位办公协作 xff0c 目的是为了提高办公效率 xff0c 减少过去由于手工操作带来的 麻烦 xff0c 和提高工作的准确
  • Nginx反向代理解决跨域问题(个人学习总结)

    一 理解Nginx Nginx是一款轻量级的Web服务器 反向代理服务器及电子邮件 xff08 IMAP POP3 xff09 代理服务器 xff0c 在BSD like 协议下发行 其特点是占有内存少 xff0c 并发能力强 xff0c
  • C语言:文本加密

    文本加密 输入一个英文句子 xff0c 以 结束 将其中所有的大写英文字母 43 3 xff0c 小写英文字母 3 xff0c 非英文字母不变 xff0c 输出加密后的句子 提示 xff1a xff08 1 xff09 当读入的字符为 时
  • (三)决策树

    0 基本流程 每个结点对应一个属性测试 xff0c 结点包含的样本集合根据结果分到不同的子结点决策树算法流程 xff1a 总结 xff1a 每次选择其中一个特征对样本集进行分类 xff0c 对分类后的子集重复前步骤根据8中的划分方法 xff
  • Nuttx 字符设备驱动

    字符设备是非常普遍的一种设备 xff0c 这种设备在I O传输过程中只能以字符为单位进行传输 xff0c 如键盘 鼠标 以及一些传感器设备都是字符设备 Nuttx采用VFS xff0c 和linux一样的设计思路 xff0c 即 一切设备皆
  • 阿木实验室 ubuntu 20.04 Prometheus 系统 编译问题

    1 compile detection sh error make 2 CMakeFiles darknet ros lib dir build make 2017 xff1a CMakeFiles darknet ros lib dir
  • prometheus 无人机平台 gazeboORBSLAM3调试实现rgbd模式

    提示 xff1a 文章写完后 xff0c 目录可以自动生成 xff0c 如何生成可参考右边的帮助文档 目录 前言 一 镜像系统安装 二 prometheus镜像快速使用 1 prometheus px4 xff0c Prometheus编译
  • TX2上用D435i跑Vins-RGBD+Octomap生成八叉树地图

    1 realsense的SDK 和普通电脑不同 xff0c TX2是ARM xff0c 不能直接从官网下载编译 教程 xff1a https blog csdn net rosfreshman article details 1164040
  • PX4和Airsim通信操作流程

    坑真几把多 先在Windows上安装UE4和Airsim不再赘述 xff0c 官网都有 虚拟机或其他计算机安装好ubuntu并安装PX4 1 安装PX4的ROS相关包 xff08 mavros xff09 1 第一种 xff1a 进入官网安