Quickly separated low-level raw RC from mapped / scaled RC, supports FMU PPM and IO PPM / Spektrum now

This commit is contained in:
Lorenz Meier
2012-11-05 16:04:45 +01:00
parent 39659e57f8
commit e7f2c053c2
8 changed files with 183 additions and 120 deletions
+18 -4
View File
@@ -57,15 +57,23 @@
#define RC_INPUT_DEVICE_PATH "/dev/input_rc"
/**
* Maximum number of R/C input channels in the system.
* Maximum number of R/C input channels in the system. S.Bus has up to 18 channels.
*/
#define RC_INPUT_MAX_CHANNELS 16
#define RC_INPUT_MAX_CHANNELS 18
/**
* Input signal type, value is a control position from zero to 100
* percent.
*/
typedef uint8_t rc_input_t;
typedef uint16_t rc_input_t;
enum RC_INPUT_SOURCE {
RC_INPUT_SOURCE_UNKNOWN = 0,
RC_INPUT_SOURCE_PX4FMU_PPM,
RC_INPUT_SOURCE_PX4IO_PPM,
RC_INPUT_SOURCE_PX4IO_SPEKTRUM,
RC_INPUT_SOURCE_PX4IO_SBUS
};
/**
* R/C input status structure.
@@ -74,10 +82,16 @@ typedef uint8_t rc_input_t;
* on the board involved.
*/
struct rc_input_values {
/** decoding time */
uint64_t timestamp;
/** number of channels actually being seen */
uint32_t channel_count;
/** desired pulse widths for each of the supported channels */
/** Input source */
enum RC_INPUT_SOURCE input_source;
/** measured pulse widths for each of the supported channels */
rc_input_t values[RC_INPUT_MAX_CHANNELS];
};
+18 -2
View File
@@ -61,9 +61,10 @@
#include <drivers/device/device.h>
#include <drivers/drv_rc_input.h>
#include <drivers/drv_pwm_output.h>
#include <systemlib/mixer/mixer.h>
#include <drivers/drv_hrt.h>
#include <drivers/drv_mixer.h>
#include <systemlib/mixer/mixer.h>
#include <systemlib/perf_counter.h>
#include <systemlib/hx_stream.h>
#include <systemlib/err.h>
@@ -105,6 +106,9 @@ private:
int _t_armed; ///< system armed control topic
actuator_armed_s _armed; ///< system armed state
orb_advert_t _to_input_rc; ///< rc inputs from io
rc_input_values _input_rc; ///< rc input values
orb_advert_t _t_outputs; ///< mixed outputs topic
actuator_outputs_s _outputs; ///< mixed outputs
@@ -317,9 +321,14 @@ PX4IO::task_main()
orb_set_interval(_t_armed, 200); /* 5Hz update rate */
/* advertise the mixed control outputs */
memset(&_outputs, 0, sizeof(_outputs));
_t_outputs = orb_advertise(_primary_pwm_device ? ORB_ID_VEHICLE_CONTROLS : ORB_ID(actuator_outputs_1),
&_outputs);
/* advertise the rc inputs */
memset(&_input_rc, 0, sizeof(_input_rc));
_to_input_rc = orb_advertise(ORB_ID(input_rc), &_input_rc);
/* poll descriptor */
pollfd fds[3];
fds[0].fd = _serial_fd;
@@ -456,7 +465,14 @@ PX4IO::rx_callback(const uint8_t *buffer, size_t bytes_received)
}
_connected = true;
/* XXX handle R/C inputs here ... needs code sharing/library */
/* publish raw rc channel values from IO */
_input_rc.timestamp = hrt_absolute_time();
for (int i = 0; i < rep->channel_count; i++)
{
_input_rc.values[i] = rep->rc_channel[i];
}
orb_publish(ORB_ID(input_rc), _to_input_rc, &_input_rc);
/* remember the latched arming switch state */
_switch_armed = rep->armed;
+1 -1
View File
@@ -338,7 +338,7 @@ static void hrt_call_invoke(void);
/* decoded PPM buffer */
#define PPM_MAX_CHANNELS 12
__EXPORT uint16_t ppm_buffer[PPM_MAX_CHANNELS];
__EXPORT unsigned ppm_decoded_channels;
__EXPORT unsigned ppm_decoded_channels = 0;
__EXPORT uint64_t ppm_last_valid_decode = 0;
/* PPM edge history */