533 Commits

Author SHA1 Message Date
Konrad
e5e66370e7 FixedwingPositionControl: Add support for figure 8 loitering.
The command is sent by a dedicated mavlink command and forwarded to the fixed wing position controller.

The pattern is defined by the radius of the major axis, the radius of the minor axis and the orientation. The pattern is then defined by:
The upper part of the pattern consist of a clockwise circle with radius defined by the minor axis. The center of the circle is defined by the major axis minus the minor axis away from the pattern center.
The lower part of the pattern consist of a counter-clockwise circle with the same definitions as above.
In between, the circles are connected with straight lines in a cross configuration. The lines are always tangetial to the circles.
The orientation rotates the major axis around the NED down axis.

The loitering logic is defined inside its own class used by the fixed wing position control module. It defines which segment (one of the circles or lines) is active and uses the path controller (npfg or l1-control) to determine the desired roll angle.

A feedback mavlink message is send with the executed pattern parameters.
2023-10-31 15:57:59 -04:00
Konrad
a4d05085a7 Navigator: Don't switch to RTL if already in landing phase of mission. 2023-10-31 14:16:02 +01:00
Konrad
698c57c5f8 [RTL] Add VTOL land approach for home with designated loiter points in the RTL mode. 2023-10-31 14:16:02 +01:00
Konrad
2779a00ac8 VTOL TAKEOFF: Add Config to deactivate, and deactivate on all boards except fmu_v5x and sitl.
QGC does not support VTOL takeoff and thus this is used to safe flash space.
2023-09-29 14:25:03 +02:00
Konrad
007ed11bbe Mission+RTL: Refactoring mission and RTL to keep them separate. RTL does all its mission related computation in its own class.
Dataman: Add write function to dataman cache.

RTL and mission have a new common base class mission_base. Both inherit from them and mission, RTL mission, and rtl reverse mission inherit from them and implement their desired functionalities. This simplifies the logic in mission as well as make the logic in rtl mission reverse and mission more readable.
Rtl mission reverse now functional again for VTOL flying back the mission and transitioning to MC at the home position.
Dataman cache has new write functionality to write to dataman while updating write item in its cache if necessary.
Dataman cache is now only updated when the respective module is active. Leads to a higher computation time once on activation, but decreases unnecessary cache updates when inactive.
2023-09-29 14:25:03 +02:00
Silvan Fuhrer
48acf98fd5 Navigator: remove deprecated _can_loiter_at_sp and _need_takeoff
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2023-09-19 10:04:30 +02:00
Silvan Fuhrer
56dd1dc930
Navigator: Resume mission with last flight speed (#21714)
* Navigator: DO_CHANGE_SPEED: only store sinlge cruising_speed_current_mode

This stored cruising speed setpoint is reset on mode change and
after a VTOL transition.

* Navigator Mission: replay DO_CHANGE_SPEED items when resuming mission

* Navigator: remove cruising_speed_sp_update()

Speed changes in a mission are handled directly in the position controllers,
and no longer in Navigator.

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>

---------

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2023-08-08 13:22:05 +02:00
Beat Küng
16a144c00f navigator: use mission topic to notify about geofence & safe point changes
This avoids the need to regularly access dataman for checking.
2023-07-24 13:10:31 +02:00
Igor Mišić
d1b660b104 rtl: integrate dataman cache 2023-07-24 13:10:31 +02:00
Igor Mišić
4038eeec3e geofence: integrate dataman cache 2023-07-24 13:10:31 +02:00
Igor Mišić
80409672b1 mission: integrate dataman cache 2023-07-24 13:10:31 +02:00
Igor Mišić
208552fdab dataman: add DatamanClient with sync functions
Rework of dataman
2023-07-24 13:10:31 +02:00
Igor Mišić
7563ddd91f navigator: increase stack size by 208 bytes 2023-07-24 13:10:31 +02:00
bresch
afa085da7f geofence: fix altitude change fence check
When asking for an altitude change only, the current position needs to
be used, otherwise the geofence check is be skipped
2023-07-06 22:39:39 -04:00
Silvan Fuhrer
c6870006c7 Navigator: move disable camera trigger on mission inactivation to seperate function
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2023-06-20 14:38:03 +02:00
Silvan Fuhrer
fc357921fd navigator: send commands to anyone listening
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2023-06-12 09:41:28 +02:00
Silvan Fuhrer
d2ca763d23
Navigator: set cruise_speed to default on entering new mode (#21503)
The resets in the modes (eg Loiter mode) are not active yet, so manually
set rep->current.cruising_speed = -1.f if not already in the same flight mode.

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2023-05-05 15:53:17 +02:00
Silvan Fuhrer
885bb7659b
navigator_main: orbit in FW: get_cruising_speed() (#21484)
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2023-04-18 16:01:24 +02:00
Silvan Fuhrer
bc560ddddb
RTL: fix Mission RTL vs normal RTL (#21464)
* Navigator: on_mission_landing() only can return true if currently in mission mode

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>

* RTL: reset RTL state when not in RTL nav_state

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>

* Navigator: fix mission vs. normal RTL

- remove extra state _should_engange_mission_for_landing from rtl and have
this logic outside of RTL where Navigator decides on running mission RTL or normal RTL
- fix logic in Navigator to decide mission RTL vs normal RTL

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>

* Mission: land_start(): fix decision if already on mission landing

Simply checking landing() is not enough, as that is not reset until
set_current_mission_index(get_land_start_index()) later in the function.
Instead ask Naviator about it (on_mission_landing()).

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>

* Navigator: only update _shouldEngangeMissionForLanding once, to not set it to false after VTOL backtansition

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>

---------

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2023-04-14 09:49:47 +02:00
Silvan Fuhrer
94fb334d8f
Navigator: fix logic around when to switch to mission landing for RTL (#21390)
* Navigator: change way of telling logic if RLT was started just now

* Navigator: change logic around when to engage Mission mode for RTL

To find out if we're currently on a mission landing, check if we either are
past the land start marker OR currently land start marker is current WP
and vehicle is already in LOITER mode.

* Navigator: do not engage RTL at all if already on mission landing

* Navigator: consider to be on mission landing if the LOITER_TO_ALT and dist small

To find out if we're currently on a mission landing, check if we either are
past the land start marker OR currently land start marker is current WP,
the type is LOITER_TO_ALT and the vehicle is inside loiter.

---------

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2023-04-05 10:11:14 +02:00
Mohamad Akkawi
9de52bb5ec [navigator] Tone Down traffic warnings
- add unit tests for adsb conflict detection
- move adsb conflict detection to lib/adsb and adsb conflict class
- use containers/Array.hpp for buffer array
- expand fake_traffic
2023-03-16 07:32:43 +01:00
Silvan Fuhrer
4be74befd2 VTOL: remove pusher reverse feature
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2023-03-06 14:00:02 +01:00
Silvan Fuhrer
1acb07c600 Navigator: set _land_start_index to first item with a position after the marker
_land_start_index is used to to start the mission from this item index, and to
avoid to publish a triplet.current.type=IDLE, we need to fill it with the actual
position setpoint that the vehicle should go to at the start of a mission landing.

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2023-02-20 06:50:53 +01:00
Konrad
6bdeb43e0d fw_path_navigation: Remove explicit L1 mentioning. 2023-02-09 17:51:55 +01:00
Beat Küng
3f2336af32
navigator: add ModeCompleted signalling topic 2023-02-07 19:11:52 -05:00
Silvan Fuhrer
148ffe4e25 add support for DO_CHANGE_ALTITUDE
Do the same as DO_REPOSITION wit only the altitude field populated
and MAV_DO_REPOSITION_FLAGS set, which means:
- switch to Loiter mode if not already in it
- set the current altitude to what is specified in the altitdue field,
keep current altitude setpoint otherwise
- keep current position setpoint
- fall back to current estimated position in case a position setpoint
is not finite

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2023-01-25 16:40:27 +01:00
Silvan Fuhrer
5edbc2f80a Navigator: remove update of reposition setpoint at Transition command
This was previously required to reset the flight speed after a VTOL transition,
but is now no longer required as the DO_CHANGE_SPEED commands are handles directly
in the controllers.

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2022-10-27 11:04:22 +02:00
Silvan Fuhrer
473b471fb6 Navigator: add guards for using mission_item.loiter_radius only if finite and >FLT_EPS
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2022-10-27 10:28:05 +02:00
Silvan Fuhrer
605d4c47b9 Navigator: initialize _mission_item for all navigation modes in Navigator::Navigator()
This fixes the issue where the init happended in the initializer list, at which point
the params were not yet initialized and thus resulted in random values for the init
values of _mission_item.loiter_radius and .acceptance_radius.

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2022-10-27 10:28:05 +02:00
Silvan Fuhrer
42c613a0c7 position_setpoint.msg: remove unused alt_valid
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2022-10-17 16:12:15 -04:00
Daniel Agar
0d6766d14d limit vehicle_command subscription updates per cycle
- this is a precaution to eliminate the possibility of getting stuck in
a loop trying to keep up with a high rate publication that could be
coming from a higher priority task
2022-10-17 16:10:51 -04:00
Beat Küng
acaa50a448 geofence: add and report reason for violation 2022-10-11 22:31:20 -04:00
mcsauder
ebc88afe46 Apply Google Style to Commander Private methods, rename geofence message geofence_violation to primary_geofence_breached. 2022-10-11 22:31:20 -04:00
Beat Küng
455b885f86 commander: use new failsafe state machine and add user intention class 2022-10-11 22:31:20 -04:00
Roman Bapst
20457c5e2e
position_setpoint: replaced loiter_direction integer by boolean (#20317)
* position_setpoint: replaced loiter_direction integer by boolean (loiter_direction_counter_clockwise)

Signed-off-by: RomanBapst <bapstroman@gmail.com>
2022-09-29 11:06:10 +02:00
Silvan Fuhrer
0df878bc18 Navigator: use NAV_FW_ALTL_RAD only for FW landings, not VTOL landings
Also containst a mini refactor by removing the unnecessary function
get_default_altitude_acceptance_radius().

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2022-09-22 16:52:51 +02:00
Claudio Micheli
30e867d4de navigator_main: use camera_trigger driver for single captures
Signed-off-by: Claudio Micheli <claudio@auterion.com>
2022-09-15 18:15:25 -04:00
Julian Oes
fc89705ef8 navigator: stop capturing images on mission exit
When a mission starts capturing images using the
MAV_CMD_IMAGE_START_CAPTURE command, it should also stop it again, in
case it is stopped early, e.g. with RTL.
2022-09-15 18:15:25 -04:00
Don Gagne
0987bb2e8e Fix bug with yaw only reposition
Fix formatting
2022-09-08 17:55:30 -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
Thomas Stastny
e512d77b89 RTL: expose RTL state 2022-07-22 14:59:20 +02:00
Thomas Stastny
1ec62c4063 rtl: let fixed-wing RTL all the way to the loiter/delay state
also fix home vs destination alt discrepancy on RTL
2022-07-20 14:15:12 +02:00
Thomas Stastny
121cc1fce8 fw pos ctrl: rework landing abort status
abort boolean and reasons no longer separated, single status field with corresponding abort triggers
2022-07-19 22:37:09 -04:00
RomanBapst
461d0561b8 replace FW_THR_CRUISE with FW_THR_TRIM
Signed-off-by: RomanBapst <bapstroman@gmail.com>
2022-07-12 09:07:20 +02:00
Junwoo Hwang
32ae00fd44
Move Vehicle Command Result Enum defs to Vehicle Command Ack (#19729)
- As it is always only used for the vehicle command ack message
- It was a duplicate, hence making it error prone for maintainment
- The uORB message comments were updated to make the relationship with
the MAVLink message / enum definitions clear
2022-07-07 16:15:11 +02:00
Alessandro Simovic
de1fa11e96 New follow-me flight task
rename follow_me_status to follow_target_status

enable follow_target_estimator on skynode

implement the responsiveness parameter:
The responsiveness parameter should behave similarly to the previous
follow-me implementation in navigator. The difference here is that
there are now two separate gains for position and velocity fusion.
The previous implemenation in navigator had no velocity fusion.

Allow follow-me to be flown without RC

SITL tests for follow-me flight task

This includes:
- Testing the setting for the follow-me angle
- Testing that streaming position only or position
  and velocity measurements both work
- Testing that RC override works

Most of these tests are done with a simulated model
of a point object that moves on a straight line. So
nothing too spectacular. But it makes the test checks
much easier.

Since the estimator for the target actually checks new
measurements and compares them to old ones, I also added
random gausian noise to the measurements with a fixed seed
for deterministic randomness. So repeated runs produce
exactly the same results over and over.

Half of the angles are still missing in MAVSDK. Need to create
an upstream PR to add center left/right and rear left/right options.
These and the corresponding SITL tests need to be implemented
later.

sitl: Increase position tolerance during follow-me

Astro seems to barely exceed the current tolerance (4.3 !< 4.0)
causing CI to fail. The point of the CI test is not to check
the accuracy of the flight behaviour, but only the fact that the
drone is doing the expected thing. So the exact value of this
tolerance is not really important.

follow-me: gimbal control in follow-me

follow-me: create sub-routines in flight task class

follow-me: use ground-dist for emergency ascent

dist_bottom is only defined when a ground facing distance sensor exist.
It's therefore better to use dist_ground instead, which has the distance
to the home altitude if no distance sensor is available.

As a consequence it will only be possible to use follow-me in a valley
when the drone has a distance sensor.

follow-me: point gimbal to the ground in 2D mode

follow-me: another fuzzy msg handling for the estimator

follow-me: bugfix in acceleration saturation limit

follow-me: parameter for filter delay compensation

mantis: dont use flow for terrain estimation

follow-me: default responsiveness 0.5 -> 0.1

0.5 is way too jerky in real and simulated tests.

flight_task: clarify comments for bottom distance

follow-me: minor comment improvement

follow-me: [debug] log emergency_ascent

follow-me: [debug] log gimbal pitch

follow-me: [debug] status values for follow-me estimator

follow-me: setting for gimbal tracking mode

follow-me: release gimbal control at destruction

mavsdk: cosmetics 💄
2022-06-16 16:14:57 -04:00
Silvan Fuhrer
9863c24b40 navigator_main: DO_REPOSITION: only trigger reposition setpoint update if vehicle is armed
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2022-06-08 21:47:06 +02:00
Alessandro Simovic
fb71e7587c failure_detector: add motor/ESC failure detection 2022-05-12 07:58:56 +02:00
bresch
e9a2b3f260 geofence: remove unused function parameters 2022-04-19 15:29:25 +02:00
bresch
3f3a4ac5c1 navigator: home_positionvalid -> global_home_position_valid
This is to make clear that the relevant part of the home position
message for navigator is the global one. Local home position isn't
required as everything is done in global coordinates.
The specific home_alt_valid is used when lat/lon are not used
2022-04-19 15:29:25 +02:00