land detector clang-tidy trivial changes

This commit is contained in:
Daniel Agar
2017-08-31 22:49:44 -04:00
parent 6e402bd6f4
commit f67ac8ba00
7 changed files with 18 additions and 34 deletions
@@ -51,7 +51,7 @@
namespace land_detector namespace land_detector
{ {
class FixedwingLandDetector : public LandDetector class FixedwingLandDetector final : public LandDetector
{ {
public: public:
FixedwingLandDetector(); FixedwingLandDetector();
+1 -1
View File
@@ -78,7 +78,7 @@ void LandDetector::_cycle()
{ {
perf_begin(_cycle_perf); perf_begin(_cycle_perf);
if (!_object) { // not initialized yet if (_object == nullptr) { // not initialized yet
// Advertise the first land detected uORB. // Advertise the first land detected uORB.
_landDetected.timestamp = hrt_absolute_time(); _landDetected.timestamp = hrt_absolute_time();
_landDetected.freefall = false; _landDetected.freefall = false;
@@ -291,14 +291,7 @@ bool MulticopterLandDetector::_get_maybe_landed_state()
// if this persists for 8 seconds AND the drone is not // if this persists for 8 seconds AND the drone is not
// falling consider it to be landed. This should even sustain // falling consider it to be landed. This should even sustain
// quite acrobatic flight. // quite acrobatic flight.
if ((_min_trust_start > 0) && return (_min_trust_start > 0) && (hrt_elapsed_time(&_min_trust_start) > 8000000);
(hrt_elapsed_time(&_min_trust_start) > 8000000)) {
return true;
} else {
return false;
}
} }
if (_ground_contact_hysteresis.get_state() && _has_minimal_thrust() && !rotating) { 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; return _actuators.control[3] <= sys_min_throttle;
} }
} } // namespace land_detector
@@ -46,10 +46,6 @@
namespace land_detector namespace land_detector
{ {
RoverLandDetector::RoverLandDetector()
{
}
void RoverLandDetector::_initialize_topics() void RoverLandDetector::_initialize_topics()
{ {
} }
@@ -88,4 +84,4 @@ float RoverLandDetector::_get_max_altitude()
return 0.0f; return 0.0f;
} }
} } // namespace land_detector
@@ -51,7 +51,7 @@ namespace land_detector
class RoverLandDetector : public LandDetector class RoverLandDetector : public LandDetector
{ {
public: public:
RoverLandDetector(); RoverLandDetector() = default;
protected: protected:
virtual void _initialize_topics() override; virtual void _initialize_topics() override;
@@ -114,4 +114,4 @@ void VtolLandDetector::_update_params()
param_get(_paramHandle.maxAirSpeed, &_params.maxAirSpeed); param_get(_paramHandle.maxAirSpeed, &_params.maxAirSpeed);
} }
} } // namespace land_detector
@@ -39,22 +39,17 @@
* @author Lorenz Meier <lorenz@px4.io> * @author Lorenz Meier <lorenz@px4.io>
*/ */
#include <drivers/drv_hrt.h>
#include <px4_config.h> #include <px4_config.h>
#include <px4_defines.h> #include <px4_defines.h>
#include <px4_tasks.h>
#include <px4_posix.h> #include <px4_posix.h>
#include <unistd.h> //usleep #include <px4_tasks.h>
#include <stdio.h> #include <systemlib/systemlib.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <drivers/drv_hrt.h>
#include <systemlib/systemlib.h> //Scheduler
#include "FixedwingLandDetector.h" #include "FixedwingLandDetector.h"
#include "MulticopterLandDetector.h" #include "MulticopterLandDetector.h"
#include "VtolLandDetector.h"
#include "RoverLandDetector.h" #include "RoverLandDetector.h"
#include "VtolLandDetector.h"
namespace land_detector namespace land_detector
@@ -73,16 +68,16 @@ int LandDetector::task_spawn(int argc, char *argv[])
LandDetector *obj; LandDetector *obj;
if (!strcmp(argv[1], "fixedwing")) { if (strcmp(argv[1], "fixedwing") == 0) {
obj = new FixedwingLandDetector(); obj = new FixedwingLandDetector();
} else if (!strcmp(argv[1], "multicopter")) { } else if (strcmp(argv[1], "multicopter") == 0) {
obj = new MulticopterLandDetector(); obj = new MulticopterLandDetector();
} else if (!strcmp(argv[1], "vtol")) { } else if (strcmp(argv[1], "vtol") == 0) {
obj = new VtolLandDetector(); obj = new VtolLandDetector();
} else if (!strcmp(argv[1], "ugv")) { } else if (strcmp(argv[1], "ugv") == 0) {
obj = new RoverLandDetector(); obj = new RoverLandDetector();
} else { } else {
@@ -90,7 +85,7 @@ int LandDetector::task_spawn(int argc, char *argv[])
return -1; return -1;
} }
if (!obj) { if (obj == nullptr) {
PX4_ERR("alloc failed"); PX4_ERR("alloc failed");
return -1; return -1;
} }
@@ -139,7 +134,7 @@ int LandDetector::print_status()
int LandDetector::print_usage(const char *reason) int LandDetector::print_usage(const char *reason)
{ {
if (reason) { if (reason != nullptr) {
PX4_ERR("%s\n", reason); PX4_ERR("%s\n", reason);
} }
@@ -182,4 +177,4 @@ int land_detector_main(int argc, char *argv[])
return LandDetector::main(argc, argv); return LandDetector::main(argc, argv);
} }
} } // namespace land_detector