mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 09:28:58 +00:00
sensors split rc_update into new standalone module
This commit is contained in:
@@ -41,53 +41,36 @@
|
||||
* @author Beat Küng <beat-kueng@gmx.net>
|
||||
*/
|
||||
|
||||
#include <board_config.h>
|
||||
|
||||
#include <px4_platform_common/px4_config.h>
|
||||
#include <px4_platform_common/module.h>
|
||||
#include <px4_platform_common/module_params.h>
|
||||
#include <px4_platform_common/getopt.h>
|
||||
#include <px4_platform_common/posix.h>
|
||||
#include <px4_platform_common/tasks.h>
|
||||
#include <px4_platform_common/time.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <mathlib/mathlib.h>
|
||||
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <drivers/drv_rc_input.h>
|
||||
#include <drivers/drv_adc.h>
|
||||
#include <drivers/drv_airspeed.h>
|
||||
|
||||
#include <airspeed/airspeed.h>
|
||||
#include <parameters/param.h>
|
||||
#include <systemlib/err.h>
|
||||
#include <perf/perf_counter.h>
|
||||
|
||||
#include <conversion/rotation.h>
|
||||
|
||||
#include <uORB/uORB.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <lib/airspeed/airspeed.h>
|
||||
#include <lib/conversion/rotation.h>
|
||||
#include <lib/mathlib/mathlib.h>
|
||||
#include <lib/parameters/param.h>
|
||||
#include <lib/perf/perf_counter.h>
|
||||
#include <px4_platform_common/getopt.h>
|
||||
#include <px4_platform_common/module.h>
|
||||
#include <px4_platform_common/module_params.h>
|
||||
#include <px4_platform_common/posix.h>
|
||||
#include <px4_platform_common/px4_config.h>
|
||||
#include <px4_platform_common/tasks.h>
|
||||
#include <px4_platform_common/time.h>
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/PublicationMulti.hpp>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/actuator_controls.h>
|
||||
#include <uORB/topics/vehicle_control_mode.h>
|
||||
#include <uORB/topics/parameter_update.h>
|
||||
#include <uORB/topics/differential_pressure.h>
|
||||
#include <uORB/topics/airspeed.h>
|
||||
#include <uORB/topics/differential_pressure.h>
|
||||
#include <uORB/topics/parameter_update.h>
|
||||
#include <uORB/topics/sensor_preflight.h>
|
||||
#include <uORB/topics/vehicle_air_data.h>
|
||||
#include <uORB/topics/vehicle_control_mode.h>
|
||||
#include <uORB/topics/vehicle_magnetometer.h>
|
||||
|
||||
#include <DevMgr.hpp>
|
||||
|
||||
#include "parameters.h"
|
||||
#include "rc_update.h"
|
||||
#include "voted_sensors_update.h"
|
||||
|
||||
#include "vehicle_acceleration/VehicleAcceleration.hpp"
|
||||
@@ -102,15 +85,6 @@ using namespace time_literals;
|
||||
* subtract 5 degrees in an attempt to account for the electrical upheating of the PCB
|
||||
*/
|
||||
#define PCB_TEMP_ESTIMATE_DEG 5.0f
|
||||
#define STICK_ON_OFF_LIMIT 0.75f
|
||||
|
||||
/**
|
||||
* Sensor app start / stop handling function
|
||||
*
|
||||
* @ingroup apps
|
||||
*/
|
||||
extern "C" __EXPORT int sensors_main(int argc, char *argv[]);
|
||||
|
||||
class Sensors : public ModuleBase<Sensors>, public ModuleParams
|
||||
{
|
||||
public:
|
||||
@@ -166,7 +140,6 @@ private:
|
||||
Parameters _parameters{}; /**< local copies of interesting parameters */
|
||||
ParameterHandles _parameter_handles{}; /**< handles for interesting parameters */
|
||||
|
||||
RCUpdate _rc_update;
|
||||
VotedSensorsUpdate _voted_sensors_update;
|
||||
|
||||
|
||||
@@ -211,7 +184,6 @@ Sensors::Sensors(bool hil_enabled) :
|
||||
ModuleParams(nullptr),
|
||||
_hil_enabled(hil_enabled),
|
||||
_loop_perf(perf_alloc(PC_ELAPSED, "sensors")),
|
||||
_rc_update(_parameters),
|
||||
_voted_sensors_update(_parameters, hil_enabled)
|
||||
{
|
||||
initialize_parameter_handles(_parameter_handles);
|
||||
@@ -237,16 +209,11 @@ Sensors::parameters_update()
|
||||
}
|
||||
|
||||
/* read the parameter values into _parameters */
|
||||
int ret = update_parameters(_parameter_handles, _parameters);
|
||||
update_parameters(_parameter_handles, _parameters);
|
||||
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
_rc_update.update_rc_functions();
|
||||
_voted_sensors_update.parametersUpdate();
|
||||
|
||||
return ret;
|
||||
return PX4_OK;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -438,8 +405,6 @@ Sensors::run()
|
||||
|
||||
diff_pres_poll(airdata);
|
||||
|
||||
_rc_update.rc_parameter_map_poll(_parameter_handles, true /* forced */);
|
||||
|
||||
/* wakeup source */
|
||||
px4_pollfd_struct_t poll_fds = {};
|
||||
poll_fds.events = POLLIN;
|
||||
@@ -532,14 +497,8 @@ Sensors::run()
|
||||
|
||||
/* check parameters for updates */
|
||||
parameter_update_poll();
|
||||
|
||||
/* check rc parameter map for updates */
|
||||
_rc_update.rc_parameter_map_poll(_parameter_handles);
|
||||
}
|
||||
|
||||
/* Look for new r/c input data */
|
||||
_rc_update.rc_poll(_parameter_handles);
|
||||
|
||||
perf_end(_loop_perf);
|
||||
}
|
||||
|
||||
@@ -599,9 +558,6 @@ The provided functionality includes:
|
||||
If there are multiple of the same type, do voting and failover handling.
|
||||
Then apply the board rotation and temperature calibration (if enabled). And finally publish the data; one of the
|
||||
topics is `sensor_combined`, used by many parts of the system.
|
||||
- Do RC channel mapping: read the raw input channels (`input_rc`), then apply the calibration, map the RC channels
|
||||
to the configured channels & mode switches, low-pass filter, and then publish as `rc_channels` and
|
||||
`manual_control_setpoint`.
|
||||
- Make sure the sensor drivers get the updated calibration parameters (scale & offset) when the parameters change or
|
||||
on startup. The sensor drivers use the ioctl interface for parameter updates. For this to work properly, the
|
||||
sensor drivers must already be running when `sensors` is started.
|
||||
@@ -653,7 +609,7 @@ Sensors *Sensors::instantiate(int argc, char *argv[])
|
||||
return new Sensors(hil_enabled);
|
||||
}
|
||||
|
||||
int sensors_main(int argc, char *argv[])
|
||||
extern "C" __EXPORT int sensors_main(int argc, char *argv[])
|
||||
{
|
||||
return Sensors::main(argc, argv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user