• PX4开发环境搭建--模拟器编译


    之前我们在做BetaFlight开源工程结构简明介绍的时候,有过一张开源飞控的介绍图谱。

    从这张图谱我们看到基本上有5条轴线:

    1. Pixhawk // PX4
    2. Ardupilot
    3. OpenPilot
    4. MultiWii // baseflight/cleanflight/betaflight
    5. Paparazzi

    BaseFlight/CleanFlight/BetaFlight目前在穿越机上的应用比较广泛。穿越机通常是小型机,比如:5寸以下。且整体起飞重量都比较轻,置空时间通常也就10分钟~30分钟范围。

    航拍,无人巡航的角度,不是仅仅RC控制,更多功能需要通过地面站的接入处理。从这个角度来说,PX4就有很好的优势(这篇文章主要是介绍PX4,其他当然也有很好的Paparazzi等)。
    飞控开源代码历史进程

    1. PX4开发环境介绍

    整个PX4开发环境可以用于非常多的实例:

    • Pixhawk和NuttX-based硬件
    • jMAVSim 仿真
    • Gazebo 仿真
    • Raspberry Pi
    • ROS (Robotics Operating System)
    • Fast DDS - Required for ROS2

    注:这里主要介绍基于Ubuntu 20.04 LTS (Focal Fossa)的搭建。

    2. PX4开发环境搭建

    2.1代码下载

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

    2.2 国内环境调整

    这些东西都是国外的,国内整体情况(比如:网络等)不理想,因此需要做一些调整。

    • 调整ubuntu本地apt升级路径:aliyun
    $ sudo vi /etc/apt/sources.list
    
    • 1
    # deb cdrom:[Ubuntu 20.04.2.0 LTS _Focal Fossa_ - Release amd64 (20210209.1)]/ focal main restricted
    
    # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
    # newer versions of the distribution.
    deb http://mirrors.aliyun.com/ubuntu/ focal main restricted
    
    ## Major bug fix updates produced after the final release of the
    ## distribution.
    deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted
    
    ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
    ## team. Also, please note that software in universe WILL NOT receive any
    ## review or updates from the Ubuntu security team.
    deb http://mirrors.aliyun.com/ubuntu/ focal universe
    # deb-src http://hk.archive.ubuntu.com/ubuntu/ focal universe
    deb http://mirrors.aliyun.com/ubuntu/ focal-updates universe
    # deb-src http://hk.archive.ubuntu.com/ubuntu/ focal-updates universe
    
    ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
    ## team, and may not be under a free licence. Please satisfy yourself as to
    ## your rights to use the software. Also, please note that software in
    ## multiverse WILL NOT receive any review or updates from the Ubuntu
    ## security team.
    # deb-src http://hk.archive.ubuntu.com/ubuntu/ focal multiverse
    # deb-src http://hk.archive.ubuntu.com/ubuntu/ focal-updates multiverse
    
    ## N.B. software from this repository may not have been tested as
    ## extensively as that contained in the main release, although it includes
    ## newer versions of some applications which may provide useful features.
    ## Also, please note that software in backports WILL NOT receive any review
    ## or updates from the Ubuntu security team.
    deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe
    
    ## Uncomment the following two lines to add software from Canonical's
    ## 'partner' repository.
    ## This software is not part of Ubuntu, but is offered by Canonical and the
    ## respective vendors as a service to Ubuntu users.
    # deb http://archive.canonical.com/ubuntu focal partner
    # deb-src http://archive.canonical.com/ubuntu focal partner
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted
    deb http://mirrors.aliyun.com/ubuntu/ focal-security universe
    # deb-src http://security.ubuntu.com/ubuntu focal-security universe
    # deb-src http://security.ubuntu.com/ubuntu focal-security multiverse
    
    # This system was installed using small removable media
    # (e.g. netinst, live or single CD). The matching "deb cdrom"
    # entries were disabled at the end of the installation process.
    # For information about how to configure apt package sources,
    # see the sources.list(5) manual.
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 调整python3本地pip升级路径:tsinghua
    diff --git a/Tools/setup/ubuntu.sh b/Tools/setup/ubuntu.sh
    index 25c12cb170..8bdc7ae910 100755
    --- a/Tools/setup/ubuntu.sh
    +++ b/Tools/setup/ubuntu.sh
    @@ -105,10 +105,10 @@ echo
     echo "Installing PX4 Python3 dependencies"
     if [ -n "$VIRTUAL_ENV" ]; then
            # virtual envrionments don't allow --user option
    -       python -m pip install -r ${DIR}/requirements.txt
    +       python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r ${DIR}/requirements.txt
     else
            # older versions of Ubuntu require --user option
    -       python3 -m pip install --user -r ${DIR}/requirements.txt
    +       python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --user -r ${DIR}/requirements.txt
     fi
    
     # NuttX toolchain (arm-none-eabi-gcc)
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    2.3 建立ubuntu开发环境

    $ bash ./PX4-Autopilot/Tools/setup/ubuntu.sh
    
    • 1

    注:如果缺少2.2步骤,将会遇到非常多莫名其妙的问题,大体还是网络问题。

    2.4 构建jMAVSim仿真

    $ make px4_sitl jmavsim
    
    • 1

    2.5 补充版本信息

    目前,使用git最新版本:

    commit ffb0097052227e1b7dc2665463b6b9de33bbf835 (HEAD -> master, origin/master, origin/HEAD)
    Author: CR <christopher.ruwisch@tu-berlin.de>
    Date:   Wed Jun 22 21:50:30 2022 +0200
    
        removed unused code - _constrainOneSide and _constrainAbs
    
    • 1
    • 2
    • 3
    • 4
    • 5

    这个版本在实际使用过程存在一个问题,当2.4编译成功后,无法看到模拟GUI界面,主要是缺少ant组件,导致脚本jmavsim_run.sh的73行代码无法执行。

    PX4-Autopilot/Tools/jmavsim_run.sh +73
    
    ant create_run_jar copy_res
    
    • 1
    • 2
    • 3

    所以请确认ant是否已经安装:

    $ sudo apt-get install ant
    
    • 1

    3. jmavsim仿真环境

    jmavsim

    3.1 仿真命令集

    仿真环境下支持的命令列表如下:

    pxh> help
    Builtin Commands:
      actuator_test
      airship_att_control
      airspeed_selector
      attitude_estimator_q
      battery_simulator
      camera_feedback
      camera_trigger
      cdev_test
      commander
      commander_tests
      control_allocator
      controllib_test
      dataman
      dyn
      ekf2
      ex_fixedwing_control
      failure
      fake_gps
      fake_imu
      fake_magnetometer
      flight_mode_manager
      fw_att_control
      fw_autotune_attitude_control
      fw_pos_control_l1
      gimbal
      gps
      gyro_calibration
      gyro_fft
      hello
      hrt_test
      land_detector
      landing_target_estimator
      led_control
      list_files
      list_tasks
      listener
      load_mon
      local_position_estimator
      logger
      mag_bias_estimator
      manual_control
      mavlink
      mavlink_tests
      mc_att_control
      mc_autotune_attitude_control
      mc_hover_thrust_estimator
      mc_pos_control
      mc_rate_control
      mixer
      motor_test
      navigator
      param
      perf
      pwm
      pwm_out_sim
      px4_mavlink_debug
      px4_simple_app
      rc_tests
      rc_update
      replay
      rover_pos_control
      rover_steering_control
      rpm_simulator
      sd_bench
      send_event
      sensor_baro_sim
      sensor_gps_sim
      sensor_mag_sim
      sensors
      shutdown
      sih
      simulator
      sleep
      system_time
      temperature_compensation
      tests
      tone_alarm
      tune_control
      uorb
      uorb_tests
      uuv_att_control
      uuv_example_app
      uuv_pos_control
      ver
      vtol_att_control
      work_item_example
      work_queue
      wqueue_test
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90

    3.2 命令实例

    举例:
    commander takeoff //起飞
    commander land //降落

    注:由于我的遥控器距离有问题,去维修了(四轴飞控DIY集成FPV功能),所以没法实际操作。后续有时间再做更新!!!

  • 相关阅读:
    Gateway服务网关
    SAP Success Factor Single Sign On(单点集成) 的文档清单
    ps2021神经ai滤镜无法使用,ps2021神经滤镜出现错误
    C++ -- IO流
    使用visual stdio中自带git无法推送代码的问题解决
    计算机毕业设计Java博弈论学习网站(源码+系统+mysql数据库+lw文档)
    408考研科目《数据结构》第三章第一节:栈和队列
    flutter问题汇总
    workman使用手册1.0
    Android 蓝牙开发( 四 )
  • 原文地址:https://blog.csdn.net/lida2003/article/details/125419971