mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-17 18:37:35 +08:00
land detector clang-tidy trivial changes
This commit is contained in:
@@ -51,7 +51,7 @@
|
||||
namespace land_detector
|
||||
{
|
||||
|
||||
class FixedwingLandDetector : public LandDetector
|
||||
class FixedwingLandDetector final : public LandDetector
|
||||
{
|
||||
public:
|
||||
FixedwingLandDetector();
|
||||
|
||||
@@ -78,7 +78,7 @@ void LandDetector::_cycle()
|
||||
{
|
||||
perf_begin(_cycle_perf);
|
||||
|
||||
if (!_object) { // not initialized yet
|
||||
if (_object == nullptr) { // not initialized yet
|
||||
// Advertise the first land detected uORB.
|
||||
_landDetected.timestamp = hrt_absolute_time();
|
||||
_landDetected.freefall = false;
|
||||
|
||||
@@ -291,14 +291,7 @@ bool MulticopterLandDetector::_get_maybe_landed_state()
|
||||
// if this persists for 8 seconds AND the drone is not
|
||||
// falling consider it to be landed. This should even sustain
|
||||
// quite acrobatic flight.
|
||||
if ((_min_trust_start > 0) &&
|
||||
(hrt_elapsed_time(&_min_trust_start) > 8000000)) {
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return (_min_trust_start > 0) && (hrt_elapsed_time(&_min_trust_start) > 8000000);
|
||||
}
|
||||
|
||||
if (_ground_contact_hysteresis.get_state() && _has_minimal_thrust() && !rotating) {
|
||||
@@ -416,4 +409,4 @@ bool MulticopterLandDetector::_has_minimal_thrust()
|
||||
return _actuators.control[3] <= sys_min_throttle;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace land_detector
|
||||
|
||||
@@ -46,10 +46,6 @@
|
||||
namespace land_detector
|
||||
{
|
||||
|
||||
RoverLandDetector::RoverLandDetector()
|
||||
{
|
||||
}
|
||||
|
||||
void RoverLandDetector::_initialize_topics()
|
||||
{
|
||||
}
|
||||
@@ -88,4 +84,4 @@ float RoverLandDetector::_get_max_altitude()
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace land_detector
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace land_detector
|
||||
class RoverLandDetector : public LandDetector
|
||||
{
|
||||
public:
|
||||
RoverLandDetector();
|
||||
RoverLandDetector() = default;
|
||||
|
||||
protected:
|
||||
virtual void _initialize_topics() override;
|
||||
|
||||
@@ -114,4 +114,4 @@ void VtolLandDetector::_update_params()
|
||||
param_get(_paramHandle.maxAirSpeed, &_params.maxAirSpeed);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace land_detector
|
||||
|
||||
@@ -39,22 +39,17 @@
|
||||
* @author Lorenz Meier <lorenz@px4.io>
|
||||
*/
|
||||
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <px4_config.h>
|
||||
#include <px4_defines.h>
|
||||
#include <px4_tasks.h>
|
||||
#include <px4_posix.h>
|
||||
#include <unistd.h> //usleep
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <systemlib/systemlib.h> //Scheduler
|
||||
#include <px4_tasks.h>
|
||||
#include <systemlib/systemlib.h>
|
||||
|
||||
#include "FixedwingLandDetector.h"
|
||||
#include "MulticopterLandDetector.h"
|
||||
#include "VtolLandDetector.h"
|
||||
#include "RoverLandDetector.h"
|
||||
#include "VtolLandDetector.h"
|
||||
|
||||
|
||||
namespace land_detector
|
||||
@@ -73,16 +68,16 @@ int LandDetector::task_spawn(int argc, char *argv[])
|
||||
|
||||
LandDetector *obj;
|
||||
|
||||
if (!strcmp(argv[1], "fixedwing")) {
|
||||
if (strcmp(argv[1], "fixedwing") == 0) {
|
||||
obj = new FixedwingLandDetector();
|
||||
|
||||
} else if (!strcmp(argv[1], "multicopter")) {
|
||||
} else if (strcmp(argv[1], "multicopter") == 0) {
|
||||
obj = new MulticopterLandDetector();
|
||||
|
||||
} else if (!strcmp(argv[1], "vtol")) {
|
||||
} else if (strcmp(argv[1], "vtol") == 0) {
|
||||
obj = new VtolLandDetector();
|
||||
|
||||
} else if (!strcmp(argv[1], "ugv")) {
|
||||
} else if (strcmp(argv[1], "ugv") == 0) {
|
||||
obj = new RoverLandDetector();
|
||||
|
||||
} else {
|
||||
@@ -90,7 +85,7 @@ int LandDetector::task_spawn(int argc, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!obj) {
|
||||
if (obj == nullptr) {
|
||||
PX4_ERR("alloc failed");
|
||||
return -1;
|
||||
}
|
||||
@@ -139,7 +134,7 @@ int LandDetector::print_status()
|
||||
|
||||
int LandDetector::print_usage(const char *reason)
|
||||
{
|
||||
if (reason) {
|
||||
if (reason != nullptr) {
|
||||
PX4_ERR("%s\n", reason);
|
||||
}
|
||||
|
||||
@@ -182,4 +177,4 @@ int land_detector_main(int argc, char *argv[])
|
||||
return LandDetector::main(argc, argv);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace land_detector
|
||||
|
||||
Reference in New Issue
Block a user