mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 10:46:33 +08:00
move systemlib/rc_check to commander (the only usage) and convert to c++
This commit is contained in:
committed by
Lorenz Meier
parent
a6883c3a0d
commit
3399ec9e73
@@ -38,20 +38,21 @@ px4_add_module(
|
|||||||
COMPILE_FLAGS
|
COMPILE_FLAGS
|
||||||
-Wno-sign-compare # TODO: fix all sign-compare
|
-Wno-sign-compare # TODO: fix all sign-compare
|
||||||
SRCS
|
SRCS
|
||||||
commander.cpp
|
|
||||||
state_machine_helper.cpp
|
|
||||||
commander_helper.cpp
|
|
||||||
calibration_routines.cpp
|
|
||||||
accelerometer_calibration.cpp
|
accelerometer_calibration.cpp
|
||||||
gyro_calibration.cpp
|
|
||||||
mag_calibration.cpp
|
|
||||||
baro_calibration.cpp
|
|
||||||
rc_calibration.cpp
|
|
||||||
airspeed_calibration.cpp
|
airspeed_calibration.cpp
|
||||||
esc_calibration.cpp
|
|
||||||
PreflightCheck.cpp
|
|
||||||
arm_auth.cpp
|
arm_auth.cpp
|
||||||
|
baro_calibration.cpp
|
||||||
|
calibration_routines.cpp
|
||||||
|
commander.cpp
|
||||||
|
commander_helper.cpp
|
||||||
|
esc_calibration.cpp
|
||||||
|
gyro_calibration.cpp
|
||||||
health_flag_helper.cpp
|
health_flag_helper.cpp
|
||||||
|
mag_calibration.cpp
|
||||||
|
PreflightCheck.cpp
|
||||||
|
rc_calibration.cpp
|
||||||
|
rc_check.cpp
|
||||||
|
state_machine_helper.cpp
|
||||||
DEPENDS
|
DEPENDS
|
||||||
df_driver_framework
|
df_driver_framework
|
||||||
git_ecl
|
git_ecl
|
||||||
|
|||||||
@@ -42,18 +42,8 @@
|
|||||||
|
|
||||||
#include <px4_config.h>
|
#include <px4_config.h>
|
||||||
#include <px4_posix.h>
|
#include <px4_posix.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <poll.h>
|
|
||||||
|
|
||||||
#include <systemlib/err.h>
|
|
||||||
#include <parameters/param.h>
|
#include <parameters/param.h>
|
||||||
#include <systemlib/rc_check.h>
|
|
||||||
#include <systemlib/mavlink_log.h>
|
#include <systemlib/mavlink_log.h>
|
||||||
|
|
||||||
#include <drivers/drv_hrt.h>
|
#include <drivers/drv_hrt.h>
|
||||||
@@ -73,6 +63,7 @@
|
|||||||
|
|
||||||
#include "PreflightCheck.h"
|
#include "PreflightCheck.h"
|
||||||
#include "health_flag_helper.h"
|
#include "health_flag_helper.h"
|
||||||
|
#include "rc_check.h"
|
||||||
|
|
||||||
#include "DevMgr.hpp"
|
#include "DevMgr.hpp"
|
||||||
|
|
||||||
|
|||||||
@@ -78,8 +78,6 @@
|
|||||||
#include <systemlib/hysteresis/hysteresis.h>
|
#include <systemlib/hysteresis/hysteresis.h>
|
||||||
#include <systemlib/mavlink_log.h>
|
#include <systemlib/mavlink_log.h>
|
||||||
#include <parameters/param.h>
|
#include <parameters/param.h>
|
||||||
#include <systemlib/rc_check.h>
|
|
||||||
#include <systemlib/state_table.h>
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
* RC calibration check
|
* RC calibration check
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "rc_check.h"
|
||||||
|
|
||||||
#include <px4_config.h>
|
#include <px4_config.h>
|
||||||
#include <px4_time.h>
|
#include <px4_time.h>
|
||||||
|
|
||||||
@@ -45,7 +47,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include <systemlib/err.h>
|
#include <systemlib/err.h>
|
||||||
#include <systemlib/rc_check.h>
|
|
||||||
#include <parameters/param.h>
|
#include <parameters/param.h>
|
||||||
#include <systemlib/mavlink_log.h>
|
#include <systemlib/mavlink_log.h>
|
||||||
#include <drivers/drv_rc_input.h>
|
#include <drivers/drv_rc_input.h>
|
||||||
@@ -54,7 +56,6 @@
|
|||||||
|
|
||||||
int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool isVTOL)
|
int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool isVTOL)
|
||||||
{
|
{
|
||||||
|
|
||||||
char nbuf[20];
|
char nbuf[20];
|
||||||
param_t _parameter_handles_min, _parameter_handles_trim, _parameter_handles_max,
|
param_t _parameter_handles_min, _parameter_handles_trim, _parameter_handles_max,
|
||||||
_parameter_handles_rev, _parameter_handles_dz;
|
_parameter_handles_rev, _parameter_handles_dz;
|
||||||
@@ -63,7 +64,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i
|
|||||||
|
|
||||||
const char *rc_map_mandatory[] = { /*"RC_MAP_MODE_SW",*/
|
const char *rc_map_mandatory[] = { /*"RC_MAP_MODE_SW",*/
|
||||||
/* needs discussion if this should be mandatory "RC_MAP_POSCTL_SW"*/
|
/* needs discussion if this should be mandatory "RC_MAP_POSCTL_SW"*/
|
||||||
0 /* end marker */
|
nullptr /* end marker */
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned j = 0;
|
unsigned j = 0;
|
||||||
@@ -93,7 +94,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i
|
|||||||
|
|
||||||
|
|
||||||
/* first check channel mappings */
|
/* first check channel mappings */
|
||||||
while (rc_map_mandatory[j] != 0) {
|
while (rc_map_mandatory[j] != nullptr) {
|
||||||
|
|
||||||
param_t map_parm = param_find(rc_map_mandatory[j]);
|
param_t map_parm = param_find(rc_map_mandatory[j]);
|
||||||
|
|
||||||
@@ -110,7 +111,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i
|
|||||||
int32_t mapping;
|
int32_t mapping;
|
||||||
param_get(map_parm, &mapping);
|
param_get(map_parm, &mapping);
|
||||||
|
|
||||||
if (mapping > RC_INPUT_MAX_CHANNELS) {
|
if (mapping > input_rc_s::RC_INPUT_MAX_CHANNELS) {
|
||||||
if (report_fail) { mavlink_log_critical(mavlink_log_pub, "RC ERROR: %s >= NUMBER OF CHANNELS.", rc_map_mandatory[j]); }
|
if (report_fail) { mavlink_log_critical(mavlink_log_pub, "RC ERROR: %s >= NUMBER OF CHANNELS.", rc_map_mandatory[j]); }
|
||||||
|
|
||||||
/* give system time to flush error message in case there are more */
|
/* give system time to flush error message in case there are more */
|
||||||
@@ -132,7 +133,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i
|
|||||||
unsigned total_fail_count = 0;
|
unsigned total_fail_count = 0;
|
||||||
unsigned channels_failed = 0;
|
unsigned channels_failed = 0;
|
||||||
|
|
||||||
for (unsigned i = 0; i < RC_INPUT_MAX_CHANNELS; i++) {
|
for (unsigned i = 0; i < input_rc_s::RC_INPUT_MAX_CHANNELS; i++) {
|
||||||
/* should the channel be enabled? */
|
/* should the channel be enabled? */
|
||||||
uint8_t count = 0;
|
uint8_t count = 0;
|
||||||
|
|
||||||
@@ -36,19 +36,14 @@
|
|||||||
*
|
*
|
||||||
* RC calibration check
|
* RC calibration check
|
||||||
*/
|
*/
|
||||||
#include <stdbool.h>
|
|
||||||
#include <uORB/uORB.h>
|
#include <uORB/uORB.h>
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
__BEGIN_DECLS
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the RC calibration
|
* Check the RC calibration
|
||||||
*
|
*
|
||||||
* @return 0 / OK if RC calibration is ok, index + 1 of the first
|
* @return 0 / OK if RC calibration is ok, index + 1 of the first
|
||||||
* channel that failed else (so 1 == first channel failed)
|
* channel that failed else (so 1 == first channel failed)
|
||||||
*/
|
*/
|
||||||
__EXPORT int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool isVTOL);
|
int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool isVTOL);
|
||||||
|
|
||||||
__END_DECLS
|
|
||||||
@@ -43,7 +43,6 @@ set(SRCS
|
|||||||
otp.c
|
otp.c
|
||||||
pid/pid.c
|
pid/pid.c
|
||||||
pwm_limit/pwm_limit.c
|
pwm_limit/pwm_limit.c
|
||||||
rc_check.c
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${OS} STREQUAL "nuttx")
|
if(${OS} STREQUAL "nuttx")
|
||||||
|
|||||||
Reference in New Issue
Block a user