mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
RTL reduce verbosity
This commit is contained in:
committed by
Lorenz Meier
parent
fbebec5d0f
commit
e0aa2e2391
@@ -37,25 +37,18 @@
|
|||||||
* @author Anton Babushkin <anton.babushkin@me.com>
|
* @author Anton Babushkin <anton.babushkin@me.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include "rtl.h"
|
||||||
#include <stdlib.h>
|
#include "navigator.h"
|
||||||
#include <math.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <float.h>
|
|
||||||
|
|
||||||
#include <systemlib/mavlink_log.h>
|
|
||||||
#include <systemlib/err.h>
|
|
||||||
#include <geo/geo.h>
|
#include <geo/geo.h>
|
||||||
|
#include <mathlib/mathlib.h>
|
||||||
#include <uORB/uORB.h>
|
#include <systemlib/err.h>
|
||||||
#include <navigator/navigation.h>
|
#include <systemlib/mavlink_log.h>
|
||||||
#include <uORB/topics/home_position.h>
|
#include <uORB/topics/home_position.h>
|
||||||
#include <uORB/topics/vtol_vehicle_status.h>
|
#include <uORB/topics/vtol_vehicle_status.h>
|
||||||
|
#include <uORB/uORB.h>
|
||||||
|
|
||||||
#include "navigator.h"
|
static constexpr float DELAY_SIGMA = 0.01f;
|
||||||
#include "rtl.h"
|
|
||||||
|
|
||||||
#define DELAY_SIGMA 0.01f
|
|
||||||
|
|
||||||
RTL::RTL(Navigator *navigator, const char *name) :
|
RTL::RTL(Navigator *navigator, const char *name) :
|
||||||
MissionBlock(navigator, name),
|
MissionBlock(navigator, name),
|
||||||
@@ -68,14 +61,11 @@ RTL::RTL(Navigator *navigator, const char *name) :
|
|||||||
{
|
{
|
||||||
/* load initial params */
|
/* load initial params */
|
||||||
updateParams();
|
updateParams();
|
||||||
|
|
||||||
/* initial reset */
|
/* initial reset */
|
||||||
on_inactive();
|
on_inactive();
|
||||||
}
|
}
|
||||||
|
|
||||||
RTL::~RTL()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
RTL::on_inactive()
|
RTL::on_inactive()
|
||||||
{
|
{
|
||||||
@@ -86,8 +76,7 @@ RTL::on_inactive()
|
|||||||
float
|
float
|
||||||
RTL::get_rtl_altitude()
|
RTL::get_rtl_altitude()
|
||||||
{
|
{
|
||||||
return (_param_return_alt.get() < _navigator->get_land_detected()->alt_max) ? _param_return_alt.get() :
|
return math::min(_param_return_alt.get(), _navigator->get_land_detected()->alt_max);
|
||||||
_navigator->get_land_detected()->alt_max;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -102,19 +91,17 @@ RTL::on_activation()
|
|||||||
/* for safety reasons don't go into RTL if landed */
|
/* for safety reasons don't go into RTL if landed */
|
||||||
if (_navigator->get_land_detected()->landed) {
|
if (_navigator->get_land_detected()->landed) {
|
||||||
_rtl_state = RTL_STATE_LANDED;
|
_rtl_state = RTL_STATE_LANDED;
|
||||||
mavlink_and_console_log_info(_navigator->get_mavlink_log_pub(), "Already landed, not executing RTL");
|
|
||||||
|
} else if (_navigator->get_global_position()->alt < (_navigator->get_home_position()->alt + get_rtl_altitude())) {
|
||||||
|
|
||||||
/* if lower than return altitude, climb up first */
|
/* if lower than return altitude, climb up first */
|
||||||
|
|
||||||
} else if (_navigator->get_global_position()->alt < (_navigator->get_home_position()->alt
|
|
||||||
+ get_rtl_altitude())) {
|
|
||||||
_rtl_state = RTL_STATE_CLIMB;
|
_rtl_state = RTL_STATE_CLIMB;
|
||||||
|
|
||||||
/* otherwise go straight to return */
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* set altitude setpoint to current altitude */
|
/* otherwise go straight to return */
|
||||||
_rtl_state = RTL_STATE_RETURN;
|
_rtl_state = RTL_STATE_RETURN;
|
||||||
|
|
||||||
|
/* set altitude setpoint to current altitude */
|
||||||
_mission_item.altitude_is_relative = false;
|
_mission_item.altitude_is_relative = false;
|
||||||
_mission_item.altitude = _navigator->get_global_position()->alt;
|
_mission_item.altitude = _navigator->get_global_position()->alt;
|
||||||
}
|
}
|
||||||
@@ -289,8 +276,6 @@ RTL::set_rtl_item()
|
|||||||
|
|
||||||
case RTL_STATE_LANDED: {
|
case RTL_STATE_LANDED: {
|
||||||
set_idle_item(&_mission_item);
|
set_idle_item(&_mission_item);
|
||||||
|
|
||||||
mavlink_and_console_log_info(_navigator->get_mavlink_log_pub(), "RTL: completed, landed");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,14 +57,11 @@ class RTL : public MissionBlock
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RTL(Navigator *navigator, const char *name);
|
RTL(Navigator *navigator, const char *name);
|
||||||
|
~RTL() = default;
|
||||||
|
|
||||||
~RTL();
|
void on_inactive() override;
|
||||||
|
void on_activation() override;
|
||||||
virtual void on_inactive();
|
void on_active() override;
|
||||||
|
|
||||||
virtual void on_activation();
|
|
||||||
|
|
||||||
virtual void on_active();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user