SRV_Channel: support for servo and ESC commands to be send via UAVCAN

This commit is contained in:
Eugene Shamaev 2017-04-02 17:55:50 +03:00 committed by Francisco Ferreira
parent 68a8d8615d
commit c43d91b92e
3 changed files with 38 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include <AP_HAL/AP_HAL.h>
#include <AP_Math/AP_Math.h>
#include <AP_Vehicle/AP_Vehicle.h>
#include <AP_Math/AP_Math.h>
#include "SRV_Channel.h"
extern const AP_HAL::HAL& hal;

View File

@ -352,6 +352,19 @@ public:
static bool upgrade_parameters(const uint8_t old_keys[14], uint16_t aux_channel_mask, RCMapper *rcmap);
static void upgrade_motors_servo(uint8_t ap_motors_key, uint8_t ap_motors_idx, uint8_t new_channel);
static uint32_t get_can_servo_bm(void) {
if(p_can_servo_bm != nullptr)
return *p_can_servo_bm;
else
return 0;
}
static uint32_t get_can_esc_bm(void) {
if(p_can_esc_bm != nullptr)
return *p_can_esc_bm;
else
return 0;
}
private:
struct {
bool k_throttle_reversible:1;
@ -382,4 +395,9 @@ private:
static bool passthrough_disabled(void) {
return disabled_passthrough;
}
AP_Int32 can_servo_bm;
AP_Int32 can_esc_bm;
static AP_Int32 *p_can_servo_bm;
static AP_Int32 *p_can_esc_bm;
};

View File

@ -30,6 +30,9 @@ bool SRV_Channels::initialised;
Bitmask SRV_Channels::function_mask{SRV_Channel::k_nr_aux_servo_functions};
SRV_Channels::srv_function SRV_Channels::functions[SRV_Channel::k_nr_aux_servo_functions];
AP_Int32* SRV_Channels::p_can_servo_bm = nullptr;
AP_Int32* SRV_Channels::p_can_esc_bm = nullptr;
const AP_Param::GroupInfo SRV_Channels::var_info[] = {
// @Group: 1_
// @Path: SRV_Channel.cpp
@ -102,6 +105,20 @@ const AP_Param::GroupInfo SRV_Channels::var_info[] = {
// @User: Advanced
AP_GROUPINFO_FRAME("_AUTO_TRIM", 17, SRV_Channels, auto_trim, 0, AP_PARAM_FRAME_PLANE),
// @Param: _CANSRV_BM
// @DisplayName: RC Out channels to be transmitted as servo over CAN bus
// @Description: Bitmask with one set for channel to be transmitted as a servo command over CAN bus
// @Bitmask: 0: Servo 1, 1: Servo 2, 2: Servo 3, 3: Servo 4, 4: Servo 5, 5: Servo 6, 6: Servo 7, 7: Servo 8, 8: Servo 9, 9: Servo 10, 10: Servo 11, 11: Servo 12, 12: Servo 13, 13: Servo 14, 14: Servo 15
// @User: Standard
AP_GROUPINFO("_CANSRV_BM", 18, SRV_Channels, can_servo_bm, 0),
// @Param: _CANESC_BM
// @DisplayName: RC Out channels to be transmitted as ESC over CAN bus
// @Description: Bitmask with one set for channel to be transmitted as a ESC command over CAN bus
// @Bitmask: 0: ESC 1, 1: ESC 2, 2: ESC 3, 3: ESC 4, 4: ESC 5, 5: ESC 6, 6: ESC 7, 7: ESC 8, 8: ESC 9, 9: ESC 10, 10: ESC 11, 11: ESC 12, 12: ESC 13, 13: ESC 14, 14: ESC 15, 15: ESC 16
// @User: Standard
AP_GROUPINFO("_CANESC_BM", 19, SRV_Channels, can_esc_bm, 0),
AP_GROUPEND
};
@ -111,6 +128,8 @@ const AP_Param::GroupInfo SRV_Channels::var_info[] = {
SRV_Channels::SRV_Channels(void)
{
channels = obj_channels;
p_can_servo_bm = &can_servo_bm;
p_can_esc_bm = &can_esc_bm;
// set defaults from the parameter table
AP_Param::setup_object_defaults(this, var_info);