aboutsummaryrefslogtreecommitdiff
path: root/apps/px4io
diff options
context:
space:
mode:
authorSimon Wilks <sjwilks@gmail.com>2013-01-05 22:13:12 +0100
committerSimon Wilks <sjwilks@gmail.com>2013-01-05 22:13:12 +0100
commit0a89ab7075e4d637c91e21246c4790599f046aec (patch)
treeb21cc275b31a2b85892f5869c9426c15488b7886 /apps/px4io
parent1b81724ef7d9c1424b493740d887e6c3ce259f38 (diff)
downloadpx4-firmware-0a89ab7075e4d637c91e21246c4790599f046aec.tar.gz
px4-firmware-0a89ab7075e4d637c91e21246c4790599f046aec.tar.bz2
px4-firmware-0a89ab7075e4d637c91e21246c4790599f046aec.zip
Send rc channel ordering and channel attributes from FMU to IO
Diffstat (limited to 'apps/px4io')
-rw-r--r--apps/px4io/comms.c13
-rw-r--r--apps/px4io/mixer.cpp34
-rw-r--r--apps/px4io/protocol.h8
-rw-r--r--apps/px4io/px4io.h14
4 files changed, 54 insertions, 15 deletions
diff --git a/apps/px4io/comms.c b/apps/px4io/comms.c
index c208db3ad..2733877a2 100644
--- a/apps/px4io/comms.c
+++ b/apps/px4io/comms.c
@@ -207,6 +207,19 @@ comms_handle_command(const void *buffer, size_t length)
system_state.servo_rate = new_servo_rate;
}
+ /* fetch the rc mappings */
+ for (unsigned i = 0; i < 4; i++)
+ system_state.rc_map[i] = cmd->rc_map[i];
+
+ /* fetch the rc channel attributes */
+ for (unsigned i = 0; i < 4; i++) {
+ system_state.rc_min[i] = cmd->rc_min[i];
+ system_state.rc_trim[i] = cmd->rc_trim[i];
+ system_state.rc_max[i] = cmd->rc_max[i];
+ system_state.rc_rev[i] = cmd->rc_rev[i];
+ system_state.rc_dz[i] = cmd->rc_dz[i];
+ }
+
/*
* update servo values immediately.
* the updates are done in addition also
diff --git a/apps/px4io/mixer.cpp b/apps/px4io/mixer.cpp
index 98232a1a2..d65602587 100644
--- a/apps/px4io/mixer.cpp
+++ b/apps/px4io/mixer.cpp
@@ -67,6 +67,12 @@ extern "C" {
*/
#define FMU_INPUT_DROP_LIMIT_US 200000
+/* XXX need to move the RC_CHANNEL_FUNCTION out of rc_channels.h and into systemlib */
+#define ROLL 0
+#define PITCH 1
+#define YAW 2
+#define THROTTLE 3
+
/* current servo arm/disarm state */
bool mixer_servos_armed = false;
@@ -112,22 +118,22 @@ mixer_tick(void)
/* when override is on or the fmu is not available, but RC is present */
control_count = system_state.rc_channels;
- // Remap the channels based on the radio type.
- // FMU: Roll, Pitch, Yaw, Throttle
- // Graupner: Throttle, Roll, Pitch, Yaw
sched_lock();
- rc_channel_data[0] = system_state.rc_channel_data[1];
- rc_channel_data[1] = system_state.rc_channel_data[2];
- rc_channel_data[2] = system_state.rc_channel_data[3];
- rc_channel_data[3] = system_state.rc_channel_data[0];
- // AETR
- //rc_channel_data[0] = system_state.rc_channel_data[0];
- //rc_channel_data[1] = system_state.rc_channel_data[1];
- //rc_channel_data[2] = system_state.rc_channel_data[3];
- //rc_channel_data[3] = system_state.rc_channel_data[2];
- for (unsigned i = 4; i < system_state.rc_channels; i++) {
+
+ /* remap roll, pitch, yaw and throttle from RC specific to internal ordering */
+ rc_channel_data[ROLL] = system_state.rc_channel_data[system_state.rc_map[ROLL]];
+ rc_channel_data[PITCH] = system_state.rc_channel_data[system_state.rc_map[PITCH]];
+ rc_channel_data[YAW] = system_state.rc_channel_data[system_state.rc_map[YAW]];
+ rc_channel_data[THROTTLE] = system_state.rc_channel_data[system_state.rc_map[THROTTLE]];
+
+ /* get the remaining channels, no remapping needed */
+ for (unsigned i = 4; i < system_state.rc_channels; i++)
rc_channel_data[i] = system_state.rc_channel_data[i];
- }
+
+ /* scale the control inputs */
+ rc_channel_data[THROTTLE] = ((rc_channel_data[THROTTLE] - system_state.rc_min[THROTTLE]) /
+ (system_state.rc_max[THROTTLE] - system_state.rc_min[THROTTLE])) * 1000 + 1000;
+
control_values = &rc_channel_data[0];
sched_unlock();
} else {
diff --git a/apps/px4io/protocol.h b/apps/px4io/protocol.h
index 3a049bb29..2632604ca 100644
--- a/apps/px4io/protocol.h
+++ b/apps/px4io/protocol.h
@@ -59,7 +59,13 @@ struct px4io_command {
bool relay_state[PX4IO_RELAY_CHANNELS]; /**< relay states as requested by FMU */
bool arm_ok; /**< FMU allows full arming */
bool vector_flight_mode_ok; /**< FMU aquired a valid position lock, ready for pos control */
- bool manual_override_ok; /**< if true, IO performs a direct manual override */
+ bool manual_override_ok; /**< if true, IO performs a direct manual override */
+ uint16_t rc_map[4]; /**< channel ordering of roll, pitch, yaw, throttle */
+ uint16_t rc_min[4]; /**< min value for each channel */
+ uint16_t rc_trim[4]; /**< trim value for each channel */
+ uint16_t rc_max[4]; /**< max value for each channel */
+ uint16_t rc_rev[4]; /**< rev value for each channel */
+ uint16_t rc_dz[4]; /**< dz value for each channel */
};
/**
diff --git a/apps/px4io/px4io.h b/apps/px4io/px4io.h
index fef0a9ba4..ef1584026 100644
--- a/apps/px4io/px4io.h
+++ b/apps/px4io/px4io.h
@@ -73,6 +73,20 @@ struct sys_state_s {
uint16_t servo_rate; /* output rate of servos in Hz */
/**
+ * Remote control input(s) channel mappings
+ */
+ uint16_t rc_map[4];
+
+ /**
+ * Remote control channel attributes
+ */
+ uint16_t rc_min[4];
+ uint16_t rc_trim[4];
+ uint16_t rc_max[4];
+ uint16_t rc_rev[4];
+ uint16_t rc_dz[4];
+
+ /**
* Data from the remote control input(s)
*/
unsigned rc_channels;