当前位置:网站首页>Px4 simulation basis

Px4 simulation basis

2022-06-25 23:41:00 Blue sky

This article describes jmavsim and gazebo The use of two simulators

    The simulator can make PX4 The flight control program is in the simulation “ The world ” To control a computer simulated aircraft . You can use QGroundControl Ground station procedures 、API Or the remote control interacts with the aircraft , It's like interacting with a real aircraft .

    Software simulation means PX4 The flight control program runs in the host computer , The host computer we use here is one with ubuntu server Of thinkpad Laptop computer ,PX4 The flight control program is installed in the host computer .

     Hardware emulation means PX4 The flight control program runs in a real flight control computer , What we use here is an installation PX4 Of flight control procedures pixhawk Flight control computer .

Operating environment Version Description :

Hardware : Hexing company pixhawk 2.1 cube black

Software :QGroundControl Ground station : 2021-02-23 daily version

           PX4 The firmware :1.11.3

            operating system :ubuntu server 20.0.04.2 LTS

1. jmavsim Emulator

Reference documents :https://docs.px4.io/master/en/simulation/jmavsim.html

1.1 jmavsim Software emulation (SITL)

step :

1.1.1. from px4 Web site to download PX4_Autopilot Source code

1.1.2. Get into PX4-Autopilot Catalog

1.1.3. Carry out orders

             make px4_sitl_default jmavsim

      px4 Source code and jmavsim plugin The corresponding source code is compiled , Then the interface of aircraft and flight environment appears

1.1.4. stay pxh Command line interface input command :commander takeoff, You can see the plane take off

1.1.5.  start-up QGroundcontrol Ground station procedures , With this program, you can observe the flight path , You can also use the virtual remote control to operate the aircraft , You can also plan a flight mission and let the aircraft perform a flight mission .

1.2. jmavsim Hardware simulation (HITL)

step

1. 2.1 start-up QGroundControl Ground station software

1.2.2 stay Vechicle Setup Of safty In function Hardware in the loop Simulation Choose from HITL enabled

1.2.3  stay Vechicle Setup Of Aireframe Select among “HIL QuadCopter X” frame , Click on apply Button .   

      Be careful : After the flight control is restarted , Prompt appears Parameters are missing from firmware. You may be running a version of firmware which is not fully supported or your firmware has a bug in it. Missing params: 1:BAT_V_CHARGED, 1:BAT_N_CELLS, 1:BAT_V_EMPTY

    This prompt means that several parameters of the system are missing , Mainly refers to the battery part , in fact ,uavcan The parameters of are also missing . You need to use missionplanner recovery . This is a pixhawk 2.1 Unique defects .

1.2.4  stay Application Settings Medium General Medium AutoConnect to the following devices, uncheck All checkboxes , leave “udp”.

1.2.5  close QGroundControl

1.2.6  Unplug the flight control usb Line

1.2.7  Plug in the flight control usb Line , Wait for the flight control to start .

1.2.8  Get into PX4-Autopilot Catalog , Run the command

    ./Tools/jmavsim_run.sh -q -s -d /dev/ttyACM0 -b 921600 -r 250

    Simulation GUI The interface starts .

1.2.9  start-up QGroundControl

    jmavsim The simulator will work with QGroundControl and px4 Auto connect .

1.2.10. Unlock the plane with the remote control , Push the oil valve to take off .

     Be careful : When it is set to HITL after ,QGroundControl Tips , Loss of power parameters ( Three parameters ), It is necessary to verify the sensor and other information . Don't care , To recover these missing parameters , May refer to pixhawk 2.1 The instructions for ( Hexing company ).

2. gazebo Emulator

Reference documents :https://docs.px4.io/master/en/simulation/gazebo.html

gazebo 9, This is a px4 Specified on the official website gazebo edition , Because the current PX4 Only... Is packaged in the firmware source code gazebo 9 Corresponding code of ,gazebo 9 Self installation required .

gazebo9 Installation steps of :

install gazebo9 And development libraries , It's all binary .

First installation gazebo9-common

sudo apt-get install gazebo9-common

then

sudo apt-get install gazebo9

then

sudo apt-get install libgazebo9-dev

2.1 gazebo Software emulation (SITL)

step :

2.1.1  from px4 Web site to download PX4_Autopilot Source code

2.1.2 Get into PX4-Autopilot Catalog

2.1.3  Carry out orders

    make px4_sitl gazebo

    px4 Source code and corresponding gazebo plugin The source code is compiled , Then the interface of aircraft and flight environment will appear

2.1.4  stay pxh Command line interface input command :commander takeoff

    You can see the plane take off

2.1.5  start-up QGroundcontrol Ground station procedures , With this program, you can observe the flight path , You can also use the virtual remote control to operate the aircraft , You can also plan a flight mission and let the aircraft perform a flight mission .

2.1.6  The flight background of the aircraft can be changed

      such as :make px4_sitl gazebo_iris__warehouse

      Be careful :iris And warehouse Between 2 Underscores , among iris stay gazebo Middle represents four axis aircraft ,warehouse Representative background .

2.2. gazebo Hardware simulation (HITL)

step :

2.2.1  start-up QGroundControl Ground station software

2.2.2 stay Vechicle Setup Of safety In function Hardware in the loop Simulation Choose from HITL enabled

2.2.3  stay Vechicle Setup Of Aireframe Select among “HIL QuadCopter X” frame , Click on apply Button .

Be careful : After the flight control is restarted , Prompt appears Parameters are missing from firmware. You may be running a version of firmware which is not fully supported or your firmware has a bug in it. Missing params: 1:BAT_V_CHARGED, 1:BAT_N_CELLS, 1:BAT_V_EMPTY

This prompt means that several parameters of the system are missing , Mainly refers to the battery part , in fact ,uavcan The parameters of are also missing . After completing the hardware simulation, you need to use missionplanner recovery . This is a uavcan The missing parameter is pixhawk 2.1 Unique defects .

2.2.4 stay Application Settings Medium General Medium AutoConnect to the following devices, uncheck All checkboxes , leave “udp”.

2.2.5 close QGroundControl

2.2.6 Unplug the flight control usb Line

2.2.7 Plug in the flight control usb Line , Wait for the flight control to start .

2.2.8 compile gazebo plugin

        Get into PX4-Autopilot Catalog , Carry out orders

   DONT_RUN=1 make px4_sitl_default gazebo

2.2.9  Modify according to the official website gazebo plugin Of xml The configuration file

Open the four axis plane sdf file Tools/sitl_gazebo/models/iris_hitl/iris_hitl.sdf. if necessary , take serialDevice Replace with /dev/ttyACM0

2.2.10  Set the environment variable , Carry out orders

     source Tools/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default

2.2.11  function gazebo

   gazebo Tools/sitl_gazebo/worlds/hitl_iris.world

2.2.12  start-up QGroundControl

gazebo The simulator will work with QGroundControl and px4 Auto connect .

2.2.13  Unlock the plane with the remote control , Push the oil valve to take off .

Be careful : When it is set to HITL after , start-up QGroundControl Post prompt , Loss of power parameters ( Three parameters ), It is necessary to verify the sensor and other information , Don't care . Recover the lost uavcan Parameters can refer to pixhawk 2.1 The instructions for ( Hexing company ).

原网站

版权声明
本文为[Blue sky]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202180602056538.html