-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FailureDetector (safe version) #10202
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0e914a3
FailureDetector - New class, first working simple implementation. Out…
bresch 309d574
FailureDetector - Update failure detector logic in commander.
bresch 2217685
FailureDetector - Add check for non-zero roll/pitch failure parameter…
bresch 30fbbe2
NullMixer - Send NAN instead of 0. NAN is mapped to disarmed in fmu a…
bresch ee2e3c7
Failsafe PWM - Add PWM_MAIN/AUX_FAILx parameters to set "failsafe" va…
bresch 0b961a7
Failure Detector - Various cleanup and style changes.
bresch 6cae98c
Vehicle_Status_msg - Add attitude_failure flag to vehicle_status message
bresch 3a4190c
Failure Detector - move "force_failsafe" flag inside circuit_breaker …
bresch 352657f
Failure Detector - Use dedicated parameters for attitude checks
bresch f3243d0
Failure Detector - Do not trigger force_failsafe flag anymore
bresch 4b9161e
Failure Detector - Move COM_FAIL_x params to dedicated _param.c file
bresch d778573
Failure Detector - Rename parameters and change group
bresch 9b89f75
Failure Detector - use bitmask field instead of boolean in vehicle_st…
bresch 1df43ba
Failure Detector - Add space between Failure and Detector in @group f…
bresch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
src/modules/commander/failure_detector/FailureDetector.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/**************************************************************************** | ||
* | ||
* Copyright (c) 2018 PX4 Development Team. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided with the | ||
* distribution. | ||
* 3. Neither the name PX4 nor the names of its contributors may be | ||
* used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
****************************************************************************/ | ||
|
||
/** | ||
* @file FailureDetector.cpp | ||
* | ||
* @author Mathieu Bresciani <[email protected]> | ||
* | ||
*/ | ||
|
||
#include "FailureDetector.hpp" | ||
|
||
FailureDetector::FailureDetector(ModuleParams *parent) : | ||
ModuleParams(parent), | ||
_sub_vehicle_attitude_setpoint(ORB_ID(vehicle_attitude_setpoint)), | ||
_sub_vehicule_attitude(ORB_ID(vehicle_attitude)) | ||
{ | ||
} | ||
|
||
bool | ||
FailureDetector::update() | ||
{ | ||
bool updated(false); | ||
|
||
updated = update_attitude_status(); | ||
|
||
return updated; | ||
} | ||
|
||
bool | ||
FailureDetector::update_attitude_status() | ||
{ | ||
bool updated(false); | ||
|
||
if (_sub_vehicule_attitude.update()) { | ||
const vehicle_attitude_s &attitude = _sub_vehicule_attitude.get(); | ||
|
||
const matrix::Eulerf euler(matrix::Quatf(attitude.q)); | ||
const float roll(euler.phi()); | ||
const float pitch(euler.theta()); | ||
|
||
const float max_roll_deg = _fail_trig_roll.get(); | ||
const float max_pitch_deg = _fail_trig_pitch.get(); | ||
const float max_roll(fabsf(math::radians(max_roll_deg))); | ||
const float max_pitch(fabsf(math::radians(max_pitch_deg))); | ||
|
||
const bool roll_status = (max_roll > 0.0f) && (fabsf(roll) > max_roll); | ||
const bool pitch_status = (max_pitch > 0.0f) && (fabsf(pitch) > max_pitch); | ||
|
||
// Update bitmask | ||
_status &= ~(FAILURE_ROLL | FAILURE_PITCH); | ||
|
||
if (roll_status) { | ||
_status |= FAILURE_ROLL; | ||
} | ||
if (pitch_status) { | ||
_status |= FAILURE_PITCH; | ||
} | ||
|
||
updated = true; | ||
|
||
} else { | ||
updated = false; | ||
} | ||
|
||
return updated; | ||
} |
88 changes: 88 additions & 0 deletions
88
src/modules/commander/failure_detector/FailureDetector.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
|
||
/**************************************************************************** | ||
* | ||
* Copyright (c) 2018 PX4 Development Team. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided with the | ||
* distribution. | ||
* 3. Neither the name PX4 nor the names of its contributors may be | ||
* used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
****************************************************************************/ | ||
|
||
/** | ||
* @file FailureDetector.hpp | ||
* Base class for failure detection logic based on vehicle states | ||
* for failsafe triggering. | ||
* | ||
* @author Mathieu Bresciani <[email protected]> | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <matrix/matrix/math.hpp> | ||
#include <mathlib/mathlib.h> | ||
#include <px4_module_params.h> | ||
|
||
// subscriptions | ||
#include <uORB/Subscription.hpp> | ||
#include <uORB/topics/vehicle_attitude_setpoint.h> | ||
#include <uORB/topics/vehicle_attitude.h> | ||
#include <uORB/topics/vehicle_status.h> | ||
|
||
typedef enum { | ||
FAILURE_NONE = vehicle_status_s::FAILURE_NONE, | ||
FAILURE_ROLL = vehicle_status_s::FAILURE_ROLL, | ||
FAILURE_PITCH = vehicle_status_s::FAILURE_PITCH, | ||
FAILURE_ALT = vehicle_status_s::FAILURE_ALT, | ||
} failure_detector_bitmak; | ||
|
||
using uORB::Subscription; | ||
|
||
class FailureDetector : public ModuleParams | ||
{ | ||
public: | ||
FailureDetector(ModuleParams *parent); | ||
|
||
bool update(); | ||
|
||
uint8_t get_status() const {return _status;} | ||
|
||
private: | ||
|
||
DEFINE_PARAMETERS( | ||
(ParamInt<px4::params::FD_FAIL_P>) _fail_trig_pitch, | ||
(ParamInt<px4::params::FD_FAIL_R>) _fail_trig_roll | ||
) | ||
|
||
// Subscriptions | ||
Subscription<vehicle_attitude_s> _sub_vehicle_attitude_setpoint; | ||
Subscription<vehicle_attitude_s> _sub_vehicule_attitude; | ||
|
||
uint8_t _status{FAILURE_NONE}; | ||
|
||
bool update_attitude_status(); | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&& vehicle_control_mode.flag_control_attitude_enabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to leave it like this as it is just an absolute attitude check and not an attitude error check (for now).