Skip to content

Commit

Permalink
added aux6 RC channel
Browse files Browse the repository at this point in the history
Signed-off-by: Roman <bapstroman@gmail.com>
  • Loading branch information
RomanBapst authored and dagar committed Apr 3, 2019
1 parent a21242b commit d36c0e1
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 2 deletions.
1 change: 1 addition & 0 deletions msg/manual_control_setpoint.msg
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ float32 aux2 # default function: camera pitch / tilt
float32 aux3 # default function: camera trigger
float32 aux4 # default function: camera roll
float32 aux5 # default function: payload drop
float32 aux6

uint8 mode_switch # main mode 3 position switch (mandatory): _MANUAL_, ASSIST, AUTO
uint8 return_switch # return to launch 2 position switch (mandatory): _NORMAL_, RTL
Expand Down
5 changes: 3 additions & 2 deletions msg/rc_channels.msg
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ uint8 RC_CHANNELS_FUNCTION_TRANSITION=21
uint8 RC_CHANNELS_FUNCTION_GEAR=22
uint8 RC_CHANNELS_FUNCTION_ARMSWITCH=23
uint8 RC_CHANNELS_FUNCTION_STAB=24
uint8 RC_CHANNELS_FUNCTION_MAN=25
uint8 RC_CHANNELS_FUNCTION_AUX_6=25
uint8 RC_CHANNELS_FUNCTION_MAN=26

uint64 timestamp_last_valid # Timestamp of last valid RC signal
float32[18] channels # Scaled to -1..1 (throttle: 0..1)
uint8 channel_count # Number of valid channels
int8[26] function # Functions mapping
int8[27] function # Functions mapping
uint8 rssi # Receive signal strength index
bool signal_lost # Control signal lost, should be checked together with topic timeout
uint32 frame_drop_count # Number of dropped frames
2 changes: 2 additions & 0 deletions src/modules/sensors/parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ void initialize_parameter_handles(ParameterHandles &parameter_handles)
parameter_handles.rc_map_aux3 = param_find("RC_MAP_AUX3");
parameter_handles.rc_map_aux4 = param_find("RC_MAP_AUX4");
parameter_handles.rc_map_aux5 = param_find("RC_MAP_AUX5");
parameter_handles.rc_map_aux6 = param_find("RC_MAP_AUX6");

/* RC to parameter mapping for changing parameters with RC */
for (int i = 0; i < rc_parameter_map_s::RC_PARAM_MAP_NCHAN; i++) {
Expand Down Expand Up @@ -314,6 +315,7 @@ int update_parameters(const ParameterHandles &parameter_handles, Parameters &par
param_get(parameter_handles.rc_map_aux3, &(parameters.rc_map_aux3));
param_get(parameter_handles.rc_map_aux4, &(parameters.rc_map_aux4));
param_get(parameter_handles.rc_map_aux5, &(parameters.rc_map_aux5));
param_get(parameter_handles.rc_map_aux6, &(parameters.rc_map_aux6));

for (int i = 0; i < rc_parameter_map_s::RC_PARAM_MAP_NCHAN; i++) {
param_get(parameter_handles.rc_map_param[i], &(parameters.rc_map_param[i]));
Expand Down
2 changes: 2 additions & 0 deletions src/modules/sensors/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ struct Parameters {
int32_t rc_map_aux3;
int32_t rc_map_aux4;
int32_t rc_map_aux5;
int32_t rc_map_aux6;

int32_t rc_map_param[rc_parameter_map_s::RC_PARAM_MAP_NCHAN];

Expand Down Expand Up @@ -190,6 +191,7 @@ struct ParameterHandles {
param_t rc_map_aux3;
param_t rc_map_aux4;
param_t rc_map_aux5;
param_t rc_map_aux6;

param_t rc_map_param[rc_parameter_map_s::RC_PARAM_MAP_NCHAN];
param_t rc_param[rc_parameter_map_s::RC_PARAM_MAP_NCHAN]; /**< param handles for the parameters which are bound
Expand Down
27 changes: 27 additions & 0 deletions src/modules/sensors/rc_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -1872,6 +1872,33 @@ PARAM_DEFINE_INT32(RC_MAP_AUX4, 0);
*/
PARAM_DEFINE_INT32(RC_MAP_AUX5, 0);

/**
* AUX6 Passthrough RC channel
*
* @min 0
* @max 18
* @group Radio Calibration
* @value 0 Unassigned
* @value 1 Channel 1
* @value 2 Channel 2
* @value 3 Channel 3
* @value 4 Channel 4
* @value 5 Channel 5
* @value 6 Channel 6
* @value 7 Channel 7
* @value 8 Channel 8
* @value 9 Channel 9
* @value 10 Channel 10
* @value 11 Channel 11
* @value 12 Channel 12
* @value 13 Channel 13
* @value 14 Channel 14
* @value 15 Channel 15
* @value 16 Channel 16
* @value 17 Channel 17
* @value 18 Channel 18
*/
PARAM_DEFINE_INT32(RC_MAP_AUX6, 0);
/**
* PARAM1 tuning channel
*
Expand Down
2 changes: 2 additions & 0 deletions src/modules/sensors/rc_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ void RCUpdate::update_rc_functions()
_rc.function[rc_channels_s::RC_CHANNELS_FUNCTION_AUX_3] = _parameters.rc_map_aux3 - 1;
_rc.function[rc_channels_s::RC_CHANNELS_FUNCTION_AUX_4] = _parameters.rc_map_aux4 - 1;
_rc.function[rc_channels_s::RC_CHANNELS_FUNCTION_AUX_5] = _parameters.rc_map_aux5 - 1;
_rc.function[rc_channels_s::RC_CHANNELS_FUNCTION_AUX_6] = _parameters.rc_map_aux6 - 1;

for (int i = 0; i < rc_parameter_map_s::RC_PARAM_MAP_NCHAN; i++) {
_rc.function[rc_channels_s::RC_CHANNELS_FUNCTION_PARAM_1 + i] = _parameters.rc_map_param[i] - 1;
Expand Down Expand Up @@ -379,6 +380,7 @@ RCUpdate::rc_poll(const ParameterHandles &parameter_handles)
manual.aux3 = get_rc_value(rc_channels_s::RC_CHANNELS_FUNCTION_AUX_3, -1.0, 1.0);
manual.aux4 = get_rc_value(rc_channels_s::RC_CHANNELS_FUNCTION_AUX_4, -1.0, 1.0);
manual.aux5 = get_rc_value(rc_channels_s::RC_CHANNELS_FUNCTION_AUX_5, -1.0, 1.0);
manual.aux6 = get_rc_value(rc_channels_s::RC_CHANNELS_FUNCTION_AUX_6, -1.0, 1.0);

/* filter controls */
manual.y = math::constrain(_filter_roll.apply(manual.y), -1.f, 1.f);
Expand Down
3 changes: 3 additions & 0 deletions src/modules/vmount/input_rc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ float InputRC::_get_aux_value(const manual_control_setpoint_s &manual_control_se
case 5:
return manual_control_setpoint.aux5;

case 6:
return manual_control_setpoint.aux6;

default:
return 0.0f;
}
Expand Down
3 changes: 3 additions & 0 deletions src/modules/vmount/vmount_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ PARAM_DEFINE_FLOAT(MNT_OB_LOCK_MODE, 0.0f);
* @value 3 AUX3
* @value 4 AUX4
* @value 5 AUX5
* @value 6 AUX6
* @min 0
* @max 5
* @group Mount
Expand All @@ -136,6 +137,7 @@ PARAM_DEFINE_INT32(MNT_MAN_ROLL, 0);
* @value 3 AUX3
* @value 4 AUX4
* @value 5 AUX5
* @value 6 AUX6
* @min 0
* @max 5
* @group Mount
Expand All @@ -151,6 +153,7 @@ PARAM_DEFINE_INT32(MNT_MAN_PITCH, 0);
* @value 3 AUX3
* @value 4 AUX4
* @value 5 AUX5
* @value 6 AUX6
* @min 0
* @max 5
* @group Mount
Expand Down

0 comments on commit d36c0e1

Please sign in to comment.