Compare commits

...

152 Commits

Author SHA1 Message Date
Julian Oes 115568eb82 setup: pass through Ubuntu setup script
- Add usage function
- Add support for Ubuntu 22.04
- Update arm-none-eabi-gcc to version 10.3
- Remove jMAVSim / Java stuff
- Remove FastRTPS / Java stuff
- Fix some typos
- Add Gazebo Ignition
- Disable Gazebo for Ubuntu 18.04
- Fix some shellcheck issues
- Cleanup apt caches in docker
2022-09-09 14:38:33 +12:00
Ramon Roche c89ae1d690 ubuntu.sh: updated dependencies and output
I double checked each new dependency and made sure to build each target
with the new install script as well as test FastRTPS and Simulations

* removed unused dependencies
* settled on the absolute most updated JDK we could possibly use given
our dependencies (JDK 14)
* added conditional support for use in a container environment via a new
flag --from-docker
* added multi-platform build tools for development
2022-09-09 13:27:34 +12:00
Julian Oes ed10146e9f fmu-v6: disable Rev 0, Rev 1 for HB Mini, and CM4
As I understand it, only Rev 3 and Rev 4 were shipped by HB for Mini and
CM4, and are likely to be used for it.

It would be nice to have all combinations but it requires quite some
flash in the current implementation.
2022-09-08 20:54:19 -04:00
Julian Oes f05fccebb7 fmu-v5x: disable rev0 for HB Mini and CM4 base
As I understand it, only Rev 1 and Rev 2 were shipped by HB, and likely
to be used for the Mini and CM4.
2022-09-08 20:54:19 -04:00
Julian Oes 6bd020e848 platforms: decrease flash usage by type for bus id
My assumption is that the bus are numbered < 127.
This saves about 100 bytes of flash.
2022-09-08 20:54:19 -04:00
vincentpoont2 4fe90322db update fmu-v6x rc.board_sensors, add V6X004003 2022-09-08 20:54:19 -04:00
vincentpoont2 167c3da99d update fmuv5x rc.board_sensors with V5X004000 2022-09-08 20:54:19 -04:00
Vincent Poon 70321ed610 update v5x rc.board_sensors
add V5X004002
2022-09-08 20:54:19 -04:00
Vincentpoont2 f476ebdcbf Correct BOARD_NUM_SPI_CFG_HW_VERSIONS at board_config.h 2022-09-08 20:54:19 -04:00
Vincentpoont2 9d5adf8bab Fix Error on manifest.c 2022-09-08 20:54:19 -04:00
Vincentpoont2 e91295e5db Fix Error on board_config.h Define on FMUv5X & FMUv6X 2022-09-08 20:54:19 -04:00
Vincentpoont2 b16a53018d Add Holybro Pixhawk Pi CM4 Baseboard Support 2022-09-08 20:54:19 -04:00
Don Gagne 0987bb2e8e Fix bug with yaw only reposition
Fix formatting
2022-09-08 17:55:30 -04:00
Matthias Grob da01dd9eeb mission_block: explicitly (re)set the acceptance radius to default for takeoff items
otherwise a previously adjusted or uninitialized radius from the last flight
can cause problems during the new takeoff
2022-09-08 14:49:32 +02:00
Matthias Grob b825b61a20 mission_block: minimal acceptance radius of 1mm
to avoid float rounding errors leading to tiny acceptance radii
getting considered
2022-09-08 14:49:32 +02:00
Ville Juven 9c204774f1 px4_userspace_init: Fix NULL dereference for px4_spi_buses in user space
For targets that define the SPI buses via px4_spi_buses_all_hw, a call
to px4_set_spi_buses_from_hw_version() is needed. Otherwise a NULL
de-reference will occur when trying to access px4_spi_buses.

Fixes a system crash in px4_fmu-v5_protected:
up_assert: Assertion failed at file:armv7-m/arm_memfault.c line: 101 task: wq:lp_default
2022-09-08 07:05:11 +02:00
Justin 88bf1030b5 Update CI to use the main branches. 2022-09-07 20:03:19 -04:00
Ville Juven d4cce452cf modules/dataman: Increase stack size by 100B
Fixes:
WARN  [load_mon] dataman low on stack! (276 bytes left)

Seen on px4_fmu-v5_protected target.
2022-09-07 20:02:26 -04:00
Junwoo Hwang 2542b1bb26 Implement Pacakge delivery via Gripper during mission
This feature allows user to use a Gripper type pacakge delivery
mechanism on a drone to trigger the delivery during a mission via the
mission item `DO_GRIPPER`.

This is a minimal change that is intended to have simplest pacakge
delivery feature on PX4, however the future scope would extend this
feature out of Navigator, and rather move towards a federated PX4
(flight-mode flexibility) architecture. But until then, this will serve
the purpose.

Update Tools/sitl_gazebo submodule to remove sdf file overwrite error

- There was an error happening due to .sdf file being overwritten, it
was caused by a wrongfully added. sdf file.
- This update pulls in the PR commit: https://github.com/Auterion/sitl_gazebo/pull/147

Initial cut on supporing PAYLOAD_PLACE mission item

Tidy and comment on navigation.h to clarify mission item definition

- Convert vehicle command ack subscription data type to
SubscriptionData, to not care about having a dedicated struct for
copying the latest data
- Tidy and comment on navigation.h to clarify the definition of
mission_item_s, which is confusing as it is an intergration of MAVLink
Standard into PX4's internal Mission Item structure

Rename mission_block's mission item reached function & cleanup navigator

- Isolated Handle Vehicle Commands function inside the Navigator
- Rename mission_block's mission item reached function to 'reached or
completed', as the navigation command can also be an action (e.g.
DO_SET_SERVO, which doesn't make sense to refer to as 'reached' when we
have successfully done executed the command)

Include MAVLink PR commit to include payload_drop message

More changes to add payload_drop MAVLink message support

- Comitting for testing purposes

Add mission item payload_drop to vehicle command payload drop link

- Now with a mission item with the nav_cmd set to 'payload drop', the
appropriate 'payload drop' vehicle command will be issued

Make Payload drop executable via Mission Plan

Implement payload_drop module to simulate payload delivery

- Simple module that acknowledges the payload drop vehicle command after
certain time, to simulate a successful delivery

Additional changes - payload drop module not working yet

- Need to do more thread stuff to make it work :(

Fix Payload Drop enum mismatch in vehicle_command enums

- First functional Payload Drop Implementation MVP
- Simple Ack & resuming mission from Navigator tested successfully

Hold the position while executing payload drop mission item

- Still the position hold is not solid, maybe I am missing something in
the position setpoint part and all the internal implications of
Navigator :(

Add DO_WINCH command support

Some fixes after rebase on develop branch

- Some missed brackets
- Some comment edits, etc

Add DO_WINCH command support

- Still has a problem of flying away from the waypoint while the
DO_WINCH is being executed, probably position setpoint related stuff :(

Apply braking of the vehicle for DO_WINCH command

- Copies the behavior of NAV_CMD_DELAY, which executes a smooth, braking
behavior when executing the delay because of the braking condition in
`set_mission_items` function
- This will not apply to Fixed wings
- The payload deploy getting triggered may be too early, as right now as
soon as the vehicle approaches the waypoint within the acceptance
threshold, the payload gets deployed

Add DO_GRIPPER support

Implement Gripper actual Hardware triggering support

- Currently not working, possibly in the mixer there's a bug
- Implemented the publishing of actuator_controls_1 uORB topic
- Implemented the test command for the payload_drop module, to test the
grpiper functionality
- Edited px4board file to include the payload_drop module
- Added Holybro X500 V2 airframe file, to enable testing on X500 V2
- Created new Quad X Payload Delivery mixer, which maps the actuator
controls 1 topic's data into the MAIN pin 5 output

Make Payload Drop Gripper Work

- Initialization of the Gripper position to CLOSED on Constructor of the
payload_drop module
- Setting the OPEN and CLOSED value to the appropriate actuator controls
input

Set vehicle_command_ack message's timestamp correctly

- By not setting the timestamp, the ack commands were not correctly
graphed in PlotJuggler!

Rename payload drop module to payload deliverer

- I think it's a more complex name (harder to type), but more generic

Add Gripper class (WIP)

Add Gripper class functionalities

- Add gripper uORB message
- Add gripper state machine

Use Gripper class as main interface in payload_deliverer

- Utilizes Gripper class functions for doing Gripper functionality

Remove mixer based package delivery trigger logic

- Remove custom mixer files that mapped actuator controls to outputs
statically

Additional improvements of the payload_deliverer

Fix payload_deliverer module not starting

- _task_id wasn't geting set appropriately in task_spawn function, which
led to runtime failure

Add Gripper Function to mixer_module

- Still not showing up as function mapping in QGC, needs fix

Add parameters to control gripper behavior

- Now user can enable / disable gripper
- Also select which type of gripper to use

Applying review from nuno

Remove timeout fetching from mission item and use gripper's timeout

- Previously, it was planned to use a custom DO_GRIPPER and DO_WINCH
MAVLink message definitions with information on timeout, but since now
we are using original message definition, only relevant timeout
information is defined in the payload_deliverer class

- This change brings in the timeout parameter to the Navigator, which
then sets the timeout in the mission_block class level, which then
processes the timeout logic

Make payload deployment work for Allmend test :P

Support gripper open/close test commands in payload_deliverer

Move enum definition for GRIPPER_ACTION to vehicle_command.msg

Remove double call for ` ${R}etc/init.d/rc.vehicle_setup`

- Was introduced during the rebase
- Was causing module already running & uORB topic can't be advertised
errors

Fix format via `make format` command

Modify S500 airframe file to use for control allocation usage

- Added Control allocation related parameters as default to not have it
reset every time the airframe is selected

Implement mission specific payload deploy timeout and more changes

Switch payload_deliverer to run on work queue

Remove unnecessary files

- Airframe changes from enabling control allocation are removed

Address review comments

- Remove debug messages
- Remove unnecessary or verbose comments & code
- Properly call parameter_update() function

Switch payload_deliverer to scheduled interval work item & refactor

- Switch to Schedeuled on Interval Work Item, as previous vehicle
command subscription callback based behavior led to vehicle comamnd ack
not being sent accordingly (since the Run() wouldn't be called unless
there's a new vehicle command), leading to ack command not being sent
out
- Also, old vehicle commands were getting fetched due to the
subscription callback as well, which was removed with this patch
- Fix the wrong population of floating point param2 field of vehicle
command by int8_t type gripper action by creating dedicated function
- Refactor and add comments to increase readability

Add gripper::grabbing() method and handle this in parameter update

- Previously, the intermediate state 'grabbing' was not considered, and
when the parameter update was called after the first initialization of
the gripper, the grab() function was being called again, which would
produce unnecessary duplicate vehicle command.
- Also replaced direct .grab() access to sending vehicle comamnd, which
unifies the gripper actuation mechanism through vehicle commands.

Navigator: Change SubscriptionData to Subscription to reduce memory usage

- Also removed unused vehicle command ack sub

PayloadDeliverer: Remove unnecessary changes & Bring back vehicle_command sub cb
2022-09-07 08:11:52 +02:00
Matthias Grob e115095f70 Functions: correct interpolate function for N points 2022-09-07 08:00:27 +02:00
Beat Küng 4087c27e84 control_allocator: handle saturation flags for helicopters 2022-09-07 08:00:27 +02:00
alexklimaj aa8d594e9b Add heli servo trim 2022-09-07 08:00:27 +02:00
Matthias Grob 667e99be81 Helicopter: fix unit test after default throttle curve was changed 2022-09-07 08:00:27 +02:00
Matthias Grob 115cf4d572 Helicopter: More intuitive yaw direction configuration for the common cases 2022-09-07 08:00:27 +02:00
Matthias Grob f233f2167e generic_250, px4vision: remove zero manual thrust without airmode
When hitting zero thrust by stick there is 0 torque authority
without airmode. So 0% minimum manual thrust should never be the default
without airmode.
2022-09-07 08:00:27 +02:00
Matthias Grob 8a25d06ed7 heli_defaults: comment and spacing 2022-09-07 08:00:26 +02:00
Beat Küng cecef7e3f6 control_allocator: update heli throttle + collective curve defaults 2022-09-07 08:00:26 +02:00
Beat Küng d38c02fd6a commander: increase maximum COM_SPOOLUP_TIME to 30s (for helis) 2022-09-07 08:00:26 +02:00
Beat Küng 2635e2c386 airframes: replace blade with generic helicopter 2022-09-07 08:00:26 +02:00
Beat Küng 7e75b497ae helicopter: add switch to engage main motor
For helicopters it's useful (e.g. during bringup) to be able to disable
the main rotor while the tail is still controlled to safely land.
2022-09-07 08:00:26 +02:00
Matthias Grob f32d931117 helicopter: add yaw sign parameter & expose settings in UI 2022-09-07 08:00:26 +02:00
Matthias Grob 349f152601 Helicopter: throttle spoolup upon arming
Uses COM_SPOOLUP_TIME to slowly ramp the throttle and allow the
tailrotor to compensate in a coordinated way based on the yaw
compesation from throttle, see CA_HELI_YAW_TH_S.

This coordinated spoolup is necessary to avoid unsafe yaw twitches
because of the heli rotating until the correct compensation kicks in
through the feedback controller.
2022-09-07 08:00:26 +02:00
Matthias Grob 7bf62373ae Helicopter: refactor complicated throttle curve logic 2022-09-07 08:00:26 +02:00
Matthias Grob 2edb35b1b5 Functions: add gradual function with arbitrary number of corner points 2022-09-07 08:00:26 +02:00
Matthias Grob 6a9a049f1e Helicopter: add unit testing for throttle curve 2022-09-07 08:00:26 +02:00
Matthias Grob 9ba6f4efb7 Helicopter: add yaw compensation from throttle CA_HELI_YAW_TH_S 2022-09-07 08:00:26 +02:00
Matthias Grob 554d965a2d Helicopter: use absolute value for yaw compensation from collective pitch 2022-09-07 08:00:26 +02:00
Beat Küng 608ab9ff9c control_allocator: extend description for CA_SP0_ANGx 2022-09-07 08:00:25 +02:00
Beat Küng e346190e63 helicopter: use tail motor & add CA_HELI_YAW_CP_S 2022-09-07 08:00:25 +02:00
Julian Oes 5ece24cdc4 setup: attempt to fix macOS CI
Somehow the wheel install of pymavlink fails without future, let's try
to work around that.
2022-09-07 13:49:37 +12:00
Peter van der Perk 8f0c2f4146 UCANS32K1 Enable some sensors by default 2022-09-06 09:43:11 -04:00
bresch 92fbd86b46 ekf2: add gps altitude drift test 2022-09-05 10:28:37 -04:00
bresch a2a5093881 ekf2: relax zero velocity update
The ZVU is too strong and prevents the EKF from following variations in
the height aiding sources, creating large innovations.
2022-09-05 10:28:37 -04:00
Daniel Agar d996af4647 ekf2: pass gpsSample around where required
- this minimizes potential misuse accessing _gps_sample_delayed and
makes the dependency clear
2022-09-05 10:27:19 -04:00
RomanBapst 0c860fa227 airspeed_selector: don't declare wind estimate valid if estmator is not initialised
Signed-off-by: RomanBapst <bapstroman@gmail.com>
2022-09-05 10:21:38 -04:00
Ville Juven 9ed35debec board_ctrl: Clean up usage of VBUS, nARMED from user/kernelspace
Move logic implemented in the header files to source files, this way
it will be simpler to define which is compiled to kernel space and
which to user space

Also allows to remove some headers that pull in half the universe
from the board definitions (which should just be pin definitions and
no functionality)
2022-09-05 07:37:28 +02:00
Benjamin Perseghetti a56f654651 Multi-Vehicle Ignition Gazebo Simulation (#20154) 2022-09-04 21:10:29 -04:00
Daniel Agar 7bbdc220f5 ekf2: initialiseFilter() simplify mag heading init and resetQuatStateYaw
- most of resetQuatStateYaw doesn't apply to initial heading init, so
removing the special case keeps it simple
2022-09-02 08:46:10 -04:00
Ville Juven e467d11990 boards/px4/fmu-v5/toc: The RD certificate signature points to the wrong place
The signature end address is incorrect
2022-09-02 08:00:27 +02:00
Daniel Agar 5dfd2f39ef boards/cubepilot/cubeorange: initialize all I2C pins immediately 2022-09-01 20:46:09 -04:00
Daniel Agar e93a3a2a3a ak09916: enable retries and reset perf count 2022-09-01 20:45:20 -04:00
Daniel Agar f66b5ce204 simulation: ignition bridge allow IMU or pose callbacks to update system time if newer than clock
* requires HRT lockstep changes to eliminate offset (PR #20146)
2022-09-01 20:42:21 -04:00
Daniel Agar c52f2143d2 posix lockstep remove HRT offset and use full sim time 2022-09-01 20:40:37 -04:00
Daniel Agar 3da0293369 simulator_ignition_bridge: init error handling 2022-09-01 18:54:59 -04:00
Beat Küng 43c5f14aa0 commander: update arming & health protocol, add modes to event hash 2022-09-01 17:07:23 -04:00
Beat Küng f57321d365 simulator_mavlink: fix esc_status publication 2022-09-01 17:07:23 -04:00
Beat Küng 295caaea60 events/enums.json: remove redundant manual_control_input 2022-09-01 17:07:23 -04:00
Beat Küng 2c96bb3746 px4_parameters.hpp.jinja: explicitly set .name attribute
Fixes the compile error on llvm:
mixture of designated and non-designated initializers in the same initializer list is a C99 extension [-Wc99-designator]
2022-09-01 17:07:23 -04:00
Beat Küng 1370cc0d74 log.h: add PRINTF_LOG option for direct printf to reduce dependencies 2022-09-01 17:07:23 -04:00
Beat Küng a9c1415337 Makefile: allow to set CMAKE_ARGS via CLI 2022-09-01 17:07:23 -04:00
Beat Küng 4e940fab83 perf_counter: remove unused include sys/queue.h 2022-09-01 17:07:23 -04:00
Beat Küng 9eff6dd049 commander: cleanup param value description for COM_POSCTL_NAVL 2022-09-01 17:07:23 -04:00
Beat Küng 0e130eac83 refactor commander: move code inside run() into separate methods 2022-09-01 17:07:23 -04:00
Beat Küng dcb9b712bb refactor commander: move vehicle control mode to ModeUtil 2022-09-01 17:07:23 -04:00
Beat Küng f197c8884d commander: move esc checks to arming check 2022-09-01 17:07:23 -04:00
Beat Küng c9037f115b refactor commander: split out home position 2022-09-01 17:07:23 -04:00
Beat Küng f17f38197d commander: move estimator checks to arming check 2022-09-01 17:07:23 -04:00
Beat Küng cfe3d793bf commander: move battery handling into arming checks 2022-09-01 17:07:23 -04:00
Daniel Agar 5cb44a521c ekf2: estimator interface handle sample time with signed integers
- this prevents unsigned integer overflow if the timestamp is smaller
than the configured delay (mostly a simulation edge case)
2022-09-01 09:47:29 -04:00
dagar 75f6f22223 [AUTO COMMIT] update change indication 2022-08-31 08:52:30 -04:00
Daniel Agar 1948c5057a ekf2: handle all time on delayed horizon (except for newest sample checks)
- a growing number of samples come into the backend with the time
already delayed (sensor's interrupt setting timestamp sample)
 - if the incoming timestamp is already delayed then the new data checks
(relative to latest IMU) can be slightly wrong
 - handle almost all timestamps and checks on delayed time horizon,
except for explicit checks of new samples
 - isRecent() and isTimedOut() helpers use delayed time
 - add new isNewestSampleRecent() used for checking the incoming
timestamp of the incoming (adjusted) data
2022-08-31 08:52:30 -04:00
Jukka Laitinen d6a4e158cf Add call-gates to px4_crypto for protected build
This adds kernel-userspace interfaces to crypto layer

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2022-08-31 09:48:49 +02:00
Beat Küng d681782c7f fix flashfs: find_entry: do not go to the next sector if the CRC is invalid 2022-08-31 09:42:59 +02:00
Beat Küng 4f52cda504 flashfs: ensure no address past the end of a sector is dereferenced
As it might result in a hardfault if it's the last flash sector.
2022-08-31 09:42:59 +02:00
Beat Küng 2776b723ea holybro/kakuteh7: switch to flash-based params 2022-08-31 09:42:59 +02:00
Hamish Willee e780a583cd Fix typo follow height: FLW_TGT_HT 2022-08-29 13:25:35 +02:00
Ben Berry 734d3e4aa0 Reverted changes that broke Level Horizon calibration 2022-08-29 09:54:36 +02:00
Beat Küng afc99749b8 px4/fmu-v5/uavcanv0perith: disable gps to reduce flash usage 2022-08-25 22:02:15 -04:00
Beat Küng 715afd27f5 ROMFS: exclude mixers on v2 & disable mixer command
The dynamic mixing is now the default
2022-08-25 22:02:15 -04:00
Beat Küng f0295cf596 px4/fmu-v2/defconfig: disable PROCFS
Reduces flash usage by ~7.3KB
2022-08-25 22:02:15 -04:00
Beat Küng ad222760dd platforms: move CONFIG_FS_PROCFS_MAX_TASKS definition to cpuload.h
So it's used for both cases
2022-08-25 22:02:15 -04:00
Beat Küng 70ec3493c5 px4/fmu-v5/stackcheck: disable distance sensors to reduce flash 2022-08-25 22:02:15 -04:00
Beat Küng 666b84027d GyroFFT: disable 4096 for IMU_GYRO_FFT_LEN
saves around 10.5KB flash on px4-fmu-v5
2022-08-25 22:02:15 -04:00
Beat Küng 060738cae1 src: avoid use of double precision pow & exp
saves around 5KB flash on px4-fmu-v5
2022-08-25 22:02:15 -04:00
Beat Küng 983a9815eb libevents: update submodule 2022-08-25 22:02:15 -04:00
Beat Küng 4c41934bb4 commander: inline HealthComponentIndex::HealthComponentIndex
Saves around 1KB flash
2022-08-25 22:02:15 -04:00
Beat Küng 1c89b0c9c8 commander: use actuator_function for ESC reporting 2022-08-25 22:02:15 -04:00
Beat Küng 13c93db11a commander: use circuit breaker params directly in arming checks 2022-08-25 22:02:15 -04:00
Beat Küng 4230eee24f commander: print 'ready for takeoff' to console for sitl after startup 2022-08-25 22:02:15 -04:00
Beat Küng 2fccb576ad commander: remove unused includes and variables 2022-08-25 22:02:15 -04:00
Beat Küng dbb814ff24 HealthAndArmingChecks: CONSOLE_PRINT_ARMING_CHECK_EVENT & reduce flash usage
- print list of events whenever they change if
  CONSOLE_PRINT_ARMING_CHECK_EVENT is set, instead of on each update call
- reduce flash usage by moving out templated code into non-template method
2022-08-25 22:02:15 -04:00
Beat Küng b2cb164c12 commander: replace health flags with health_report from arming checks 2022-08-25 22:02:15 -04:00
Beat Küng 6d1fb92eb7 commander: rework arming checks to use the events interface 2022-08-25 22:02:15 -04:00
Beat Küng b4a3597c7d posix rcS: set PWM_AUX_OUT
Prevents a shell error in rc.interface
2022-08-25 22:02:15 -04:00
Beat Küng b3fe0eeae8 mavlink_events: send reset sequence out immediately on startup 2022-08-25 22:02:15 -04:00
Beat Küng 552d08176f posix rcS: set MAV_PROTO_VER to 2
For SITL it's important that the GCS receives the first events messages
that reset the sequence number, in case the user does not press 'Disconnect'
when restarting SITL.
2022-08-25 22:02:15 -04:00
Beat Küng c7b64e3c01 commander: check for ack when calling 'commander takeoff' 2022-08-25 22:02:15 -04:00
Beat Küng 406b0bbc86 commander: handle VEHICLE_CMD_RUN_PREARM_CHECKS 2022-08-25 22:02:15 -04:00
Beat Küng 8f9be0541f HealthAndArmingChecks: add support for legacy mavlink_log reporting 2022-08-25 22:02:15 -04:00
Beat Küng f23363f88c HealthAndArmingChecks: add unit tests for Report 2022-08-25 22:02:15 -04:00
Beat Küng 2507f0a143 px4events: fix known_groups list 2022-08-25 22:02:15 -04:00
Beat Küng fcadc69e52 mavlink_receiver: set timestamp to gps_inject_data_topic 2022-08-25 22:02:15 -04:00
Beat Küng c95192d050 orb_print_message_internal: handle 64 bit bitsets 2022-08-25 22:02:15 -04:00
Beat Küng b7a6de05df arming checks: add health topic 2022-08-25 22:02:15 -04:00
Beat Küng 07afcf4586 commander preflight checks: new structure using events interface
- Reporter class that keeps track of results (list of events + whether
  arming is possible + health).
  And only reports when one or more checks change.
2022-08-25 22:02:15 -04:00
Beat Küng 04f7df3848 SubscriptionMultiArray: use Subscription instead of SubscriptionInterval
Saves ~3KB RAM on fmu-v5.
2022-08-25 22:02:15 -04:00
Daniel Agar 9b0b0d1168 ekf2: update test change indication csv 2022-08-25 15:55:45 -04:00
Ville Juven f60f6d2425 Remove px4_work_queue from the kernel side LD command
The comment is right, it is not needed -> get rid of it
2022-08-25 13:30:11 -04:00
Daniel Agar 2786239ca6 Jenkinsfile: HIL remove delete airframe from test 2022-08-25 09:48:49 -04:00
Benjamin Perseghetti 02c9ec6085 Add thumbnails for x500. 2022-08-25 09:10:03 -04:00
Benjamin Perseghetti 0e8e38e698 Add x500 ignition (replaces x3) 2022-08-25 09:10:03 -04:00
Daniel Agar 4040e4cdf2 simulation organization and cleanup
- new modules/simulation directory to collect all simulators and related modules
 - new Tools/simulation directory to collect and organize scattered simulation submodules, scripts, etc
 - simulation module renamed to simulator_mavlink
 - sih renamed to simulator_sih (not a great name, but I wanted to be clear it was a simulator)
 - ignition_simulator renamed to simulator_ignition_bridge
 - large sitl_target.cmake split by simulation option and in some cases pushed to appropriate modules
 - sitl targets broken down to what's actually available (eg jmavsim only has 1 model and 1 world)
 - new Gazebo consistently referred to as Ignition for now (probably the least confusing thing until we fully drop Gazebo classic support someday)
2022-08-25 09:10:03 -04:00
David Sidrane 6b2509cbba px4_fmu-v6c Move I2C 4 to External 2022-08-25 08:46:51 -04:00
FARHANG 8b4df8ceb2 airframes: re-add Holybro X500v2 with dynamic control allocation 2022-08-25 07:52:18 +02:00
Jukka Laitinen f8f1213841 board_adc: Small fix for printf formatter
Print sizeof type with %zu to be compatible with 64 bit targets, where it is unsigned long

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2022-08-25 07:50:23 +02:00
bresch 0061ef8b89 [AUTO COMMIT] update change indication 2022-08-24 09:16:11 -04:00
bresch 090d03eea2 ekf2: publish GNSS, rng and EV height biases 2022-08-24 09:16:11 -04:00
bresch a2a29ba0dd ekf2: verify parameter configuration for height sources 2022-08-24 09:16:11 -04:00
bresch 8dd5d0d1a3 ekf2: don't reset height when in conditional range aiding 2022-08-24 09:16:11 -04:00
bresch 20cd599bb7 ekf2: fix param migration 2022-08-24 09:16:11 -04:00
bresch 2d39097f60 ekf2: move rng height to file 2022-08-24 09:16:11 -04:00
bresch 28b4cd0579 ekf2: move GNSS hgt control to file 2022-08-24 09:16:11 -04:00
bresch b6f76b5eaa ekf2: move ev control to file 2022-08-24 09:16:11 -04:00
bresch f555281c94 ekf2: move height control-related function to file 2022-08-24 09:16:11 -04:00
bresch d87feee5b0 ekf2: move baro control logic to file 2022-08-24 09:16:11 -04:00
bresch 12e25eba62 ekf2: add common height fusion timeout parameter 2022-08-24 09:16:11 -04:00
bresch 52f726c5b7 ekf2: in bias estimator, use psd instead of var for prediction
PSD is independent from the sampling time while variance isn't
2022-08-24 09:16:11 -04:00
bresch b04d61c411 ekf2: param migration for rng aid, aid mask (gps) and hgt mode 2022-08-24 09:16:11 -04:00
bresch 3fb218600a ekf2_test: add multi height source unit tests 2022-08-24 09:16:11 -04:00
bresch aba2eac0df ekf2: publish GNSS, rng and EV height biases 2022-08-24 09:16:11 -04:00
bresch 6833c7e311 ekf2: adjust ekf2 aid parameters in configs 2022-08-24 09:16:11 -04:00
bresch 8962cf2d25 ekf2: GPS, baro and range finder control parameters
Also remove the legacy "range aid" than can be achieved by setting the
height reference to range finder and the range finder control parameter
to "conditional".

Conditional range aiding cal also be set when the height reference isn't
the range finder. This prevents the ratchetting effect due to switching
between references.
2022-08-24 09:16:11 -04:00
bresch 578e1339ca ekf2: re-implement range aid
range aid simply forces the range finder to be the height reference when
starting
2022-08-24 09:16:11 -04:00
bresch 88ac5ea210 ekf2_test: add test case for accel clipping handling 2022-08-24 09:16:11 -04:00
bresch 375753eba8 ekf2_test: add inertial nav falling detection tests 2022-08-24 09:16:11 -04:00
bresch 66ce1a002b ekf2_test: rename VisionHeight -> ExternalVisionHeight 2022-08-24 09:16:11 -04:00
bresch 82ec7a495a ekf2: refactor inertial nav falling check 2022-08-24 09:16:11 -04:00
bresch f9188b2a14 ekf2: refactor vertical acceleration check for multiple height sources 2022-08-24 09:16:11 -04:00
bresch 8fd79688c0 ekf2: enable multiple height sources fusion
Instead of having a single height source fused into the EKF and the
other ones "waiting" for a failure or the primary sensor, fuse all
sources in EKF2 at the same time. To prevent the sources from fighting against each
other, the "primary" source is set as reference and the other ones are
running a bias estimator in order to make all the secondary height
sources converge to the primary one.

If the reference isn't available, another one is automatically selected
from a priority list. This secondary reference keeps its current bias
estimate but stops updating it in order to be the new reference as close
as possible to the primary one.
2022-08-24 09:16:11 -04:00
bresch f5f31006a0 Ekf2: create HeightBiasEstimator class
Contains some logic common to all height bias estimators
2022-08-24 09:16:11 -04:00
JacobCrabill 57125a4c8f cyphal: Fix FMUv5 config; throw error if no CAN driver exists 2022-08-23 21:24:24 -04:00
huiyulhy c81efd0174 Fix velocity smoothing functional test 2022-08-23 21:11:35 -04:00
Beat Küng 7b810bb776 boards: update px4 io binary 2022-08-23 21:07:18 -04:00
Beat Küng b260df711c Makefile: force serial build for px4io_update 2022-08-23 21:07:18 -04:00
Beat Küng bae275898b rc/sbus: restart parser after sucessful decoding & increase time limit
Instead of directly passing the next packet to the parser after successful
parsing, switch the state to SBUS2_DECODE_STATE_SBUS_START and search for
the start byte again.

The timeout is increased as the IO main loop also takes a bit of time
(max ~0.7ms).

Tested on v5x with Futaba R7008SB (60Hz update rate) and FrSky X8R (111Hz
update rate).

Background:
When using the Futaba R7008SB, I noticed there's additional bytes added in
between packets. Often it's a null byte, but sometimes more. There's some
consistency but I did not find any documentation for it.
Sample data:
a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01 08 40 00 02 10 80 00 34 00 0f 05 ec
1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01 08 40 00 02 10 80 00 04 00 c0 8b
00 0f 04 ec 1f a8 fb 07 16 5b 81 05 d4 a0 06 20 00 01 08 40 00 02 10 80 00
14 00 0f 04 ec 1f a8 fb 07 16 5b 81 05 d4 a0 06 20 00 01 08 40 00 02 10 80
00 24 00 0f 05 ec 1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01 08 40 00 02 10
80 00 34 00 0f 05 ec 1f 30 60 bf 1c bd 07 16 5b 81 05 d4 a0 06 20 00 01 08
40 00 02 10 80 00 34 00 0f 07 ec 1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01
08 40 00 02 10 80 00 04 00 03 c0 31 00 0f 05 fc 1f a8 fb 07 16 5b 81 05 d4
a0 06 20 00 01 08 40 00 02 10 80 00 14 00 0f 05 fc 1f a8 fb 07 16 5b 81 05
d4 a0 06 20 00 01 08 40 00 02 10 80 00 24 00 0f 04 ec 1f a8 fd 07 16 5b 81
05 d4 a0 06 20 00 01 08 40 00 02 10 80 00 34 00 0f 04 ec 1f a8 fd 07 16 5b
81 05 d4 a0 06 20 00 01 08 40 00 02 10 80 00 04 00 03 c4 00 00 0f 04 ec 1f
a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01 08 40 00 02 10 80 00 14 00 0f 04 ec
1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01 08 40 00 02 10 80 00 24 00 0f 04
ec 1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01 08 40 00 02 10 80 00 34 00 0f
05 ec 1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01 08 40 00 02 10 80 00 04 00
03 c0 31 00 0f 05 ec 1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01 08 40 00 02
10 80 00 14 00 0f 05 fc 1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01 08 40 00
02 10 80 00 24 00 0f 05 fc 1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01 08 40
00 02 10 80 00 34 00 0f 05 ec 1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01 08
40 00 0f 05 ec 1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01 08 40 00 02 10 80
00 04 00 03 c0 31 00 0f 05 ec 1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01 08
40 00 02 10 80 00 14 00 0f 05 ec 1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01
08 40 00 02 10 80 00 24 00 0f 05 ec 1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00
01 08 40 00 02 10 80 00 34 00 0f 05 f4 1f a8 fb 07 16 5b 81 05 d4 a0 06 20
00 01 08 40 00 02 10 80 00 04 00 03 c4 00 00 b0 60 7f 1c bd 07 16 5b 81 05
d4 a0 06 20 00 01 08 40 00 02 10 80 00 14 00 0f 05 ec 1f a8 fd 07 16 5b 81
05 d4 a0 06 20 00 01 08 40 00 02 10 80 00 24 00 0f 05 ec 1f a8 fd 07 16 5b
81 05 d4 a0 06 20 00 01 08 40 00 02 10 80 00 34 00 0f 05 ec 1f a8 fb 07 16
5b 81 05 d4 a0 06 20 00 01 08 40 00 02 10 80 00 04 00 03 c0 31 00 b0 60 bf
1c bd 07 16 5b 81 05 d4 a0 06 20 00 01 08 40 00 02 10 80 00 14 00 0f 04 f4
1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01 08 40 00 02 10 80 00 24 00 30 70
7f 1c bd 07 16 5b 81 05 d4 a0 06 20 00 01 08 40 00 02 10 80 00 34 00 0f 05
f4 1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01 08 40 00 02 10 80 00 04 00 03
c4 00 00 0f 05 fc 1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01 08 40 00 02 10
80 00 14 00 0f 05 ec 1f b0 60 bf 1c bd 07 16 5b 81 05 d4 a0 06 20 00 01 08
40 00 02 10 80 00 14 00 0f 05 ec 1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00 01
08 40 00 02 10 80 00 24 00 0f 05 ec 1f a8 fd 07 16 5b 81 05 d4 a0 06 20 00

This was causing the parser to skip entire packets resulting in an update
rate of ~31Hz on the FMU side.
With this patch the update rate increases to 42-48Hz.

The investigation was triggered by an RC glitch with a packet containing
random channel data. It's likely, although not completely verified that
the frequent desync randomly happend to pass the CRC check with garbage
data.
2022-08-23 21:07:18 -04:00
Daniel Agar b58f70726f ekf2: scale delta angle and delta velocity bias to particular IMU sample 2022-08-23 21:06:13 -04:00
Ville Juven 213d5dac2a platforms/nuttx: Fix hard coded path for karch library
Use CONFIG_ARCH instead of arm
2022-08-23 21:05:41 -04:00
Ville Juven 4f6d523c95 mixer_module: Fix linking of mixer_module
The module has a hard dependency on mixer library, so link them together
2022-08-23 21:04:58 -04:00
bresch f89044cfbe ekf2: fix replay EKF2 start when CONSTRAINED_FLASH 2022-08-23 11:14:15 -04:00
modaltb 40149ecabc boards: modalai_fc-v2 configure SPI6, disable unused SPI3/4 (#20093) 2022-08-22 20:58:44 -04:00
alexklimaj 913bae9924 Revert "drivers/uavcan: update libuavcan"
This reverts commit deb938fcea.
2022-08-22 20:57:06 -04:00
Daniel Agar cfc579542e new Ignition Gazebo simulation interface architecture (#20057)
- much simpler direct interface using Ignition Transport 
 - in tree models and worlds
 - control allocation output configuration, no more magic actuator mapping to mavlink and back
 - currently requires no custom Gazebo plugins (keeping things as lightweight and simple as possible)

Co-authored-by: Jaeyoung-Lim <jalim@ethz.ch>
2022-08-22 10:58:19 -04:00
547 changed files with 17990 additions and 9464 deletions
+1 -1
View File
@@ -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()
+1 -1
View File
@@ -3,7 +3,7 @@ name: Checks
on:
push:
branches:
- 'master'
- 'main'
pull_request:
branches:
- '*'
+1 -1
View File
@@ -3,7 +3,7 @@ name: Clang Tidy
on:
push:
branches:
- 'master'
- 'main'
pull_request:
branches:
- '*'
+1 -1
View File
@@ -3,7 +3,7 @@ name: Linux Targets
on:
push:
branches:
- 'master'
- 'main'
pull_request:
branches:
- '*'
+1 -1
View File
@@ -3,7 +3,7 @@ name: Linux ARM64 Targets
on:
push:
branches:
- 'master'
- 'main'
pull_request:
branches:
- '*'
+1 -1
View File
@@ -3,7 +3,7 @@ name: MacOS build
on:
push:
branches:
- 'master'
- 'main'
pull_request:
branches:
- '*'
+1 -1
View File
@@ -3,7 +3,7 @@ name: Nuttx Targets
on:
push:
branches:
- 'master'
- 'main'
pull_request:
branches:
- '*'
+1 -1
View File
@@ -3,7 +3,7 @@ name: Deploy metadata for all targets
on:
push:
branches:
- 'master'
- 'main'
- 'release/*'
- 'pr-metadata-test'
+1 -1
View File
@@ -3,7 +3,7 @@ name: MAVROS Mission Tests
on:
push:
branches:
- 'master'
- 'main'
pull_request:
branches:
- '*'
+1 -1
View File
@@ -3,7 +3,7 @@ name: MAVROS Offboard Tests
on:
push:
branches:
- 'master'
- 'main'
pull_request:
branches:
- '*'
+1 -1
View File
@@ -3,7 +3,7 @@ name: Metadata
on:
push:
branches:
- 'master'
- 'main'
- 'release/*'
- 'pr-metadata-test'
+1 -1
View File
@@ -3,7 +3,7 @@ name: Python CI Checks
on:
push:
branches:
- 'master'
- 'main'
pull_request:
branches:
- '*'
+1 -1
View File
@@ -3,7 +3,7 @@ name: SITL Tests
on:
push:
branches:
- 'master'
- 'main'
pull_request:
branches:
- '*'
+7 -10
View File
@@ -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
View File
@@ -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-
+6 -1
View File
@@ -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
+63 -45
View File
@@ -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
View File
@@ -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/')
+16 -12
View File
@@ -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
+43 -30
View File
@@ -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
+7 -1
View File
@@ -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
=======================================================
+2 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
-901
View File
@@ -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; Removed type_emptyline @ line %d\", 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; Removed %s @ line %d\", 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; Removed type_emptyline @ line %d\", ptr, line[ptr] $DE
}
# And replace the comment type.
--ptr; $DB \"ptr = %d; replacing the %s @ line %d\", ptr, type_name[type[ptr]], line[ptr] $DE
l = line[ptr];
}
line[ptr] = l; $DB \"ptr = %d; %s @ line %d\", 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
View File
-200
View File
@@ -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
View File
-5
View File
@@ -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
+2
View File
@@ -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 = []
+5 -2
View File
@@ -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
View File
-6
View File
@@ -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
+2
View File
@@ -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
View File
@@ -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
-23
View File
@@ -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"
-39
View File
@@ -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"
+47
View File
@@ -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
+180
View File
@@ -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