mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 02:03:35 +08:00
Merge branch 'master' of github.com:PX4/Firmware into prearm_checks
This commit is contained in:
@@ -45,7 +45,6 @@
|
|||||||
|
|
||||||
#include <uORB/uORB.h>
|
#include <uORB/uORB.h>
|
||||||
#include <uORB/topics/sensor_combined.h>
|
#include <uORB/topics/sensor_combined.h>
|
||||||
#include <uORB/topics/rc_channels.h>
|
|
||||||
#include <uORB/topics/vehicle_attitude.h>
|
#include <uORB/topics/vehicle_attitude.h>
|
||||||
#include <uORB/topics/vehicle_gps_position.h>
|
#include <uORB/topics/vehicle_gps_position.h>
|
||||||
#include <uORB/topics/vehicle_global_position.h>
|
#include <uORB/topics/vehicle_global_position.h>
|
||||||
|
|||||||
@@ -651,25 +651,22 @@ int position_estimator_inav_thread_main(int argc, char *argv[])
|
|||||||
|
|
||||||
} else if (t > ref_init_start + ref_init_delay) {
|
} else if (t > ref_init_start + ref_init_delay) {
|
||||||
ref_inited = true;
|
ref_inited = true;
|
||||||
/* update baro offset */
|
|
||||||
baro_offset -= z_est[0];
|
|
||||||
|
|
||||||
/* set position estimate to (0, 0, 0), use GPS velocity for XY */
|
/* set position estimate to (0, 0, 0), use GPS velocity for XY */
|
||||||
x_est[0] = 0.0f;
|
x_est[0] = 0.0f;
|
||||||
x_est[1] = gps.vel_n_m_s;
|
x_est[1] = gps.vel_n_m_s;
|
||||||
y_est[0] = 0.0f;
|
y_est[0] = 0.0f;
|
||||||
y_est[1] = gps.vel_e_m_s;
|
y_est[1] = gps.vel_e_m_s;
|
||||||
z_est[0] = 0.0f;
|
|
||||||
|
|
||||||
local_pos.ref_lat = lat;
|
local_pos.ref_lat = lat;
|
||||||
local_pos.ref_lon = lon;
|
local_pos.ref_lon = lon;
|
||||||
local_pos.ref_alt = alt;
|
local_pos.ref_alt = alt + z_est[0];
|
||||||
local_pos.ref_timestamp = t;
|
local_pos.ref_timestamp = t;
|
||||||
|
|
||||||
/* initialize projection */
|
/* initialize projection */
|
||||||
map_projection_init(&ref, lat, lon);
|
map_projection_init(&ref, lat, lon);
|
||||||
warnx("init ref: lat=%.7f, lon=%.7f, alt=%.2f", (double)lat, (double)lon, (double)alt);
|
warnx("init ref: lat=%.7f, lon=%.7f, alt=%.2f", (double)lat, (double)lon, (double)alt);
|
||||||
mavlink_log_info(mavlink_fd, "[inav] init ref: lat=%.7f, lon=%.7f, alt=%.2f", (double)lat, (double)lon, (double)alt);
|
mavlink_log_info(mavlink_fd, "[inav] init ref: %.7f, %.7f, %.2f", (double)lat, (double)lon, (double)alt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1394,8 +1394,8 @@ int sdlog2_thread_main(int argc, char *argv[])
|
|||||||
if (copy_if_updated(ORB_ID(rc_channels), subs.rc_sub, &buf.rc)) {
|
if (copy_if_updated(ORB_ID(rc_channels), subs.rc_sub, &buf.rc)) {
|
||||||
log_msg.msg_type = LOG_RC_MSG;
|
log_msg.msg_type = LOG_RC_MSG;
|
||||||
/* Copy only the first 8 channels of 14 */
|
/* Copy only the first 8 channels of 14 */
|
||||||
memcpy(log_msg.body.log_RC.channel, buf.rc.chan, sizeof(log_msg.body.log_RC.channel));
|
memcpy(log_msg.body.log_RC.channel, buf.rc.channels, sizeof(log_msg.body.log_RC.channel));
|
||||||
log_msg.body.log_RC.channel_count = buf.rc.chan_count;
|
log_msg.body.log_RC.channel_count = buf.rc.channel_count;
|
||||||
log_msg.body.log_RC.signal_lost = buf.rc.signal_lost;
|
log_msg.body.log_RC.signal_lost = buf.rc.signal_lost;
|
||||||
LOGBUFFER_WRITE_AND_COUNT(RC);
|
LOGBUFFER_WRITE_AND_COUNT(RC);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1223,9 +1223,9 @@ Sensors::parameter_update_poll(bool forced)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
printf("CH0: RAW MAX: %d MIN %d S: %d MID: %d FUNC: %d\n", (int)_parameters.max[0], (int)_parameters.min[0], (int)(_rc.chan[0].scaling_factor * 10000), (int)(_rc.chan[0].mid), (int)_rc.function[0]);
|
printf("CH0: RAW MAX: %d MIN %d S: %d MID: %d FUNC: %d\n", (int)_parameters.max[0], (int)_parameters.min[0], (int)(_rc.channels[0].scaling_factor * 10000), (int)(_rc.channels[0].mid), (int)_rc.function[0]);
|
||||||
printf("CH1: RAW MAX: %d MIN %d S: %d MID: %d FUNC: %d\n", (int)_parameters.max[1], (int)_parameters.min[1], (int)(_rc.chan[1].scaling_factor * 10000), (int)(_rc.chan[1].mid), (int)_rc.function[1]);
|
printf("CH1: RAW MAX: %d MIN %d S: %d MID: %d FUNC: %d\n", (int)_parameters.max[1], (int)_parameters.min[1], (int)(_rc.channels[1].scaling_factor * 10000), (int)(_rc.channels[1].mid), (int)_rc.function[1]);
|
||||||
printf("MAN: %d %d\n", (int)(_rc.chan[0].scaled * 100), (int)(_rc.chan[1].scaled * 100));
|
printf("MAN: %d %d\n", (int)(_rc.channels[0] * 100), (int)(_rc.channels[1] * 100));
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
#endif
|
#endif
|
||||||
@@ -1355,7 +1355,7 @@ float
|
|||||||
Sensors::get_rc_value(enum RC_CHANNELS_FUNCTION func, float min_value, float max_value)
|
Sensors::get_rc_value(enum RC_CHANNELS_FUNCTION func, float min_value, float max_value)
|
||||||
{
|
{
|
||||||
if (_rc.function[func] >= 0) {
|
if (_rc.function[func] >= 0) {
|
||||||
float value = _rc.chan[_rc.function[func]].scaled;
|
float value = _rc.channels[_rc.function[func]];
|
||||||
|
|
||||||
if (value < min_value) {
|
if (value < min_value) {
|
||||||
return min_value;
|
return min_value;
|
||||||
@@ -1376,7 +1376,7 @@ switch_pos_t
|
|||||||
Sensors::get_rc_sw3pos_position(enum RC_CHANNELS_FUNCTION func, float on_th, bool on_inv, float mid_th, bool mid_inv)
|
Sensors::get_rc_sw3pos_position(enum RC_CHANNELS_FUNCTION func, float on_th, bool on_inv, float mid_th, bool mid_inv)
|
||||||
{
|
{
|
||||||
if (_rc.function[func] >= 0) {
|
if (_rc.function[func] >= 0) {
|
||||||
float value = 0.5f * _rc.chan[_rc.function[func]].scaled + 0.5f;
|
float value = 0.5f * _rc.channels[_rc.function[func]] + 0.5f;
|
||||||
|
|
||||||
if (on_inv ? value < on_th : value > on_th) {
|
if (on_inv ? value < on_th : value > on_th) {
|
||||||
return SWITCH_POS_ON;
|
return SWITCH_POS_ON;
|
||||||
@@ -1397,7 +1397,7 @@ switch_pos_t
|
|||||||
Sensors::get_rc_sw2pos_position(enum RC_CHANNELS_FUNCTION func, float on_th, bool on_inv)
|
Sensors::get_rc_sw2pos_position(enum RC_CHANNELS_FUNCTION func, float on_th, bool on_inv)
|
||||||
{
|
{
|
||||||
if (_rc.function[func] >= 0) {
|
if (_rc.function[func] >= 0) {
|
||||||
float value = 0.5f * _rc.chan[_rc.function[func]].scaled + 0.5f;
|
float value = 0.5f * _rc.channels[_rc.function[func]] + 0.5f;
|
||||||
|
|
||||||
if (on_inv ? value < on_th : value > on_th) {
|
if (on_inv ? value < on_th : value > on_th) {
|
||||||
return SWITCH_POS_ON;
|
return SWITCH_POS_ON;
|
||||||
@@ -1489,25 +1489,25 @@ Sensors::rc_poll()
|
|||||||
* DO NOT REMOVE OR ALTER STEP 1!
|
* DO NOT REMOVE OR ALTER STEP 1!
|
||||||
*/
|
*/
|
||||||
if (rc_input.values[i] > (_parameters.trim[i] + _parameters.dz[i])) {
|
if (rc_input.values[i] > (_parameters.trim[i] + _parameters.dz[i])) {
|
||||||
_rc.chan[i].scaled = (rc_input.values[i] - _parameters.trim[i] - _parameters.dz[i]) / (float)(_parameters.max[i] - _parameters.trim[i] - _parameters.dz[i]);
|
_rc.channels[i] = (rc_input.values[i] - _parameters.trim[i] - _parameters.dz[i]) / (float)(_parameters.max[i] - _parameters.trim[i] - _parameters.dz[i]);
|
||||||
|
|
||||||
} else if (rc_input.values[i] < (_parameters.trim[i] - _parameters.dz[i])) {
|
} else if (rc_input.values[i] < (_parameters.trim[i] - _parameters.dz[i])) {
|
||||||
_rc.chan[i].scaled = (rc_input.values[i] - _parameters.trim[i] + _parameters.dz[i]) / (float)(_parameters.trim[i] - _parameters.min[i] - _parameters.dz[i]);
|
_rc.channels[i] = (rc_input.values[i] - _parameters.trim[i] + _parameters.dz[i]) / (float)(_parameters.trim[i] - _parameters.min[i] - _parameters.dz[i]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* in the configured dead zone, output zero */
|
/* in the configured dead zone, output zero */
|
||||||
_rc.chan[i].scaled = 0.0f;
|
_rc.channels[i] = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
_rc.chan[i].scaled *= _parameters.rev[i];
|
_rc.channels[i] *= _parameters.rev[i];
|
||||||
|
|
||||||
/* handle any parameter-induced blowups */
|
/* handle any parameter-induced blowups */
|
||||||
if (!isfinite(_rc.chan[i].scaled)) {
|
if (!isfinite(_rc.channels[i])) {
|
||||||
_rc.chan[i].scaled = 0.0f;
|
_rc.channels[i] = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_rc.chan_count = rc_input.channel_count;
|
_rc.channel_count = rc_input.channel_count;
|
||||||
_rc.rssi = rc_input.rssi;
|
_rc.rssi = rc_input.rssi;
|
||||||
_rc.signal_lost = signal_lost;
|
_rc.signal_lost = signal_lost;
|
||||||
_rc.timestamp = rc_input.timestamp_last_signal;
|
_rc.timestamp = rc_input.timestamp_last_signal;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved.
|
* Copyright (c) 2012-2014 PX4 Development Team. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -42,60 +42,44 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "../uORB.h"
|
#include "../uORB.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* The number of RC channel inputs supported.
|
|
||||||
* Current (Q4/2013) radios support up to 18 channels,
|
|
||||||
* leaving at a sane value of 16.
|
|
||||||
* This number can be greater then number of RC channels,
|
|
||||||
* because single RC channel can be mapped to multiple
|
|
||||||
* functions, e.g. for various mode switches.
|
|
||||||
*/
|
|
||||||
#define RC_CHANNELS_MAPPED_MAX 16
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This defines the mapping of the RC functions.
|
* This defines the mapping of the RC functions.
|
||||||
* The value assigned to the specific function corresponds to the entry of
|
* The value assigned to the specific function corresponds to the entry of
|
||||||
* the channel array chan[].
|
* the channel array channels[].
|
||||||
*/
|
*/
|
||||||
enum RC_CHANNELS_FUNCTION {
|
enum RC_CHANNELS_FUNCTION {
|
||||||
THROTTLE = 0,
|
THROTTLE = 0,
|
||||||
ROLL = 1,
|
ROLL,
|
||||||
PITCH = 2,
|
PITCH,
|
||||||
YAW = 3,
|
YAW,
|
||||||
MODE = 4,
|
MODE,
|
||||||
RETURN = 5,
|
RETURN,
|
||||||
POSCTL = 6,
|
POSCTL,
|
||||||
LOITER = 7,
|
LOITER,
|
||||||
OFFBOARD_MODE = 8,
|
OFFBOARD_MODE,
|
||||||
ACRO = 9,
|
ACRO,
|
||||||
FLAPS = 10,
|
FLAPS,
|
||||||
AUX_1 = 11,
|
AUX_1,
|
||||||
AUX_2 = 12,
|
AUX_2,
|
||||||
AUX_3 = 13,
|
AUX_3,
|
||||||
AUX_4 = 14,
|
AUX_4,
|
||||||
AUX_5 = 15,
|
AUX_5,
|
||||||
RC_CHANNELS_FUNCTION_MAX /**< indicates the number of functions. There can be more functions than RC channels. */
|
RC_CHANNELS_FUNCTION_MAX /**< Indicates the number of functions. There can be more functions than RC channels. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup topics
|
* @addtogroup topics
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct rc_channels_s {
|
struct rc_channels_s {
|
||||||
|
uint64_t timestamp; /**< Timestamp in microseconds since boot time */
|
||||||
uint64_t timestamp; /**< In microseconds since boot time. */
|
uint64_t timestamp_last_valid; /**< Timestamp of last valid RC signal */
|
||||||
uint64_t timestamp_last_valid; /**< timestamp of last valid RC signal. */
|
float channels[RC_CHANNELS_FUNCTION_MAX]; /**< Scaled to -1..1 (throttle: 0..1) */
|
||||||
struct {
|
uint8_t channel_count; /**< Number of valid channels */
|
||||||
float scaled; /**< Scaled to -1..1 (throttle: 0..1) */
|
char function_name[RC_CHANNELS_FUNCTION_MAX][20]; /**< String array to store the names of the functions */
|
||||||
} chan[RC_CHANNELS_MAPPED_MAX];
|
int8_t function[RC_CHANNELS_FUNCTION_MAX]; /**< Functions mapping */
|
||||||
uint8_t chan_count; /**< number of valid channels */
|
uint8_t rssi; /**< Receive signal strength index */
|
||||||
|
bool signal_lost; /**< Control signal lost, should be checked together with topic timeout */
|
||||||
/*String array to store the names of the functions*/
|
|
||||||
char function_name[RC_CHANNELS_FUNCTION_MAX][20];
|
|
||||||
int8_t function[RC_CHANNELS_FUNCTION_MAX];
|
|
||||||
uint8_t rssi; /**< Overall receive signal strength */
|
|
||||||
bool signal_lost; /**< control signal lost, should be checked together with topic timeout */
|
|
||||||
}; /**< radio control channels. */
|
}; /**< radio control channels. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user