PX4-Autopilot v1_13提供了Holybro PX4Vision v1.5无人机的.sdf文件和airframe文件,使得利用该模型进行SITL仿真成为了可能。但是这一模型并不在官方SITL文档的受支持模型列表中,且当我们在PX4-Autopilot根目录下运行以下编译指令时:

make px4_sitl gazebo_px4vision

将发生报错。本文将对相关文件进行修改,以实现该模型的SITL仿真。

1. 运行效果

本文最终实现的仿真效果如下图所示:

 2. 修改init.d/airframes文件

部分参数在PX4 SITL中尚不存在,编译这些参数会引起上文所述的报错。此处采用将这些参数注释掉的方式解决该问题。注释后的文件如下所示:

#!/bin/sh
#
# @name PX4 Vision Dev Kit v1.5
#
# @type Quadrotor x
# @class Copter
#
# @board px4_fmu-v2 exclude
# @board bitcraze_crazyflie exclude
#

. ${R}etc/init.d/rc.mc_defaults

# System parameters
# use FMU motor outputs for less delay in the rate control loop
# param set-default SYS_USE_IO 0

# Commander Parameters
param set-default COM_OBS_AVOID 0
param set-default COM_DISARM_LAND 0.5

# EKF2 parameters
param set-default EKF2_AID_MASK 35
param set-default EKF2_IMU_POS_X 0.02
param set-default EKF2_GPS_POS_X 0.055
param set-default EKF2_GPS_POS_Z -0.15
param set-default EKF2_MIN_RNG 0.03
param set-default EKF2_OF_POS_X 0.055
param set-default EKF2_OF_POS_Y 0.02
param set-default EKF2_OF_POS_Z 0.065
param set-default EKF2_REQ_HDRIFT 0.3
param set-default EKF2_REQ_SACC 1
param set-default EKF2_REQ_VDRIFT 0.3
param set-default EKF2_RNG_A_HMAX 8
param set-default EKF2_RNG_A_VMAX 2
param set-default EKF2_RNG_POS_X 0.055
param set-default EKF2_RNG_POS_Y -0.01
param set-default EKF2_RNG_POS_Z 0.065
param set-default EKF2_PCOEF_XP -0.25
param set-default EKF2_PCOEF_YN -0.55
param set-default EKF2_PCOEF_YP -0.55

# MAVLink parameters
# param set-default MAV_0_CONFIG 101
# param set-default MAV_1_CONFIG 102
param set-default MAV_1_RATE 80000
param set-default MAV_1_MODE 9
# param set-default SER_TEL1_BAUD 921600

# Vehicle attitude PID tuning
param set-default MC_ACRO_EXPO 0
param set-default MC_ACRO_EXPO_Y 0
param set-default MC_ACRO_P_MAX 200
param set-default MC_ACRO_R_MAX 200
param set-default MC_ACRO_SUPEXPO 0
param set-default MC_ACRO_SUPEXPOY 0
param set-default MC_ACRO_Y_MAX 150
param set-default MC_PITCHRATE_D 0.0015
param set-default MC_ROLLRATE_D 0.0015
param set-default MC_YAWRATE_P 0.3

# Position Control Tuning
param set-default CP_DIST 6
param set-default MPC_ACC_DOWN_MAX 5
param set-default MPC_ACC_HOR_MAX 10
param set-default MPC_ACC_UP_MAX 4
param set-default MPC_MANTHR_MIN 0
param set-default MPC_MAN_Y_MAX 120
param set-default MPC_TILTMAX_AIR 45
param set-default MPC_THR_HOVER 0.3
param set-default MPC_TKO_SPEED 1
param set-default MPC_VEL_MANUAL 5
param set-default MPC_XY_CRUISE 5
param set-default MPC_XY_VEL_MAX 5
param set-default MPC_XY_VEL_P_ACC 1.58
param set-default MPC_XY_TRAJ_P 0.3
# param set-default MPC_Z_TRAJ_P 0.3
param set-default MPC_Z_VEL_P_ACC 5
param set-default MPC_Z_VEL_I_ACC 3
param set-default MPC_LAND_ALT1 3
param set-default MPC_LAND_ALT2 1
param set-default MPC_POS_MODE 3
param set-default CP_GO_NO_DATA 1

# Navigator Parameters
param set-default NAV_ACC_RAD 2

# use oneshot motor output protocol
param set-default PWM_MAIN_RATE 0

# RTL Parameters
param set-default RTL_DESCEND_ALT 5
param set-default RTL_RETURN_ALT 5

# Logging Parameters
param set-default SDLOG_PROFILE 131

# Sensors Parameters
# param set-default SENS_CM8JL65_CFG 202
param set-default SENS_FLOW_MAXHGT 25
param set-default SENS_FLOW_MINHGT 0.5
param set-default IMU_GYRO_CUTOFF 100
# param set-default SENS_TFLOW_CFG 103

# Power Parameters
param set-default BAT1_N_CELLS 4
# param set-default BAT1_A_PER_V 36.364
# param set-default BAT1_V_DIV 18.182

# Circuit breakers
param set-default CBRK_IO_SAFETY 22027

param set-default THR_MDL_FAC 0.3

param set-default CA_ROTOR_COUNT 4
param set-default CA_ROTOR0_PX 0.15
param set-default CA_ROTOR0_PY 0.15
param set-default CA_ROTOR0_KM 0.05
param set-default CA_ROTOR1_PX -0.15
param set-default CA_ROTOR1_PY -0.15
param set-default CA_ROTOR1_KM 0.05
param set-default CA_ROTOR2_PX 0.15
param set-default CA_ROTOR2_PY -0.15
param set-default CA_ROTOR2_KM -0.05
param set-default CA_ROTOR3_PX -0.15
param set-default CA_ROTOR3_PY 0.15
param set-default CA_ROTOR3_KM -0.05

# Outputs
# param set-default PWM_AUX_FUNC1 101
# param set-default PWM_AUX_FUNC2 102
# param set-default PWM_AUX_FUNC3 103
# param set-default PWM_AUX_FUNC4 104

 3. 修改init.d-posix/airframes文件

此处主要是将4016_holybro_px4vision替换为4020_holybro_px4vision_v1_5以使用新版无人机配置。修改后的文件如下所示:

#!/bin/sh
#
# @name PX4Vision SITL
# Holybro px4vision. Gazebo Only.
#
# @type Quadrotor
#

. ${R}etc/init.d/airframes/4020_holybro_px4vision_v1_5

set MIXER quad_x

4.编写launch文件

 如下所示

<?xml version="1.0"?>
<launch>
    <!-- MAVROS posix SITL environment launch script -->
    <!-- launches MAVROS, PX4 SITL, Gazebo environment, and spawns vehicle -->
    <!-- vehicle pose -->
    <arg name="x" default="0"/>
    <arg name="y" default="0"/>
    <arg name="z" default="0"/>
    <arg name="R" default="0"/>
    <arg name="P" default="0"/>
    <arg name="Y" default="0"/>
    <!-- vehicle model and world -->
    <arg name="est" default="ekf2"/>
    <arg name="vehicle" default="px4vision"/>
    <!-- <arg name="world" default="$(find mavlink_sitl_gazebo)/worlds/windy.world"/> -->
    <arg name="world" default="$(find offboard)/worlds/empty.world"/>
    <arg name="sdf" default="$(find offboard)/models/px4vision_ancl/px4vision_ancl.sdf"/>

    <!-- gazebo configs -->
    <arg name="gui" default="true"/>
    <arg name="debug" default="false"/>
    <arg name="verbose" default="false"/>
    <arg name="paused" default="false"/>
    <arg name="respawn_gazebo" default="false"/>
    <!-- MAVROS configs -->
    <arg name="fcu_url" default="udp://:14540@localhost:14557"/>
    <arg name="respawn_mavros" default="false"/>
    <!-- PX4 configs -->
    <arg name="interactive" default="true"/>
    <!-- PX4 SITL and Gazebo -->
    <include file="$(find px4)/launch/posix_sitl.launch">
        <arg name="x" value="$(arg x)"/>
        <arg name="y" value="$(arg y)"/>
        <arg name="z" value="$(arg z)"/>
        <arg name="R" value="$(arg R)"/>
        <arg name="P" value="$(arg P)"/>
        <arg name="Y" value="$(arg Y)"/>
        <arg name="world" value="$(arg world)"/>
        <arg name="vehicle" value="$(arg vehicle)"/>
        <arg name="sdf" value="$(arg sdf)"/>
        <arg name="gui" value="$(arg gui)"/>
        <arg name="interactive" value="$(arg interactive)"/>
        <arg name="debug" value="$(arg debug)"/>
        <arg name="verbose" value="$(arg verbose)"/>
        <arg name="paused" value="$(arg paused)"/>
        <arg name="respawn_gazebo" value="$(arg respawn_gazebo)"/>
    </include>
    <!-- MAVROS -->
    <include file="$(find mavros)/launch/px4.launch">
        <!-- GCS link is provided by SITL -->
        <arg name="gcs_url" value=""/>
        <arg name="fcu_url" value="$(arg fcu_url)"/>
        <arg name="respawn_mavros" value="$(arg respawn_mavros)"/>
    </include>
</launch>

5. 注意事项

这样修改出的仿真模型存在无法使用QGroundControl右侧虚拟Joystick的问题,但是已经足够用于控制器设计。

GitHub 加速计划 / vi / vision
15.85 K
6.89 K
下载
pytorch/vision: 一个基于 PyTorch 的计算机视觉库,提供了各种计算机视觉算法和工具,适合用于实现计算机视觉应用程序。
最近提交(Master分支:3 个月前 )
518ee93d 7 天前
7d077f13 9 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐