mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 06:53:35 +08:00
Move PX4 Guide source into /docs (#24490)
* Add vitepress tree * Update existing workflows so they dont trigger on changes in the docs path * Add nojekyll, package.json, LICENCE etc * Add crowdin docs upload/download scripts * Add docs flaw checker workflows * Used docs prefix for docs workflows * Crowdin obvious fixes * ci: docs move to self hosted runner runs on a beefy server for faster builds Signed-off-by: Ramon Roche <mrpollo@gmail.com> * ci: don't run build action for docs or ci changes Signed-off-by: Ramon Roche <mrpollo@gmail.com> * ci: update runners Signed-off-by: Ramon Roche <mrpollo@gmail.com> * Add docs/en * Add docs assets and scripts * Fix up editlinks to point to PX4 sources * Download just the translations that are supported * Add translation sources for zh, uk, ko * Update latest tranlsation and uorb graphs * update vitepress to latest --------- Signed-off-by: Ramon Roche <mrpollo@gmail.com> Co-authored-by: Ramon Roche <mrpollo@gmail.com>
This commit is contained in:
co-authored by
Ramon Roche
parent
8e6d2ebe4a
commit
88d623bedb
@@ -0,0 +1,21 @@
|
||||
# Симулятори, що підтримуються спільнотою
|
||||
|
||||
Цей розділ містить інформацію про симуляції, що _підтримуються спільнотою_.
|
||||
|
||||
:::warning
|
||||
These simulators are not maintained, tested, or supported, by the core development team.
|
||||
Вони можуть працювати або не працювати з поточними версіями PX4.
|
||||
|
||||
Дивіться [Встановлення інструментарію](../dev_setup/dev_env.md) для інформації про середовища та інструменти, що підтримуються основною командою розробників.
|
||||
:::
|
||||
|
||||
Інструменти мають різний рівень підтримки своїми спільнотами (деякі добре підтримують, інші - ні).
|
||||
Питання про ці інструменти повинні порушуватися на [форумах для обговорення](../contribute/support.md#forums-and-chat)
|
||||
|
||||
| Симулятор | Опис |
|
||||
| ----------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [FlightGear](../sim_flightgear/README.md) | <p>Симулятор який надає фізично та візуально реалістичні симуляції. Зокрема він може моделювати багато погодних умов, включаючи грози, сніг, дощ та град, а також може симулювати температурні режими та різні типи атмосферних течій. [Симуляція кількох засобів](../sim_flightgear/multi_vehicle.md) також підтримується.</p> <p><strong>Рухомі засоби, що підтримуються:</strong> Літак, Автожир, Ровер</p> |
|
||||
| [JMAVSim](../sim_jmavsim/index.md) | <p>A simple multirotor/quad simulator. This was previously part of the PX4 development toolchain but was removed in favour of [Gazebo](../sim_gazebo_gz/index.md).</p> <p><strong>Supported Vehicles:</strong> Quad</p> |
|
||||
| [JSBSim](../sim_jsbsim/README.md) | <p>Симулятор, який надає моделі просунутої динаміки польоту. Він може використовуватися для моделювання реалістичної динаміки польоту, заснованої на даних з аеродинамічної труби.</p> <p><strong>Рухомі засоби, що підтримуються:</strong> Літак, Квадрокоптер, Гексакоптер</p> |
|
||||
| [AirSim](../sim_airsim/README.md) | <p>Міжплатформовий симулятор який надає фізично та візуально реалістичні симуляції. Цей симулятор ресурсомісткий та потребує значно потужніший комп'ютер ніж інші описані тут симулятори.</p><p><strong>Рухомі засоби, що підтримуються:</strong> Iris (модель мультиротора та налаштування для PX4 квадрокоптера в конфігурації "X").</p> |
|
||||
| [Simulation-In-Hardware](../sim_sih/README.md) (SIH) | <p>Альтернатива симуляції HITL, яка пропонує важку симуляцію в реальному часі безпосередньо на обладнанні автопілота. Цей симулятор реалізований на C++ у вигляді модуля PX4 безпосередньо в [коді](https://github.com/PX4/PX4-Autopilot/tree/main/src/modules/simulator_sih) прошивки. </p><p><strong>Supported Vehicles:</strong> Plane, Quad, Tailsitter, Standard VTOL</p> |
|
||||
@@ -0,0 +1,70 @@
|
||||
# Симуляція запобігання відмовам
|
||||
|
||||
[Failsafes](../config/safety.md) define the safe limits/conditions under which you can safely use PX4, and the action that will be performed if a failsafe is triggered (for example, landing, holding position, or returning to a specified point).
|
||||
|
||||
У SITL деякі запобіжники відмов за замовчуванням вимкнені, щоб забезпечити простіше використання симуляції.
|
||||
Ця тема пояснює, як ви можете перевірити критично важливу для безпеки поведінку в симуляції SITL перед тим, як спробувати її в реальному світі.
|
||||
|
||||
:::info
|
||||
You can also test failsafes using [HITL simulation](../simulation/hitl.md).
|
||||
HITL використовує нормальні параметри налаштувань вашого контролера польоту.
|
||||
:::
|
||||
|
||||
## Втрата каналу зв'язку
|
||||
|
||||
The _Data Link Loss_ failsafe (unavailability of external data via MAVLink) is enabled by default.
|
||||
Це робить симуляцію придатною до використання тільки з під'єднаним GCS, SDK або іншим додатком MAVLink.
|
||||
|
||||
Set the parameter [NAV_DLL_ACT](../advanced_config/parameter_reference.md#NAV_DLL_ACT) to the desired failsafe action to change the behavior.
|
||||
For example, set to `0` to disable it.
|
||||
|
||||
:::info
|
||||
All parameters in SITL including this one get reset when you do `make clean`.
|
||||
:::
|
||||
|
||||
## Втрата каналу радіо керування
|
||||
|
||||
The _RC Link Loss_ failsafe (unavailability of data from a remote control) is enabled by default.
|
||||
Це робить симуляцію придатною до використання тільки з активним з'єднанням MAVLink або дистанційного керування.
|
||||
|
||||
Set the parameter [NAV_RCL_ACT](../advanced_config/parameter_reference.md#NAV_RCL_ACT) to the desired failsafe action to change the behavior.
|
||||
For example, set to `0` to disable it.
|
||||
|
||||
:::info
|
||||
All parameters in SITL including this one get reset when you do `make clean`.
|
||||
:::
|
||||
|
||||
## Низький заряд батареї
|
||||
|
||||
Батарею, що моделюється реалізовано таким чином щоб енергія ніколи не закінчувалась та за замовчуванням вона виснажується тільки до 50% її заряду, а отже і напруги, що доповідається.
|
||||
Це дозволяє тестувати індикацію батареї в GCS Ui без спрацювання реакцій на низький заряд, що може перервати інші тести.
|
||||
|
||||
To change this minimal battery percentage value use the parameter [SIM_BAT_MIN_PCT](../advanced_config/parameter_reference.md#SIM_BAT_MIN_PCT).
|
||||
|
||||
To control how fast the battery depletes to the minimal value use the parameter [SIM_BAT_DRAIN](../advanced_config/parameter_reference.md#SIM_BAT_DRAIN).
|
||||
|
||||
:::tip
|
||||
By changing [SIM_BAT_MIN_PCT](../advanced_config/parameter_reference.md#SIM_BAT_MIN_PCT) in flight, you can also test regaining capacity to simulate inaccurate battery state estimation or in-air charging technology.
|
||||
:::
|
||||
|
||||
It is also possible to disable the simulated battery using [SIM_BAT_ENABLE](../advanced_config/parameter_reference.md#SIM_BAT_ENABLE) in order to, for example, provide an external battery simulation via MAVLink.
|
||||
|
||||
## Помилка датчику/системи
|
||||
|
||||
[Failure injection](../debug/failure_injection.md) can be used to simulate different types of failures in many sensors and systems.
|
||||
Наприклад, це може бути використано для імітації відсутнього або переривчастого сигналу GPS, сигналу РК який перервався або застиг на певному значенні, збої в системі уникнення, і багато іншого.
|
||||
|
||||
Наприклад, для імітації відмови сигналу GPS:
|
||||
|
||||
1. Enable the parameter [SYS_FAILURE_EN](../advanced_config/parameter_reference.md#SYS_FAILURE_EN).
|
||||
2. Enter the following commands on the SITL instance _pxh shell_:
|
||||
|
||||
```sh
|
||||
# Turn (all) GPS off
|
||||
failure gps off
|
||||
|
||||
# Turn (all) GPS on
|
||||
failure gps ok
|
||||
```
|
||||
|
||||
See [System Failure Injection](../debug/failure_injection.md) for a list of supported target sensors and failure modes.
|
||||
@@ -0,0 +1,172 @@
|
||||
# Симуляція з апаратним забезпеченням в контурі (HITL)
|
||||
|
||||
:::warning
|
||||
HITL is [community supported and maintained](../simulation/community_supported_simulators.md).
|
||||
Це може працювати або не працювати з поточними версіями PX4.
|
||||
|
||||
Дивіться [Встановлення інструментарію](../dev_setup/dev_env.md) для інформації про середовища та інструменти, що підтримуються основною командою розробників.
|
||||
:::
|
||||
|
||||
Апаратне забезпечення в контурі (HITL або HIL) режим симуляції в якому звичайна прошивка PX4 виконується на реальному пристрої польотного контролера.
|
||||
Цей підхід має перевагу у вигляді можливості тестування більшості коду для польоту на реальному апаратному забезпеченні.
|
||||
|
||||
PX4 supports HITL for multicopters (using [jMAVSim](../sim_jmavsim/index.md) or [Gazebo Classic](../sim_gazebo_classic/index.md)) and VTOL (using Gazebo Classic).
|
||||
|
||||
<a id="compatible_airframe"></a>
|
||||
|
||||
## Планери сумісні з HITL
|
||||
|
||||
The set of compatible airframes vs simulators is:
|
||||
|
||||
| Планер | `SYS_AUTOSTART` | Gazebo Classic | jMAVSim |
|
||||
| ---------------------------------------------------------------------------------------------------------------- | --------------- | -------------- | ------- |
|
||||
| [HIL Quadcopter X](../airframes/airframe_reference.md#copter_simulation_hil_quadcopter_x) | 1001 | Y | Y |
|
||||
| [HIL Standard VTOL QuadPlane](../airframes/airframe_reference.md#vtol_standard_vtol_hil_standard_vtol_quadplane) | 1002 | Y | |
|
||||
| [Generic Quadrotor x](../airframes/airframe_reference.md#copter_quadrotor_x_generic_quadcopter) copter | 4001 | Y | Y |
|
||||
|
||||
<a id="simulation_environment"></a>
|
||||
|
||||
## Середовище симуляції HITL
|
||||
|
||||
У симуляції з апаратним забезпеченням у контурі (HITL) звичайна прошивка PX4 виконується на реальному обладнані.
|
||||
JMAVSim або Gazebo Classic (які працюють на комп'ютері розробки) підключені до пристрою польотного контролера через USB/UART.
|
||||
The simulator acts as gateway to share MAVLink data between PX4 and _QGroundControl_.
|
||||
|
||||
:::info
|
||||
The simulator can also be connected via UDP if the flight controller has networking support and uses a stable, low-latency connection (e.g. a wired Ethernet connection - WiFi is usually not sufficiently reliable).
|
||||
For example, this configuration has been tested with PX4 running on a Raspberry Pi connected via Ethernet to the computer (a startup configuration that includes the command for running jMAVSim can be found [here](https://github.com/PX4/PX4-Autopilot/blob/main/posix-configs/rpi/px4_hil.config)).
|
||||
:::
|
||||
|
||||
Діаграма нижче показує середовище симуляції:
|
||||
|
||||
- A HITL configuration is selected (via _QGroundControl_) that doesn't start any real sensors.
|
||||
- _jMAVSim_ or _Gazebo Classic_ are connected to the flight controller via USB.
|
||||
- The simulator is connected to _QGroundControl_ via UDP and bridges its MAVLink messages to PX4.
|
||||
- _Gazebo Classic_ and _jMAVSim_ can also connect to an offboard API and bridge MAVLink messages to PX4.
|
||||
- (Optional) A serial connection can be used to connect Joystick/Gamepad hardware via _QGroundControl_.
|
||||
|
||||

|
||||
|
||||
## HITL у порівнянні з SITL
|
||||
|
||||
SITL працює на комп'ютері розробки в модельованому середовищі та використовує прошивку спеціально створену для цього середовища.
|
||||
Крім драйверів симуляції для забезпечення підроблених даних середовища від симулятора система поводиться як зазвичай.
|
||||
|
||||
На противагу, HITL виконує звичайну прошивку PX4 в "режимі HITL" на звичайному обладнані.
|
||||
Дані симуляції потрапляють в систему в іншій точці ніж для SITL.
|
||||
Основні модулі на кшталт командного або датчиків мають режими HITL, що оминають частину звичайної функціональності при старті.
|
||||
|
||||
Підсумовуючи, HITL виконує PX4 на реальному обладнанні за допомогою стандартної прошивки, а SITL фактично більше виконує стандартний системний код.
|
||||
|
||||
## Налаштування HITL
|
||||
|
||||
### Конфігурація PX4
|
||||
|
||||
1. Connect the autopilot directly to _QGroundControl_ via USB.
|
||||
|
||||
2. Увімкніть режим HITL
|
||||
|
||||
1. Open **Setup > Safety** section.
|
||||
2. Enable HITL mode by selecting **Enabled** from the _HITL Enabled_ list:
|
||||
|
||||

|
||||
|
||||
3. Вибір планера
|
||||
|
||||
1. Open **Setup > Airframes**
|
||||
2. Select a [compatible airframe](#compatible_airframe) you want to test.
|
||||
Then click **Apply and Restart** on top-right of the _Airframe Setup_ page.
|
||||
|
||||

|
||||
|
||||
4. При необхідності відкалібруйте пульт РК або джойстик.
|
||||
|
||||
5. Налаштування UDP
|
||||
|
||||
1. Under the _General_ tab of the settings menu, uncheck all _AutoConnect_ boxes except for **UDP**.
|
||||
|
||||

|
||||
|
||||
6. (Необов'язково) Налаштуйте джойстик та запобіжник відмови.
|
||||
Set the following [parameters](../advanced_config/parameters.md) in order to use a joystick instead of an RC remote control transmitter:
|
||||
|
||||
- [COM_RC_IN_MODE](../advanced_config/parameter_reference.md#COM_RC_IN_MODE) to "Joystick/No RC Checks". Це дозволить керування джойстиком та відключить перевірки пульту РК.
|
||||
- [NAV_RCL_ACT](../advanced_config/parameter_reference.md#NAV_RCL_ACT) to "Disabled". Це гарантує, що ніякі дії запобігання відмові не будуть перешкоджати коли не виконується HITL з радіо керуванням.
|
||||
|
||||
:::tip
|
||||
The _QGroundControl User Guide_ also has instructions on [Joystick](https://docs.qgroundcontrol.com/master/en/qgc-user-guide/setup_view/joystick.html) and [Virtual Joystick](https://docs.qgroundcontrol.com/master/en/qgc-user-guide/settings_view/virtual_joystick.html) setup.
|
||||
|
||||
:::
|
||||
|
||||
Once configuration is complete, **close** _QGroundControl_ and disconnect the flight controller hardware from the computer.
|
||||
|
||||
### Налаштування відповідних симуляторів
|
||||
|
||||
Дотримуйтесь відповідних кроків для певного симулятора в наступних розділах.
|
||||
|
||||
#### Gazebo Classic
|
||||
|
||||
:::info
|
||||
Make sure _QGroundControl_ is not running!
|
||||
:::
|
||||
|
||||
1. Build PX4 with [Gazebo Classic](../sim_gazebo_classic/index.md) (in order to build the Gazebo Classic plugins).
|
||||
|
||||
```sh
|
||||
cd <Firmware_clone>
|
||||
DONT_RUN=1 make px4_sitl_default gazebo-classic
|
||||
```
|
||||
|
||||
2. Open the vehicle model's sdf file (e.g. **Tools/simulation/gazebo-classic/sitl_gazebo-classic/models/iris_hitl/iris_hitl.sdf**).
|
||||
|
||||
3. Replace the `serialDevice` parameter (`/dev/ttyACM0`) if necessary.
|
||||
|
||||
::: info
|
||||
The serial device depends on what port is used to connect the vehicle to the computer (this is usually `/dev/ttyACM0`).
|
||||
An easy way to check on Ubuntu is to plug in the autopilot, open up a terminal, and type `dmesg | grep "tty"`.
|
||||
Останній показаний пристрій і буде тим що потрібно.
|
||||
|
||||
:::
|
||||
|
||||
4. Налаштуйте змінні середовища:
|
||||
|
||||
```sh
|
||||
source Tools/simulation/gazebo-classic/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
|
||||
```
|
||||
|
||||
та запустіть Gazebo Classic в режимі HITL:
|
||||
|
||||
```sh
|
||||
gazebo Tools/simulation/gazebo-classic/sitl_gazebo-classic/worlds/hitl_iris.world
|
||||
```
|
||||
|
||||
5. Start _QGroundControl_.
|
||||
Воно повинно автоматично підключитися до PX4 та Gazebo Classic.
|
||||
|
||||
#### jMAVSim (тільки квадрокоптер)
|
||||
|
||||
:::info
|
||||
Make sure _QGroundControl_ is not running!
|
||||
:::
|
||||
|
||||
1. Під'єднайте політний контролер до комп'ютера та дочекайтесь коли він завантажиться.
|
||||
|
||||
2. Запустіть jMAVSim в режимі HITL:
|
||||
|
||||
```sh
|
||||
./Tools/simulation/jmavsim/jmavsim_run.sh -q -s -d /dev/ttyACM0 -b 921600 -r 250
|
||||
```
|
||||
|
||||
::: info
|
||||
Replace the serial port name `/dev/ttyACM0` as appropriate.
|
||||
On macOS this port would be `/dev/tty.usbmodem1`.
|
||||
На Windows (включно з Cygwin) це буде COM1 або інший порт - перевірте з'єднання в менеджері пристроїв Windows.
|
||||
|
||||
:::
|
||||
|
||||
3. Start _QGroundControl_.
|
||||
Воно повинно автоматично підключитися до PX4 та jMAVSim.
|
||||
|
||||
## Політ за автономним завданням у HITL
|
||||
|
||||
You should be able to use _QGroundControl_ to [run missions](https://docs.qgroundcontrol.com/master/en/qgc-user-guide/fly_view/fly_view.html#missions) and otherwise control the vehicle.
|
||||
@@ -0,0 +1,342 @@
|
||||
# Симуляція
|
||||
|
||||
Симулятори дозволяють польотному коду PX4 керувати комп'ютерно змодельованим апаратом у змодельованому "світі".
|
||||
You can interact with this vehicle just as you might with a real vehicle, using _QGroundControl_, an offboard API, or a radio controller/gamepad.
|
||||
|
||||
:::tip
|
||||
Simulation is a quick, easy, and most importantly, _safe_ way to test changes to PX4 code before attempting to fly in the real world.
|
||||
Це також хороший спосіб почати літати з PX4, якщо у вас ще немає апарату для експериментів.
|
||||
:::
|
||||
|
||||
PX4 supports both _Software In the Loop (SITL)_ simulation, where the flight stack runs on computer (either the same computer or another computer on the same network) and _Hardware In the Loop (HITL)_ simulation using a simulation firmware on a real flight controller board.
|
||||
|
||||
Інформація про доступні тренажери та способи їх налаштування наведена в наступному розділі.
|
||||
The other sections provide general information about how the simulator works, and are not required to _use_ the simulators.
|
||||
|
||||
## Підтримувані симулятори
|
||||
|
||||
Наступні симулятори підтримуються основною командою розробників PX4.
|
||||
|
||||
| Симулятор | Опис |
|
||||
| ------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [Gazebo](../sim_gazebo_gz/index.md) | Gazebo supersedes [Gazebo Classic](../sim_gazebo_classic/index.md), featuring more advanced rendering, physics and sensor models. It is the only version of Gazebo available from Ubuntu Linux 22.04<br><br>A powerful 3D simulation environment that is particularly suitable for testing object-avoidance and computer vision. Він також може бути використаний для [multi-vehicle simulation](../simulation/multi-vehicle-simulation.md) і зазвичай використовується з [ROS](../simulation/ros_interface.md), набором інструментів для автоматизації керування апаратами. <br><br><strong>Supported Vehicles:</strong> Quad, VTOL (Standard, Tailsitter, Tiltroter), Plane, Rovers |
|
||||
| [Gazebo Classic](../sim_gazebo_classic/index.md) | A powerful 3D simulation environment that is particularly suitable for testing object-avoidance and computer vision. It can also be used for [multi-vehicle simulation](../simulation/multi-vehicle-simulation.md) and is commonly used with [ROS](../simulation/ros_interface.md), a collection of tools for automating vehicle control.<br><br>**Supported Vehicles:** Quad ([Iris](../airframes/airframe_reference.md#copter_quadrotor_x_generic_quadcopter)), Hex (Typhoon H480), [Generic Standard VTOL (QuadPlane)](../airframes/airframe_reference.md#vtol_standard_vtol_generic_standard_vtol), Tailsitter, Plane, Rover, Submarine |
|
||||
|
||||
There are also a number of [Community Supported Simulators](../simulation/community_supported_simulators.md).
|
||||
|
||||
---
|
||||
|
||||
Решта цієї теми - це "дещо загальний" опис того, як працює інфраструктура симуляції.
|
||||
It is not required to _use_ the simulators.
|
||||
|
||||
## Симулятор MAVLink API
|
||||
|
||||
Всі симулятори, крім Gazebo, взаємодіють з PX4 за допомогою API симулятора MAVLink.
|
||||
Цей API визначає набір повідомлень MAVLink, які передають дані датчиків з модельованого світу в PX4 і повертають значення двигуна і приводу з польотного коду, які будуть застосовані до модельованого апарату.
|
||||
На зображенні нижче показано потік повідомлень.
|
||||
|
||||

|
||||
|
||||
:::info
|
||||
A SITL build of PX4 uses [SimulatorMavlink.cpp](https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/simulation/simulator_mavlink/SimulatorMavlink.cpp) to handle these messages while a hardware build in HIL mode uses [mavlink_receiver.cpp](https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/mavlink/mavlink_receiver.cpp).
|
||||
Дані датчиків з симулятора записуються в теми PX4 uORB.
|
||||
Всі двигуни/приводи заблоковані, але внутрішнє програмне забезпечення повністю функціонує.
|
||||
:::
|
||||
|
||||
Повідомлення описані нижче (див. посилання для більш детальної інформації).
|
||||
|
||||
| Повідомлення | Напрямок | Опис |
|
||||
| -------------------------------------------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [MAV\_MODE:MAV\_MODE\_FLAG\_HIL\_ENABLED][mav_mode_flag_hil_enabled] | NA | Прапорець режиму при використанні симуляції. Всі двигуни/приводи заблоковані, але внутрішнє програмне забезпечення повністю функціонує. |
|
||||
| [HIL\_ACTUATOR\_CONTROLS][hil_actuator_controls] | PX4 -> Sim | Виходи керування PX4 (до двигунів, приводів). |
|
||||
| [HIL\_SENSOR][hil_sensor] | Sim -> PX4 | Імітація показань IMU в одиницях СІ в рамі корпусу NED. |
|
||||
| [HIL\_GPS][hil_gps] | Sim -> PX4 | Симульоване значення датчика GPS RAW. |
|
||||
| [HIL\_OPTICAL\_FLOW][hil_optical_flow] | Sim -> PX4 | Імітація оптичного потоку від датчика потоку (наприклад, PX4FLOW або датчика оптичної миші) |
|
||||
| [HIL\_STATE\_QUATERNION][hil_state_quaternion] | Sim -> PX4 | Містить фактичне "змодельоване" положення апарату, орієнтацію, швидкість і т.д. Це може бути записано в журнал і співставлено з оцінками PX4 для аналізу і діагностики (наприклад, перевірка того, наскільки добре оцінювач працює для зашумлених (імітованих) вхідних сигналів датчика). |
|
||||
| [HIL\_RC\_INPUTS\_RAW][hil_rc_inputs_raw] | Sim -> PX4 | Отримані RAW-значення каналів РК. |
|
||||
|
||||
<!-- links for table above -->
|
||||
|
||||
[mav_mode_flag_hil_enabled]: https://mavlink.io/en/messages/common.html#MAV_MODE_FLAG_HIL_ENABLED
|
||||
[hil_actuator_controls]: https://mavlink.io/en/messages/common.html#HIL_ACTUATOR_CONTROLS
|
||||
[hil_sensor]: https://mavlink.io/en/messages/common.html#HIL_SENSOR
|
||||
[hil_gps]: https://mavlink.io/en/messages/common.html#HIL_GPS
|
||||
[hil_optical_flow]: https://mavlink.io/en/messages/common.html#HIL_OPTICAL_FLOW
|
||||
[hil_state_quaternion]: https://mavlink.io/en/messages/common.html#HIL_STATE_QUATERNION
|
||||
[hil_rc_inputs_raw]: https://mavlink.io/en/messages/common.html#HIL_RC_INPUTS_RAW
|
||||
|
||||
<!-- above ^^^ links for table -->
|
||||
|
||||
PX4 directly uses the [Gazebo API](https://gazebosim.org/docs) to interface with [Gazebo](../sim_gazebo_gz/index.md) and MAVlink is not required.
|
||||
|
||||
## Порти UDP PX4 MAVLink за замовчуванням
|
||||
|
||||
By default, PX4 uses commonly established UDP ports for MAVLink communication with ground control stations (e.g. _QGroundControl_), Offboard APIs (e.g. MAVSDK, MAVROS) and simulator APIs (e.g. Gazebo).
|
||||
Ці порти:
|
||||
|
||||
- PX4's remote UDP Port **14550** is used for communication with ground control stations.
|
||||
Очікується, що GCS прослуховуватиме з'єднання на цьому порту.
|
||||
_QGroundControl_ listens to this port by default.
|
||||
- PX4's remote UDP Port **14540** is used for communication with offboard APIs.
|
||||
Очікується, що зовнішні API будуть чекати на з'єднання через цей порт.
|
||||
::: info
|
||||
Multi-vehicle simulations use a separate remote port for each instance, allocated sequentially from `14540` to `14549`
|
||||
(additional instances all use port `14549`).
|
||||
|
||||
:::
|
||||
- The simulator's local TCP Port, **4560**, is used for communication with PX4.
|
||||
Симулятор слухає цей порт, і PX4 ініціює TCP-з'єднання з ним.
|
||||
|
||||
:::info
|
||||
The ports for the GCS, offboard APIs and simulator are specified by startup scripts.
|
||||
See [System Startup](../concept/system_startup.md) to learn more.
|
||||
:::
|
||||
|
||||
<!-- A useful discussion about UDP ports here: https://github.com/PX4/PX4-user_guide/issues/1035#issuecomment-777243106 -->
|
||||
|
||||
## Середовище симуляції SITL
|
||||
|
||||
На схемі нижче показано типове середовище симуляції SITL для будь-якого з підтримуваних тренажерів, що використовують MAVLink (тобто всіх, окрім Gazebo).
|
||||
|
||||

|
||||
|
||||
Різні частини системи з'єднуються через протокол UDP і можуть працювати як на одному комп'ютері, так і на іншому комп'ютері в тій самій мережі.
|
||||
|
||||
- PX4 використовує спеціальний модуль для підключення до локального TCP-порту 4560 симулятора.
|
||||
Simulators then exchange information with PX4 using the [Simulator MAVLink API](#simulator-mavlink-api) described above.
|
||||
PX4 на SITL і симулятор можуть працювати як на одному комп'ютері, так і на різних комп'ютерах в одній мережі.
|
||||
|
||||
::: info
|
||||
Simulators can also use the _uxrce-dds bridge_ ([XRCE-DDS](../middleware/uxrce_dds.md)) to directly interact with PX4 (i.e. via [UORB topics](../middleware/uorb.md) rather than MAVLink).
|
||||
This approach _may_ used by Gazebo Classic for [multi-vehicle simulation](../sim_gazebo_classic/multi_vehicle_simulation.md#build-and-test-xrce-dds).
|
||||
|
||||
:::
|
||||
|
||||
- PX4 використовує звичайний модуль MAVLink для підключення до наземних станцій і зовнішніх API розробників, таких як MAVSDK або ROS
|
||||
- Ground stations listen to PX4's remote UDP port: `14550`
|
||||
- External developer APIs listen to PX4's remote UDP port: `14540`.
|
||||
For multi-vehicle simulations, PX4 sequentially allocates a separate remote port for each instance from `14540` to `14549` (additional instances all use port `14549`).
|
||||
|
||||
- PX4 defines a number of _local_ UDP ports (`14580`,`18570`), which are sometimes used when networking with PX4 running in a container or virtual machine.
|
||||
Вони не рекомендуються для "загального" використання і можуть змінюватися в майбутньому.
|
||||
|
||||
- A serial connection may be used to connect [Joystick/Gamepad](../config/joystick.md) hardware via _QGroundControl_.
|
||||
|
||||
If you use the normal build system SITL `make` configuration targets (see next section) then both SITL and the Simulator will be launched on the same computer and the ports above will automatically be configured.
|
||||
Ви можете налаштувати додаткові UDP-з'єднання MAVLink та іншим чином змінити середовище моделювання у файлах конфігурації та ініціалізації збірки.
|
||||
|
||||
### Запуск/створення симуляції SITL
|
||||
|
||||
Система збірки дозволяє дуже легко зібрати і запустити PX4 на SITL, активувати симулятор і з'єднати їх.
|
||||
Синтаксис (спрощений) виглядає наступним чином:
|
||||
|
||||
```sh
|
||||
make px4_sitl simulator[_vehicle-model]
|
||||
```
|
||||
|
||||
where `simulator` is `gz` (for Gazebo), `gazebo-classic`, `jmavsim` or some other simulator, and vehicle-model is a particular vehicle type supported by that simulator ([Gazebo](../sim_gazebo_gz/index.md) and [jMAVSim](../sim_jmavsim/index.md) only support multicopters at time of writing, while [Gazebo Classic](../sim_gazebo_classic/index.md) supports many different types).
|
||||
|
||||
Нижче наведено кілька прикладів, і їх набагато більше на окремих сторінках для кожного з симуляторів:
|
||||
|
||||
```sh
|
||||
# Start Gazebo with the x500 multicopter
|
||||
make px4_sitl gz_x500
|
||||
|
||||
# Start Gazebo Classic with plane
|
||||
make px4_sitl gazebo-classic_plane
|
||||
|
||||
# Start Gazebo Classic with iris and optical flow
|
||||
make px4_sitl gazebo-classic_iris_opt_flow
|
||||
|
||||
# Start JMavSim with iris (default vehicle model)
|
||||
make px4_sitl jmavsim
|
||||
|
||||
# Start PX4 with no simulator (i.e. to use your own "custom" simulator)
|
||||
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.
|
||||
|
||||
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).
|
||||
|
||||
### Run Simulation Faster than Realtime {#simulation_speed}
|
||||
|
||||
SITL can be run faster or slower than real-time when using Gazebo, Gazebo Classic, or jMAVSim.
|
||||
|
||||
The speed factor is set using the environment variable `PX4_SIM_SPEED_FACTOR`.
|
||||
|
||||
:::info
|
||||
PX4 SITL and the simulators are run in _lockstep_, which means that they are locked to run at the same speed, and therefore can react appropriately to sensor and actuator messages.
|
||||
This is what makes it possible to run the simulation at different speeds, and also pause the simulation in order to step through code.
|
||||
:::
|
||||
|
||||
Для додаткової інформації дивіться:
|
||||
|
||||
- Gazebo: [Change Simulation Speed](../sim_gazebo_gz/index.md#change-simulation-speed)
|
||||
- Gazebo Classic: [Change Simulation Speed](../sim_gazebo_classic/index.md#change-simulation-speed) and [Lockstep](../sim_gazebo_classic/index.md#lockstep)
|
||||
- jMAVSim: [Change Simulation Speed](../sim_jmavsim/index.md#change-simulation-speed) and [Lockstep](../sim_jmavsim/index.md#lockstep)
|
||||
|
||||
### Сценарії запуску
|
||||
|
||||
Scripts are used to control which parameter settings to use or which modules to start.
|
||||
They are located in the [ROMFS/px4fmu_common/init.d-posix](https://github.com/PX4/PX4-Autopilot/tree/main/ROMFS/px4fmu_common/init.d-posix) directory, the `rcS` file is the main entry point.
|
||||
See [System Startup](../concept/system_startup.md) for more information.
|
||||
|
||||
### Імітація збоїв та відмов датчиків/обладнання
|
||||
|
||||
[Simulate Failsafes](../simulation/failsafes.md) explains how to trigger safety failsafes like GPS failure and battery drain.
|
||||
|
||||
## Середовище симуляції HITL
|
||||
|
||||
У симуляції з апаратним забезпеченням у контурі (HITL) звичайна прошивка PX4 виконується на реальному обладнані.
|
||||
The HITL Simulation Environment in documented in: [HITL Simulation](../simulation/hitl.md).
|
||||
|
||||
## Інтеграція джойстиків/геймпада
|
||||
|
||||
_QGroundControl_ desktop versions can connect to a USB Joystick/Gamepad and send its movement commands and button presses to PX4 over MAVLink.
|
||||
Це працює як на SITL, так і на HITL симуляціях, і дозволяє вам безпосередньо керувати симульованим апаратом.
|
||||
Якщо у вас немає джойстика, ви можете керувати апаратом за допомогою екранних віртуальних паличок QGroundControl.
|
||||
|
||||
For setup information see the _QGroundControl User Guide_:
|
||||
|
||||
- [Joystick Setup](https://docs.qgroundcontrol.com/master/en/qgc-user-guide/setup_view/joystick.html)
|
||||
- [Virtual Joystick](https://docs.qgroundcontrol.com/master/en/qgc-user-guide/settings_view/virtual_joystick.html)
|
||||
|
||||
<!-- FYI Airsim info on this setting up remote controls: https://github.com/Microsoft/AirSim/blob/master/docs/remote_controls.md -->
|
||||
|
||||
## Симуляція камери
|
||||
|
||||
PX4 supports capture of both still images and video from within the [Gazebo Classic](../sim_gazebo_classic/index.md) simulated environment.
|
||||
This can be enabled/set up as described in [Gazebo Glassic > Video Streaming](../sim_gazebo_classic/index.md#video-streaming).
|
||||
|
||||
The simulated camera is a gazebo classic plugin that implements the [MAVLink Camera Protocol](https://mavlink.io/en/protocol/camera.html) <!-- **PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/src/gazebo_geotagged_images_plugin.cpp -->.
|
||||
PX4 connects/integrates with this camera in _exactly the same way_ as it would with any other MAVLink camera:
|
||||
|
||||
1. [TRIG_INTERFACE](../advanced_config/parameter_reference.md#TRIG_INTERFACE) must be set to `3` to configure the camera trigger driver for use with a MAVLink camera
|
||||
:::tip
|
||||
In this mode the driver just sends a [CAMERA_TRIGGER](https://mavlink.io/en/messages/common.html#CAMERA_TRIGGER) message whenever an image capture is requested.
|
||||
For more information see [Cameras Connected to Flight Controller Outputs](../camera/fc_connected_camera.md).
|
||||
|
||||
:::
|
||||
2. PX4 повинен перенаправляти всі команди камери між GCS і (симулятором) MAVLink Camera.
|
||||
You can do this by starting [MAVLink](../modules/modules_communication.md#mavlink) with the `-f` flag as shown, specifying the UDP ports for the new connection.
|
||||
|
||||
```sh
|
||||
mavlink start -u 14558 -o 14530 -r 4000 -f -m camera
|
||||
```
|
||||
|
||||
::: info
|
||||
More than just the camera MAVLink messages will be forwarded, but the camera will ignore those that it doesn't consider relevant.
|
||||
|
||||
:::
|
||||
|
||||
Інші симулятори можуть використовувати такий самий підхід для реалізації підтримки камери.
|
||||
|
||||
## Запуск симуляції на віддаленому сервері
|
||||
|
||||
Симулятор можна запустити на одному комп'ютері, а доступ до нього отримати з іншого комп'ютера в тій же мережі (або в іншій мережі з відповідною маршрутизацією).
|
||||
Це може бути корисно, наприклад, якщо ви хочете протестувати програму для безпілотника, що працює на реальному комп'ютері-компаньйоні на фоні змодельованого транспортного засобу.
|
||||
|
||||
Це не працює "з коробки", оскільки PX4 за замовчуванням не маршрутизує пакети на зовнішні інтерфейси (щоб уникнути спаму в мережі та втручання різних симуляцій одна в одну).
|
||||
Замість цього він спрямовує трафік всередину - на "localhost".
|
||||
|
||||
Існує декілька способів зробити UDP-пакети доступними на зовнішніх інтерфейсах, як описано нижче.
|
||||
|
||||
### Використання MAVLink Router
|
||||
|
||||
The [mavlink-router](https://github.com/mavlink-router/mavlink-router) can be used to route packets from localhost to an external interface.
|
||||
|
||||
To route packets between SITL running on one computer (sending MAVLink traffic to localhost on UDP port 14550), and QGC running on another computer (e.g. at address `10.73.41.30`) you could:
|
||||
|
||||
- Start _mavlink-router_ with the following command:
|
||||
|
||||
```sh
|
||||
mavlink-routerd -e 10.73.41.30:14550 127.0.0.1:14550
|
||||
```
|
||||
|
||||
- Use a _mavlink-router_ conf file.
|
||||
|
||||
```ini
|
||||
[UdpEndpoint QGC]
|
||||
Mode = Normal
|
||||
Address = 10.73.41.30
|
||||
Port = 14550
|
||||
|
||||
[UdpEndpoint SIM]
|
||||
Mode = Eavesdropping
|
||||
Address = 127.0.0.1
|
||||
Port = 14550
|
||||
```
|
||||
|
||||
:::info
|
||||
More information about _mavlink-router_ configuration can be found [here](https://github.com/mavlink-router/mavlink-router#running).
|
||||
:::
|
||||
|
||||
### Увімкнення трансляції UDP
|
||||
|
||||
The [mavlink module](../modules/modules_communication.md#mavlink_usage) routes to _localhost_ by default, but you can enable UDP broadcasting of heartbeats using its `-p` option.
|
||||
Any remote computer on the network can then connect to the simulator by listening to the appropriate port (i.e. 14550 for _QGroundControl_).
|
||||
|
||||
:::info
|
||||
UDP broadcasting provides a simple way to set up the connection when there is only one simulation running on the network.
|
||||
Do not use this approach if there are multiple simulations running on the network (you might instead [publish to a specific address](#enable-streaming-to-specific-address)).
|
||||
:::
|
||||
|
||||
This should be done in an appropriate configuration file where `mavlink start` is called.
|
||||
For example: [/ROMFS/px4fmu_common/init.d-posix/px4-rc.mavlink](https://github.com/PX4/PX4-Autopilot/blob/main/ROMFS/px4fmu_common/init.d-posix/px4-rc.mavlink).
|
||||
|
||||
### Увімкнення стрімінгу на певну адресу
|
||||
|
||||
The [mavlink module](../modules/modules_communication.md#mavlink_usage) routes to _localhost_ by default, but you can specify an external IP address to stream to using its `-t` option.
|
||||
The specified remote computer can then connect to the simulator by listening to the appropriate port (i.e. 14550 for _QGroundControl_).
|
||||
|
||||
This should be done in various configuration files where `mavlink start` is called.
|
||||
For example: [/ROMFS/px4fmu_common/init.d-posix/px4-rc.mavlink](https://github.com/PX4/PX4-Autopilot/blob/main/ROMFS/px4fmu_common/init.d-posix/px4-rc.mavlink).
|
||||
|
||||
### Тунелювання по SSH
|
||||
|
||||
Тунелювання SSH є гнучким варіантом, оскільки комп'ютер для моделювання та система, що його використовує, не обов'язково повинні знаходитися в одній мережі.
|
||||
|
||||
:::info
|
||||
You might similarly use VPN to provide a tunnel to an external interface (on the same network or another network).
|
||||
:::
|
||||
|
||||
Одним із способів створення тунелю є використання параметрів тунелювання SSH.
|
||||
The tunnel itself can be created by running the following command on _localhost_, where `remote.local` is the name of a remote computer:
|
||||
|
||||
```sh
|
||||
ssh -C -fR 14551:localhost:14551 remote.local
|
||||
```
|
||||
|
||||
UDP-пакети потрібно перетворити на TCP-пакети, щоб їх можна було перенаправляти через SSH.
|
||||
The [netcat](https://en.wikipedia.org/wiki/Netcat) utility can be used on both sides of the tunnel - first to convert packets from UDP to TCP, and then back to UDP at the other end.
|
||||
|
||||
:::tip
|
||||
QGC must be running before executing _netcat_.
|
||||
:::
|
||||
|
||||
On the _QGroundControl_ computer, UDP packet translation may be implemented by running following commands:
|
||||
|
||||
```sh
|
||||
mkfifo /tmp/tcp2udp
|
||||
netcat -lvp 14551 < /tmp/tcp2udp | netcat -u localhost 14550 > /tmp/tcp2udp
|
||||
```
|
||||
|
||||
Команда на стороні симулятора тунелю SSH:
|
||||
|
||||
```sh
|
||||
mkfifo /tmp/udp2tcp
|
||||
netcat -lvup 14550 < /tmp/udp2tcp | netcat localhost 14551 > /tmp/udp2tcp
|
||||
```
|
||||
|
||||
The port number `14550` is valid for connecting to QGroundControl or another GCS, but should be adjusted for other endpoints (e.g. developer APIs etc.).
|
||||
|
||||
The tunnel may in theory run indefinitely, but _netcat_ connections may need to be restarted if there is a problem.
|
||||
|
||||
The [QGC_remote_connect.bash](https://raw.githubusercontent.com/ThunderFly-aerospace/sitl_gazebo/autogyro-sitl/scripts/QGC_remote_connect.bash) script can be run on the QGC computer to automatically setup/run the above instructions.
|
||||
Симуляція вже має бути запущена на віддаленому сервері, і ви повинні мати доступ по SSH до цього сервера.
|
||||
@@ -0,0 +1,22 @@
|
||||
# Симуляція кількох рухомих засобів
|
||||
|
||||
PX4 підтримує симуляцію кількох рухомих засобів використовуючи наступні симулятори:
|
||||
|
||||
- [Multi-Vehicle Sim with Gazebo](../sim_gazebo_gz/multi_vehicle_simulation.md) (both with and without ROS)
|
||||
- [Multi-Vehicle Sim with Gazebo Classic](../sim_gazebo_classic/multi_vehicle_simulation.md) (both with and without ROS)
|
||||
- [Multi-Vehicle Sim with FlightGear](../sim_flightgear/multi_vehicle.md)
|
||||
- [Multi-Vehicle Sim with JMAVSim](../sim_jmavsim/multi_vehicle.md)
|
||||
|
||||
Вибір симулятора залежить від рухомого засобу що моделюється, наскільки "якісна" потрібна симуляція (і для яких функцій), і скільки засобів потрібно симулювати одночасно.
|
||||
|
||||
- FlightGear це найбільш точний симулятор і в результаті найбільш ресурсомісткий.
|
||||
Він може бути використаний, якщо вам потрібна гарна симуляція, але не надто багато засобів за раз.
|
||||
Також його можна використати, якщо потрібно симулювати різні типи рухомих засобів одночасно.
|
||||
- [Gazebo](../sim_gazebo_gz/index.md) is less accurate and less heavy-weight and supports many features that aren't available for FlightGear.
|
||||
Він може симулювати набагато більше засобів за раз, ніж FlightGear, та дозволяє симулювати різні їх типи водночас.
|
||||
Він може використовуватись тільки на Ubuntu 20.04 і новіше.
|
||||
Note, this is the successor of [Gazebo Classic](../sim_gazebo_classic/index.md) (below).
|
||||
- [Gazebo Classic](../sim_gazebo_classic/index.md) is less accurate and less heavy-weight and supports many features and vehicles that aren't available for FlightGear.
|
||||
Він може симулювати набагато більше засобів за раз, ніж FlightGear, та дозволяє симулювати різні їх типи водночас.
|
||||
- JMAVSim - це дуже легкий симулятор, який підтримує лише квадрокоптери.
|
||||
Рекомендується у випадку, якщо вам необхідно підтримувати багато квадрокоптерів та симуляція може бути приблизна.
|
||||
@@ -0,0 +1,139 @@
|
||||
# ROS з симулятором Gazebo Classic
|
||||
|
||||
[ROS](../ros/index.md) (Robot Operating System) can be used with PX4 and the [Gazebo Classic](../sim_gazebo_classic/index.md) simulator.
|
||||
It uses the [MAVROS](../ros/mavros_installation.md) MAVLink node to communicate with PX4.
|
||||
|
||||
The ROS/Gazebo Classic integration with PX4 follows the pattern in the diagram below (this shows the _generic_ [PX4 simulation environment](../simulation/index.md#sitl-simulation-environment)).
|
||||
PX4 спілкується з симулятором (наприклад Gazebo Classic), щоб отримувати дані датчиків із модельованого світу і надсилає значення для двигунів та сервоприводів.
|
||||
Вона спілкується з GCS та зовнішнім API (наприклад ROS) щоб надіслати телеметрію із модельованого середовища та отримати команди.
|
||||
|
||||

|
||||
|
||||
:::info
|
||||
The only _slight_ difference to "normal behaviour" is that ROS initiates the connection on port 14557, while it is more typical for an offboard API to listen for connections on UDP port 14540.
|
||||
:::
|
||||
|
||||
## Встановлення ROS та Gazebo Classic
|
||||
|
||||
[ROS (1) with MAVROS Installation Guide](../ros/mavros_installation.md) explains how to set up a guide for working with ROS (1), MAVROS, and PX4.
|
||||
|
||||
:::info
|
||||
_ROS_ is only supported on Linux (not macOS or Windows).
|
||||
:::
|
||||
|
||||
## Запуск ROS/симуляції
|
||||
|
||||
The command below can be used to launch the simulation and connect ROS to it via [MAVROS](../ros/mavros_installation.md), where `fcu_url` is the IP / port of the computer running the simulation:
|
||||
|
||||
```sh
|
||||
roslaunch mavros px4.launch fcu_url:="udp://:14540@192.168.1.36:14557"
|
||||
```
|
||||
|
||||
Для з'єднання з localhost (локальним комп'ютером), використовуйте цей URL:
|
||||
|
||||
```sh
|
||||
roslaunch -w 2 -v mavros px4.launch fcu_url:="udp://:14540@127.0.0.1:14557"
|
||||
```
|
||||
|
||||
:::info
|
||||
It can be useful to call _roslaunch_ with the `-w NUM_WORKERS` (override number of worker threads) and/or `-v` (verbose) in order to get warnings about missing dependencies in your setup. Наприклад:
|
||||
|
||||
```sh
|
||||
roslaunch -w 2 -v mavros px4.launch fcu_url:="udp://:14540@127.0.0.1:14557"
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
## Запуск Gazebo Classic за допомогою обгорток ROS
|
||||
|
||||
Симуляція Gazebo Classic може бути змінена для інтеграції публікації даних датчиків напряму в рубрики ROS наприклад ROS плагін лазера для Gazebo Classic.
|
||||
Для підтримки цієї функції, Gazebo Classic повинна бути запущена з відповідною обгорткою ROS.
|
||||
|
||||
Доступні скрипти запуску ROS для запуску симуляції в обгортці ROS:
|
||||
|
||||
- [posix_sitl.launch](https://github.com/PX4/PX4-Autopilot/blob/main/launch/posix_sitl.launch): plain SITL launch
|
||||
- [mavros_posix_sitl.launch](https://github.com/PX4/PX4-Autopilot/blob/main/launch/mavros_posix_sitl.launch): SITL and MAVROS
|
||||
|
||||
Щоб запустити SITL обгорнуту в ROS, необхідно оновити середовище ROS, а потім запустити як завжди:
|
||||
|
||||
(необов'язково): виконувати команду source у робочому просторі catkin потрібно тільки якщо ви скомпілювали MAVROS або інші пакети ROS з вихідного коду:
|
||||
|
||||
```sh
|
||||
cd <PX4-Autopilot_clone>
|
||||
DONT_RUN=1 make px4_sitl_default gazebo-classic
|
||||
source ~/catkin_ws/devel/setup.bash # (optional)
|
||||
source Tools/simulation/gazebo-classic/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
|
||||
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)
|
||||
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/simulation/gazebo-classic/sitl_gazebo-classic
|
||||
roslaunch px4 posix_sitl.launch
|
||||
```
|
||||
|
||||
Включіть один зі згаданих вище файлів запуску у ваш власний файл запуску для запуску застосунку ROS в симуляції.
|
||||
|
||||
## Що відбувається за лаштунками
|
||||
|
||||
This section shows how the _roslaunch_ instructions provided previously actually work (you can follow them to manually launch the simulation and ROS).
|
||||
|
||||
Вам потрібно три термінали, у всіх потрібно запустити команду source у ROS середовищі.
|
||||
|
||||
Спочатку запустіть симулятор, використовуючи наступну команду:
|
||||
|
||||
```sh
|
||||
cd <PX4-Autopilot_clone>
|
||||
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)
|
||||
roslaunch px4 px4.launch
|
||||
```
|
||||
|
||||
У консолі буде приблизно це:
|
||||
|
||||
```sh
|
||||
INFO [px4] instance: 0
|
||||
|
||||
______ __ __ ___
|
||||
| ___ \ \ \ / / / |
|
||||
| |_/ / \ V / / /| |
|
||||
| __/ / \ / /_| |
|
||||
| | / /^\ \ \___ |
|
||||
\_| \/ \/ |_/
|
||||
|
||||
px4 starting.
|
||||
|
||||
INFO [px4] startup script: /bin/sh etc/init.d-posix/rcS 0
|
||||
INFO [init] found model autostart file as SYS_AUTOSTART=10016
|
||||
INFO [param] selected parameter default file parameters.bson
|
||||
INFO [param] importing from 'parameters.bson'
|
||||
INFO [parameters] BSON document size 295 bytes, decoded 295 bytes (INT32:12, FLOAT:3)
|
||||
INFO [param] selected parameter backup file parameters_backup.bson
|
||||
INFO [dataman] data manager file './dataman' size is 7866640 bytes
|
||||
etc/init.d-posix/rcS: 31: [: Illegal number:
|
||||
INFO [init] PX4_SIM_HOSTNAME: localhost
|
||||
INFO [simulator_mavlink] Waiting for simulator to accept connection on TCP port 4560
|
||||
```
|
||||
|
||||
У другому терміналі переконайтесь, що зможете запустити gazebo з файлами світу, визначеними у PX4-Autopilot. To do this set your environment variables to include the appropriate `sitl_gazebo-classic` folders.
|
||||
|
||||
```sh
|
||||
cd <PX4-Autopilot_clone>
|
||||
source Tools/simulation/gazebo-classic/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
|
||||
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/simulation/gazebo-classic/sitl_gazebo-classic
|
||||
```
|
||||
|
||||
Тепер запустіть з Gazebo Classic так, як ви хотіли б працювати з ROS:
|
||||
|
||||
```sh
|
||||
roslaunch gazebo_ros empty_world.launch world_name:=$(pwd)/Tools/simulation/gazebo-classic/sitl_gazebo-classic/worlds/empty.world
|
||||
```
|
||||
|
||||
У третьому терміналі переконайтесь що зможете відтворити модель з sdf файлами, визначеними у PX4-Autopilot. To do this set your environment variables to include the appropriate `sitl_gazebo-classic` folders.
|
||||
|
||||
```sh
|
||||
cd <PX4-Autopilot_clone>
|
||||
source Tools/simulation/gazebo-classic/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
|
||||
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/simulation/gazebo-classic/sitl_gazebo-classic
|
||||
```
|
||||
|
||||
Тепер додайте модель квадрокоптера Iris так, як ви б хотіли коли працюєте з ROS. Після завантаження Iris автоматично з'єднається із застосунком px4.
|
||||
|
||||
```sh
|
||||
rosrun gazebo_ros spawn_model -sdf -file $(pwd)/Tools/simulation/gazebo-classic/sitl_gazebo-classic/models/iris/iris.sdf -model iris -x 0 -y 0 -z 0 -R 0 -P 0 -Y 0
|
||||
```
|
||||
Reference in New Issue
Block a user