mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-27 00:30:05 +08:00
Compare commits
152 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 115568eb82 | |||
| c89ae1d690 | |||
| ed10146e9f | |||
| f05fccebb7 | |||
| 6bd020e848 | |||
| 4fe90322db | |||
| 167c3da99d | |||
| 70321ed610 | |||
| f476ebdcbf | |||
| 9d5adf8bab | |||
| e91295e5db | |||
| b16a53018d | |||
| 0987bb2e8e | |||
| da01dd9eeb | |||
| b825b61a20 | |||
| 9c204774f1 | |||
| 88bf1030b5 | |||
| d4cce452cf | |||
| 2542b1bb26 | |||
| e115095f70 | |||
| 4087c27e84 | |||
| aa8d594e9b | |||
| 667e99be81 | |||
| 115cf4d572 | |||
| f233f2167e | |||
| 8a25d06ed7 | |||
| cecef7e3f6 | |||
| d38c02fd6a | |||
| 2635e2c386 | |||
| 7e75b497ae | |||
| f32d931117 | |||
| 349f152601 | |||
| 7bf62373ae | |||
| 2edb35b1b5 | |||
| 6a9a049f1e | |||
| 9ba6f4efb7 | |||
| 554d965a2d | |||
| 608ab9ff9c | |||
| e346190e63 | |||
| 5ece24cdc4 | |||
| 8f0c2f4146 | |||
| 92fbd86b46 | |||
| a2a5093881 | |||
| d996af4647 | |||
| 0c860fa227 | |||
| 9ed35debec | |||
| a56f654651 | |||
| 7bbdc220f5 | |||
| e467d11990 | |||
| 5dfd2f39ef | |||
| e93a3a2a3a | |||
| f66b5ce204 | |||
| c52f2143d2 | |||
| 3da0293369 | |||
| 43c5f14aa0 | |||
| f57321d365 | |||
| 295caaea60 | |||
| 2c96bb3746 | |||
| 1370cc0d74 | |||
| a9c1415337 | |||
| 4e940fab83 | |||
| 9eff6dd049 | |||
| 0e130eac83 | |||
| dcb9b712bb | |||
| f197c8884d | |||
| c9037f115b | |||
| f17f38197d | |||
| cfe3d793bf | |||
| 5cb44a521c | |||
| 75f6f22223 | |||
| 1948c5057a | |||
| d6a4e158cf | |||
| d681782c7f | |||
| 4f52cda504 | |||
| 2776b723ea | |||
| e780a583cd | |||
| 734d3e4aa0 | |||
| afc99749b8 | |||
| 715afd27f5 | |||
| f0295cf596 | |||
| ad222760dd | |||
| 70ec3493c5 | |||
| 666b84027d | |||
| 060738cae1 | |||
| 983a9815eb | |||
| 4c41934bb4 | |||
| 1c89b0c9c8 | |||
| 13c93db11a | |||
| 4230eee24f | |||
| 2fccb576ad | |||
| dbb814ff24 | |||
| b2cb164c12 | |||
| 6d1fb92eb7 | |||
| b4a3597c7d | |||
| b3fe0eeae8 | |||
| 552d08176f | |||
| c7b64e3c01 | |||
| 406b0bbc86 | |||
| 8f9be0541f | |||
| f23363f88c | |||
| 2507f0a143 | |||
| fcadc69e52 | |||
| c95192d050 | |||
| b7a6de05df | |||
| 07afcf4586 | |||
| 04f7df3848 | |||
| 9b0b0d1168 | |||
| f60f6d2425 | |||
| 2786239ca6 | |||
| 02c9ec6085 | |||
| 0e8e38e698 | |||
| 4040e4cdf2 | |||
| 6b2509cbba | |||
| 8b4df8ceb2 | |||
| f8f1213841 | |||
| 0061ef8b89 | |||
| 090d03eea2 | |||
| a2a29ba0dd | |||
| 8dd5d0d1a3 | |||
| 20cd599bb7 | |||
| 2d39097f60 | |||
| 28b4cd0579 | |||
| b6f76b5eaa | |||
| f555281c94 | |||
| d87feee5b0 | |||
| 12e25eba62 | |||
| 52f726c5b7 | |||
| b04d61c411 | |||
| 3fb218600a | |||
| aba2eac0df | |||
| 6833c7e311 | |||
| 8962cf2d25 | |||
| 578e1339ca | |||
| 88ac5ea210 | |||
| 375753eba8 | |||
| 66ce1a002b | |||
| 82ec7a495a | |||
| f9188b2a14 | |||
| 8fd79688c0 | |||
| f5f31006a0 | |||
| 57125a4c8f | |||
| c81efd0174 | |||
| 7b810bb776 | |||
| b260df711c | |||
| bae275898b | |||
| b58f70726f | |||
| 213d5dac2a | |||
| 4f6d523c95 | |||
| f89044cfbe | |||
| 40149ecabc | |||
| 913bae9924 | |||
| cfc579542e |
@@ -794,7 +794,7 @@ void resetParameters() {
|
||||
void runTests() {
|
||||
|
||||
// test loading a range of airframes
|
||||
sh './Tools/HIL/test_airframes.sh `find /dev/serial -name *usb-*` 2100 3000 4001 6001 8001 10016'
|
||||
sh './Tools/HIL/test_airframes.sh `find /dev/serial -name *usb-*` 2100 3000 4001 6001 8001'
|
||||
|
||||
resetParameters()
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ name: Checks
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'main'
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
|
||||
@@ -3,7 +3,7 @@ name: Clang Tidy
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'main'
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
|
||||
@@ -3,7 +3,7 @@ name: Linux Targets
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'main'
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
|
||||
@@ -3,7 +3,7 @@ name: Linux ARM64 Targets
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'main'
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
|
||||
@@ -3,7 +3,7 @@ name: MacOS build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'main'
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
|
||||
@@ -3,7 +3,7 @@ name: Nuttx Targets
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'main'
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
|
||||
@@ -3,7 +3,7 @@ name: Deploy metadata for all targets
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'main'
|
||||
- 'release/*'
|
||||
- 'pr-metadata-test'
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ name: MAVROS Mission Tests
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'main'
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
|
||||
@@ -3,7 +3,7 @@ name: MAVROS Offboard Tests
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'main'
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
|
||||
@@ -3,7 +3,7 @@ name: Metadata
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'main'
|
||||
- 'release/*'
|
||||
- 'pr-metadata-test'
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ name: Python CI Checks
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'main'
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
|
||||
@@ -3,7 +3,7 @@ name: SITL Tests
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'main'
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
|
||||
+7
-10
@@ -6,12 +6,12 @@
|
||||
path = src/drivers/uavcan/libuavcan
|
||||
url = https://github.com/dronecan/libuavcan.git
|
||||
branch = main
|
||||
[submodule "Tools/jMAVSim"]
|
||||
path = Tools/jMAVSim
|
||||
[submodule "Tools/simulation/jmavsim/jMAVSim"]
|
||||
path = Tools/simulation/jmavsim/jMAVSim
|
||||
url = https://github.com/PX4/jMAVSim.git
|
||||
branch = master
|
||||
[submodule "Tools/sitl_gazebo"]
|
||||
path = Tools/sitl_gazebo
|
||||
[submodule "Tools/simulation/gazebo/sitl_gazebo"]
|
||||
path = Tools/simulation/gazebo/sitl_gazebo
|
||||
url = https://github.com/PX4/PX4-SITL_gazebo.git
|
||||
branch = master
|
||||
[submodule "src/drivers/gps/devices"]
|
||||
@@ -31,10 +31,10 @@
|
||||
url = https://github.com/PX4/NuttX-apps.git
|
||||
branch = px4_firmware_nuttx-10.1.0+
|
||||
[submodule "Tools/flightgear_bridge"]
|
||||
path = Tools/flightgear_bridge
|
||||
path = Tools/simulation/flightgear/flightgear_bridge
|
||||
url = https://github.com/PX4/PX4-FlightGear-Bridge.git
|
||||
[submodule "Tools/jsbsim_bridge"]
|
||||
path = Tools/jsbsim_bridge
|
||||
[submodule "Tools/simulation/jsbsim/jsbsim_bridge"]
|
||||
path = Tools/simulation/jsbsim/jsbsim_bridge
|
||||
url = https://github.com/PX4/px4-jsbsim-bridge.git
|
||||
[submodule "src/drivers/cyphal/libcanard"]
|
||||
path = src/drivers/cyphal/libcanard
|
||||
@@ -53,9 +53,6 @@
|
||||
[submodule "src/lib/events/libevents"]
|
||||
path = src/lib/events/libevents
|
||||
url = https://github.com/mavlink/libevents.git
|
||||
[submodule "Tools/simulation-ignition"]
|
||||
path = Tools/simulation-ignition
|
||||
url = https://github.com/PX4/px4-simulation-ignition.git
|
||||
[submodule "src/lib/crypto/libtomcrypt"]
|
||||
path = src/lib/crypto/libtomcrypt
|
||||
url = https://github.com/PX4/libtomcrypt.git
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ matrix:
|
||||
dist: xenial
|
||||
# In order to stay under the coverity rate limit, we only run this weekly
|
||||
# and not on push which is configured in travis-ci settings.
|
||||
if: branch = master
|
||||
if: branch = main
|
||||
|
||||
before_install:
|
||||
- echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
|
||||
|
||||
Vendored
+6
-1
@@ -2,10 +2,15 @@ CONFIG:
|
||||
default: px4_sitl_default
|
||||
choices:
|
||||
px4_sitl_default:
|
||||
short: px4_sitl
|
||||
short: px4_sitl_default
|
||||
buildType: RelWithDebInfo
|
||||
settings:
|
||||
CONFIG: px4_sitl_default
|
||||
px4_sitl_ign:
|
||||
short: px4_sitl_ign
|
||||
buildType: RelWithDebInfo
|
||||
settings:
|
||||
CONFIG: px4_sitl_ign
|
||||
px4_sitl_rtps:
|
||||
short: px4_sitl_rtps
|
||||
buildType: RelWithDebInfo
|
||||
|
||||
Vendored
+63
-45
@@ -54,7 +54,7 @@
|
||||
"type": "shell",
|
||||
"command": "ant create_run_jar copy_res",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/Tools/jMAVSim"
|
||||
"cwd": "${workspaceFolder}/Tools/simulation/jmavsim/jMAVSim"
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"presentation":{
|
||||
@@ -72,7 +72,7 @@
|
||||
"dependsOn": "jmavsim build",
|
||||
"command": "java -Djava.ext.dirs= -jar jmavsim_run.jar -r 250 -lockstep -tcp localhost:4560 -qgc",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/Tools/jMAVSim/out/production",
|
||||
"cwd": "${workspaceFolder}/Tools/simulation/jmavsim/jMAVSim/out/production",
|
||||
"env": {
|
||||
"PX4_SIM_SPEED_FACTOR": "1"
|
||||
}
|
||||
@@ -86,23 +86,7 @@
|
||||
"showReuseMessage": false,
|
||||
"clear": false
|
||||
},
|
||||
"problemMatcher": [
|
||||
{
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": ".",
|
||||
"file": 1,
|
||||
"location": 2,
|
||||
"message": 3
|
||||
}
|
||||
],
|
||||
"background": {
|
||||
"activeOnStart": true,
|
||||
"beginsPattern": ".",
|
||||
"endsPattern": ".",
|
||||
}
|
||||
}
|
||||
]
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "jmavsim kill",
|
||||
@@ -116,7 +100,8 @@
|
||||
"showReuseMessage": false,
|
||||
"clear": false
|
||||
},
|
||||
"problemMatcher": []
|
||||
"problemMatcher": [],
|
||||
"dependsOn":["px4_sitl_cleanup"]
|
||||
},
|
||||
{
|
||||
"label": "gazebo build",
|
||||
@@ -143,11 +128,11 @@
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"GAZEBO_PLUGIN_PATH": "${workspaceFolder}/build/px4_sitl_default/build_gazebo",
|
||||
"GAZEBO_MODEL_PATH": "${workspaceFolder}/Tools/sitl_gazebo/models",
|
||||
"GAZEBO_MODEL_PATH": "${workspaceFolder}/Tools/simulation/gazebo/sitl_gazebo/models",
|
||||
"PX4_SIM_SPEED_FACTOR": "1"
|
||||
}
|
||||
},
|
||||
"command": "gzserver --verbose ${workspaceFolder}/Tools/sitl_gazebo/worlds/${input:gazeboWorld}.world",
|
||||
"command": "gzserver --verbose ${workspaceFolder}/Tools/simulation/gazebo/sitl_gazebo/worlds/${input:gazeboWorld}.world",
|
||||
"isBackground": true,
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
@@ -183,11 +168,11 @@
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"GAZEBO_PLUGIN_PATH": "${workspaceFolder}/build/px4_sitl_default/build_gazebo",
|
||||
"GAZEBO_MODEL_PATH": "${workspaceFolder}/Tools/sitl_gazebo/models",
|
||||
"GAZEBO_MODEL_PATH": "${workspaceFolder}/Tools/simulation/gazebo/sitl_gazebo/models",
|
||||
"PX4_SIM_SPEED_FACTOR": "1"
|
||||
}
|
||||
},
|
||||
"command": "gz model --verbose --spawn-file=${workspaceFolder}/Tools/sitl_gazebo/models/${input:vehicleModel}/${input:vehicleModel}.sdf --model-name=${input:vehicleModel} -x 1.01 -y 0.98 -z 0.83",
|
||||
"command": "gz model --verbose --spawn-file=${workspaceFolder}/Tools/simulation/gazebo/sitl_gazebo/models/${input:gazeboModel}/${input:gazeboModel}.sdf --model-name=${input:gazeboModel} -x 1.01 -y 0.98 -z 0.83",
|
||||
"isBackground": false,
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
@@ -216,26 +201,26 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "gazebo client",
|
||||
"label": "ign gazebo",
|
||||
"type": "shell",
|
||||
"dependsOn": "gazebo build",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"GAZEBO_PLUGIN_PATH": "${workspaceFolder}/build/px4_sitl_default/build_gazebo",
|
||||
"GAZEBO_MODEL_PATH": "${workspaceFolder}/Tools/sitl_gazebo/models",
|
||||
"IGN_GAZEBO_RESOURCE_PATH": "${workspaceFolder}/Tools/simulation/ignition/models",
|
||||
"PX4_SIM_SPEED_FACTOR": "1"
|
||||
}
|
||||
},
|
||||
"command": "gzclient --verbose",
|
||||
"command": "ign gazebo -v 4 -r ${workspaceFolder}/Tools/simulation/ignition/worlds/${input:ignWorld}.sdf",
|
||||
"isBackground": true,
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "never",
|
||||
"revealProblems": "onProblem",
|
||||
"focus": false,
|
||||
"panel": "shared",
|
||||
"panel": "dedicated",
|
||||
"showReuseMessage": false,
|
||||
"clear": false
|
||||
"clear": false,
|
||||
"close": true
|
||||
},
|
||||
"problemMatcher": [
|
||||
{
|
||||
@@ -258,29 +243,51 @@
|
||||
{
|
||||
"label": "gazebo kill",
|
||||
"type": "shell",
|
||||
"command": "killall gzserver",
|
||||
"command": "pkill -9 -f gzserver || true",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "silent",
|
||||
"reveal": "never",
|
||||
"revealProblems": "onProblem",
|
||||
"focus": false,
|
||||
"panel": "shared",
|
||||
"panel": "dedicated",
|
||||
"showReuseMessage": false,
|
||||
"clear": false
|
||||
"clear": false,
|
||||
"close": true
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"dependsOn":["px4_sitl_cleanup"]
|
||||
},
|
||||
{
|
||||
"label": "px4_sitl_cleanup",
|
||||
"label": "ign gazebo kill",
|
||||
"type": "shell",
|
||||
"command": "rm -rfv /tmp/px4*",
|
||||
"command": "pkill -9 -f ign || true",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "silent",
|
||||
"reveal": "never",
|
||||
"revealProblems": "onProblem",
|
||||
"focus": false,
|
||||
"panel": "shared",
|
||||
"panel": "dedicated",
|
||||
"showReuseMessage": false,
|
||||
"clear": false
|
||||
"clear": false,
|
||||
"close": true
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"dependsOn":["px4_sitl_cleanup"]
|
||||
},
|
||||
|
||||
{
|
||||
"label": "px4_sitl_cleanup",
|
||||
"type": "shell",
|
||||
"command": "rm -rfv /tmp/px4* || true",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "never",
|
||||
"revealProblems": "onProblem",
|
||||
"focus": false,
|
||||
"panel": "dedicated",
|
||||
"showReuseMessage": false,
|
||||
"clear": false,
|
||||
"close": true
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"dependsOn":["px4_kill"]
|
||||
@@ -288,14 +295,16 @@
|
||||
{
|
||||
"label": "px4_kill",
|
||||
"type": "shell",
|
||||
"command": "killall px4 || true",
|
||||
"command": "pkill -9 px4 || true",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "silent",
|
||||
"reveal": "never",
|
||||
"revealProblems": "onProblem",
|
||||
"focus": false,
|
||||
"panel": "shared",
|
||||
"panel": "dedicated",
|
||||
"showReuseMessage": false,
|
||||
"clear": false
|
||||
"clear": false,
|
||||
"close": true
|
||||
},
|
||||
"problemMatcher": []
|
||||
},
|
||||
@@ -337,7 +346,16 @@
|
||||
"inputs": [
|
||||
{
|
||||
"type": "pickString",
|
||||
"id": "vehicleModel",
|
||||
"id": "ignWorld",
|
||||
"description": "Ignition world",
|
||||
"options": [
|
||||
"default"
|
||||
],
|
||||
"default": "default"
|
||||
},
|
||||
{
|
||||
"type": "pickString",
|
||||
"id": "gazeboModel",
|
||||
"description": "gazebo model",
|
||||
"options": [
|
||||
"iris",
|
||||
|
||||
Vendored
+6
-6
@@ -26,15 +26,15 @@ pipeline {
|
||||
// echo $0;
|
||||
// mkdir -p catkin_ws/src;
|
||||
// cd catkin_ws;
|
||||
// git -C ${WORKSPACE}/catkin_ws/src/Firmware submodule update --init --recursive --force Tools/sitl_gazebo
|
||||
// git clone --recursive ${WORKSPACE}/catkin_ws/src/Firmware/Tools/sitl_gazebo src/mavlink_sitl_gazebo;
|
||||
// git -C ${WORKSPACE}/catkin_ws/src/Firmware submodule update --init --recursive --force Tools/simulation/gazebo/sitl_gazebo
|
||||
// git clone --recursive ${WORKSPACE}/catkin_ws/src/Firmware/Tools/simulation/gazebo/sitl_gazebo src/mavlink_sitl_gazebo;
|
||||
// git -C ${WORKSPACE}/catkin_ws/src/Firmware fetch --tags;
|
||||
// source /opt/ros/melodic/setup.bash;
|
||||
// export PYTHONPATH=/opt/ros/$ROS_DISTRO/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages;
|
||||
// catkin init;
|
||||
// catkin build -j$(nproc) -l$(nproc);
|
||||
// '''
|
||||
// // test if the binary was correctly installed and runs using 'mavros_posix_silt.launch'
|
||||
// // test if the binary was correctly installed and runs using 'mavros_posix_sitl.launch'
|
||||
// sh '''#!/bin/bash -l
|
||||
// echo $0;
|
||||
// source catkin_ws/devel/setup.bash;
|
||||
@@ -68,7 +68,7 @@ pipeline {
|
||||
unset ROS_DISTRO;
|
||||
mkdir -p colcon_ws/src;
|
||||
cd colcon_ws;
|
||||
git -C ${WORKSPACE}/colcon_ws/src/Firmware submodule update --init --recursive --force Tools/sitl_gazebo;
|
||||
git -C ${WORKSPACE}/colcon_ws/src/Firmware submodule update --init --recursive --force Tools/simulation/gazebo/sitl_gazebo;
|
||||
git -C ${WORKSPACE}/colcon_ws/src/Firmware fetch --tags;
|
||||
source /opt/ros/foxy/setup.sh;
|
||||
colcon build --event-handlers console_direct+ --symlink-install;
|
||||
@@ -297,10 +297,10 @@ pipeline {
|
||||
sh('make distclean; git clean -ff -x -d .')
|
||||
withCredentials([usernamePassword(credentialsId: 'px4buildbot_github_personal_token', passwordVariable: 'GIT_PASS', usernameVariable: 'GIT_USER')]) {
|
||||
sh("git clone https://${GIT_USER}:${GIT_PASS}@github.com/PX4/px4_msgs.git")
|
||||
// 'master' branch
|
||||
// 'main' branch
|
||||
sh('./msg/tools/uorb_to_ros_msgs.py msg/ px4_msgs/msg/')
|
||||
sh('cd px4_msgs; git status; git add .; git commit -a -m "Update message definitions `date`" || true')
|
||||
sh('cd px4_msgs; git push origin master || true')
|
||||
sh('cd px4_msgs; git push origin main || true')
|
||||
// 'ros1' branch
|
||||
sh('cd px4_msgs; git checkout ros1')
|
||||
sh('./msg/tools/uorb_to_ros_msgs.py msg/ px4_msgs/msg/')
|
||||
|
||||
@@ -129,57 +129,59 @@ else
|
||||
BUILD_DIR_SUFFIX :=
|
||||
endif
|
||||
|
||||
CMAKE_ARGS ?=
|
||||
|
||||
# additional config parameters passed to cmake
|
||||
ifdef EXTERNAL_MODULES_LOCATION
|
||||
CMAKE_ARGS += -DEXTERNAL_MODULES_LOCATION:STRING=$(EXTERNAL_MODULES_LOCATION)
|
||||
override CMAKE_ARGS += -DEXTERNAL_MODULES_LOCATION:STRING=$(EXTERNAL_MODULES_LOCATION)
|
||||
endif
|
||||
|
||||
ifdef PX4_CMAKE_BUILD_TYPE
|
||||
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=${PX4_CMAKE_BUILD_TYPE}
|
||||
override CMAKE_ARGS += -DCMAKE_BUILD_TYPE=${PX4_CMAKE_BUILD_TYPE}
|
||||
else
|
||||
|
||||
# Address Sanitizer
|
||||
ifdef PX4_ASAN
|
||||
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=AddressSanitizer
|
||||
override CMAKE_ARGS += -DCMAKE_BUILD_TYPE=AddressSanitizer
|
||||
endif
|
||||
|
||||
# Memory Sanitizer
|
||||
ifdef PX4_MSAN
|
||||
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=MemorySanitizer
|
||||
override CMAKE_ARGS += -DCMAKE_BUILD_TYPE=MemorySanitizer
|
||||
endif
|
||||
|
||||
# Thread Sanitizer
|
||||
ifdef PX4_TSAN
|
||||
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=ThreadSanitizer
|
||||
override CMAKE_ARGS += -DCMAKE_BUILD_TYPE=ThreadSanitizer
|
||||
endif
|
||||
|
||||
# Undefined Behavior Sanitizer
|
||||
ifdef PX4_UBSAN
|
||||
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=UndefinedBehaviorSanitizer
|
||||
override CMAKE_ARGS += -DCMAKE_BUILD_TYPE=UndefinedBehaviorSanitizer
|
||||
endif
|
||||
|
||||
# Fuzz Testing
|
||||
ifdef PX4_FUZZ
|
||||
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=FuzzTesting
|
||||
override CMAKE_ARGS += -DCMAKE_BUILD_TYPE=FuzzTesting
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
# Pick up specific Python path if set
|
||||
ifdef PYTHON_EXECUTABLE
|
||||
CMAKE_ARGS += -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
|
||||
override CMAKE_ARGS += -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
|
||||
endif
|
||||
|
||||
# Check if the microRTPS agent is to be built
|
||||
ifdef BUILD_MICRORTPS_AGENT
|
||||
CMAKE_ARGS += -DBUILD_MICRORTPS_AGENT=ON
|
||||
override CMAKE_ARGS += -DBUILD_MICRORTPS_AGENT=ON
|
||||
endif
|
||||
|
||||
# Functions
|
||||
# --------------------------------------------------------------------
|
||||
# describe how to build a cmake config
|
||||
define cmake-build
|
||||
$(eval CMAKE_ARGS += -DCONFIG=$(1))
|
||||
$(eval override CMAKE_ARGS += -DCONFIG=$(1))
|
||||
@$(eval BUILD_DIR = "$(SRC_DIR)/build/$(1)")
|
||||
@# check if the desired cmake configuration matches the cache then CMAKE_CACHE_CHECK stays empty
|
||||
@$(call cmake-cache-check)
|
||||
@@ -314,7 +316,9 @@ uorb_graphs:
|
||||
@$(MAKE) --no-print-directory px4_fmu-v5_default uorb_graph
|
||||
@$(MAKE) --no-print-directory px4_sitl_default uorb_graph
|
||||
|
||||
px4io_update: px4_io-v2_default cubepilot_io-v2_default
|
||||
px4io_update:
|
||||
@$(MAKE) --no-print-directory px4_io-v2_default
|
||||
@$(MAKE) --no-print-directory cubepilot_io-v2_default
|
||||
# px4_io-v2_default
|
||||
cp build/px4_io-v2_default/px4_io-v2_default.bin boards/holybro/durandal-v1/extras/px4_io-v2_default.bin
|
||||
cp build/px4_io-v2_default/px4_io-v2_default.bin boards/holybro/pix32v5/extras/px4_io-v2_default.bin
|
||||
@@ -381,7 +385,7 @@ format:
|
||||
.PHONY: rostest python_coverage
|
||||
|
||||
tests:
|
||||
$(eval CMAKE_ARGS += -DTESTFILTER=$(TESTFILTER))
|
||||
$(eval override CMAKE_ARGS += -DTESTFILTER=$(TESTFILTER))
|
||||
$(eval ARGS += test_results)
|
||||
$(eval ASAN_OPTIONS += color=always:check_initialization_order=1:detect_stack_use_after_return=1)
|
||||
$(eval UBSAN_OPTIONS += color=always)
|
||||
|
||||
@@ -30,4 +30,3 @@ param set-default PWM_MAIN_FUNC1 101
|
||||
param set-default PWM_MAIN_FUNC2 102
|
||||
param set-default PWM_MAIN_FUNC3 103
|
||||
param set-default PWM_MAIN_FUNC4 104
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
. ${R}etc/init.d/rc.mc_defaults
|
||||
|
||||
PX4_SIMULATOR=${PX4_SIMULATOR:=sihsim}
|
||||
PX4_SIM_MODEL=${PX4_SIM_MODEL:=quadx}
|
||||
|
||||
# disable some checks to allow to fly:
|
||||
# - with usb
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
. ${R}etc/init.d/rc.fw_defaults
|
||||
|
||||
PX4_SIMULATOR=${PX4_SIMULATOR:=sihsim}
|
||||
PX4_SIM_MODEL=${PX4_SIM_MODEL:=airplane}
|
||||
|
||||
# disable some checks to allow to fly:
|
||||
# - with usb
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
|
||||
. ${R}etc/init.d/rc.vtol_defaults
|
||||
|
||||
PX4_SIMULATOR=${PX4_SIMULATOR:=sihsim}
|
||||
PX4_SIM_MODEL=${PX4_SIM_MODEL:=xvert}
|
||||
|
||||
param set-default VT_ELEV_MC_LOCK 0
|
||||
param set-default VT_TYPE 0
|
||||
param set-default VT_FW_DIFTHR_EN 1
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
# EKF2
|
||||
param set-default EKF2_AID_MASK 2
|
||||
param set-default EKF2_GPS_CTRL 0
|
||||
param set-default EKF2_EVP_NOISE 0.05
|
||||
param set-default EKF2_EVA_NOISE 0.05
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
# EKF2: Vision position and heading
|
||||
param set-default EKF2_AID_MASK 24
|
||||
param set-default EKF2_EV_DELAY 5
|
||||
param set-default EKF2_GPS_CTRL 0
|
||||
|
||||
# LPE: Vision + baro
|
||||
param set-default LPE_FUSION 132
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
# EKF2
|
||||
param set-default EKF2_AID_MASK 2
|
||||
param set-default EKF2_GPS_CTRL 0
|
||||
|
||||
# LPE: Flow-only mode
|
||||
param set-default LPE_FUSION 242
|
||||
|
||||
@@ -10,3 +10,4 @@
|
||||
# EKF2: Vision velocity and heading
|
||||
param set-default EKF2_AID_MASK 272
|
||||
param set-default EKF2_EV_DELAY 5
|
||||
param set-default EKF2_GPS_CTRL 0
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# @name Ignition Gazebo X3
|
||||
#
|
||||
# @type Quadrotor
|
||||
#
|
||||
|
||||
. ${R}etc/init.d/rc.mc_defaults
|
||||
|
||||
PX4_SIMULATOR=${PX4_SIMULATOR:=ignition}
|
||||
PX4_SIM_MODEL=${PX4_SIM_MODEL:=x500}
|
||||
PX4_SIM_WORLD=${PX4_SIM_WORLD:=default}
|
||||
|
||||
param set-default SYS_CTRL_ALLOC 1
|
||||
|
||||
param set-default CA_AIRFRAME 0
|
||||
param set-default CA_ROTOR_COUNT 4
|
||||
|
||||
param set-default CA_ROTOR0_PX 0.13
|
||||
param set-default CA_ROTOR0_PY 0.22
|
||||
param set-default CA_ROTOR0_KM 0.05
|
||||
|
||||
param set-default CA_ROTOR1_PX -0.13
|
||||
param set-default CA_ROTOR1_PY -0.20
|
||||
param set-default CA_ROTOR1_KM 0.05
|
||||
|
||||
param set-default CA_ROTOR2_PX 0.13
|
||||
param set-default CA_ROTOR2_PY -0.22
|
||||
param set-default CA_ROTOR2_KM -0.05
|
||||
|
||||
param set-default CA_ROTOR3_PX -0.13
|
||||
param set-default CA_ROTOR3_PY 0.20
|
||||
param set-default CA_ROTOR3_KM -0.05
|
||||
|
||||
param set-default SIM_IGN_FUNC1 101
|
||||
param set-default SIM_IGN_FUNC2 102
|
||||
param set-default SIM_IGN_FUNC3 103
|
||||
param set-default SIM_IGN_FUNC4 104
|
||||
|
||||
param set-default SIM_IGN_MIN1 150
|
||||
param set-default SIM_IGN_MIN2 150
|
||||
param set-default SIM_IGN_MIN3 150
|
||||
param set-default SIM_IGN_MIN4 150
|
||||
|
||||
param set-default SIM_IGN_MAX1 1000
|
||||
param set-default SIM_IGN_MAX2 1000
|
||||
param set-default SIM_IGN_MAX3 1000
|
||||
param set-default SIM_IGN_MAX4 1000
|
||||
|
||||
param set-default MPC_THR_HOVER 0.60
|
||||
@@ -72,9 +72,13 @@ px4_add_romfs_files(
|
||||
1070_boat
|
||||
3010_quadrotor_x
|
||||
3011_hexarotor_x
|
||||
|
||||
4001_x500
|
||||
|
||||
17001_tf-g1
|
||||
17002_tf-g2
|
||||
2507_cloudship
|
||||
|
||||
6011_typhoon_h480
|
||||
6011_typhoon_h480.post
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ mavlink start -x -u $udp_onboard_payload_port_local -r 4000 -f -m onboard -o $ud
|
||||
mavlink start -x -u $udp_onboard_gimbal_port_local -r 400000 -m gimbal -o $udp_onboard_gimbal_port_remote
|
||||
|
||||
# To display for SIH sitl
|
||||
if [ "$SIM_MODE" = "sihsim" ]; then
|
||||
if [ "$PX4_SIMULATOR" = "sihsim" ]; then
|
||||
udp_sihsim_port_local=$((19450+px4_instance))
|
||||
udp_sihsim_port_remote=$((19410+px4_instance))
|
||||
mavlink start -x -u $udp_sihsim_port_local -r 400000 -m custom -o $udp_sihsim_port_remote
|
||||
|
||||
@@ -1,20 +1,92 @@
|
||||
#!/bin/sh
|
||||
# shellcheck disable=SC2154
|
||||
|
||||
simulator_tcp_port=$((4560+px4_instance))
|
||||
# Simulator IMU data provided at 250 Hz
|
||||
param set-default IMU_INTEG_RATE 250
|
||||
|
||||
if [ "$PX4_SIMULATOR" = "sihsim" ] || [ "$(param show -q SYS_AUTOSTART)" -eq "0" ]; then
|
||||
|
||||
if ! simulator_sih start; then
|
||||
echo "ERROR [init] simulator_sih failed to start"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [ "$PX4_SIMULATOR" = "ignition" ]; then
|
||||
|
||||
# source generated gazebo_env.sh for IGN_GAZEBO_RESOURCE_PATH
|
||||
if [ -f gazebo_env.sh ]; then
|
||||
. ./gazebo_env.sh
|
||||
elif [ -f ../gazebo_env.sh ]; then
|
||||
. ../gazebo_env.sh
|
||||
fi
|
||||
|
||||
ign_world=$( ign topic -l | grep -m 1 -e "/world/.*/clock" | sed 's/\/world\///g; s/\/clock//g' )
|
||||
|
||||
if [ -z $ign_world ]; then
|
||||
|
||||
# starting ign gazebo with ${PX4_SIM_WORLD} world
|
||||
echo "INFO [init] starting ign gazebo"
|
||||
|
||||
if [ -z $HEADLESS ]; then
|
||||
ign gazebo --verbose=1 -r "${PX4_IGN_GAZEBO_WORLDS}/${PX4_SIM_WORLD}.sdf" &
|
||||
else
|
||||
# starting ign gazebo headless
|
||||
ign gazebo --verbose=1 -r -s "${PX4_IGN_GAZEBO_WORLDS}/${PX4_SIM_WORLD}.sdf" &
|
||||
fi
|
||||
else
|
||||
echo "INFO [init] ign gazebo already running world: $ign_world"
|
||||
PX4_SIM_WORLD=$ign_world
|
||||
fi
|
||||
|
||||
if [ -z $PX4_IGN_MODEL_POSE ]; then
|
||||
# start ignition bridge without pose arg.
|
||||
echo "WARN [init] PX4_IGN_MODEL_POSE not set, spawning at origin."
|
||||
if simulator_ignition_bridge start -m "${PX4_SIM_MODEL}" -w "${PX4_SIM_WORLD}"; then
|
||||
sensor_baro_sim start
|
||||
sensor_gps_sim start
|
||||
sensor_mag_sim start
|
||||
else
|
||||
echo "ERROR [init] ign gazebo failed to start"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
|
||||
# Clean potential input line formatting.
|
||||
model_pose="$( echo ${PX4_IGN_MODEL_POSE} | sed -e 's/^[ \t]*//; s/[ \t]*$//; s/,/ /g; s/ / /g; s/ /,/g' )"
|
||||
echo "INFO [init] PX4_IGN_MODEL_POSE set, spawning at: ${model_pose}"
|
||||
|
||||
# start ignition bridge with pose arg.
|
||||
if simulator_ignition_bridge start -p "${model_pose}" -m "${PX4_SIM_MODEL}" -w "${PX4_SIM_WORLD}"; then
|
||||
sensor_baro_sim start
|
||||
sensor_gps_sim start
|
||||
sensor_mag_sim start
|
||||
else
|
||||
echo "ERROR [init] ign gazebo failed to start"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# Check if PX4_SIM_HOSTNAME environment variable is empty
|
||||
# If empty check if PX4_SIM_HOST_ADDR environment variable is empty
|
||||
# If both are empty use localhost for simulator
|
||||
if [ -z "${PX4_SIM_HOSTNAME}" ]; then
|
||||
if [ -z "${PX4_SIM_HOST_ADDR}" ]; then
|
||||
echo "PX4 SIM HOST: localhost"
|
||||
simulator start -c $simulator_tcp_port
|
||||
else
|
||||
echo "PX4 SIM HOST: $PX4_SIM_HOST_ADDR"
|
||||
simulator start -t $PX4_SIM_HOST_ADDR $simulator_tcp_port
|
||||
fi
|
||||
else
|
||||
echo "PX4 SIM HOST: $PX4_SIM_HOSTNAME"
|
||||
simulator start -h $PX4_SIM_HOSTNAME $simulator_tcp_port
|
||||
# otherwise start simulator (mavlink) module
|
||||
simulator_tcp_port=$((4560+px4_instance))
|
||||
|
||||
# Check if PX4_SIM_HOSTNAME environment variable is empty
|
||||
# If empty check if PX4_SIM_HOST_ADDR environment variable is empty
|
||||
# If both are empty use localhost for simulator
|
||||
if [ -z "${PX4_SIM_HOSTNAME}" ]; then
|
||||
|
||||
if [ -z "${PX4_SIM_HOST_ADDR}" ]; then
|
||||
echo "PX4 SIM HOST: localhost"
|
||||
simulator_mavlink start -c $simulator_tcp_port
|
||||
else
|
||||
echo "PX4 SIM HOST: $PX4_SIM_HOST_ADDR"
|
||||
simulator_mavlink start -t $PX4_SIM_HOST_ADDR $simulator_tcp_port
|
||||
fi
|
||||
|
||||
else
|
||||
echo "PX4 SIM HOST: $PX4_SIM_HOSTNAME"
|
||||
simulator_mavlink start -h $PX4_SIM_HOSTNAME $simulator_tcp_port
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
@@ -30,6 +30,7 @@ set MIXER_FILE none
|
||||
set OUTPUT_MODE sim
|
||||
set EXTRA_MIXER_MODE none
|
||||
set PWM_OUT none
|
||||
set PWM_AUX_OUT none
|
||||
set SDCARD_MIXERS_PATH etc/mixers
|
||||
set USE_IO no
|
||||
set VEHICLE_TYPE none
|
||||
@@ -38,10 +39,24 @@ set LOGGER_BUF 1000
|
||||
|
||||
set RUN_MINIMAL_SHELL no
|
||||
|
||||
# Use the variable set by sitl_run.sh to choose the model settings.
|
||||
if [ "$PX4_SIM_MODEL" = "shell" ]; then
|
||||
set SYS_AUTOSTART=0
|
||||
|
||||
if [ "$PX4_SIM_MODEL" = "shell" ]
|
||||
then
|
||||
set RUN_MINIMAL_SHELL yes
|
||||
else
|
||||
|
||||
elif [ -n "$PX4_SYS_AUTOSTART" ]
|
||||
then
|
||||
echo "env SYS_AUTOSTART: ${PX4_SYS_AUTOSTART}"
|
||||
SYS_AUTOSTART=${PX4_SYS_AUTOSTART}
|
||||
|
||||
elif [ "$PX4_SIM_MODEL" = "none" ] || [ -z $PX4_SIM_MODEL ]
|
||||
then
|
||||
# no airframe selected
|
||||
SYS_AUTOSTART=0
|
||||
|
||||
elif [ -n "$PX4_SIM_MODEL" ]
|
||||
then
|
||||
# Find the matching Autostart ID (file name has the form: [0-9]+_${PX4_SIM_MODEL})
|
||||
# TODO: unify with rc.autostart generation
|
||||
# shellcheck disable=SC2012
|
||||
@@ -50,12 +65,13 @@ else
|
||||
echo "ERROR [init] Unknown model $PX4_SIM_MODEL (not found by name on ${R}etc/init.d-posix/airframes)"
|
||||
exit 1
|
||||
else
|
||||
SYS_AUTOSTART=$REQUESTED_AUTOSTART
|
||||
echo "INFO [init] found model autostart file as SYS_AUTOSTART=$REQUESTED_AUTOSTART"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Load parameters
|
||||
set PARAM_FILE eeprom/parameters_"$REQUESTED_AUTOSTART"
|
||||
set PARAM_FILE parameters.bson
|
||||
param select $PARAM_FILE
|
||||
|
||||
if [ -f $PARAM_FILE ]
|
||||
@@ -66,26 +82,16 @@ then
|
||||
else
|
||||
echo "[param] FAILED loading $PARAM_FILE"
|
||||
fi
|
||||
else
|
||||
echo "[param] parameter file not found, creating $PARAM_FILE"
|
||||
fi
|
||||
|
||||
# exit early when the minimal shell is requested
|
||||
[ $RUN_MINIMAL_SHELL = yes ] && exit 0
|
||||
|
||||
if param compare SYS_AUTOSTART $SYS_AUTOSTART
|
||||
then
|
||||
set AUTOCNF no
|
||||
|
||||
# Use environment variable PX4_ESTIMATOR to choose estimator.
|
||||
if [ "$PX4_ESTIMATOR" = "q" ]; then
|
||||
param set SYS_MC_EST_GROUP 3
|
||||
elif [ "$PX4_ESTIMATOR" = "ekf2" ]; then
|
||||
param set SYS_MC_EST_GROUP 2
|
||||
elif [ "$PX4_ESTIMATOR" = "lpe" ]; then
|
||||
param set SYS_MC_EST_GROUP 1
|
||||
elif [ "$PX4_ESTIMATOR" = "inav" ]; then
|
||||
param set SYS_MC_EST_GROUP 0
|
||||
fi
|
||||
|
||||
if param compare SYS_AUTOSTART $REQUESTED_AUTOSTART
|
||||
elif [ "$SYS_AUTOSTART" -eq 0 ]
|
||||
then
|
||||
set AUTOCNF no
|
||||
else
|
||||
@@ -106,7 +112,7 @@ param set MAV_SYS_ID $((px4_instance+1))
|
||||
|
||||
if [ $AUTOCNF = yes ]
|
||||
then
|
||||
param set SYS_AUTOSTART $REQUESTED_AUTOSTART
|
||||
param set SYS_AUTOSTART $SYS_AUTOSTART
|
||||
|
||||
param set CAL_ACC0_ID 1310988 # 1310988: DRV_IMU_DEVTYPE_SIM, BUS: 1, ADDR: 1, TYPE: SIMULATION
|
||||
param set CAL_GYRO0_ID 1310988 # 1310988: DRV_IMU_DEVTYPE_SIM, BUS: 1, ADDR: 1, TYPE: SIMULATION
|
||||
@@ -143,6 +149,7 @@ param set-default EKF2_MULTI_MAG 2
|
||||
param set-default SENS_MAG_MODE 0
|
||||
|
||||
param set-default IMU_GYRO_FFT_EN 1
|
||||
param set-default MAV_PROTO_VER 2 # Ensures QGC does not drop the first few packets after a SITL restart due to MAVLINK 1 packets
|
||||
|
||||
param set-default -s MC_AT_EN 1
|
||||
|
||||
@@ -190,28 +197,28 @@ do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ ! -e "$autostart_file" ]; then
|
||||
|
||||
if [ -e "$autostart_file" ]
|
||||
then
|
||||
. "$autostart_file"
|
||||
|
||||
elif [ ! -e "$autostart_file" ] && [ "$SYS_AUTOSTART" -ne "0" ]
|
||||
then
|
||||
echo "Error: no autostart file found ($autostart_file)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. "$autostart_file"
|
||||
|
||||
# Simulator IMU data provided at 250 Hz
|
||||
param set IMU_INTEG_RATE 250
|
||||
|
||||
#user defined params for instances can be in PATH
|
||||
. px4-rc.params
|
||||
|
||||
dataman start
|
||||
# start sih in sih_sim mode, otherwise simulator module
|
||||
if [ "$SIM_MODE" = "sihsim" ]; then
|
||||
sih start
|
||||
|
||||
# only start the simulator if not in replay mode, as both control the lockstep time
|
||||
elif ! replay tryapplyparams
|
||||
if ! replay tryapplyparams
|
||||
then
|
||||
. px4-rc.simulator
|
||||
. px4-rc.simulator
|
||||
fi
|
||||
|
||||
load_mon start
|
||||
battery_simulator start
|
||||
tone_alarm start
|
||||
@@ -255,6 +262,12 @@ then
|
||||
gyro_calibration start
|
||||
fi
|
||||
|
||||
# Payload deliverer module if gripper is enabled
|
||||
if param compare -s PD_GRIPPER_EN 1
|
||||
then
|
||||
payload_deliverer start
|
||||
fi
|
||||
|
||||
#user defined mavlink streams for instances can be in PATH
|
||||
. px4-rc.mavlink
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ px4_add_romfs_files(
|
||||
rc.boat_defaults
|
||||
rc.fw_apps
|
||||
rc.fw_defaults
|
||||
rc.heli_defaults
|
||||
rc.interface
|
||||
rc.logging
|
||||
rc.mc_apps
|
||||
|
||||
@@ -1,55 +1,27 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# @name Blade 130X
|
||||
# @name Generic Helicopter (Tail ESC)
|
||||
#
|
||||
# @type Helicopter
|
||||
# @class Copter
|
||||
#
|
||||
# @maintainer Bart Slinger <bartslinger@gmail.com>
|
||||
#
|
||||
# @output Motor1 main motor
|
||||
# @output Servo1 front swashplate servo
|
||||
# @output Servo2 right swashplate servo
|
||||
# @output Servo3 left swashplate servo
|
||||
# @output Servo4 tail-rotor servo
|
||||
#
|
||||
# @board px4_fmu-v2 exclude
|
||||
# @board bitcraze_crazyflie exclude
|
||||
#
|
||||
|
||||
. ${R}etc/init.d/rc.mc_defaults
|
||||
|
||||
# Configure as helicopter
|
||||
param set-default MAV_TYPE 4
|
||||
. ${R}etc/init.d/rc.heli_defaults
|
||||
|
||||
|
||||
|
||||
param set-default ATT_BIAS_MAX 0
|
||||
|
||||
param set-default CBRK_IO_SAFETY 22027
|
||||
|
||||
param set-default MC_ROLL_P 5
|
||||
# Disable PID gains for initial setup. These should be enabled after setting the FF gain.
|
||||
# P is expected to be lower than FF.
|
||||
param set-default MC_ROLLRATE_P 0
|
||||
param set-default MC_ROLLRATE_I 0
|
||||
param set-default MC_ROLLRATE_D 0
|
||||
param set-default MC_ROLLRATE_FF 0.15
|
||||
param set-default MC_ROLLRATE_FF 0.1
|
||||
param set-default MC_PITCHRATE_P 0
|
||||
param set-default MC_PITCHRATE_I 0
|
||||
param set-default MC_PITCHRATE_D 0
|
||||
param set-default MC_PITCHRATE_FF 0.15
|
||||
param set-default MC_YAW_P 3
|
||||
param set-default MC_YAWRATE_P 0.1
|
||||
param set-default MC_YAWRATE_I 0
|
||||
param set-default MC_ROLLRATE_MAX 720
|
||||
param set-default MC_PITCHRATE_MAX 720
|
||||
param set-default MC_YAWRATE_MAX 400
|
||||
param set-default MC_ACRO_R_MAX 360
|
||||
param set-default MC_ACRO_P_MAX 360
|
||||
|
||||
param set-default MPC_THR_MIN 0.06
|
||||
param set-default MPC_MANTHR_MIN 0.06
|
||||
|
||||
param set-default PWM_MAIN_MIN 1075
|
||||
param set-default MC_PITCHRATE_FF 0.1
|
||||
|
||||
param set-default CA_AIRFRAME 10
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ 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
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# @name Holybro X500 V2
|
||||
#
|
||||
# @type Quadrotor x
|
||||
# @class Copter
|
||||
#
|
||||
# @maintainer Farhang Naderi <farhang.nba@gmail.com>
|
||||
#
|
||||
# @board px4_fmu-v2 exclude
|
||||
# @board bitcraze_crazyflie exclude
|
||||
#
|
||||
|
||||
. ${R}etc/init.d/rc.mc_defaults
|
||||
|
||||
param set-default IMU_GYRO_CUTOFF 30
|
||||
|
||||
param set-default MC_ROLLRATE_P 0.14
|
||||
param set-default MC_PITCHRATE_P 0.14
|
||||
param set-default MC_ROLLRATE_I 0.3
|
||||
param set-default MC_PITCHRATE_I 0.3
|
||||
param set-default MC_ROLLRATE_D 0.004
|
||||
param set-default MC_PITCHRATE_D 0.004
|
||||
|
||||
param set-default CA_ROTOR_COUNT 4
|
||||
param set-default CA_ROTOR0_PX 0.25
|
||||
param set-default CA_ROTOR0_PY 0.25
|
||||
param set-default CA_ROTOR1_PX -0.25
|
||||
param set-default CA_ROTOR1_PY -0.25
|
||||
param set-default CA_ROTOR2_PX 0.25
|
||||
param set-default CA_ROTOR2_PY -0.25
|
||||
param set-default CA_ROTOR2_KM -0.05
|
||||
param set-default CA_ROTOR3_PX -0.25
|
||||
param set-default CA_ROTOR3_PY 0.25
|
||||
param set-default CA_ROTOR3_KM -0.05
|
||||
@@ -26,7 +26,6 @@ param set-default MC_ROLLRATE_MAX 1600
|
||||
param set-default MC_PITCHRATE_MAX 1600
|
||||
param set-default MC_YAWRATE_MAX 1000
|
||||
|
||||
param set-default MPC_MANTHR_MIN 0
|
||||
param set-default MPC_MAN_TILT_MAX 60
|
||||
|
||||
param set-default THR_MDL_FAC 0.3
|
||||
|
||||
@@ -73,7 +73,7 @@ param set-default EKF2_PCOEF_YN -0.4
|
||||
param set-default EKF2_PCOEF_YP -0.4
|
||||
|
||||
param set-default EKF2_RNG_A_VMAX 1.0
|
||||
param set-default EKF2_RNG_AID 0
|
||||
param set-default EKF2_RNG_CTRL 0
|
||||
param set-default EKF2_RNG_DELAY 55
|
||||
param set-default EKF2_RNG_POS_X -0.035
|
||||
param set-default EKF2_RNG_POS_Y 0.0
|
||||
|
||||
@@ -38,7 +38,7 @@ param set-default SENS_BOARD_ROT 10
|
||||
|
||||
# EKF2
|
||||
param set-default EKF2_GND_EFF_DZ 6
|
||||
param set-default EKF2_HGT_MODE 1
|
||||
param set-default EKF2_HGT_REF 1
|
||||
|
||||
# Position control
|
||||
param set-default MPC_Z_P 1
|
||||
|
||||
@@ -42,7 +42,7 @@ param set-default SENS_EN_BATT 1
|
||||
# EKF2
|
||||
param set-default EKF2_AID_MASK 3
|
||||
param set-default EKF2_GND_EFF_DZ 6
|
||||
param set-default EKF2_HGT_MODE 1
|
||||
param set-default EKF2_HGT_REF 1
|
||||
param set-default EKF2_MIN_RNG 0.3
|
||||
|
||||
# Flow
|
||||
|
||||
@@ -26,7 +26,8 @@ param set-default COM_RC_IN_MODE 1
|
||||
|
||||
param set-default EKF2_ABL_LIM 2
|
||||
param set-default EKF2_AID_MASK 3
|
||||
param set-default EKF2_HGT_MODE 2
|
||||
param set-default EKF2_HGT_REF 2
|
||||
param set-default EKF2_RNG_CTRL 2
|
||||
param set-default EKF2_MAG_TYPE 1
|
||||
param set-default EKF2_OF_DELAY 10
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
param set-default SYS_MC_EST_GROUP 2
|
||||
param set-default SYS_HAS_MAG 0
|
||||
param set-default EKF2_AID_MASK 2
|
||||
param set-default EKF2_GPS_CTRL 0
|
||||
param set-default EKF2_MAG_TYPE 5
|
||||
|
||||
param set-default BAT1_N_CELLS 1
|
||||
|
||||
@@ -71,7 +71,7 @@ param set-default MIS_TAKEOFF_ALT 1.1
|
||||
# EKF
|
||||
#####################################
|
||||
# Height mode as GPS
|
||||
param set-default EKF2_HGT_MODE 1
|
||||
param set-default EKF2_HGT_REF 1
|
||||
# Enable optical flow and GPS
|
||||
param set-default EKF2_MAG_TYPE 1
|
||||
param set-default EKF2_OF_QMIN 80
|
||||
|
||||
@@ -56,6 +56,7 @@ px4_add_romfs_files(
|
||||
4015_holybro_s500
|
||||
4016_holybro_px4vision
|
||||
4017_nxp_hovergames
|
||||
4019_x500_v2
|
||||
4040_reaper
|
||||
4041_beta75x
|
||||
4050_generic_250
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Helicopter default parameters.
|
||||
#
|
||||
# NOTE: Script variables are declared/initialized/unset in the rcS script.
|
||||
#
|
||||
|
||||
# Inherit from mc
|
||||
. ${R}etc/init.d/rc.mc_defaults
|
||||
|
||||
param set-default MAV_TYPE 4
|
||||
|
||||
param set-default COM_PREARM_MODE 2
|
||||
param set-default COM_SPOOLUP_TIME 10
|
||||
|
||||
# No need for minimum collective pitch (or airmode) to keep torque authority
|
||||
param set-default MPC_MANTHR_MIN 0
|
||||
@@ -368,7 +368,7 @@ else
|
||||
# start the simulator in hardware if needed
|
||||
if param compare SYS_HITL 2
|
||||
then
|
||||
sih start
|
||||
simulator_sih start
|
||||
fi
|
||||
|
||||
else
|
||||
@@ -505,6 +505,12 @@ else
|
||||
px4flow start -X &
|
||||
fi
|
||||
|
||||
# Payload deliverer module if gripper is enabled
|
||||
if param compare -s PD_GRIPPER_EN 1
|
||||
then
|
||||
payload_deliverer start
|
||||
fi
|
||||
|
||||
#
|
||||
# Optional board supplied extras: rc.board_extras
|
||||
#
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Aileron/rudder/elevator/throttle/wheel/flaps mixer for PX4FMU
|
||||
=======================================================
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Aileron/v-tail/throttle/wheel/flaps mixer for PX4FMU
|
||||
=======================================================
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Aileron/v-tail/throttle/wheel/flaps mixer for PX4FMU
|
||||
=======================================================
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Aileron/rudder/elevator/throttle mixer for PX4FMU
|
||||
==================================================
|
||||
|
||||
@@ -73,4 +74,4 @@ Ch6: Landing gear mixer
|
||||
By default pass-through of gear switch
|
||||
|
||||
M: 1
|
||||
S: 3 5 10000 10000 0 -10000 10000
|
||||
S: 3 5 10000 10000 0 -10000 10000
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Aileron/Elevator/Throttle/Rudder/Gear/Flaps mixer
|
||||
==================================================
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Helicopter 120 degree Cyclic-Collective-Pitch Mixing (CCPM) for PX4FMU
|
||||
==================================================
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Passthrough mixer for PX4IO
|
||||
============================
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Coaxial helicopter mixer
|
||||
- Two servomotors act on the swashplate (90 degree angle on the swashplate, decoupled effect on roll and pitch).
|
||||
- No collective pitch.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Generic wing mixer
|
||||
===========================
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Generic differential-drive rover
|
||||
===========================
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
# Hexa +
|
||||
|
||||
R: 6+
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
# Hexa coaxial
|
||||
|
||||
R: 6c
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
# Hexa X
|
||||
|
||||
R: 6x
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
# Mount Mixer (e.g. Gimbal, servo-controlled gimbal, etc...)
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
# Octo +
|
||||
|
||||
R: 8+
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
# Octo coaxial
|
||||
|
||||
R: 8c
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
# Octo X
|
||||
|
||||
R: 8x
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
# Manual pass through mixer for servo outputs 1-4
|
||||
|
||||
# AUX1 channel (select RC channel with RC_MAP_AUX1 param)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Multirotor mixer for PX4FMU
|
||||
===========================
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Mixer for Tailsitter with + motor configuration and elevons
|
||||
===========================================================
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Multirotor mixer
|
||||
===========================
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Multirotor mixer for PX4FMU
|
||||
===========================
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Multirotor mixer for PX4FMU
|
||||
===========================
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
R: 4x
|
||||
|
||||
AUX1 Passthrough
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Mixer for an AAERT VTOL
|
||||
=======================
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Generic car mixer (eg DF Robot GPX:Asurada RC Car)
|
||||
===========================
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Generic car mixer (eg Traxxas Stampede RC Car)
|
||||
===========================
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
|
||||
|
||||
# Tricopter Y-Configuration Mixer
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
|
||||
|
||||
# Tricopter Y-Configuration Mixer
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# @board px4_fmu-v2 exclude
|
||||
Tailsitter duo mixer
|
||||
============================
|
||||
|
||||
|
||||
Regular → Executable
@@ -1,901 +0,0 @@
|
||||
#! /bin/bash
|
||||
|
||||
# Written by Carlo Wood, September/October 2016.
|
||||
|
||||
function fatal
|
||||
{
|
||||
echo "$0: ERROR: $*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Make sure we're not having a broken gawk.
|
||||
AWK_VERSION=$(awk -V | head -n 1)
|
||||
if [[ $AWK_VERSION =~ ^GNU\ Awk\ 4\.[0-9]+\.[0-9]+ ]]; then
|
||||
AWK_VERSION=$(echo $AWK_VERSION | sed -e 's/GNU Awk \(4\.[0-9]*\.[0-9]*\).*/\1/')
|
||||
if [[ $AWK_VERSION =~ ^4\.0*([2-9]+|1\.0*[2-9]+) ]]; then
|
||||
fatal "Your version of awk ($AWK_VERSION) is broken. Please use version 4.1.1 or lower."
|
||||
fi
|
||||
fi
|
||||
echo "AWK_VERSION=$AWK_VERSION"
|
||||
|
||||
# Find out what the base directory is.
|
||||
BASEDIR="$(dirname $(dirname $(readlink -en "$0")))"
|
||||
echo "BASEDIR=\"$BASEDIR\""
|
||||
striplen=$((${#BASEDIR} + 2))
|
||||
|
||||
# BASEDIR may not contain a space, that's just too hard to get to work.
|
||||
expr index "$BASEDIR" " " >/dev/null && fatal "it is not supported that BASEDIR contains a space."
|
||||
|
||||
# Make sure that worked.
|
||||
test -f $BASEDIR/cmake/posix/px4_impl_posix.cmake || fatal "Failed to determine BASEDIR: '\$BASEDIR/cmake/posix/px4_impl_posix.cmake' is not a regular file."
|
||||
|
||||
# Parse command line parameters.
|
||||
debug=0 # Set to non-zero to enable debugging.
|
||||
force=0 # Set to 1 to force running of script even when there are uncommitted changes.
|
||||
merge=0 # Set to 1 when merging a branch that didn't run this script into master that did already run this script.
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
--debug)
|
||||
debug=1
|
||||
;;
|
||||
--force)
|
||||
force=1
|
||||
;;
|
||||
--merge)
|
||||
force=1
|
||||
merge=1
|
||||
fatal "--merge is not implemented yet."
|
||||
;;
|
||||
-*)
|
||||
fatal "Unknown option $1"
|
||||
;;
|
||||
--|*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
non_option_arguments=$#
|
||||
if [ $non_option_arguments -eq 0 -a $debug -ne 0 ]; then
|
||||
fatal "--debug screws up the source files with debug output! You must provide a single filename to run on."
|
||||
fi
|
||||
|
||||
# Better not run this script with changes that still need to be committed.
|
||||
cd "$BASEDIR" || fatal "Could not change directory to \"$BASEDIR\""
|
||||
if ! git diff-index --quiet HEAD --; then
|
||||
if [ $non_option_arguments -ne 0 -o $force -eq 1 ]; then
|
||||
if [ $force -eq 1 ]; then
|
||||
echo "Uncommitted changes, but running anyway because --force is used."
|
||||
else
|
||||
echo -n "WARNING: You have uncommitted changes (use --force to remove this warning). Run anyway? [y/N] "
|
||||
read answer
|
||||
if [ "x$answer" != "xy" -a "x$answer" != "xY" ]; then exit 0; fi
|
||||
fi
|
||||
else
|
||||
fatal "Your working directory has uncommitted changes (see 'git status')! Bailing out."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Find a reasonable tmp directory.
|
||||
# First make a list of all build directories by looking for a CMakeCache.txt in them. Sort them so the most recent one is first.
|
||||
CMAKECACHE_FILES=$(find "$BASEDIR" -mindepth 2 -maxdepth 2 -type f -name CMakeCache.txt -wholename "$BASEDIR/build/*/CMakeCache.txt" | xargs /bin/ls -td)
|
||||
# Make a list of all candidate tmp directories.
|
||||
TMPDIRS=
|
||||
for f in $CMAKECACHE_FILES; do
|
||||
if [ -d $(dirname $f)/tmp ]; then
|
||||
TMPDIRS+=" $(dirname $f)/tmp"
|
||||
fi
|
||||
done
|
||||
# Put BASEDIR first in case there are no build directories because /tmp is probably on a different file system.
|
||||
TMPDIRS+=" $BASEDIR /tmp ."
|
||||
# Pick the first one that is actually writable.
|
||||
for tmp in $TMPDIRS; do
|
||||
TMPDIR="$tmp"
|
||||
if [ -w "$TMPDIR" ]; then
|
||||
break;
|
||||
fi
|
||||
done
|
||||
test -n "$TMPDIR" || fatal "Can not find a writable tmp directory."
|
||||
echo "TMPDIR=\"$TMPDIR\""
|
||||
|
||||
# Make a list of all source and header files that we need to fix.
|
||||
# List of directories that we don't want to touch.
|
||||
EXCLUDE_FOLDERS=".git Tools"
|
||||
EXCLUDE_PATTERNS="examples matlab/scripts tests test unit_test *_test *_tests test_* apps/test_* UnitTests"
|
||||
# A regular expression for the exclude patterns.
|
||||
EXCLUDE_PATTERNS_RE="($(echo $EXCLUDE_PATTERNS | sed -e 's/\*/[^\/]*/g;s/ /|/g'))"
|
||||
# Extensions of files that we do want to change (leaving out .y and .py for now).
|
||||
C_EXTENSIONS=".c .c_in .c_shipped"
|
||||
H_EXTENSIONS=".h .h.in .h_template"
|
||||
CXX_EXTENSIONS=".cc .cpp .cpp.in .cxx .cpp_template"
|
||||
HXX_EXTENSIONS=".hh .hpp .hxx"
|
||||
# The regular expression that we consider to be an #include.
|
||||
INCLUDE_RE='^[[:space:]]*#[[:space:]]*include[[:space:]]*[<"]'
|
||||
# Regular expression for empty lines.
|
||||
EMPTY_LINE_RE='^[[:space:]]*$'
|
||||
# Regular expression for one-line comments.
|
||||
COMMENT_LINE_RE='^[[:space:]]*(\/\/.*|\/\*([^*]|\*+[^\/*])*\*+\/[[:space:]]*)$'
|
||||
# Regular expression for a #define (on one line).
|
||||
DEFINE_RE='^[[:space:]]*#[[:space:]]*define[[:space:]].*[^\\]$'
|
||||
# Regular expression for an #if[[n]def].
|
||||
IF_RE='^[[:space:]]*#[[:space:]]*if(n?def)?[[:space:]]'
|
||||
# Regular expression for an #endif.
|
||||
ENDIF_RE='^[[:space:]]*#[[:space:]]*endif($|[^[:alnum:]])'
|
||||
# Regular expression for header file extension.
|
||||
HEADER_RE="($(echo $H_EXTENSIONS $HXX_EXTENSIONS | sed -e 's/\./\\./g;s/ /|/g'))"
|
||||
# Regular expression for C++ source and header files.
|
||||
CXXSRC_RE="($(echo $CXX_EXTENSIONS $HXX_EXTENSIONS | sed -e 's/\./\\./g;s/ /|/g'))"
|
||||
# List of standard C header files. Note that cfcntl, cshed and cunistd are NOT standard header files, even though they are in NuttX/nuttx/include/cxx.
|
||||
REAL_STDC_HEADERS_RE='(cassert|ccomplex|cctype|cerrno|cfenv|cfloat|cinttypes|ciso646|climits|clocale|cmath|csetjmp|csignal|cstdalign|cstdarg|cstdbool|cstddef|cstdint|cstdio|cstdlib|cstring|ctgmath|ctime|cuchar|cwchar|cwctype)'
|
||||
STDC_HEADERS=$(find "$BASEDIR/NuttX/nuttx/include/cxx" -mindepth 1 -maxdepth 1 -type f | xargs basename -a | grep -E "$REAL_STDC_HEADERS_RE" | xargs echo)
|
||||
# Regular expression of standard C header files, but with the leading 'c' stripped.
|
||||
STDC_HEADERS_RE="($(echo $STDC_HEADERS | sed -e 's/^c//;s/ c/|/g'))"
|
||||
# Actual list of standard C header files.
|
||||
# List of standard C++ header files.
|
||||
REAL_STDCXX_HEADERS_RE='(algorithm|any|array|atomic|bitset|cassert|ccomplex|cctype|cerrno|cfenv|cfloat|chrono|cinttypes|ciso646|climits|clocale|cmath|codecvt|complex|condition_variable|csetjmp|csignal|cstdalign|cstdarg|cstdbool|cstddef|cstdint|cstdio|cstdlib|cstring|ctgmath|ctime|cuchar|cwchar|cwctype|deque|exception|execution|filesystem|forward_list|fstream|functional|future|initializer_list|iomanip|ios|iosfwd|iostream|istream|iterator|limits|list|locale|map|memory|memory_resource|mutex|new|numeric|optional|ostream|queue|random|ratio|regex|scoped_allocator|set|shared_mutex|sstream|stack|stdexcept|streambuf|string|string_view|strstream|system_error|thread|tuple|typeindex|typeinfo|type_traits|unordered_map|unordered_set|utility|valarray|variant|vector)'
|
||||
STDCXX_HEADERS=$(find "$BASEDIR/NuttX/misc/uClibc++/include/uClibc++" -mindepth 1 -maxdepth 1 -type f | xargs basename -a | grep -E "$REAL_STDCXX_HEADERS_RE" | grep -E -v "$REAL_STDC_HEADERS_RE" | xargs echo)
|
||||
# Regular expression of C++ header files.
|
||||
STDCXX_HEADERS_RE="($(echo $STDCXX_HEADERS | sed -e 's/ /|/g'))"
|
||||
# Regular expression for #pragma once.
|
||||
PRAGMA_ONCE_RE='^#pragma once'
|
||||
# Regular expression to recognize the start of a C-comment block.
|
||||
COMMENT_BEGIN_RE='(^|[^\/])\/\*([^*]|\*+($|[^\/*]))*$'
|
||||
# Regular expression to recognize the end of a C-comment block.
|
||||
COMMENT_END_RE='\*\/'
|
||||
# Regular expression to match C++ unsafe headers. We currently don't have any C++ unsafe headers, do we?
|
||||
# v2.0/standard/mavlink.h is not unsafe, but this way the script will leave it alone and not
|
||||
# move it above function declarations that need to be declared before including it.
|
||||
UNSAFE_HEADERS_RE='(v2\.0\/standard\/mavlink\.h)'
|
||||
#UNSAFE_HEADERS_RE='(stm32\.h|arch\/board\/board\.h)'
|
||||
|
||||
# Find all submodules.
|
||||
test -f $BASEDIR/.gitmodules || fatal "No such file: $BASEDIR/.gitmodules"
|
||||
SUBMODULES=$(grep -A 1 '^\[submodule' $BASEDIR/.gitmodules | grep '^[[:space:]]*path = ' | sed -r -e 's/^[[:space:]]*path = //' | xargs echo)
|
||||
echo "SUBMODULES=\"$SUBMODULES\""
|
||||
SUBMODULES_RE="($(echo $SUBMODULES | sed -e 's/ /|/g'))"
|
||||
|
||||
# Disable path name expansion (otherwise the find patterns will be expanded against the files in the current working directory).
|
||||
set -f
|
||||
|
||||
EXCLUDE_ARGS=
|
||||
for excl in $EXCLUDE_FOLDERS; do
|
||||
if [ -z "$EXCLUDE_ARGS" ]; then
|
||||
EXCLUDE_ARGS="-wholename $BASEDIR/$excl/*"
|
||||
else
|
||||
EXCLUDE_ARGS+=" -o -wholename $BASEDIR/$excl/*"
|
||||
fi
|
||||
done
|
||||
for excl in $EXCLUDE_PATTERNS; do
|
||||
EXCLUDE_ARGS+=" -o -wholename */$excl/*"
|
||||
done
|
||||
INCLUDE_H_ARGS=
|
||||
for ext in $H_EXTENSIONS $HXX_EXTENSIONS; do
|
||||
if [ -z "$INCLUDE_H_ARGS" ]; then
|
||||
INCLUDE_H_ARGS="-name *$ext"
|
||||
else
|
||||
INCLUDE_H_ARGS+=" -o -name *$ext"
|
||||
fi
|
||||
done
|
||||
INCLUDE_C_ARGS=
|
||||
for ext in $C_EXTENSIONS $CXX_EXTENSIONS; do
|
||||
if [ -z "$INCLUDE_C_ARGS" ]; then
|
||||
INCLUDE_C_ARGS="-name *$ext"
|
||||
else
|
||||
INCLUDE_C_ARGS+=" -o -name *$ext"
|
||||
fi
|
||||
done
|
||||
# Also exclude all submodules -- because we don't maintain those (are we?).
|
||||
for subm in $SUBMODULES; do
|
||||
if [ -z "$SUBMODULES_ARGS" ]; then
|
||||
SUBMODULES_ARGS="-wholename $BASEDIR/$subm/*"
|
||||
else
|
||||
SUBMODULES_ARGS+=" -o -wholename $BASEDIR/$subm/*"
|
||||
fi
|
||||
done
|
||||
|
||||
echo -n "Finding all source files with #include's (excluding submodules and build directory)... "
|
||||
find $BASEDIR -mindepth 2 -type f ! \( -wholename $BASEDIR/build/* -o $EXCLUDE_ARGS -o $SUBMODULES_ARGS \) \( $INCLUDE_C_ARGS -o $INCLUDE_H_ARGS \) > $TMPDIR/fix_headers_sources
|
||||
cat "$TMPDIR/fix_headers_sources" | xargs grep -l "$INCLUDE_RE" > $TMPDIR/fix_headers_sources_with_includes
|
||||
echo "done"
|
||||
number_of_files=$(sed -n '$=' "$TMPDIR/fix_headers_sources_with_includes")
|
||||
count=0
|
||||
|
||||
echo -n "Finding all submodule header files (excluding stdc++ headers)... "
|
||||
find $BASEDIR -type f ! \( $EXCLUDE_ARGS \) \( $SUBMODULES_ARGS \) \( $INCLUDE_H_ARGS \) > $TMPDIR/fix_headers_SUBMODULE_HEADERS
|
||||
echo "done"
|
||||
|
||||
echo -n "Finding all header files (excluding stdc++ headers)... "
|
||||
find $BASEDIR -type f ! \( $EXCLUDE_ARGS \) -wholename $BASEDIR/build/* \( $INCLUDE_H_ARGS \) > $TMPDIR/fix_headers_HEADERS
|
||||
grep -E "$HEADER_RE" $TMPDIR/fix_headers_sources >> $TMPDIR/fix_headers_HEADERS
|
||||
cat $TMPDIR/fix_headers_SUBMODULE_HEADERS >> $TMPDIR/fix_headers_HEADERS
|
||||
echo "done"
|
||||
|
||||
echo -n "Finding all include paths... "
|
||||
for f in `cat $TMPDIR/fix_headers_sources_with_includes`; do grep -E "$INCLUDE_RE" $f | sed -r -e "s%$INCLUDE_RE%%"';s/[">].*//'; done | sort -u | grep -E -v "(/|^)$EXCLUDE_PATTERNS_RE/" > $TMPDIR/fix_headers_include_paths
|
||||
echo "done"
|
||||
|
||||
function include_path()
|
||||
{
|
||||
# If the include path starts with a '.', then it is a local header.
|
||||
if [[ $1 =~ ^\. ]]; then return 1; fi
|
||||
# If the include path starts with 'platforms/' then it is a local header;
|
||||
# added this exception here because not everyone has all build_ directories for all targets installed.
|
||||
if [[ $1 =~ platforms/ ]]; then return 1; fi
|
||||
# apps.h is generated from apps.h.in.
|
||||
if [ $1 = "apps.h" ]; then return 1; fi
|
||||
# Treat the following headers from src/platforms/*/include as system header because they replace what is found in nuttx (for posix and qurt).
|
||||
if [ $1 = "arch/board/board.h" -o $1 = "crc32.h" -o $1 = "i2c.h" -o $1 = "queue.h" -o $1 = "poll.h" -o $1 = "sys/ioctl.h" ]; then return 2; fi
|
||||
# Escape the path for reg.exp. matching.
|
||||
PATH_RE=$(echo $1 | sed -e 's/\([+.]\)/\\\1/')
|
||||
issubmodule=0;
|
||||
islocal=0;
|
||||
foo=0
|
||||
for includedir in $(grep "/$PATH_RE\$" $TMPDIR/fix_headers_HEADERS | cut -c $striplen-); do
|
||||
# If the include directory is NuttX header that was copied to the build directory, then it's still a system file.
|
||||
if [[ $includedir/ =~ ^build/.*/NuttX/ ]]; then
|
||||
issubmodule=1
|
||||
# If the include directory is a submodule, then treat it as a system file.
|
||||
elif [[ $includedir/ =~ ^$SUBMODULES_RE/ ]]; then
|
||||
issubmodule=1;
|
||||
else
|
||||
islocal=1
|
||||
fi
|
||||
done
|
||||
if [ $islocal -eq 0 ]; then
|
||||
if [ $issubmodule -eq 0 ]; then
|
||||
# If an include path can't be found then usually it will be a real system header,
|
||||
# however, there are a few (ros related?) files that start with px4... In that
|
||||
# case just leave the quotes alone ("px4muorb.h" and several <px4/...>).
|
||||
if [[ $1 =~ ^px4 ]]; then return 0; fi
|
||||
# While if the include path starts with uORB/topics or topics, and it isn't found,
|
||||
# then likely we just don't have a build directory. These should be local though.
|
||||
# Same for the generated files mixer_multirotor.generated.h and build_git_version.h.
|
||||
if [[ $1 =~ ((/|^)topics/|mixer_multirotor\.generated\.h|build_git_version\.h) ]]; then return 1; fi
|
||||
fi
|
||||
return 2;
|
||||
fi # Submodule or system header.
|
||||
if [ $issubmodule -eq 0 ]; then return 1; fi # Local.
|
||||
# Files that are both local and submodule are simply left alone.
|
||||
# These are (at this moment): "battery.h" "common.h" "Matrix.hpp" "mavlink.h" "protocol.h" "pwm.h" "spi.h" "Vector.hpp".
|
||||
return 0;
|
||||
}
|
||||
|
||||
# Run the include_path function for each of the files in $TMPDIR/fix_headers_include_paths
|
||||
echo -n "Determining which headers need to be included with double quotes... "
|
||||
echo -n > $TMPDIR/fix_headers_quotes
|
||||
for arg in $(cat "$TMPDIR/fix_headers_include_paths"); do
|
||||
include_path $arg
|
||||
localsystem=$?
|
||||
if [ $localsystem -eq 1 ]; then
|
||||
echo "$arg \"$arg\"" >> $TMPDIR/fix_headers_quotes
|
||||
elif [ $localsystem -eq 2 ]; then
|
||||
echo "$arg <$arg>" >> $TMPDIR/fix_headers_quotes
|
||||
fi
|
||||
done
|
||||
echo "done"
|
||||
|
||||
# Truncate the error log.
|
||||
echo -n > $TMPDIR/fix_headers_ERROR.log
|
||||
|
||||
function print_error
|
||||
{
|
||||
echo
|
||||
echo -n " ";
|
||||
echo "*** $1" | tee -a "$TMPDIR/fix_headers_ERROR.log"
|
||||
return 1
|
||||
}
|
||||
|
||||
if [ $debug -ne 0 ]; then
|
||||
# Debug Line.
|
||||
DL='if (cdbl != NR) { printf "\n%u. \"%s\"", NR, $0; cdbl = NR }'
|
||||
# Debug Begin.
|
||||
DB='if (cdbl != NR) { printf "\n%u. \"%s\" ---> ", NR, $0; cdbl = NR } else printf "; "; printf'
|
||||
# Debug End.
|
||||
DE=''
|
||||
else
|
||||
DL='#'
|
||||
DB='#'
|
||||
DE=''
|
||||
fi
|
||||
# Error Prefix.
|
||||
EP='###'
|
||||
|
||||
# The main function that is called for each source file.
|
||||
function fixup_header
|
||||
{
|
||||
count=$((count + 1))
|
||||
echo -n "[$((100 * count / number_of_files))%] Fixing headers of $1... "
|
||||
|
||||
# Is this a header?
|
||||
echo "$1" | sed -e 's/\.in$/;in/;s/.*\././;s/;in$/.in/' | grep -v -E "$HEADER_RE\$" >/dev/null; is_header=$?
|
||||
if [ $debug -ne 0 ]; then echo "is_header = \"$is_header\""; fi
|
||||
|
||||
# Is this C++ source?
|
||||
echo "$1" | sed -e 's/.*\././' | grep -v -E $CXXSRC_RE >/dev/null; is_cxxsrc=$?
|
||||
if [ $debug -ne 0 ]; then echo "is_cxxsrc = \"$is_cxxsrc\""; fi
|
||||
dont_make_cxxsrc=1
|
||||
if [ $is_cxxsrc -eq 0 -a $is_header -ne 0 ]; then
|
||||
grep -m 1 -q -E "^[[:space:]]*(#[[:space:]]*include[[:space:]]*<$STDCXX_HEADERS_RE>|(template|namespace|class)(\$|[^[:alnum:]_]))" "$1"
|
||||
dont_make_cxxsrc=$?
|
||||
fi
|
||||
if [ $dont_make_cxxsrc -eq 0 ]; then
|
||||
is_cxxsrc=1
|
||||
fi
|
||||
|
||||
# Current directory.
|
||||
curdir=$(dirname "$BASEDIR/$1")
|
||||
|
||||
# Parse the file.
|
||||
#
|
||||
# Returns an array of line[]'s. The first line is either the first #include, when it is outside
|
||||
# any #if*...#endif constructs not counting the header guard if the file is a header. For example:
|
||||
#
|
||||
# // Anything here except #include lines.
|
||||
# #include <first_include.h> // <-- first line.
|
||||
#
|
||||
# Or, the first #if* that contains the first #include line. For example:
|
||||
# // Anything here except #include lines.
|
||||
# #ifndef FOO_H // header guard.
|
||||
# #define FOO_H
|
||||
# int global = 1; // Anything unknown.
|
||||
# #ifdef SOMETHING // <-- first line.
|
||||
# #if maybe_more
|
||||
# // anything except #include lines.
|
||||
# #else
|
||||
# // anything except #include lines.
|
||||
# #include <first_include.h>
|
||||
#
|
||||
# Subsequent line[]'s mark the beginning of a new block, where we have the following blocks:
|
||||
# type[] Description
|
||||
type_include=0 # An #include, outside #if*...#endif constructs except a possible header guard.
|
||||
type_ifincludeendif=1 # #if*...#endif constructs with #include's.
|
||||
type_ifendif=2 # #if*...#endif constructs without #include's.
|
||||
type_decls=3 # __BEGIN_DECLS ... __END_DECLS block.
|
||||
type_macro=4 # Contiguous #define block.
|
||||
type_comment=5 #(Multi-line) comments.
|
||||
type_emptyline=6 # Empty lines.
|
||||
type_pragmaonce=7 # #pragma once (must be outside any #if*...#endif constructs).
|
||||
type_end=8 # The first line of the remainder of the file.
|
||||
#
|
||||
# However, any block NOT containing one or more #include's (all types > 1) will
|
||||
# cause subsequent blocks that do not contain #include's to be ignored,
|
||||
# with as result that those blocks will be treated as contiguous code blocks.
|
||||
# A comment that is followed by a type that is not to be ignored as such
|
||||
# is given the type that follows (which itself is then ignored).
|
||||
# Empty lines are ignored unless they appear directly in front of a type
|
||||
# that is not to be ignored according to the above rules, where 'previous
|
||||
# types' then are the types before the empty line.
|
||||
#
|
||||
# For example:
|
||||
#
|
||||
# > #include <first_header.h> # type_include
|
||||
# > #include <second_header.h> # type_include
|
||||
# > # type_emptyline
|
||||
# > #include <third_header.h> # type_include
|
||||
# ^ #ifdef FOO # type_ifendif
|
||||
# | #define BAR 1
|
||||
# | #endif # (detected here)
|
||||
# | <-- ignored because:
|
||||
# v #define BAZ(x) x // Do baz <-- ignored (prev and this type in {type_ifendif, type_macro})
|
||||
# > # type_emptyline
|
||||
# ^ // This include is important: # type_comment, but then replaced by type_ifincludeendif
|
||||
# | <-- ignored because:
|
||||
# | // more here. <-- ignored same type
|
||||
# | #ifdef BAR <-- "ignored": type_ifincludeendif, but put 3 lines higher.
|
||||
# | #include <bar.h>
|
||||
# v #endif # (detected here)
|
||||
# > # type_emptyline
|
||||
# > #include <another.h> # type_include
|
||||
#
|
||||
# This script stops parsing at the first not recognized line outside #if*...#endif constructs
|
||||
# unless no first line was found yet. It does not attempt overly hard to decode rare constructs,
|
||||
# most notably anything with a leading C comment is not recognized and will thus lead to an abort.
|
||||
# For example the following lines are not recognized:
|
||||
#
|
||||
# /* Some comment */ #include <header.h>
|
||||
# /* Some comment */ // Another comment.
|
||||
#
|
||||
# Lines that have a trailing comment are recognized (by ignoring the comment).
|
||||
|
||||
result=$(awk "\
|
||||
function add(l, t) {
|
||||
# First add always succeeds.
|
||||
if (ptr > 0) {
|
||||
# An empty line is always added, at first, unless the immediate preceding type is an empty line.
|
||||
if (t == $type_emptyline && type[ptr - 1] == $type_emptyline) {
|
||||
return; $DB \"ignored because line %d is also empty.\", line[ptr - 1] $DE
|
||||
}
|
||||
# A comment is always, added at first, unless the preceding non-empty line type is a comment.
|
||||
# Same for #include's.
|
||||
if (t == $type_comment && last_none_type == t) {
|
||||
$DB \"ignoring because same type as last_none_type (%s)\", type_name[t] $DE
|
||||
# Gobble up preceding empty lines.
|
||||
if (type[ptr - 1] == $type_emptyline) {
|
||||
--ptr; $DB \"ptr = %d; [43mRemoved type_emptyline @ line %d[0m\", ptr, line[ptr] $DE
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
# {ifendif, macro}'s are collapsed too.
|
||||
if ((t == $type_ifendif || t == $type_macro) && (last_nonws_type == $type_ifendif || last_nonws_type == $type_macro)) {
|
||||
# Gobble up preceding comments and empty lines.
|
||||
while (ptr > 0 && (type[ptr - 1] == $type_emptyline || type[ptr - 1] == $type_comment)) {
|
||||
--ptr; $DB \"ptr = %d; [43mRemoved %s @ line %d[0m\", ptr, type_name[type[ptr]], line[ptr] $DE
|
||||
}
|
||||
# ptr > 0 here because the first add is never for an empty line or comment.
|
||||
last_none_type = type[ptr - 1]; $DB \"last_none_type = %s\", type_name[last_none_type] $DE
|
||||
return;
|
||||
}
|
||||
# type_include and type_pragmaonce and higher are always added.
|
||||
}
|
||||
if (t == $type_end) {
|
||||
# Remove drag.
|
||||
while(ptr > 0 && line[ptr - 1] >= l) --ptr;
|
||||
}
|
||||
# If this type is not an empty line and it was preceded by a comment, then melt it together with that comment.
|
||||
else if (t != $type_emptyline && last_none_type == $type_comment) {
|
||||
# In this case t cannot be type_comment.
|
||||
# Gobble up preceding empty lines.
|
||||
if (type[ptr - 1] == $type_emptyline) {
|
||||
--ptr; $DB \"ptr = %d; [43mRemoved type_emptyline @ line %d[0m\", ptr, line[ptr] $DE
|
||||
}
|
||||
# And replace the comment type.
|
||||
--ptr; $DB \"ptr = %d; [45mreplacing the %s @ line %d[0m\", ptr, type_name[type[ptr]], line[ptr] $DE
|
||||
l = line[ptr];
|
||||
|
||||
}
|
||||
line[ptr] = l; $DB \"ptr = %d; [42m%s @ line %d[0m\", ptr, type_name[t], l $DE;
|
||||
type[ptr++] = t;
|
||||
if (t != $type_emptyline) {
|
||||
last_none_type = t; $DB \"last_none_type = %s\", type_name[last_none_type] $DE
|
||||
if (t != $type_comment)
|
||||
last_nonws_type = t;
|
||||
}
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
debug = $debug; # 0: no debug output; non-zero: print debug output.
|
||||
header = $is_header; # 0: do not look for a header guard; 1: treat first #ifndef as header guard.
|
||||
in_if = 0; # The number of nested levels inside #if, #ifdef or #ifndef ... #endif constructs.
|
||||
in_if_base = 0; # 0: no header guard was found (or #pragma once); 1: an #ifndef header guard was found.
|
||||
in_decl = 0; # 0: not inside a __BEGIN_DECLS ... __END_DECLS block; 1: inside such a block.
|
||||
found_guard = 0; # 0: no header guard was found; 1: a header guard was found (including #pragma once).
|
||||
base_if = 0; # The current base-level #if that we are scanning.
|
||||
drag = 0; # The number of lines since the last certainly relevant line (a base-level #include or a base-level #endif containing one of more #includes).
|
||||
skipped = 0; # 0: No #include was encountered in the current (base-level) #if block; 1: one or more #include's encountered in the current base-level #if block.
|
||||
in_comment = 0; # 0: not in a multi-line C comment; 1: in a multi-line C comment.
|
||||
cdbl = 0; # Current debug line.
|
||||
error = 0; # 0: no error occured; 1: an error occured.
|
||||
ptr = 0; # Current pointer into line[] and type[].
|
||||
found_comment_end = 0; # The last line (possibly the current line) that is/was a multi-line C comment termination.
|
||||
last_none_type = -1; # The last non-emptyline type that was added.
|
||||
last_nonws_type = -1; # The last non-whitespace type that was added.
|
||||
# For debug purposes:
|
||||
type_name[$type_ifendif] = \"type_ifendif\";
|
||||
type_name[$type_ifincludeendif] = \"type_ifincludeendif\";
|
||||
type_name[$type_decls] = \"type_decls\";
|
||||
type_name[$type_comment] = \"type_comment\";
|
||||
type_name[$type_emptyline] = \"type_emptyline\";
|
||||
type_name[$type_include] = \"type_include\";
|
||||
type_name[$type_macro] = \"type_macro\";
|
||||
type_name[$type_pragmaonce] = \"type_pragmaonce\";
|
||||
type_name[$type_end] = \"type_end\";
|
||||
}
|
||||
|
||||
END {
|
||||
last_line = NR - drag;
|
||||
add(last_line + 1, $type_end); $DB \"\n\" $DE;
|
||||
# Print output.
|
||||
if (error || ptr == 0 || last_line < line[0]) {
|
||||
print \"error=1\";
|
||||
exit
|
||||
}
|
||||
printf \"lines=\\\"\";
|
||||
for (i = 0; i < ptr - 1; ++i)
|
||||
printf \"%d \", line[i];
|
||||
printf \"%d\\\"; \", line[ptr - 1];
|
||||
printf \"types=\\\"\";
|
||||
for (i = 0; i < ptr - 1; ++i)
|
||||
printf \"%d \", type[i];
|
||||
printf \"%d\\\"; \", type[ptr - 1];
|
||||
print \"error=0; first_line=\" line[0] \"; last_line=\" last_line
|
||||
}
|
||||
|
||||
#======================================================================================================
|
||||
# Handle multi-line C comments.
|
||||
|
||||
/$COMMENT_END_RE/ {
|
||||
if (in_comment) {
|
||||
in_comment = 0; $DB \"comment end\" $DE;
|
||||
found_comment_end = NR;
|
||||
sub(/^([^*]|\*+[^*\/])*\*+\//, \"\") # Remove the tail of the comment.
|
||||
}
|
||||
# FALL-THROUGH
|
||||
}
|
||||
|
||||
{
|
||||
if (in_comment) {
|
||||
++drag; $DB \"in comment; drag = %d\", drag $DE;
|
||||
next
|
||||
}
|
||||
found_comment_begin = 0;
|
||||
# FALL-THROUGH
|
||||
}
|
||||
|
||||
/$COMMENT_BEGIN_RE/ {
|
||||
in_comment = 1; $DB \"comment begin\" $DE;
|
||||
found_comment_begin = 1;
|
||||
sub(/\/\*([^*]|\*+($|[^*\/]))*$/, \"\") # Remove the head of the comment so that we'll recognize this as an empty line if it is.
|
||||
# FALL-THROUGH
|
||||
}
|
||||
|
||||
#======================================================================================================
|
||||
# Detect and handle header guard.
|
||||
|
||||
/$PRAGMA_ONCE_RE/ {
|
||||
++drag; $DB \"drag = %d\", drag $DE;
|
||||
if (header && found_guard == 0 && in_if == 0) {
|
||||
found_guard = NR; $DB \"found_guard = %d\", found_guard $DE;
|
||||
if (ptr > 0)
|
||||
add(NR, $type_pragmaonce)
|
||||
next
|
||||
}
|
||||
print \"\\n$EP $1:\" NR \": unexpected #pragma once\";
|
||||
error = 1;
|
||||
exit
|
||||
}
|
||||
|
||||
/^#ifndef / {
|
||||
if (ptr == 0 && header && found_guard == 0 && in_if == 0) {
|
||||
found_guard = NR; $DB \"found_guard = %d\", found_guard $DE;
|
||||
in_if = 1; $DB \"in_if = %d\", in_if $DE;
|
||||
in_if_base = 1; $DB \"in_if_base = %d\", in_if_base $DE;
|
||||
next
|
||||
}
|
||||
# FALL-THROUGH
|
||||
}
|
||||
|
||||
#======================================================================================================
|
||||
# Detect and handle __BEGIN_DECLS ... __END_DECLS blocks.
|
||||
|
||||
/^[[:space:]]*__BEGIN_DECLS/ {
|
||||
++drag; $DB \"drag = %d\", drag $DE;
|
||||
if (in_decl == 0) {
|
||||
in_decl = 1; $DB \"in_decl = 1\" $DE
|
||||
add(NR, $type_decls);
|
||||
next
|
||||
}
|
||||
print \"\\n$EP $1:\" NR \": Nested __BEGIN_DECLS!\";
|
||||
error = 1;
|
||||
exit
|
||||
}
|
||||
|
||||
/^[[:space:]]*__END_DECLS/ {
|
||||
++drag; $DB \"drag = %d\", drag $DE;
|
||||
if (in_decl == 1) {
|
||||
in_decl = 0; $DB \"in_decl = 0\" $DE
|
||||
if (skipped) {
|
||||
drag = 0;
|
||||
} else if (ptr == 1) {
|
||||
ptr = 0; $DB \"erase DECLS block\" $DE
|
||||
last_none_type = -1;
|
||||
}
|
||||
next
|
||||
}
|
||||
print \"\\n$EP $1:\" NR \": __END_DECLS without matching __BEGIN_DECLS!\";
|
||||
error = 1;
|
||||
exit
|
||||
}
|
||||
|
||||
#======================================================================================================
|
||||
# Detect and handle #if ... #endif blocks.
|
||||
|
||||
/$IF_RE/ {
|
||||
++drag; $DB \"drag = %d\", drag $DE;
|
||||
if (in_if == in_if_base && in_decl == 0) {
|
||||
skipped = 0; $DB \"skipped = 0\" $DE;
|
||||
base_if = NR; $DB \"base_if = %d\", NR $DE;
|
||||
}
|
||||
++in_if; $DB \"in_if = %d\", in_if $DE;
|
||||
next
|
||||
}
|
||||
|
||||
/$ENDIF_RE/ {
|
||||
--in_if; $DB \"in_if = %d\", in_if $DE;
|
||||
if (in_if < 0) {
|
||||
print \"\\n$EP $1:\" NR \": #endif without matching #if!\";
|
||||
error = 1;
|
||||
exit
|
||||
}
|
||||
++drag;
|
||||
if (in_if == in_if_base && in_decl == 0) {
|
||||
if (skipped) {
|
||||
drag = 0;
|
||||
add(base_if, $type_ifincludeendif);
|
||||
} else if (ptr > 0)
|
||||
add(base_if, $type_ifendif);
|
||||
} $DB \"drag = %d\", drag $DE;
|
||||
# Left header guard?
|
||||
if (in_if < in_if_base) { $DB \"left header guard:\" $DE;
|
||||
# assert(in_if == 0 && in_if_base == 1 && header && found_guard)
|
||||
exit
|
||||
}
|
||||
next
|
||||
}
|
||||
|
||||
#======================================================================================================
|
||||
# Handle #include lines.
|
||||
|
||||
/$INCLUDE_RE/ {
|
||||
if (!/\"(\.\/)?mavlink_msg/) {
|
||||
# If we're inside a __BEGIN_DECLS ... __END_DECLS block then only certain headers may be included.
|
||||
hname = gensub(/^[[:space:]]*#[[:space:]]*include[[:space:]]*[<\"]([^>\"]*)[>\"].*/, \"\\\1\", \"1\");
|
||||
cpp_safe = !(hname ~ /$UNSAFE_HEADERS_RE/);
|
||||
$DB \"hname = \\\"\" hname \"\\\"; cpp_safe = \" cpp_safe \"; in_decl = \" in_decl \"; is_cxxsrc = $is_cxxsrc\" $DE
|
||||
if (in_decl && cpp_safe) {
|
||||
print \"\\n$EP $1:\" NR \": including \" hname \" inside a __BEGIN_DECLS ... __END_DECLS block.\";
|
||||
error = 1;
|
||||
exit
|
||||
} else if (!in_decl && !cpp_safe && $is_cxxsrc) {
|
||||
print \"\\n$EP $1:\" NR \": including \" hname \" outside a __BEGIN_DECLS ... __END_DECLS block!\";
|
||||
error = 1;
|
||||
exit
|
||||
}
|
||||
if (in_if > in_if_base || in_decl) {
|
||||
skipped = 1; $DB \"skipped = 1\" $DE;
|
||||
} else {
|
||||
drag = 0; $DB \"drag = 0\" $DE;
|
||||
add(NR, $type_include); $DB \"first_line = %d\", NR $DE;
|
||||
}
|
||||
next
|
||||
}
|
||||
}
|
||||
|
||||
#======================================================================================================
|
||||
# Ignore #define's, empty lines and lines with just comments.
|
||||
|
||||
/$DEFINE_RE/ {
|
||||
++drag; $DB \"drag = %d\", drag $DE;
|
||||
if (ptr > 0 && in_if == in_if_base && in_decl == 0) {
|
||||
add(NR, $type_macro);
|
||||
}
|
||||
next
|
||||
}
|
||||
|
||||
/$EMPTY_LINE_RE/ {
|
||||
++drag; $DB \"drag = %d\", drag $DE;
|
||||
if (ptr > 0 && in_if == in_if_base && in_decl == 0) {
|
||||
if (found_comment_begin)
|
||||
add(NR, $type_comment);
|
||||
else if (found_comment_end != NR)
|
||||
add(NR, $type_emptyline);
|
||||
}
|
||||
next
|
||||
}
|
||||
|
||||
/$COMMENT_LINE_RE/ {
|
||||
++drag; $DB \"drag = %d\", drag $DE;
|
||||
if (ptr > 0 && in_if == in_if_base && in_decl == 0 && type[ptr - 1] != $type_comment) {
|
||||
add(NR, $type_comment);
|
||||
}
|
||||
next
|
||||
}
|
||||
|
||||
#======================================================================================================
|
||||
# Handle everything else (unrecognized lines).
|
||||
|
||||
{
|
||||
++drag; $DB \"unknown; drag = %d\", drag $DE;
|
||||
if (ptr > 0 && in_if <= in_if_base && in_decl == 0) {
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
" "$BASEDIR/$1")
|
||||
|
||||
# Decode the result.
|
||||
vars=$(echo "$result" | tail -n 1)
|
||||
error_msg=$(echo "$result" | grep "^$EP " | sed -e 's/^....//')
|
||||
if [ $debug -ne 0 ]; then
|
||||
len=$(echo "$result" | wc --lines)
|
||||
echo "$result" | head -n $((len - 1)) | grep -v "^$EP " # Debug messages
|
||||
echo "vars: $vars"
|
||||
fi
|
||||
# Evaluate the last line printed in END.
|
||||
error=1; eval $vars
|
||||
test -z "$error_msg" || print_error "$error_msg" || return
|
||||
test $error -eq 0 -a $first_line -gt 0 || print_error "FAILED to find an #include in $1?!" || return
|
||||
test $last_line -ge $first_line || print_error "FAILED to find a sensible last line in $1?!" || return
|
||||
|
||||
# Calculate the number of lines starting from the current line.
|
||||
# Use sed to count lines, because wc --lines doesn't report the last line when that doesn't end on a new-line, contrary to the fact that tail treats such lines as lines.
|
||||
total_lines=$(sed -n '$=' "$BASEDIR/$1")
|
||||
if [ $debug -ne 0 ]; then echo "total_lines = \"$total_lines\""; fi
|
||||
|
||||
# Edit the first_line...last_line block.
|
||||
# Header files are ordered as follows (lowest value first):
|
||||
cat_winsock=0; # Winsock2.h
|
||||
cat_posix_sys=1; # posix_sys.h or one of the px4_ headers that include it.
|
||||
cat_px4=2; # Other px4_*.h
|
||||
cat_local=3; # "*.h"
|
||||
cat_cxx=4; # <std c++ header>, ie <iostream>
|
||||
cat_c=5; # <c std c++ header>, ie <cstdio>
|
||||
cat_system=6; # <*.h>
|
||||
|
||||
head -n $last_line "$BASEDIR/$1" | tail -n $((last_line - first_line + 1)) | awk "
|
||||
|
||||
function sort_by_type_line_header_type_hname(blk2, v2, blk1, v1) {
|
||||
# Return true if blk1 comes before blk2.
|
||||
# Move type_include before the rest. Keep the same line order for the rest.
|
||||
return (type[blk2] != $type_include && (type[blk1] == $type_include || line[blk1] < line[blk2])) ||
|
||||
(type[blk2] == $type_include && type[blk1] == $type_include &&
|
||||
# If both are include's then put include with a lower header_type first; sort alphabetically for the same header type.
|
||||
(header_type[blk1] < header_type[blk2] || (header_type[blk1] == header_type[blk2] && hname[blk1] < hname[blk2])));
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
first_line = $first_line;
|
||||
split(\"$lines\", line);
|
||||
split(\"$types\", type);
|
||||
i = 0;
|
||||
do {
|
||||
line[++i] -= first_line - 1;
|
||||
} while(type[i] != $type_end)
|
||||
for(b = 0; b < i; ++b) header_type[b] = 100;
|
||||
blk = 1;
|
||||
n = 0;
|
||||
is_cxxsrc = $is_cxxsrc;
|
||||
# px4_posix.h includes px4_defines.h includes px4_log.h includes posix_sys.h which must be the first header included.
|
||||
sys_val[\"px4_posix.h\"] = 1;
|
||||
sys_val[\"px4_defines.h\"] = 2;
|
||||
sys_val[\"px4_log.h\"] = 3;
|
||||
sys_val[\"posix_sys.h\"] = 4;
|
||||
saw_sys_val = 5; # Didn't see any of the above; otherwise the lowest value of the header seen.
|
||||
for(b = 0; b < i; ++b) saw_sys[b] = saw_sys_val;
|
||||
}
|
||||
|
||||
END {
|
||||
l = asorti(txt, k, \"sort_by_type_line_header_type_hname\");
|
||||
for (b = 1; b <= l; ++b) {
|
||||
if (type[k[b]] == $type_include && header_type[k[b]] == $cat_posix_sys && saw_sys[k[b]] > saw_sys_val) continue;
|
||||
len = length(txt[k[b]]);
|
||||
for (n = 0; n < len; ++n) print txt[k[b]][n];
|
||||
if (b < l && type[k[b]] == $type_include && type[k[b+1]] != $type_emptyline &&
|
||||
(type[k[b+1]] != $type_include || (header_type[k[b]] != header_type[k[b+1]] && header_type[k[b+1]] != $cat_px4))) {
|
||||
printf \"\n\";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
if (NR == line[blk + 1]) {
|
||||
++blk;
|
||||
n = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/$INCLUDE_RE/ {
|
||||
# Don't use double quotes around standard header names.
|
||||
\$0 = gensub(/^([[:space:]]*#[[:space:]]*include[[:space:]]*)\\\"$STDC_HEADERS_RE\\.h\\\"/, \"\\\1<\\\2.h>\", \"1\");
|
||||
if (is_cxxsrc) {
|
||||
\$0 = gensub(/^([[:space:]]*#[[:space:]]*include[[:space:]]*)\\\"$STDCXX_HEADERS_RE\\\"/, \"\\\1<\\\2>\", \"1\");
|
||||
# Change deprecated C header names to standard C++ header names in C++ source files.
|
||||
\$0 = gensub(/^([[:space:]]*#[[:space:]]*include[[:space:]]*<)$STDC_HEADERS_RE\\.h>/, \"\\\1c\\\2>\", \"1\");
|
||||
}
|
||||
# Don't include \"./foo.h\", that is implied, so just include \"foo.h\".
|
||||
\$0 = gensub(/^([[:space:]]*#[[:space:]]*include[[:space:]]*\\\")\.\//, \"\\\1\", \"1\");
|
||||
# Extract the header filename.
|
||||
hname[blk] = gensub(/^[[:space:]]*#[[:space:]]*include[[:space:]]*[<\"]([^>\"]*)[>\"].*/, \"\\\1\", \"1\");
|
||||
# If the header exists in the directory of the including file, then it is a local header.
|
||||
command = sprintf(\"test -e %s/%s\", \"$curdir\", hname[blk]);
|
||||
if (system(command) == 0) {
|
||||
\$0 = gensub(/^([[:space:]]*#[[:space:]]*include[[:space:]]*)[\"<]([^\">]*)[\">]/, \"\\\1\\\"\\\2\\\"\", \"1\");
|
||||
} else {
|
||||
# Do we know if this is a local file, or a submodule / system header?
|
||||
# The grep reg.exp needs \\ (for backslah) and \1 for back reference, thus: \\\1.
|
||||
# However we print the grep command using sprintf, so each backslash needs to be escaped once more: \\\\\\1.
|
||||
# Finally, this is a bash string and we need to escape each backslash once more to pass it corrently to awk, hence we need twelve backslahes:
|
||||
command = sprintf(\"grep '^%s ' '%s' 2>/dev/null\", gensub(/([.+])/, \"\\\\\\\\\\\\1\", \"g\", hname[blk]), \"$TMPDIR/fix_headers_quotes\");
|
||||
ret = command | getline result;
|
||||
if (ret != 0) {
|
||||
result = substr(result, index(result, \" \") + 1);
|
||||
\$0 = gensub(/^([[:space:]]*#[[:space:]]*include[[:space:]]*)[\"<][^\">]*[\">]/, \"\\\1\" result, \"1\");
|
||||
}
|
||||
}
|
||||
# Categorise the header.
|
||||
if (hname[blk] == \"Winsock2.h\") {
|
||||
if (header_type[blk] > $cat_winsock)
|
||||
header_type[blk] = $cat_winsock;
|
||||
}
|
||||
else if (hname[blk] in sys_val) {
|
||||
if (header_type[blk] > $cat_posix_sys)
|
||||
header_type[blk] = $cat_posix_sys;
|
||||
# posix_sys.h is sometimes included within #ifdef __PX4_POSIX ... #endif. The other headers should not be conditional.
|
||||
if ((hname[blk] == \"posix_sys.h\" || type[blk] == $type_include)) {
|
||||
type[blk] = $type_include; # Treat #ifdef __PX4_POSIX #include \"posix_sys.h\" #endif as an include for sorting purposes.
|
||||
saw_sys[blk] = sys_val[hname[blk]]; # There will be only one include (header name) for this block.
|
||||
if (sys_val[hname[blk]] < saw_sys_val)
|
||||
saw_sys_val = sys_val[hname[blk]];
|
||||
}
|
||||
# Use double quotes for these headers.
|
||||
\$0 = gensub(/<([[:alnum:]_\/.]*)>/, \"\\\"\\\1\\\"\", \"1\");
|
||||
}
|
||||
else if (hname[blk] ~ /^(platforms\/px4_|px4_)/) {
|
||||
if (header_type[blk] > $cat_px4)
|
||||
header_type[blk] = $cat_px4;
|
||||
# Use double quotes for these headers.
|
||||
\$0 = gensub(/<([[:alnum:]_\/.]*)>/, \"\\\"\\\1\\\"\", \"1\");
|
||||
}
|
||||
else if (\$0 ~ /^[[:space:]]*#[[:space:]]*include[[:space:]]*\"/) {
|
||||
if (header_type[blk] > $cat_local)
|
||||
header_type[blk] = $cat_local;
|
||||
}
|
||||
else if (hname[blk] ~ /^$STDCXX_HEADERS_RE\$/) {
|
||||
if (header_type[blk] > $cat_cxx)
|
||||
header_type[blk] = $cat_cxx;
|
||||
}
|
||||
else if (hname[blk] ~ /^c$STDC_HEADERS_RE\$/) {
|
||||
if (header_type[blk] > $cat_c)
|
||||
header_type[blk] = $cat_c;
|
||||
}
|
||||
else if (hname[blk] ~ /^$STDC_HEADERS_RE\.h\$/) {
|
||||
if (header_type[blk] > $cat_system)
|
||||
header_type[blk] = $cat_system;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
# Remove empty lines before #include's.
|
||||
if (type[blk] == $type_include) {
|
||||
for (i = 1; blk > i && type[blk - i] == $type_emptyline; ++i)
|
||||
delete txt[blk - i]
|
||||
}
|
||||
txt[blk][n++] = \$0;
|
||||
}
|
||||
|
||||
" > $TMPDIR/fix_headers_current_block
|
||||
|
||||
# Construct a new file in TMPDIR.
|
||||
head -n $((first_line - 1)) "$BASEDIR/$1" > $TMPDIR/fix_headers_current_file
|
||||
|
||||
# Append the editted block.
|
||||
cat $TMPDIR/fix_headers_current_block >> $TMPDIR/fix_headers_current_file
|
||||
|
||||
# Append the rest.
|
||||
tail -n $((total_lines - last_line)) "$BASEDIR/$1" >> $TMPDIR/fix_headers_current_file
|
||||
|
||||
# Compare original with result.
|
||||
if cmp --quiet "$BASEDIR/$1" $TMPDIR/fix_headers_current_file; then
|
||||
echo "No change"
|
||||
else
|
||||
echo "Fixed lines $first_line-$last_line"
|
||||
mv $TMPDIR/fix_headers_current_file "$BASEDIR/$1" || fatal "Failed to move $TMPDIR/fix_headers_current_file to $BASEDIR/$1 !?!"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ $non_option_arguments -ne 0 ]; then
|
||||
fixup_header $1
|
||||
exit
|
||||
fi
|
||||
|
||||
# Run the fixup function for each of the files in $TMPDIR/fix_headers_sources_with_includes.
|
||||
# Strip BASEDIR because we don't know how long that is and it might too much for bash.
|
||||
for arg in $(cat "$TMPDIR/fix_headers_sources_with_includes" | cut -c $striplen-); do
|
||||
fixup_header $arg
|
||||
done
|
||||
|
||||
# Clean up.
|
||||
if [ $debug -eq 0 -o $# -eq 0 ]; then
|
||||
rm "$TMPDIR/fix_headers_sources" "$TMPDIR/fix_headers_sources_with_includes" "$TMPDIR/fix_headers_SUBMODULE_HEADERS" "$TMPDIR/fix_headers_HEADERS" \
|
||||
"$TMPDIR/fix_headers_include_paths" "$TMPDIR/fix_headers_quotes" "$TMPDIR/fix_headers_current_block"
|
||||
fi
|
||||
|
||||
# Print all error messages again at the end.
|
||||
if [ -s "$TMPDIR/fix_headers_ERROR.log" ]; then
|
||||
echo "$0 finished with errors:"
|
||||
cat "$TMPDIR/fix_headers_ERROR.log"
|
||||
else
|
||||
echo "SUCCESS"
|
||||
rm "$TMPDIR/fix_headers_ERROR.log"
|
||||
fi
|
||||
Regular → Executable
-200
@@ -1,200 +0,0 @@
|
||||
#!/bin/bash
|
||||
#Author: Benjamin Perseghetti
|
||||
#Email: bperseghetti@rudislabs.com
|
||||
# This script unifies running gazebo simulation for HITL and SITL
|
||||
# You can run multiple instances of the 'px4' binary, with the gazebo SITL simulation
|
||||
# This script assumes px4 is already built, with 'make px4_sitl_default gazebo'
|
||||
# You can also run HITL with -h flag
|
||||
# Generate world and/or model files with editable json -j [m (model), w (world), mw (model and world), or wm (world and model)]
|
||||
|
||||
# The simulator in SITL is expected to send to TCP port 4560+i for i in [0, N-1]
|
||||
# For example gazebo can be run like this for multiple SITL:
|
||||
# ./Tools/gz_sim.sh -n 10 -m iris
|
||||
# Or gazebo can be run like this for HITL:
|
||||
# ./Tools/gz_sim.sh -h 1 -m standard_vtol
|
||||
|
||||
function cleanup() {
|
||||
echo "running the cleanup"
|
||||
pkill -x px4
|
||||
pkill gazebo
|
||||
pkill gzclient
|
||||
pkill gzserver
|
||||
}
|
||||
|
||||
trap "cleanup" INT SIGINT SIGTERM EXIT
|
||||
|
||||
function spawn_model() {
|
||||
MODEL=$1
|
||||
N=$2 #Instance Number
|
||||
WORLD_FILE=$3
|
||||
MJ=$4
|
||||
SITL_MODEL_NAME="${MODEL}_${N}"
|
||||
sitl_path=${SCRIPT_DIR}/sitl_gazebo
|
||||
jinja_model_script=${sitl_path}/scripts/jinja_model_gen.py
|
||||
base_model="--base_model ${MODEL}"
|
||||
model_json="--json_gen ${MJ}"
|
||||
|
||||
if [ $hitl == true ]; then
|
||||
python3 ${src_path}/Tools/boot_now.py "/dev/ttyACM0"
|
||||
hil_mode="--hil_mode 1"
|
||||
model_name="--model_name ${MODEL}"
|
||||
hitl_launch_command="${model_json} ${base_model} ${hil_mode} ${model_name}"
|
||||
echo "Generating: ${jinja_model_script} ${hitl_launch_command}"
|
||||
python3 ${jinja_model_script} ${hitl_launch_command}
|
||||
sleep 1
|
||||
source ${src_path}/Tools/setup_gazebo.bash ${src_path} ${src_path}/build/${target}
|
||||
sleep 2
|
||||
gazebo ${sitl_path}/worlds/temp_${WORLD_FILE}.world --verbose
|
||||
|
||||
else
|
||||
mavlink_tcp="--mavlink_tcp_port $((4560+${N}))"
|
||||
mavlink_udp="--mavlink_udp_port $((14560+${N}))"
|
||||
model_name="--model_name ${SITL_MODEL_NAME}"
|
||||
output_path="--output_path /tmp"
|
||||
working_dir="$build_path/instance_$n"
|
||||
sitl_launch_command="${model_json} ${base_model} ${mavlink_tcp} ${mavlink_udp} ${model_name} ${output_path}"
|
||||
[ ! -d "$working_dir" ] && mkdir -p "$working_dir"
|
||||
pushd "$working_dir" &>/dev/null
|
||||
echo "starting instance $N in $(pwd)"
|
||||
../bin/px4 -i $N -d "$build_path/etc" -w sitl_${SITL_MODEL_NAME} -s etc/init.d-posix/rcS >out.log 2>err.log &
|
||||
python3 ${jinja_model_script} ${sitl_launch_command}
|
||||
echo "Generating: ${jinja_model_script} ${sitl_launch_command}"
|
||||
echo "Spawning ${SITL_MODEL_NAME}"
|
||||
gz model --spawn-file=/tmp/${SITL_MODEL_NAME}.sdf --model-name=${SITL_MODEL_NAME} -x 0.0 -y $((3*${N})) -z 0.2
|
||||
popd &>/dev/null
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
if [ "$1" == "--help" ]; then
|
||||
echo "Usage: $0 [-n <num_vehicles>] [-m <vehicle_model>] [-h <run_hitl>] [-w <world>] [-s <script>] [-t <num_threads>] [-j <json_params>]"
|
||||
echo "-s flag is used to script spawning vehicles e.g. $0 -s iris:3,plane:2"
|
||||
echo "-h flag is used to launch a single vehicle in HITL mode"
|
||||
echo "-t flag is used to set the number of ODE threads for the world"
|
||||
echo "-j flag is used to enable json parameters from gen_params.json for the world (w), model (m), or both (wm or mw)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while getopts n:m:h:w:s:t:j:p option
|
||||
do
|
||||
case "${option}"
|
||||
in
|
||||
n) NUM_VEHICLES=${OPTARG};;
|
||||
m) VEHICLE_MODEL=${OPTARG};;
|
||||
h) HITL=${OPTARG};;
|
||||
w) WORLD=${OPTARG};;
|
||||
s) SCRIPT=${OPTARG};;
|
||||
t) THREADS=${OPTARG};;
|
||||
j) JSON=${OPTARG};;
|
||||
p) TARGET=${OPTARG};;
|
||||
esac
|
||||
done
|
||||
|
||||
num_vehicles=${NUM_VEHICLES:=1}
|
||||
world=${WORLD:=empty}
|
||||
hitl=${HITL:=false}
|
||||
threads=${THREADS:=1}
|
||||
json_opts=${JSON:=0}
|
||||
target=${TARGET:=px4_sitl_default}
|
||||
system_threads=`grep -Pc '^processor\t' /proc/cpuinfo`
|
||||
echo "Number of requested ODE threads: $((threads))"
|
||||
echo "Max number of possilbe threads: $((system_threads))"
|
||||
if [ $((threads)) -gt $((system_threads)) ]; then
|
||||
threads=$system_threads
|
||||
echo "Requested ODE thread count too high, set to system max of $threads threads."
|
||||
elif [ $(( ${threads} )) -lt 1 ]; then
|
||||
threads=1
|
||||
echo "Requested ODE thread count too low, set to $threads thread."
|
||||
else
|
||||
echo "Using $threads threads for ODE."
|
||||
fi
|
||||
|
||||
if [ "$json_opts" == "mw" ] || [ "$json_opts" == "wm" ]; then
|
||||
echo "JSON used for both world and model generation"
|
||||
wjson="1"
|
||||
mjson="1"
|
||||
elif [ "$json_opts" == "w" ]; then
|
||||
echo "JSON used for world generation"
|
||||
wjson="1"
|
||||
mjson="0"
|
||||
elif [ "$json_opts" == "m" ]; then
|
||||
echo "JSON used for model generation"
|
||||
mjson="1"
|
||||
wjson="0"
|
||||
else
|
||||
wjson="0"
|
||||
mjson="0"
|
||||
fi
|
||||
|
||||
if [ "$hitl" == "True" ] || [ "$hitl" == "1" ] || [ "$hitl" == "true" ]; then
|
||||
hitl=true
|
||||
else
|
||||
hitl=false
|
||||
fi
|
||||
|
||||
export PX4_SIM_MODEL=${VEHICLE_MODEL:=iris}
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
src_path="$SCRIPT_DIR/.."
|
||||
echo ${SCRIPT}
|
||||
build_path=${src_path}/build/${target}
|
||||
source ${src_path}/Tools/setup_gazebo.bash ${src_path} ${src_path}/build/${target}
|
||||
sleep 1
|
||||
|
||||
sitl_path=${SCRIPT_DIR}/sitl_gazebo
|
||||
world_name="--world_name ${world}"
|
||||
jinja_world_script=${sitl_path}/scripts/jinja_world_gen.py
|
||||
sitl_ode_threads="--ode_threads ${threads}"
|
||||
world_json="--json_gen ${wjson}"
|
||||
|
||||
if [ $hitl == true ]; then
|
||||
hitl_model_name="--model_name ${PX4_SIM_MODEL}"
|
||||
echo "HITL mode is currently turned on, disabling multiple vehicle spawn and script spawn."
|
||||
echo "RUNNING: python3 $jinja_world_script $world_name $hitl_model_name $world_json"
|
||||
python3 $jinja_world_script $world_name $hitl_model_name $world_json
|
||||
echo "Generated temp_${world}.world"
|
||||
spawn_model ${PX4_SIM_MODEL} 0 ${world} ${mjson}
|
||||
|
||||
else
|
||||
echo "killing running instances"
|
||||
pkill -x px4 || true
|
||||
echo "HITL mode is currently turned off."
|
||||
echo "RUNNING: python3 $jinja_world_script $world_name $sitl_ode_threads $world_json"
|
||||
python3 $jinja_world_script $world_name $sitl_ode_threads $world_json
|
||||
echo "Generated temp_${world}.world"
|
||||
echo "Starting gazebo: gzserver ${sitl_path}/worlds/temp_${world}.world --verbose"
|
||||
gzserver ${sitl_path}/worlds/temp_${world}.world --verbose &
|
||||
sleep 5
|
||||
|
||||
n=0
|
||||
if [ -z ${SCRIPT} ]; then
|
||||
if [ $num_vehicles -gt 255 ]; then
|
||||
echo "Tried spawning $num_vehicles vehicles. The maximum number of supported vehicles is 255"
|
||||
exit 1
|
||||
fi
|
||||
while [ $n -lt $num_vehicles ]; do
|
||||
spawn_model ${PX4_SIM_MODEL} $n ${world} ${mjson}
|
||||
n=$(($n + 1))
|
||||
done
|
||||
else
|
||||
for target in ${SCRIPT}; do
|
||||
target="$(echo "$target" | tr -d ' ')" #Remove spaces
|
||||
target_vehicle="${target%:*}"
|
||||
target_number="${target#*:}"
|
||||
|
||||
if [ $n -gt 255 ]; then
|
||||
echo "Tried spawning $n vehicles. The maximum number of supported vehicles is 255"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
m=0
|
||||
while [ $m -lt ${target_number} ]; do
|
||||
spawn_model ${PX4_SIM_MODEL} $n ${world} ${mjson}
|
||||
m=$(($m + 1))
|
||||
n=$(($n + 1))
|
||||
done
|
||||
done
|
||||
fi
|
||||
echo "Starting gazebo client"
|
||||
gzclient
|
||||
fi
|
||||
Regular → Executable
@@ -1,5 +0,0 @@
|
||||
$(info px4_developer.mk inclded)
|
||||
ifeq ($(UAVCAN_BL_OVERRIDE),y)
|
||||
$(info ************************** UAVCAN BOOT LOADERS built for In place application Debugging ***************************************)
|
||||
export EXTRAFLAGS +=-DDEBUG_APPLICATION_INPLACE
|
||||
endif
|
||||
@@ -25,6 +25,8 @@ class JsonOutput():
|
||||
event_obj = {}
|
||||
event_obj['name'] = e.name
|
||||
event_obj['message'] = e.message
|
||||
if e.type is not None:
|
||||
event_obj['type'] = e.type
|
||||
if e.description is not None:
|
||||
event_obj['description'] = e.description
|
||||
args = []
|
||||
|
||||
@@ -23,6 +23,7 @@ class Event(object):
|
||||
self.message = None
|
||||
self.description = None
|
||||
self.group = "default"
|
||||
self.type = None
|
||||
self._arguments = []
|
||||
|
||||
@staticmethod
|
||||
@@ -125,11 +126,13 @@ class SourceParser(object):
|
||||
descr = descr[:i] + ' ' + descr[i+1:]
|
||||
event.description = descr
|
||||
elif tag == "group":
|
||||
known_groups = ["calibration", "health", "arming_check", "normal"]
|
||||
known_groups = ["calibration", "health", "arming_check", "default"]
|
||||
event.group = value.strip()
|
||||
if not event.group in known_groups:
|
||||
raise Exception("Unknown event group: '{}'\nKnown groups: {}\n" \
|
||||
"If this is not a typo, add the new group to the script".format(event.group, known_groups))
|
||||
elif tag == "type":
|
||||
event.type = value.strip()
|
||||
elif tag.startswith("arg"):
|
||||
arg_index = int(tag[3:])-1
|
||||
arg_name = value.strip()
|
||||
@@ -237,7 +240,7 @@ class SourceParser(object):
|
||||
event.group = "health"
|
||||
else:
|
||||
event.group = "arming_check"
|
||||
event.prepend_arguments([('common::navigation_mode_category_t', 'modes'),
|
||||
event.prepend_arguments([('navigation_mode_group_t', 'modes'),
|
||||
('uint8_t', 'health_component_index')])
|
||||
else:
|
||||
raise Exception("unknown event method call: {}, args: {}".format(call, args))
|
||||
|
||||
Regular → Executable
@@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
make parameters_metadata
|
||||
cp parameters.xml ../qgroundcontrol/src/FirmwarePlugin/PX4/PX4ParameterFactMetaData.xml
|
||||
make airframe_metadata
|
||||
cp airframes.xml ../qgroundcontrol/src/AutoPilotPlugins/PX4/AirframeFactMetaData.xml
|
||||
@@ -47,6 +47,8 @@ fi
|
||||
|
||||
# Python dependencies
|
||||
echo "Installing PX4 Python3 dependencies"
|
||||
# We need to have future to install pymavlink later.
|
||||
python3 -m pip install future
|
||||
python3 -m pip install --user -r ${DIR}/requirements.txt
|
||||
|
||||
# Optional, but recommended additional simulation tools:
|
||||
|
||||
+189
-110
@@ -2,20 +2,29 @@
|
||||
|
||||
set -e
|
||||
|
||||
## Bash script to setup PX4 development environment on Ubuntu LTS (20.04, 18.04, 16.04).
|
||||
## Can also be used in docker.
|
||||
##
|
||||
## Installs:
|
||||
## - Common dependencies and tools for nuttx, jMAVSim, Gazebo
|
||||
## - NuttX toolchain (omit with arg: --no-nuttx)
|
||||
## - jMAVSim and Gazebo9 simulator (omit with arg: --no-sim-tools)
|
||||
##
|
||||
## Not Installs:
|
||||
## - FastRTPS and FastCDR
|
||||
usage() {
|
||||
echo "
|
||||
Bash script to set up the PX4 development environment on Ubuntu LTS versions
|
||||
- 22.04
|
||||
- 20.04
|
||||
- 18.04 (without simulation support)
|
||||
|
||||
The script can be used directly or inside docker
|
||||
(use --from-docker when running inside docker).
|
||||
|
||||
Installs:
|
||||
- Build dependencies
|
||||
- NuttX toolchain (omit with arg: --no-nuttx)
|
||||
- Gazebo Classic (omit with arg: --no-gazebo-classic)
|
||||
- Gazebo Ignition (omit with arg: --no-gazebo-ignition)
|
||||
"
|
||||
}
|
||||
|
||||
INSTALL_NUTTX="true"
|
||||
INSTALL_SIM="true"
|
||||
INSTALL_ARCH=`uname -m`
|
||||
INSTALL_GAZEBO_CLASSIC="true"
|
||||
INSTALL_GAZEBO_IGNITION="true"
|
||||
INSTALL_ARCH=$(uname -m)
|
||||
INSIDE_DOCKER="false"
|
||||
|
||||
# Parse arguments
|
||||
for arg in "$@"
|
||||
@@ -24,38 +33,38 @@ do
|
||||
INSTALL_NUTTX="false"
|
||||
fi
|
||||
|
||||
if [[ $arg == "--no-sim-tools" ]]; then
|
||||
INSTALL_SIM="false"
|
||||
if [[ $arg == "--no-gazebo-classic" ]]; then
|
||||
INSTALL_GAZEBO_CLASSIC="false"
|
||||
fi
|
||||
|
||||
if [[ $arg == "--no-gazebo-ignition" ]]; then
|
||||
INSTALL_GAZEBO_IGNITION="false"
|
||||
fi
|
||||
|
||||
if [[ $arg == "--from-docker" ]]; then
|
||||
INSIDE_DOCKER="true"
|
||||
fi
|
||||
|
||||
if [[ $arg == "--help" ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
# detect if running in docker
|
||||
if [ -f /.dockerenv ]; then
|
||||
echo "Running within docker, installing initial dependencies";
|
||||
apt-get --quiet -y update && DEBIAN_FRONTEND=noninteractive apt-get --quiet -y install \
|
||||
ca-certificates \
|
||||
gnupg \
|
||||
lsb-core \
|
||||
sudo \
|
||||
wget \
|
||||
;
|
||||
fi
|
||||
|
||||
# script directory
|
||||
# Script directory
|
||||
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
|
||||
# check requirements.txt exists (script not run in source tree)
|
||||
# Check requirements.txt exists (script not run in source tree)
|
||||
REQUIREMENTS_FILE="requirements.txt"
|
||||
if [[ ! -f "${DIR}/${REQUIREMENTS_FILE}" ]]; then
|
||||
echo "FAILED: ${REQUIREMENTS_FILE} needed in same directory as ubuntu.sh (${DIR})."
|
||||
return 1
|
||||
echo "Failed: ${REQUIREMENTS_FILE} needed in same directory as ubuntu.sh (${DIR})."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# check ubuntu version
|
||||
# otherwise warn and point to docker?
|
||||
UBUNTU_RELEASE="`lsb_release -rs`"
|
||||
# Check ubuntu version
|
||||
UBUNTU_RELEASE=$(lsb_release -rs)
|
||||
|
||||
if [[ "${UBUNTU_RELEASE}" == "14.04" ]]; then
|
||||
echo "Ubuntu 14.04 is no longer supported"
|
||||
@@ -65,24 +74,43 @@ elif [[ "${UBUNTU_RELEASE}" == "16.04" ]]; then
|
||||
exit 1
|
||||
elif [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then
|
||||
echo "Ubuntu 18.04"
|
||||
echo "Gazebo Classic and Gazebo Ignition omitted"
|
||||
INSTALL_GAZEBO_IGNITION="false"
|
||||
INSTALL_GAZEBO_CLASSIC="false"
|
||||
elif [[ "${UBUNTU_RELEASE}" == "20.04" ]]; then
|
||||
echo "Ubuntu 20.04"
|
||||
elif [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then
|
||||
echo "Ubuntu 22.04"
|
||||
fi
|
||||
|
||||
VERBOSE_BAR="================================================================================"
|
||||
echo
|
||||
echo $VERBOSE_BAR
|
||||
echo "⚡️ Starting PX4 Dependency Installer for Ubuntu ${UBUNTU_RELEASE} (${INSTALL_ARCH})"
|
||||
echo ""
|
||||
echo "Options:
|
||||
- Install NuttX toolchain: ${INSTALL_NUTTX}
|
||||
- Install Gazebo Classic: ${INSTALL_GAZEBO_CLASSIC}
|
||||
- Install Gazebo Ignition: ${INSTALL_GAZEBO_IGNITION}"
|
||||
echo $VERBOSE_BAR
|
||||
echo
|
||||
|
||||
echo
|
||||
echo "Installing PX4 general dependencies"
|
||||
echo $VERBOSE_BAR
|
||||
echo "🍻 Installing System Dependencies"
|
||||
echo $VERBOSE_BAR
|
||||
echo
|
||||
|
||||
sudo apt-get update -y --quiet
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
|
||||
astyle \
|
||||
build-essential \
|
||||
cmake \
|
||||
cppcheck \
|
||||
file \
|
||||
g++ \
|
||||
gcc \
|
||||
gdb \
|
||||
astyle \
|
||||
cmake \
|
||||
cppcheck \
|
||||
file \
|
||||
git \
|
||||
lcov \
|
||||
libxml2-dev \
|
||||
@@ -98,34 +126,32 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends i
|
||||
shellcheck \
|
||||
unzip \
|
||||
zip \
|
||||
libssl-dev \
|
||||
;
|
||||
|
||||
# Python3 dependencies
|
||||
# Python 3 dependencies
|
||||
echo
|
||||
echo "Installing PX4 Python3 dependencies"
|
||||
if [ -n "$VIRTUAL_ENV" ]; then
|
||||
# virtual environments don't allow --user option
|
||||
python -m pip install -r ${DIR}/requirements.txt
|
||||
else
|
||||
# older versions of Ubuntu require --user option
|
||||
python3 -m pip install --user -r ${DIR}/requirements.txt
|
||||
fi
|
||||
echo $VERBOSE_BAR
|
||||
echo "🍻 Installing Python dependencies"
|
||||
echo $VERBOSE_BAR
|
||||
echo
|
||||
|
||||
python3 -m pip install -r "$DIR"/requirements.txt
|
||||
|
||||
# NuttX toolchain (arm-none-eabi-gcc)
|
||||
if [[ $INSTALL_NUTTX == "true" ]]; then
|
||||
|
||||
echo
|
||||
echo "Installing NuttX dependencies"
|
||||
echo $VERBOSE_BAR
|
||||
echo "🍻 Installing NuttX dependencies"
|
||||
echo $VERBOSE_BAR
|
||||
echo
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
|
||||
automake \
|
||||
binutils-dev \
|
||||
bison \
|
||||
build-essential \
|
||||
flex \
|
||||
g++-multilib \
|
||||
gcc-multilib \
|
||||
gdb-multiarch \
|
||||
genromfs \
|
||||
gettext \
|
||||
gperf \
|
||||
@@ -144,99 +170,108 @@ if [[ $INSTALL_NUTTX == "true" ]]; then
|
||||
texinfo \
|
||||
u-boot-tools \
|
||||
util-linux \
|
||||
vim-common \
|
||||
g++-arm-linux-gnueabihf \
|
||||
gcc-arm-linux-gnueabihf \
|
||||
g++-aarch64-linux-gnu \
|
||||
gcc-aarch64-linux-gnu \
|
||||
;
|
||||
if [[ "${UBUNTU_RELEASE}" == "20.04" ]]; then
|
||||
|
||||
if [[ "${UBUNTU_RELEASE}" == "20.04" ]] || [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
|
||||
kconfig-frontends \
|
||||
;
|
||||
fi
|
||||
|
||||
|
||||
if [ -n "$USER" ]; then
|
||||
# add user to dialout group (serial port access)
|
||||
sudo usermod -a -G dialout $USER
|
||||
# Add user to dialout group (serial port access)
|
||||
sudo usermod -a -G dialout "$USER"
|
||||
fi
|
||||
|
||||
# arm-none-eabi-gcc
|
||||
NUTTX_GCC_VERSION="9-2020-q2-update"
|
||||
NUTTX_GCC_VERSION_SHORT="9-2020q2"
|
||||
NUTTX_GCC_VERSION="10.3-2021.10"
|
||||
echo
|
||||
echo $VERBOSE_BAR
|
||||
echo "🍻 Verifying arm-none-eabi-gcc version (${NUTTX_GCC_VERSION}), and installing if not found"
|
||||
echo
|
||||
|
||||
source $HOME/.profile # load changed path for the case the script is reran before relogin
|
||||
if [ $(which arm-none-eabi-gcc) ]; then
|
||||
source "$HOME/.profile" # load changed path for the case the script is reran before relogin
|
||||
if [ "$(which arm-none-eabi-gcc)" ]; then
|
||||
GCC_VER_STR=$(arm-none-eabi-gcc --version)
|
||||
GCC_FOUND_VER=$(echo $GCC_VER_STR | grep -c "${NUTTX_GCC_VERSION}")
|
||||
fi
|
||||
|
||||
if [[ "$GCC_FOUND_VER" == "1" ]]; then
|
||||
echo "arm-none-eabi-gcc-${NUTTX_GCC_VERSION} found, skipping installation"
|
||||
if [[ $(echo "$GCC_VER_STR" | grep -c "${NUTTX_GCC_VERSION}") == "1" ]]; then
|
||||
echo "📌 Skipping installation, the arm cross compiler was found"
|
||||
echo $VERBOSE_BAR
|
||||
echo
|
||||
|
||||
else
|
||||
echo "Installing arm-none-eabi-gcc-${NUTTX_GCC_VERSION}";
|
||||
wget -O /tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2 https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/${NUTTX_GCC_VERSION_SHORT}/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-${INSTALL_ARCH}-linux.tar.bz2 && \
|
||||
sudo tar -jxf /tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2 -C /opt/;
|
||||
echo "📌 The arm cross compiler was not found";
|
||||
echo " * Installing arm-none-eabi-gcc-${NUTTX_GCC_VERSION}";
|
||||
# The arm cross compiler hosting provider is known to throttle download speeds
|
||||
# for users who reach a certain limit of downloads in a given time frame
|
||||
# for this reason we allow for using a previously downloaded file
|
||||
# this is specially helpful when debugging this installer script
|
||||
# from within a container COMPILER_PATH="/tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2"
|
||||
COMPILER_NAME="gcc-arm-none-eabi-${NUTTX_GCC_VERSION}"
|
||||
COMPILER_PATH="/tmp/$COMPILER_NAME-linux.tar.bz2"
|
||||
if [ ! -f "$COMPILER_PATH" ]; then
|
||||
wget -O "/tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2 https://developer.arm.com/-/media/Files/downloads/gnu-rm/${NUTTX_GCC_VERSION}/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-${INSTALL_ARCH}-linux.tar.bz2"
|
||||
fi
|
||||
sudo tar -jxf $COMPILER_PATH -C /opt/;
|
||||
|
||||
# add arm-none-eabi-gcc to user's PATH
|
||||
exportline="export PATH=/opt/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}/bin:\$PATH"
|
||||
|
||||
if grep -Fxq "$exportline" $HOME/.profile; then
|
||||
exportline="export PATH=\"/opt/${COMPILER_NAME}/bin:\$PATH\""
|
||||
if [[ $INSIDE_DOCKER == "true" ]]; then
|
||||
# when running on a docker container its best to set the environment globally
|
||||
# since we don't know which user is going to be running commands on the container
|
||||
touch /etc/profile.d/px4env.sh
|
||||
echo "$exportline" >> /etc/profile.d/px4env.sh
|
||||
elif grep -Fxq "$exportline" "$HOME"/.profile; then
|
||||
echo "${NUTTX_GCC_VERSION} path already set.";
|
||||
else
|
||||
echo $exportline >> $HOME/.profile;
|
||||
echo "$exportline" >> "$HOME"/.profile;
|
||||
fi
|
||||
echo " * arm-none-eabi-gcc (${NUTTX_GCC_VERSION}) Installed successfully to /opt/${COMPILER_NAME}/bin"
|
||||
echo $VERBOSE_BAR
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
|
||||
# Simulation tools
|
||||
if [[ $INSTALL_SIM == "true" ]]; then
|
||||
|
||||
echo
|
||||
echo "Installing PX4 simulation dependencies"
|
||||
|
||||
install_gazebo_common() {
|
||||
# General simulation dependencies
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
|
||||
bc \
|
||||
;
|
||||
|
||||
if [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then
|
||||
java_version=11
|
||||
elif [[ "${UBUNTU_RELEASE}" == "20.04" ]]; then
|
||||
java_version=13
|
||||
elif [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then
|
||||
java_version=11
|
||||
else
|
||||
java_version=14
|
||||
fi
|
||||
# Java (jmavsim or fastrtps)
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
|
||||
ant \
|
||||
openjdk-$java_version-jre \
|
||||
openjdk-$java_version-jdk \
|
||||
libvecmath-java \
|
||||
;
|
||||
# Installing Gazebo and dependencies
|
||||
# Setup OSRF Gazebo repository
|
||||
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
|
||||
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
|
||||
# Update list, since new gazebo-stable.list has been added
|
||||
sudo apt-get update -y --quiet
|
||||
}
|
||||
|
||||
# Set Java 11 as default
|
||||
sudo update-alternatives --set java $(update-alternatives --list java | grep "java-$java_version")
|
||||
# Gazebo Classic
|
||||
if [[ $INSTALL_GAZEBO_CLASSIC == "true" ]]; then
|
||||
|
||||
# Gazebo
|
||||
if [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then
|
||||
gazebo_version=9
|
||||
gazebo_packages="gazebo$gazebo_version libgazebo$gazebo_version-dev"
|
||||
elif [[ "${UBUNTU_RELEASE}" == "22.04" ]]; then
|
||||
gazebo_packages="gazebo libgazebo-dev"
|
||||
else
|
||||
# default and Ubuntu 20.04
|
||||
gazebo_version=11
|
||||
gazebo_packages="gazebo$gazebo_version libgazebo$gazebo_version-dev"
|
||||
fi
|
||||
echo
|
||||
echo $VERBOSE_BAR
|
||||
echo "🍻 Installing Gazebo Classic"
|
||||
echo
|
||||
|
||||
echo " * Gazebo Classic (Version 11)"
|
||||
echo $VERBOSE_BAR
|
||||
|
||||
install_gazebo_common
|
||||
|
||||
# Installing Gazebo and dependencies
|
||||
# Setup OSRF Gazebo repository
|
||||
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
|
||||
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
|
||||
# Update list, since new gazebo-stable.list has been added
|
||||
sudo apt-get update -y --quiet
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
|
||||
dmidecode \
|
||||
$gazebo_packages \
|
||||
gazebo libgazebo-dev \
|
||||
gstreamer1.0-plugins-bad \
|
||||
gstreamer1.0-plugins-base \
|
||||
gstreamer1.0-plugins-good \
|
||||
@@ -257,7 +292,51 @@ if [[ $INSTALL_SIM == "true" ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $INSTALL_NUTTX == "true" ]]; then
|
||||
# Gazebo Ignition
|
||||
if [[ $INSTALL_GAZEBO_IGNITION == "true" ]]; then
|
||||
|
||||
echo
|
||||
echo "Relogin or reboot computer before attempting to build NuttX targets"
|
||||
echo $VERBOSE_BAR
|
||||
echo "🍻 Installing Gazebo IGNITION"
|
||||
echo
|
||||
|
||||
echo " * Gazebo Ignition (Version 6 / Fortress)"
|
||||
echo $VERBOSE_BAR
|
||||
|
||||
# We have likely done the common pieces already earlier.
|
||||
if [[ $INSTALL_GAZEBO_CLASSIC != "true" ]]; then
|
||||
install_gazebo_common
|
||||
fi
|
||||
|
||||
#
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
|
||||
ignition-fortress \
|
||||
;
|
||||
fi
|
||||
|
||||
|
||||
if [[ $INSIDE_DOCKER == "true" ]]; then
|
||||
# cleanup installation
|
||||
rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*
|
||||
fi
|
||||
|
||||
if [[ $INSIDE_DOCKER == "false" ]] && [[ $INSTALL_NUTTX == "true" ]]; then
|
||||
echo
|
||||
echo $VERBOSE_BAR
|
||||
echo "💡 We recommend you relogin/reboot before attempting to upload NuttX targets"
|
||||
echo " to be part of the dialout group to have access to serial ports."
|
||||
echo $VERBOSE_BAR
|
||||
echo
|
||||
fi
|
||||
|
||||
echo
|
||||
echo
|
||||
echo $VERBOSE_BAR
|
||||
echo "⚡️ PX4 Dependency Installer ended successfully
|
||||
|
||||
For more information on PX4 Autopilot check out our docs
|
||||
at https://docs.px4.io.
|
||||
If you find a bug please file an issue
|
||||
on https://github.com/PX4/PX4-Autopilot"
|
||||
echo $VERBOSE_BAR
|
||||
echo
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Setup environment to make PX4 visible to Gazebo.
|
||||
#
|
||||
# Note, this is not necessary if using a ROS catkin workspace with the px4
|
||||
# package as the paths are exported.
|
||||
#
|
||||
# License: according to LICENSE.md in the root directory of the PX4 Firmware repository
|
||||
|
||||
if [ "$#" != 2 ]; then
|
||||
echo -e "usage: source setup_gazebo.bash src_dir build_dir\n"
|
||||
return 1
|
||||
fi
|
||||
|
||||
SRC_DIR=$1
|
||||
BUILD_DIR=$2
|
||||
|
||||
# setup Gazebo env and update package path
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${SRC_DIR}/build/px4_sitl_default/build_ign_gazebo
|
||||
export IGN_GAZEBO_SYSTEM_PLUGIN_PATH=$IGN_GAZEBO_SYSTEM_PLUGIN_PATH:${SRC_DIR}/build/px4_sitl_default/build_ign_gazebo
|
||||
export IGN_GAZEBO_RESOURCE_PATH=$IGN_GAZEBO_RESOURCE_PATH:${SRC_DIR}/Tools/simulation-ignition/models
|
||||
|
||||
echo -e "LD_LIBRARY_PATH $LD_LIBRARY_PATH"
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Setup environment to make JSBSim visible to PX4.
|
||||
#
|
||||
# License: according to LICENSE.md in the root directory of the PX4 Firmware repository
|
||||
|
||||
if [ "$#" != 3 ]; then
|
||||
echo -e "usage: source setup_jsbsim.bash src_dir build_dir model\n"
|
||||
return 1
|
||||
fi
|
||||
|
||||
SRC_DIR="$1"
|
||||
BUILD_DIR="$2"
|
||||
MODEL="$3"
|
||||
|
||||
export FG_AIRCRAFT="${SRC_DIR}/Tools/jsbsim_bridge/models"
|
||||
|
||||
# This is needed for aircraft namespace mapping
|
||||
# Need more architectural discussions to make this more scalable
|
||||
case "$MODEL" in
|
||||
rascal)
|
||||
MODEL_NAME="Rascal110-JSBSim"
|
||||
;;
|
||||
malolo)
|
||||
MODEL_NAME="Malolo1"
|
||||
;;
|
||||
quadrotor_x)
|
||||
MODEL_NAME="quadrotor_x"
|
||||
;;
|
||||
hexarotor_x)
|
||||
MODEL_NAME="hexarotor_x"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown Model"
|
||||
exit 1
|
||||
|
||||
esac
|
||||
|
||||
export JSBSIM_AIRCRAFT_MODEL="$MODEL_NAME"
|
||||
Submodule Tools/simulation-ignition deleted from 483193d9b8
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ "$#" -lt 4 ]; then
|
||||
echo usage: sitl_run.sh sitl_bin model src_path build_path
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sitl_bin="$1"
|
||||
model="$2"
|
||||
src_path="$3"
|
||||
build_path="$4"
|
||||
|
||||
echo SITL ARGS
|
||||
|
||||
echo sitl_bin: $sitl_bin
|
||||
echo model: $model
|
||||
echo src_path: $src_path
|
||||
echo build_path: $build_path
|
||||
|
||||
rootfs="$build_path/rootfs" # this is the working directory
|
||||
mkdir -p "$rootfs"
|
||||
|
||||
export PX4_SIM_MODEL=${model}
|
||||
|
||||
echo "FG setup"
|
||||
cd "${src_path}/Tools/simulation/flightgear/flightgear_bridge/"
|
||||
./FG_run.py models/${model}.json 0
|
||||
"${build_path}/build_flightgear_bridge/flightgear_bridge" 0 `./get_FGbridge_params.py "models/"${model}".json"` &
|
||||
FG_BRIDGE_PID=$!
|
||||
|
||||
pushd "$rootfs" >/dev/null
|
||||
|
||||
# Do not exit on failure now from here on because we want the complete cleanup
|
||||
set +e
|
||||
|
||||
sitl_command="\"$sitl_bin\" \"$build_path\"/etc"
|
||||
|
||||
echo SITL COMMAND: $sitl_command
|
||||
|
||||
eval $sitl_command
|
||||
|
||||
popd >/dev/null
|
||||
|
||||
kill $FG_BRIDGE_PID
|
||||
kill -9 `cat /tmp/px4fgfspid_0`
|
||||
@@ -17,7 +17,7 @@ BUILD_DIR=$2
|
||||
|
||||
# setup Gazebo env and update package path
|
||||
export GAZEBO_PLUGIN_PATH=$GAZEBO_PLUGIN_PATH:${BUILD_DIR}/build_gazebo
|
||||
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:${SRC_DIR}/Tools/sitl_gazebo/models
|
||||
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:${SRC_DIR}/Tools/simulation/gazebo/sitl_gazebo/models
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${BUILD_DIR}/build_gazebo
|
||||
|
||||
echo -e "GAZEBO_PLUGIN_PATH $GAZEBO_PLUGIN_PATH"
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
# The simulator is expected to send to TCP port 4560+i for i in [0, N-1]
|
||||
# For example gazebo can be run like this:
|
||||
#./Tools/gazebo_sitl_multiple_run.sh -n 10 -m iris
|
||||
#./Tools/simulation/gazebo/sitl_multiple_run.sh -n 10 -m iris
|
||||
|
||||
function cleanup() {
|
||||
pkill -x px4
|
||||
@@ -29,13 +29,13 @@ function spawn_model() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
working_dir="$build_path/instance_$n"
|
||||
working_dir="$build_path/rootfs/$n"
|
||||
[ ! -d "$working_dir" ] && mkdir -p "$working_dir"
|
||||
|
||||
pushd "$working_dir" &>/dev/null
|
||||
echo "starting instance $N in $(pwd)"
|
||||
../bin/px4 -i $N -d "$build_path/etc" -w sitl_${MODEL}_${N} -s etc/init.d-posix/rcS >out.log 2>err.log &
|
||||
python3 ${src_path}/Tools/sitl_gazebo/scripts/jinja_gen.py ${src_path}/Tools/sitl_gazebo/models/${MODEL}/${MODEL}.sdf.jinja ${src_path}/Tools/sitl_gazebo --mavlink_tcp_port $((4560+${N})) --mavlink_udp_port $((14560+${N})) --mavlink_id $((1+${N})) --gst_udp_port $((5600+${N})) --video_uri $((5600+${N})) --mavlink_cam_udp_port $((14530+${N})) --output-file /tmp/${MODEL}_${N}.sdf
|
||||
$build_path/bin/px4 -i $N -d "$build_path/etc" >out.log 2>err.log &
|
||||
python3 ${src_path}/Tools/simulation/gazebo/sitl_gazebo/scripts/jinja_gen.py ${src_path}/Tools/simulation/gazebo/sitl_gazebo/models/${MODEL}/${MODEL}.sdf.jinja ${src_path}/Tools/simulation/gazebo/sitl_gazebo --mavlink_tcp_port $((4560+${N})) --mavlink_udp_port $((14560+${N})) --mavlink_id $((1+${N})) --gst_udp_port $((5600+${N})) --video_uri $((5600+${N})) --mavlink_cam_udp_port $((14530+${N})) --output-file /tmp/${MODEL}_${N}.sdf
|
||||
|
||||
echo "Spawning ${MODEL}_${N} at ${X} ${Y}"
|
||||
|
||||
@@ -73,7 +73,7 @@ export PX4_SIM_MODEL=${vehicle_model}
|
||||
|
||||
echo ${SCRIPT}
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
src_path="$SCRIPT_DIR/.."
|
||||
src_path="$SCRIPT_DIR/../../.."
|
||||
|
||||
build_path=${src_path}/build/${target}
|
||||
mavlink_udp_port=14560
|
||||
@@ -84,7 +84,7 @@ pkill -x px4 || true
|
||||
|
||||
sleep 1
|
||||
|
||||
source ${src_path}/Tools/setup_gazebo.bash ${src_path} ${src_path}/build/${target}
|
||||
source ${src_path}/Tools/simulation/gazebo/setup_gazebo.bash ${src_path} ${src_path}/build/${target}
|
||||
|
||||
# To use gazebo_ros ROS2 plugins
|
||||
if [[ -n "$ROS_VERSION" ]] && [ "$ROS_VERSION" == "2" ]; then
|
||||
@@ -94,7 +94,7 @@ else
|
||||
fi
|
||||
|
||||
echo "Starting gazebo"
|
||||
gzserver ${src_path}/Tools/sitl_gazebo/worlds/${world}.world --verbose $ros_args &
|
||||
gzserver ${src_path}/Tools/simulation/gazebo/sitl_gazebo/worlds/${world}.world --verbose $ros_args &
|
||||
sleep 5
|
||||
|
||||
n=0
|
||||
Executable
+180
@@ -0,0 +1,180 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
if [ "$#" -lt 6 ]; then
|
||||
echo usage: sitl_run.sh sitl_bin debugger model world src_path build_path
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -n "$DONT_RUN" ]]; then
|
||||
echo "Not running simulation (DONT_RUN is set)."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
sitl_bin="$1"
|
||||
debugger="$2"
|
||||
model="$3"
|
||||
world="$4"
|
||||
src_path="$5"
|
||||
build_path="$6"
|
||||
|
||||
echo SITL ARGS
|
||||
|
||||
echo sitl_bin: $sitl_bin
|
||||
echo debugger: $debugger
|
||||
echo model: $model
|
||||
echo world: $world
|
||||
echo src_path: $src_path
|
||||
echo build_path: $build_path
|
||||
|
||||
rootfs="$build_path/rootfs" # this is the working directory
|
||||
mkdir -p "$rootfs"
|
||||
|
||||
# To disable user input
|
||||
if [[ -n "$NO_PXH" ]]; then
|
||||
no_pxh=-d
|
||||
else
|
||||
no_pxh=""
|
||||
fi
|
||||
|
||||
# To disable user input
|
||||
if [[ -n "$VERBOSE_SIM" ]]; then
|
||||
verbose="--verbose"
|
||||
else
|
||||
verbose=""
|
||||
fi
|
||||
|
||||
# Disable follow mode
|
||||
if [[ "$PX4_NO_FOLLOW_MODE" != "1" ]]; then
|
||||
follow_mode="--gui-client-plugin libgazebo_user_camera_plugin.so"
|
||||
else
|
||||
follow_mode=""
|
||||
fi
|
||||
|
||||
# To use gazebo_ros ROS2 plugins
|
||||
if [[ -n "$ROS_VERSION" ]] && [ "$ROS_VERSION" == "2" ]; then
|
||||
ros_args="-s libgazebo_ros_init.so -s libgazebo_ros_factory.so"
|
||||
else
|
||||
ros_args=""
|
||||
fi
|
||||
|
||||
if [ "$model" == "" ] || [ "$model" == "none" ]; then
|
||||
echo "empty model, setting iris as default"
|
||||
model="iris"
|
||||
fi
|
||||
|
||||
# kill process names that might stil
|
||||
# be running from last time
|
||||
pkill -x gazebo || true
|
||||
|
||||
export PX4_SIM_MODEL=${model}
|
||||
export PX4_SIM_WORLD=${world}
|
||||
|
||||
SIM_PID=0
|
||||
|
||||
if [ -x "$(command -v gazebo)" ]; then
|
||||
# Get the model name
|
||||
model_name="${model}"
|
||||
# Check if a 'modelname-gen.sdf' file exist for the models using jinja and generating the SDF files
|
||||
if [ -f "${src_path}/Tools/simulation/gazebo/sitl_gazebo/models/${model}/${model}-gen.sdf" ]; then
|
||||
model_name="${model}-gen"
|
||||
fi
|
||||
|
||||
# Set the plugin path so Gazebo finds our model and sim
|
||||
source "$src_path/Tools/simulation/gazebo/setup_gazebo.bash" "${src_path}" "${build_path}"
|
||||
if [ -z $PX4_SITL_WORLD ]; then
|
||||
#Spawn predefined world
|
||||
if [ "$world" == "none" ]; then
|
||||
if [ -f ${src_path}/Tools/simulation/gazebo/sitl_gazebo/worlds/${model}.world ]; then
|
||||
echo "empty world, default world ${model}.world for model found"
|
||||
world_path="${src_path}/Tools/simulation/gazebo/sitl_gazebo/worlds/${model}.world"
|
||||
else
|
||||
echo "empty world, setting empty.world as default"
|
||||
world_path="${src_path}/Tools/simulation/gazebo/sitl_gazebo/worlds/empty.world"
|
||||
fi
|
||||
else
|
||||
#Spawn empty world if world with model name doesn't exist
|
||||
world_path="${src_path}/Tools/simulation/gazebo/sitl_gazebo/worlds/${world}.world"
|
||||
fi
|
||||
else
|
||||
if [ -f ${src_path}/Tools/simulation/gazebo/sitl_gazebo/worlds/${PX4_SITL_WORLD}.world ]; then
|
||||
# Spawn world by name if exists in the worlds directory from environment variable
|
||||
world_path="${src_path}/Tools/simulation/gazebo/sitl_gazebo/worlds/${PX4_SITL_WORLD}.world"
|
||||
else
|
||||
# Spawn world from environment variable with absolute path
|
||||
world_path="$PX4_SITL_WORLD"
|
||||
fi
|
||||
fi
|
||||
gzserver $verbose $world_path $ros_args &
|
||||
SIM_PID=$!
|
||||
|
||||
# Check all paths in ${GAZEBO_MODEL_PATH} for specified model
|
||||
IFS_bak=$IFS
|
||||
IFS=":"
|
||||
for possible_model_path in ${GAZEBO_MODEL_PATH}; do
|
||||
if [ -z $possible_model_path ]; then
|
||||
continue
|
||||
fi
|
||||
# trim \r from path
|
||||
possible_model_path=$(echo $possible_model_path | tr -d '\r')
|
||||
if test -f "${possible_model_path}/${model}/${model}.sdf" ; then
|
||||
modelpath=$possible_model_path
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS=$IFS_bak
|
||||
|
||||
if [ -z $modelpath ]; then
|
||||
echo "Model ${model} not found in model path: ${GAZEBO_MODEL_PATH}"
|
||||
exit 1
|
||||
else
|
||||
echo "Using: ${modelpath}/${model}/${model}.sdf"
|
||||
fi
|
||||
|
||||
while gz model --verbose --spawn-file="${modelpath}/${model}/${model_name}.sdf" --model-name=${model} -x 1.01 -y 0.98 -z 0.83 2>&1 | grep -q "An instance of Gazebo is not running."; do
|
||||
echo "gzserver not ready yet, trying again!"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [[ -n "$HEADLESS" ]]; then
|
||||
echo "not running gazebo gui"
|
||||
else
|
||||
# gzserver needs to be running to avoid a race. Since the launch
|
||||
# is putting it into the background we need to avoid it by backing off
|
||||
sleep 3
|
||||
nice -n 20 gzclient --verbose $follow_mode &
|
||||
GUI_PID=$!
|
||||
fi
|
||||
else
|
||||
echo "You need to have gazebo simulator installed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pushd "$rootfs" >/dev/null
|
||||
|
||||
# Do not exit on failure now from here on because we want the complete cleanup
|
||||
set +e
|
||||
|
||||
sitl_command="\"$sitl_bin\" $no_pxh \"$build_path\"/etc"
|
||||
|
||||
echo SITL COMMAND: $sitl_command
|
||||
|
||||
if [ "$debugger" == "lldb" ]; then
|
||||
eval lldb -- $sitl_command
|
||||
elif [ "$debugger" == "gdb" ]; then
|
||||
eval gdb --args $sitl_command
|
||||
elif [ "$debugger" == "valgrind" ]; then
|
||||
eval valgrind --track-origins=yes --leak-check=full -v $sitl_command
|
||||
elif [ "$debugger" == "callgrind" ]; then
|
||||
eval valgrind --tool=callgrind -v $sitl_command
|
||||
else
|
||||
eval $sitl_command
|
||||
fi
|
||||
|
||||
popd >/dev/null
|
||||
|
||||
|
||||
kill -9 $SIM_PID
|
||||
if [[ ! -n "$HEADLESS" ]]; then
|
||||
kill -9 $GUI_PID
|
||||
fi
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.5 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user