diff --git a/docs/uk/SUMMARY.md b/docs/uk/SUMMARY.md index 2810ea2fb2..13544e66de 100644 --- a/docs/uk/SUMMARY.md +++ b/docs/uk/SUMMARY.md @@ -181,6 +181,7 @@ - [Holybro Kakute H7v2](flight_controller/kakuteh7v2.md) - [Holybro Kakute H7mini](flight_controller/kakuteh7mini.md) - [Holybro Kakute H7](flight_controller/kakuteh7.md) + - [Holybro Kakute H7 Wing](flight_controller/kakuteh7-wing.md) - [Holybro Durandal](flight_controller/durandal.md) - [Wiring Quickstart](assembly/quick_start_durandal.md) - [Holybro Pix32 v5](flight_controller/holybro_pix32_v5.md) @@ -808,8 +809,10 @@ - [Тест MC_05 - Політ у приміщенні (ручні режими)](test_cards/mc_05_indoor_flight_manual_modes.md) - [Модульні Тести](test_and_ci/unit_tests.md) - [Безперервна інтеграція](test_and_ci/continous_integration.md) - - [MAVSDK Тестування інтеграції ](test_and_ci/integration_testing_mavsdk.md) - - [ROS Тестування інтеграції ](test_and_ci/integration_testing.md) + - [Integration Testing](test_and_ci/integration_testing.md) + - [MAVSDK Тестування інтеграції ](test_and_ci/integration_testing_mavsdk.md) + - [PX4 ROS2 Interface Library Integration Testing](test_and_ci/integration_testing_px4_ros2_interface.md) + - [ROS 1 Integration Testing](test_and_ci/integration_testing_ros1_mavros.md) - [Докер-контейнер](test_and_ci/docker.md) - [Підтримка](test_and_ci/maintenance.md) diff --git a/docs/uk/dev_log/ulog_file_format.md b/docs/uk/dev_log/ulog_file_format.md index 6e989a82a1..db9e342a3b 100644 --- a/docs/uk/dev_log/ulog_file_format.md +++ b/docs/uk/dev_log/ulog_file_format.md @@ -499,8 +499,8 @@ struct message_dropout_s { - [MAVGAnalysis](https://github.com/ecmnet/MAVGCL): Java, ULog streaming via MAVLink and parser for plotting and analysis. - [PlotJuggler](https://github.com/facontidavide/PlotJuggler): C++/Qt application to plot logs and time series. Підтримує ULog з версії 2.1.3. - [ulogreader](https://github.com/maxsun/ulogreader): Javascript, ULog reader and parser outputs log in JSON object format. -- [Foxglove Studio](https://github.com/foxglove/studio): an integrated visualization and diagnosis tool for robotics - (Typescript ULog parser: https://github.com/foxglove/ulog). +- [Foxglove](https://foxglove.dev): an integrated visualization and diagnosis tool for robotics data that supports ULog files. +- [TypeScript ULog parser](https://github.com/foxglove/ulog): TypeScript, ULog reader that outputs JS objects. ## Історія версій формату файлу diff --git a/docs/uk/flight_controller/kakuteh7-wing.md b/docs/uk/flight_controller/kakuteh7-wing.md new file mode 100644 index 0000000000..2461dc41bf --- /dev/null +++ b/docs/uk/flight_controller/kakuteh7-wing.md @@ -0,0 +1,84 @@ +# Holybro Kakute H7 V2 + +:::warning +PX4 не розробляє цей (або будь-який інший) автопілот. +Contact the [manufacturer](https://holybro.com/) for hardware support or compliance issues. +::: + +The [Holybro Kakute H743 Wing](https://holybro.com/products/kakute-h743-wing) is a fully featured flight controller specifically aimed at fixed-wing and VTOL applications. It has the STM32 H743 Processor running at 480 MHz and CAN Bus support, along with dual camera support & switch, ON/OFF Pit Switch, 5V, 6V/8V, 9V/12 BEC, and plug-and-play GPS, CAN, I2C ports. + +:::info +This flight controller is [manufacturer supported](../flight_controller/autopilot_manufacturer_supported.md). +::: + +## Де купити + +Плату можна придбати в одному з наступних магазинів (наприклад): + +- [Holybro](https://holybro.com/products/kakute-h743-wing) + +## Конектори та контакти + +| Pin | Функція | PX4 default | +| ---------------- | --------------------------------- | ------------------------------------------------------------- | +| GPS 1 | USART1 and I2C1 | GPS1 | +| R2, T2 | USART2 RX and TX | GPS2 | +| R3, T3 | USART3 RX and TX | TELEM1 | +| R5, T5 | USART5 RX and TX | TELEM2 | +| R6, T6 | USART6 RX and TX | RC (PPM, SBUS, etc.) input | +| R7, T7, RTS, CTS | UART7 RX and TX with flow control | TELEM3 | +| R8, T8 | UART8 RX and TX | Консоль | +| Buz-, Buz+ | Piezo buzzer | | +| M1 to M14 | Motor signal outputs | | + + + +## Оновлення завантажувача PX4 + +The board comes pre-installed with [Betaflight](https://github.com/betaflight/betaflight/wiki). +Before the PX4 firmware can be installed, the _PX4 bootloader_ must be flashed. +Download the [holybro_kakuteh7-wing.hex](https://github.com/PX4/PX4-Autopilot/raw/main/docs/assets/flight_controller/kakuteh7-wing/holybro_kakuteh7-wing_bootloader.hex) bootloader binary and read [this page](../advanced_config/bootloader_update_from_betaflight.md) for flashing instructions. + +## Збірка прошивки + +To [build PX4](../dev_setup/building_px4.md) for this target: + +``` +make holybro_kakuteh7-wing_default +``` + +## Встановлення прошивки PX4 + +:::info +KakuteH7-wing is supported with PX4 master & PX4 v1.16 or newer.. +До випуску вам потрібно буде вручну зібрати та встановити прошивку. +::: + +Прошивку можна встановити вручну будь-якими звичайними способами: + +- Збудуйте та завантажте джерело: + + ``` + make holybro_kakuteh7-wing_default upload + ``` + +- [Load the firmware](../config/firmware.md) using _QGroundControl_. + Ви можете використовувати або готове вбудоване програмне забезпечення, або власне користувацьке програмне забезпечення. + +## Налаштування послідовного порту + +| UART | Пристрій | Порт | Default function | +| ------ | ---------- | --------------------------- | ---------------- | +| USART1 | /dev/ttyS0 | GPS 1 | GPS1 | +| USART2 | /dev/ttyS1 | R2, T2 | GPS2 | +| USART3 | /dev/ttyS2 | R3, T3 | TELEM1 | +| UART5 | /dev/ttyS3 | R5, T5 | TELEM2 | +| USART6 | /dev/ttyS4 | R6, (T6) | Вхід RC | +| UART7 | /dev/ttyS5 | R7, T7, RTS, CTS | TELEM3 | +| UART8 | /dev/ttyS6 | R8, T8 | Консоль | + +## Відладочний порт + +### Системна консоль + +UART8 RX and TX are configured for use as the [System Console](../debug/system_console.md). diff --git a/docs/uk/releases/main.md b/docs/uk/releases/main.md index cfb2aa4d2e..9003f6a93d 100644 --- a/docs/uk/releases/main.md +++ b/docs/uk/releases/main.md @@ -2,6 +2,17 @@ + + +
+
+

This page is on a release bramch, and hence probably out of date. See the latest version.

+
+
+ This contains changes to PX4 `main` branch since the last major release ([PX v1.15](../releases/1.15.md)). :::warning diff --git a/docs/uk/ros2/px4_ros2_interface_lib.md b/docs/uk/ros2/px4_ros2_interface_lib.md index 4cc8a14562..7459ef0e14 100644 --- a/docs/uk/ros2/px4_ros2_interface_lib.md +++ b/docs/uk/ros2/px4_ros2_interface_lib.md @@ -54,20 +54,4 @@ При відкритті запиту на PX4, CI запускає тест з інтеграції до бібліотеки. -Тести можуть також бути виконані локально з PX4: - -```sh -./test/ros_test_runner.py -``` - -І щоб керувати лише одним випадком: - -```sh -./test/ros_test_runner.py --verbose --case -``` - -Ви можете скласти список доступних тестових кейсів з: - -```sh -./test/ros_test_runner.py --list-cases -``` +For more information see [PX4 ROS2 Interface Library Integration Testing](../test_and_ci/integration_testing_px4_ros2_interface.md). \ No newline at end of file diff --git a/docs/uk/sim_gazebo_gz/index.md b/docs/uk/sim_gazebo_gz/index.md index e9d4e6a793..74cf4c66c4 100644 --- a/docs/uk/sim_gazebo_gz/index.md +++ b/docs/uk/sim_gazebo_gz/index.md @@ -131,6 +131,21 @@ The simulation can be run in headless mode by prefixing the command with the `HE HEADLESS=1 make px4_sitl gz_x500 ``` +### Встановлення власного місця зльоту + +The takeoff location in Gazebo Classic can be set using environment variables. + +The variables to set are: PX4_HOME_LAT, PX4_HOME_LON, and PX4_HOME_ALT. + +Наприклад: + +``` +export PX4_HOME_LAT=51.1788 +export PX4_HOME_LON=-1.8263 +export PX4_HOME_ALT=101 +make px4_sitl gz_x500 +``` + ### Вказання світу Симуляція може бути запущена в певному світі додаванням бажаного світу до імені бажаного рухомого засобу. diff --git a/docs/uk/sim_gazebo_gz/multi_vehicle_simulation.md b/docs/uk/sim_gazebo_gz/multi_vehicle_simulation.md index b2fd70114e..f675417698 100644 --- a/docs/uk/sim_gazebo_gz/multi_vehicle_simulation.md +++ b/docs/uk/sim_gazebo_gz/multi_vehicle_simulation.md @@ -35,23 +35,31 @@ ARGS ./build/px4_sitl_default/bin/px4 [-i ] [Multiple vehicles with ROS 2](../ros2/multi_vehicle.md) are possible. - First follow the installation instructions for [Gazebo](../sim_gazebo_gz/index.md). - - Then configure your system for [ROS 2 / PX4 operations](../ros2/user_guide.md#installation-setup). - - В різних терміналах вручну запустіть симуляцію декількох рухомих засобів. - Цей приклад відтворює 2 квадрокоптери X500 та літак з фіксованим крилом aFPX: + This example spawns 2 X500 Quadrotors and aFPX fixed-wing. - ```sh - PX4_SYS_AUTOSTART=4001 PX4_SIM_MODEL=gz_x500 ./build/px4_sitl_default/bin/px4 -i 1 - ``` +:::info +Note that in the first terminal you **do not** specify standalone mode. The first terminal will start the gz-server and the other two +instances will connect to it. +**Terminal 1** +::: - ```sh - PX4_SYS_AUTOSTART=4001 PX4_GZ_MODEL_POSE="0,1" PX4_SIM_MODEL=gz_x500 ./build/px4_sitl_default/bin/px4 -i 2 - ``` +```sh +PX4_SYS_AUTOSTART=4001 PX4_SIM_MODEL=gz_x500 ./build/px4_sitl_default/bin/px4 -i 1 +``` - ```sh - PX4_SYS_AUTOSTART=4003 PX4_GZ_MODEL_POSE="0,2" PX4_SIM_MODEL=gz_rc_cessna ./build/px4_sitl_default/bin/px4 -i 3 - ``` +**Terminal 2** + +```sh +PX4_GZ_STANDALONE=1 PX4_SYS_AUTOSTART=4001 PX4_GZ_MODEL_POSE="0,1" PX4_SIM_MODEL=gz_x500 ./build/px4_sitl_default/bin/px4 -i 2 +``` + +**Terminal 3** + +```sh +PX4_GZ_STANDALONE=1 PX4_SYS_AUTOSTART=4003 PX4_GZ_MODEL_POSE="0,2" PX4_SIM_MODEL=gz_rc_cessna ./build/px4_sitl_default/bin/px4 -i 3 +``` - Запустіть агента: diff --git a/docs/uk/simulation/index.md b/docs/uk/simulation/index.md index bf50457e44..e9a85d3c41 100644 --- a/docs/uk/simulation/index.md +++ b/docs/uk/simulation/index.md @@ -157,9 +157,8 @@ make px4_sitl none_iris Симуляцію можна додатково налаштувати за допомогою змінних середовища: -- `PX4_ESTIMATOR`: This variable configures which estimator to use. - Possible options are: `ekf2` (default), `lpe` (deprecated). - It can be set via `export PX4_ESTIMATOR=lpe` before running the simulation. +- Any of the [PX4 parameters](../advanced_config/parameter_reference.md) can be overridden via `export PX4_PARAM_{name}={value}`. + For example changing the estimator: `export PX4_PARAM_EKF2_EN=0; export PX4_PARAM_ATT_EN=1`. The syntax described here is simplified, and there are many other options that you can configure via _make_ - for example, to set that you wish to connect to an IDE or debugger. For more information see: [Building the Code > PX4 Make Build Targets](../dev_setup/building_px4.md#px4-make-build-targets). diff --git a/docs/uk/telemetry/jfi_telemetry.md b/docs/uk/telemetry/jfi_telemetry.md index a5f986e45a..f1a5b1951c 100644 --- a/docs/uk/telemetry/jfi_telemetry.md +++ b/docs/uk/telemetry/jfi_telemetry.md @@ -21,7 +21,7 @@ Operating in the 2.4GHz frequency band, it allows unrestricted global use withou - **Frequency Band:** 2.4GHz - **Speed:** Up to 11 Mbps (adjustable) - **Range:** Up to 500 meters (varies upon environments) -- **Payload Capacity:** Up to 1400 bytes +- **Payload Capacity:** Up to 1024 bytes ### Network Schemes @@ -124,7 +124,7 @@ However if you change the baud rate from 57600 you will need to create and use a - **Smart device:** Connect to Wi-Fi network named `J.Fi-xxxxxx` (x: alphanumeric characters) - **Browser:** Go to `192.168.4.1` to open the **configuration page**. - **Configuration page:** Adjust settings as needed, then click **Save** - - _LED 1_ blinks once upon saving + - _LED 2_ blinks once upon saving ![J.Fi Wireless Telemetry Broadcast Communication](../../assets/hardware/telemetry/jmarple/jfi_telemetry_config.jpg) diff --git a/docs/uk/test_and_ci/index.md b/docs/uk/test_and_ci/index.md index c312e7c02d..570eeedba5 100644 --- a/docs/uk/test_and_ci/index.md +++ b/docs/uk/test_and_ci/index.md @@ -8,7 +8,9 @@ PX4 широко протестовано за допомогою модульн - [Test Flights](../test_and_ci/test_flights.md) - How to make test flights (e.g. to [test PRs](../contribute/code.md#pull-requests)) - [Unit Tests](../test_and_ci/unit_tests.md) - [Continuous Integration (CI)](../test_and_ci/continous_integration.md) -- [ROS Integration Testing](../test_and_ci/integration_testing.md) -- [MAVSDK Integration Testing](../test_and_ci/integration_testing_mavsdk.md) +- [Integration Testing](../test_and_ci/integration_testing.md) + - [MAVSDK Integration Testing](../test_and_ci/integration_testing_mavsdk.md) + - [PX4 ROS2 Interface Library Integration Testing](../test_and_ci/integration_testing_px4_ros2_interface.md) + - [ROS 1 Integration Testing](../test_and_ci/integration_testing_ros1_mavros.md) (Deprecated) - [Docker](../test_and_ci/docker.md) - [Maintenance](../test_and_ci/maintenance.md) diff --git a/docs/uk/test_and_ci/integration_testing.md b/docs/uk/test_and_ci/integration_testing.md index e97acd338b..2cb01ca697 100644 --- a/docs/uk/test_and_ci/integration_testing.md +++ b/docs/uk/test_and_ci/integration_testing.md @@ -1,152 +1,13 @@ -# Тестування інтеграції з використанням ROS +# Integration Testing -У цій темі пояснюється, як запускати (і розширювати) інтеграційні тести PX4 на основі ROS. +Integration tests are used to verify how well larger parts of a system work together. +In PX4 this generally means testing whole features of a vehicle, usually running in simulation. +The tests are run in [Continuous Integration (CI)](../test_and_ci/continous_integration.md) on every pull request. -:::info -[MAVSDK Integration Testing](../test_and_ci/integration_testing_mavsdk.md) is preferred when writing new tests. -Use the ROS-based integration test framework for use cases that _require_ ROS (e.g. object avoidance). +- [MAVSDK Integration Testing](../test_and_ci/integration_testing_mavsdk.md) - MAVSDK-based test framework for PX4. + _This is the recommended framework for writing new Integration tests_ +- [PX4 ROS2 Interface Library Integration Testing](../test_and_ci/integration_testing_px4_ros2_interface.md) - Integration Tests for the [PX4 ROS 2 Interface Library](../ros2/px4_ros2_interface_lib.md). -All PX4 integraton tests are executed automatically by our [Continuous Integration](../test_and_ci/continous_integration.md) system. -::: +The following framework should only be used for tests that require ROS 1: -## Попередня підготовка: - -- [jMAVSim Simulator](../sim_jmavsim/index.md) -- [Gazebo Classic Simulator](../sim_gazebo_classic/index.md) -- [ROS and MAVROS](../simulation/ros_interface.md) - -## Виконати тести - -Щоб запустити тести MAVROS: - -```sh -source /devel/setup.bash -cd -make px4_sitl_default sitl_gazebo -make -``` - -`test_target` is a makefile targets from the set: _tests_mission_, _tests_mission_coverage_, _tests_offboard_ and _tests_avoidance_. - -Test can also be executed directly by running the test scripts, located under `test/`: - -```sh -source /devel/setup.bash -cd -make px4_sitl_default sitl_gazebo -./test/ -``` - -Наприклад: - -```sh -./test/rostest_px4_run.sh mavros_posix_tests_offboard_posctl.test -``` - -Тести також можна запускати за допомогою графічного інтерфейсу користувача, щоб побачити, що відбувається (за замовчуванням тести виконуються без голови): - -```sh -./test/rostest_px4_run.sh mavros_posix_tests_offboard_posctl.test gui:=true headless:=false -``` - -The **.test** files launch the corresponding Python tests defined in `integrationtests/python_src/px4_it/mavros/` - -## Напишіть новий MAVROS-тест (Python) - -Цей розділ пояснює, як написати новий python тест з використанням ROS 1/MAVROS, протестувати його та додати до набору тестів PX4. - -We recommend you review the existing tests as examples/inspiration ([integrationtests/python_src/px4_it/mavros/](https://github.com/PX4/PX4-Autopilot/tree/main/integrationtests/python_src/px4_it/mavros)). -The official ROS documentation also contains information on how to use [unittest](http://wiki.ros.org/unittest) (on which this test suite is based). - -Щоб написати новий тест: - -1. Створити новий тестовий скрипт, копіюючи порожній тестовий каркас нижче: - - ```python - #!/usr/bin/env python - # [... LICENSE ...] - - # - # @author Example Author - # - PKG = 'px4' - - import unittest - import rospy - import rosbag - - from sensor_msgs.msg import NavSatFix - - class MavrosNewTest(unittest.TestCase): - """ - Test description - """ - - def setUp(self): - rospy.init_node('test_node', anonymous=True) - rospy.wait_for_service('mavros/cmd/arming', 30) - - rospy.Subscriber("mavros/global_position/global", NavSatFix, self.global_position_callback) - self.rate = rospy.Rate(10) # 10hz - self.has_global_pos = False - - def tearDown(self): - pass - - # - # General callback functions used in tests - # - def global_position_callback(self, data): - self.has_global_pos = True - - def test_method(self): - """Test method description""" - - # FIXME: hack to wait for simulation to be ready - while not self.has_global_pos: - self.rate.sleep() - - # TODO: execute test - - if __name__ == '__main__': - import rostest - rostest.rosrun(PKG, 'mavros_new_test', MavrosNewTest) - ``` - -2. Запустити лише новий тест - - - Запустити симулятор - - ```sh - cd - source Tools/simulation/gazebo/setup_gazebo.bash - roslaunch launch/mavros_posix_sitl.launch - ``` - - - Запустити тест (в новій оболонці): - - ```sh - cd - source Tools/simulation/gazebo/setup_gazebo.bash - rosrun px4 mavros_new_test.py - ``` - -3. Додати новий тестовий вузол до файлу запуску - - - In `test/` create a new `.test` ROS launch file. - - Call the test file using one of the base scripts _rostest_px4_run.sh_ or _rostest_avoidance_run.sh_ - -4. (Необов'язково) Створити нову ціль в Makefile - - - Відкрийте Makefile - - Search the _Testing_ section - - Додати нову назву цілі та викликати тест - - Наприклад: - - ```sh - tests_: rostest - @"$(SRC_DIR)"/test/rostest_px4_run.sh mavros_posix_tests_.test - ``` - -Запустити тести, як описані вище. +- [ROS 1 Integration Testing](../test_and_ci/integration_testing_ros1_mavros.md) (Deprecated) diff --git a/docs/uk/test_and_ci/integration_testing_mavsdk.md b/docs/uk/test_and_ci/integration_testing_mavsdk.md index 7369bf704d..82b72e02e6 100644 --- a/docs/uk/test_and_ci/integration_testing_mavsdk.md +++ b/docs/uk/test_and_ci/integration_testing_mavsdk.md @@ -7,6 +7,10 @@ PX4 can be tested end to end to using integration tests based on [MAVSDK](https: Інструкції нижче пояснюють, як налаштувати та запустити тести локально. +:::note +This is the recommended integration test framework for PX4. +::: + ## Вимоги ### Налаштування середовища розробника @@ -47,21 +51,21 @@ To run all SITL tests as defined in [sitl.json](https://github.com/PX4/PX4-Autop test/mavsdk_tests/mavsdk_test_runner.py test/mavsdk_tests/configs/sitl.json --speed-factor 10 ``` -Буде перелічено всі тести, а потім запущено їх послідовно. +This will list all the tests and then run them sequentially. To see all possible command line arguments use the `-h` argument: ```sh test/mavsdk_tests/mavsdk_test_runner.py -h -usage: mavsdk_test_runner.py [-h] [--log-dir LOG_DIR] [--speed-factor SPEED_FACTOR] [--iterations ITERATIONS] [--abort-early] [--gui] [--model MODEL] - [--case CASE] [--debugger DEBUGGER] [--verbose] - config_file +usage: mavsdk_test_runner.py [-h] [--log-dir LOG_DIR] [--speed-factor SPEED_FACTOR] [--iterations ITERATIONS] [--abort-early] + [--gui] [--model MODEL] [--case CASE] [--debugger DEBUGGER] [--upload] [--force-color] + [--verbose] [--build-dir BUILD_DIR] positional arguments: config_file JSON config file to use -optional arguments: +options: -h, --help show this help message and exit --log-dir LOG_DIR Directory for log files --speed-factor SPEED_FACTOR @@ -71,9 +75,13 @@ optional arguments: --abort-early abort on first unsuccessful test --gui display the visualization for a simulation --model MODEL only run tests for one model - --case CASE only run tests for one case + --case CASE only run tests for one case (or multiple cases with wildcard '*') --debugger DEBUGGER choice from valgrind, callgrind, gdb, lldb + --upload Upload logs to logs.px4.io + --force-color Force colorized output --verbose enable more verbose output + --build-dir BUILD_DIR + relative path where the built files are stored ``` ## Запуск одного тесту diff --git a/docs/uk/test_and_ci/integration_testing_px4_ros2_interface.md b/docs/uk/test_and_ci/integration_testing_px4_ros2_interface.md new file mode 100644 index 0000000000..deafaa3fce --- /dev/null +++ b/docs/uk/test_and_ci/integration_testing_px4_ros2_interface.md @@ -0,0 +1,29 @@ +# Integration Testing for the PX4 ROS 2 Interface Library + +This topic outlines the integration tests for the [PX4 ROS 2 Interface Library](../ros2/px4_ros2_interface_lib.md). + + + +## CI Testing + +При відкритті запиту на PX4, CI запускає тест з інтеграції до бібліотеки. + +## Running Tests Locally + +Тести можуть також бути виконані локально з PX4: + +```sh +./test/ros_test_runner.py +``` + +І щоб керувати лише одним випадком: + +```sh +./test/ros_test_runner.py --verbose --case +``` + +Ви можете скласти список доступних тестових кейсів з: + +```sh +./test/ros_test_runner.py --list-cases +``` \ No newline at end of file diff --git a/docs/uk/test_and_ci/integration_testing_ros1_mavros.md b/docs/uk/test_and_ci/integration_testing_ros1_mavros.md new file mode 100644 index 0000000000..449b85a6b9 --- /dev/null +++ b/docs/uk/test_and_ci/integration_testing_ros1_mavros.md @@ -0,0 +1,155 @@ +# Integration Testing using ROS 1 + +This topic explains how to run (and extend) PX4's ROS (1) and MAVROS -based integration tests. + +:::warning +This test framework is deprecated. +It should be used only for new test cases that _require_ ROS 1. + +[MAVSDK Integration Testing](../test_and_ci/integration_testing_mavsdk.md) is preferred when writing new tests. +::: + +:::note +All PX4 integration tests are executed automatically by our [Continuous Integration](../test_and_ci/continous_integration.md) system. +::: + +## Вимоги + +- [Gazebo Classic Simulator](../sim_gazebo_classic/index.md) +- [ROS and MAVROS](../simulation/ros_interface.md) + +## Execute Tests + +To run the MAVROS tests: + +```sh +source /devel/setup.bash +cd +make px4_sitl_default sitl_gazebo +make +``` + +`test_target` is a makefile targets from the set: _tests_mission_, _tests_mission_coverage_, _tests_offboard_ and _tests_avoidance_. + +Test can also be executed directly by running the test scripts, located under `test/`: + +```sh +source /devel/setup.bash +cd +make px4_sitl_default sitl_gazebo +./test/ +``` + +Наприклад: + +```sh +./test/rostest_px4_run.sh mavros_posix_tests_offboard_posctl.test +``` + +Tests can also be run with a GUI to see what's happening (by default the tests run "headless"): + +```sh +./test/rostest_px4_run.sh mavros_posix_tests_offboard_posctl.test gui:=true headless:=false +``` + +The **.test** files launch the corresponding Python tests defined in `integrationtests/python_src/px4_it/mavros/` + +## Write a New MAVROS Test (Python) + +This section explains how to write a new python test using ROS 1/MAVROS, test it, and add it to the PX4 test suite. + +We recommend you review the existing tests as examples/inspiration ([integrationtests/python_src/px4_it/mavros/](https://github.com/PX4/PX4-Autopilot/tree/main/integrationtests/python_src/px4_it/mavros)). +The official ROS documentation also contains information on how to use [unittest](http://wiki.ros.org/unittest) (on which this test suite is based). + +To write a new test: + +1. Create a new test script by copying the empty test skeleton below: + + ```python + #!/usr/bin/env python + # [... LICENSE ...] + + # + # @author Example Author + # + PKG = 'px4' + + import unittest + import rospy + import rosbag + + from sensor_msgs.msg import NavSatFix + + class MavrosNewTest(unittest.TestCase): + """ + Test description + """ + + def setUp(self): + rospy.init_node('test_node', anonymous=True) + rospy.wait_for_service('mavros/cmd/arming', 30) + + rospy.Subscriber("mavros/global_position/global", NavSatFix, self.global_position_callback) + self.rate = rospy.Rate(10) # 10hz + self.has_global_pos = False + + def tearDown(self): + pass + + # + # General callback functions used in tests + # + def global_position_callback(self, data): + self.has_global_pos = True + + def test_method(self): + """Test method description""" + + # FIXME: hack to wait for simulation to be ready + while not self.has_global_pos: + self.rate.sleep() + + # TODO: execute test + + if __name__ == '__main__': + import rostest + rostest.rosrun(PKG, 'mavros_new_test', MavrosNewTest) + ``` + +2. Run the new test only + + - Start the simulator: + + ```sh + cd + source Tools/simulation/gazebo/setup_gazebo.bash + roslaunch launch/mavros_posix_sitl.launch + ``` + + - Run test (in a new shell): + + ```sh + cd + source Tools/simulation/gazebo/setup_gazebo.bash + rosrun px4 mavros_new_test.py + ``` + +3. Add new test node to a launch file + + - In `test/` create a new `.test` ROS launch file. + - Call the test file using one of the base scripts _rostest_px4_run.sh_ or _rostest_avoidance_run.sh_ + +4. (Optional) Create a new target in the Makefile + + - Open the Makefile + - Search the _Testing_ section + - Add a new target name and call the test + + Наприклад: + + ```sh + tests_: rostest + @"$(SRC_DIR)"/test/rostest_px4_run.sh mavros_posix_tests_.test + ``` + +Run the tests as described above. \ No newline at end of file