forked from Archive/PX4-Autopilot
Completely implemented offboard control
This commit is contained in:
parent
572efc3383
commit
082074f991
|
@ -33,7 +33,7 @@
|
|||
|
||||
APPNAME = attitude_estimator_ekf
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = 20000
|
||||
STACKSIZE = 2048
|
||||
|
||||
CSRCS = attitude_estimator_ekf_main.c \
|
||||
codegen/eye.c \
|
||||
|
|
|
@ -98,7 +98,7 @@ static float P_aposteriori[81] = {100.f, 0, 0, 0, 0, 0, 0, 0, 0,
|
|||
0, 0, 0, 0, 0, 0, 0, 100.f, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 100.f,
|
||||
}; /**< init: diagonal matrix with big values */
|
||||
static float knownConst[20] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; /**< knownConst has the following entries [PrvaA,PrvarM,PrvarWO,PrvarW||MsvarA,MsvarM,MsvarW] */
|
||||
static float knownConst[15] = {1, 1, 1, 1, 1, 0.04, 4, 0.1, 70, 70, -2000, 9.81, 1, 4, 1}; /**< knownConst has the following entries [PrvaA,PrvarM,PrvarWO,PrvarW||MsvarA,MsvarM,MsvarW] */
|
||||
static float Rot_matrix[9] = {1.f, 0, 0,
|
||||
0, 1.f, 0,
|
||||
0, 0, 1.f
|
||||
|
@ -149,7 +149,7 @@ int attitude_estimator_ekf_main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
thread_should_exit = false;
|
||||
attitude_estimator_ekf_task = task_create("attitude_estimator_ekf", SCHED_PRIORITY_DEFAULT, 4096, attitude_estimator_ekf_thread_main, (argv) ? (const char **)&argv[2] : (const char **)NULL);
|
||||
attitude_estimator_ekf_task = task_create("attitude_estimator_ekf", SCHED_PRIORITY_DEFAULT, 20000, attitude_estimator_ekf_thread_main, (argv) ? (const char **)&argv[2] : (const char **)NULL);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
@ -235,19 +235,19 @@ int attitude_estimator_ekf_thread_main(int argc, char *argv[])
|
|||
dt = (raw.timestamp - last_measurement) / 1000000.0f;
|
||||
last_measurement = raw.timestamp;
|
||||
|
||||
/* Fill in gyro measurements */
|
||||
z_k[0] = raw.gyro_rad_s[0];
|
||||
z_k[1] = raw.gyro_rad_s[1];
|
||||
z_k[2] = raw.gyro_rad_s[2];
|
||||
|
||||
/* scale from 14 bit to m/s2 */
|
||||
z_k[3] = raw.accelerometer_m_s2[0];
|
||||
z_k[4] = raw.accelerometer_raw[1];
|
||||
z_k[5] = raw.accelerometer_raw[2];
|
||||
|
||||
z_k[0] = raw.magnetometer_ga[0];
|
||||
z_k[1] = raw.magnetometer_ga[1];
|
||||
z_k[2] = raw.magnetometer_ga[2];
|
||||
|
||||
/* Fill in gyro measurements */
|
||||
z_k[6] = raw.gyro_rad_s[0];
|
||||
z_k[7] = raw.gyro_rad_s[1];
|
||||
z_k[8] = raw.gyro_rad_s[2];
|
||||
z_k[6] = raw.magnetometer_ga[0];
|
||||
z_k[7] = raw.magnetometer_ga[1];
|
||||
z_k[8] = raw.magnetometer_ga[2];
|
||||
|
||||
uint64_t now = hrt_absolute_time();
|
||||
unsigned int time_elapsed = now - last_run;
|
||||
|
@ -268,6 +268,24 @@ int attitude_estimator_ekf_thread_main(int argc, char *argv[])
|
|||
int32_t z_k_sizes = 9;
|
||||
float u[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
static bool const_initialized = false;
|
||||
|
||||
/* initialize with good values once we have a reasonable dt estimate */
|
||||
if (!const_initialized && dt < 0.05 && dt > 0.005)
|
||||
{
|
||||
knownConst[0] = powf(0.6f, 2.0f*dt);
|
||||
knownConst[1] = powf(0.6f, 2.0f*dt);
|
||||
knownConst[2] = powf(0.2f, 2.0f*dt);
|
||||
knownConst[3] = powf(0.2f, 2.0f*dt);
|
||||
knownConst[4] = powf(0.000001f, 2.0f*dt);
|
||||
const_initialized = true;
|
||||
}
|
||||
|
||||
/* do not execute the filter if not initialized */
|
||||
if (!const_initialized) {
|
||||
continue;
|
||||
}
|
||||
|
||||
uint64_t timing_start = hrt_absolute_time();
|
||||
attitudeKalmanfilter(dt, update_vect, z_k, &z_k_sizes, u, x_aposteriori_k, P_aposteriori_k, knownConst, euler,
|
||||
Rot_matrix, x_aposteriori, P_aposteriori);
|
||||
|
@ -277,15 +295,15 @@ int attitude_estimator_ekf_thread_main(int argc, char *argv[])
|
|||
uint64_t timing_diff = hrt_absolute_time() - timing_start;
|
||||
|
||||
/* print rotation matrix every 200th time */
|
||||
if (printcounter % 200 == 0) {
|
||||
printf("EKF attitude iteration: %d, runtime: %d us, dt: %d us (%d Hz)\n", loopcounter, (int)timing_diff, (int)(dt * 1000000.0f), (int)(1.0f / dt));
|
||||
printf("roll: %8.4f\tpitch: %8.4f\tyaw:%8.4f", (double)euler[0], (double)euler[1], (double)euler[2]);
|
||||
printf("\n%d\t%d\t%d\n%d\t%d\t%d\n%d\t%d\t%d\n", (int)(Rot_matrix[0] * 100), (int)(Rot_matrix[1] * 100), (int)(Rot_matrix[2] * 100),
|
||||
(int)(Rot_matrix[3] * 100), (int)(Rot_matrix[4] * 100), (int)(Rot_matrix[5] * 100),
|
||||
(int)(Rot_matrix[6] * 100), (int)(Rot_matrix[7] * 100), (int)(Rot_matrix[8] * 100));
|
||||
}
|
||||
// if (printcounter % 200 == 0) {
|
||||
// printf("EKF attitude iteration: %d, runtime: %d us, dt: %d us (%d Hz)\n", loopcounter, (int)timing_diff, (int)(dt * 1000000.0f), (int)(1.0f / dt));
|
||||
// printf("roll: %8.4f\tpitch: %8.4f\tyaw:%8.4f", (double)euler[0], (double)euler[1], (double)euler[2]);
|
||||
// printf("\n%d\t%d\t%d\n%d\t%d\t%d\n%d\t%d\t%d\n", (int)(Rot_matrix[0] * 100), (int)(Rot_matrix[1] * 100), (int)(Rot_matrix[2] * 100),
|
||||
// (int)(Rot_matrix[3] * 100), (int)(Rot_matrix[4] * 100), (int)(Rot_matrix[5] * 100),
|
||||
// (int)(Rot_matrix[6] * 100), (int)(Rot_matrix[7] * 100), (int)(Rot_matrix[8] * 100));
|
||||
// }
|
||||
|
||||
printcounter++;
|
||||
// printcounter++;
|
||||
|
||||
if (last_data > 0 && raw.timestamp - last_data > 8000) printf("sensor data missed! (%llu)\n", raw.timestamp - last_data);
|
||||
|
||||
|
|
|
@ -65,7 +65,8 @@
|
|||
#include <poll.h>
|
||||
#include <uORB/uORB.h>
|
||||
#include <uORB/topics/sensor_combined.h>
|
||||
#include <uORB/topics/rc_channels.h>
|
||||
#include <uORB/topics/manual_control_setpoint.h>
|
||||
#include <uORB/topics/offboard_control_setpoint.h>
|
||||
#include <uORB/topics/vehicle_gps_position.h>
|
||||
#include <uORB/topics/vehicle_command.h>
|
||||
#include <uORB/topics/subsystem_info.h>
|
||||
|
@ -83,7 +84,8 @@
|
|||
#include <drivers/drv_baro.h>
|
||||
|
||||
|
||||
|
||||
PARAM_DEFINE_INT32(SYS_FAILSAVE_LL, 0); /**< Go into low-level failsafe after 0 ms */
|
||||
//PARAM_DEFINE_INT32(SYS_FAILSAVE_HL, 0); /**< Go into high-level failsafe after 0 ms */
|
||||
|
||||
#include <arch/board/up_cpuload.h>
|
||||
extern struct system_load_s system_load;
|
||||
|
@ -94,14 +96,15 @@ extern struct system_load_s system_load;
|
|||
#define LOW_VOLTAGE_BATTERY_COUNTER_LIMIT (LOW_VOLTAGE_BATTERY_HYSTERESIS_TIME_MS*COMMANDER_MONITORING_LOOPSPERMSEC)
|
||||
#define CRITICAL_VOLTAGE_BATTERY_COUNTER_LIMIT (CRITICAL_VOLTAGE_BATTERY_HYSTERESIS_TIME_MS*COMMANDER_MONITORING_LOOPSPERMSEC)
|
||||
|
||||
#define STICK_ON_OFF_LIMIT 7500
|
||||
#define STICK_THRUST_RANGE 20000
|
||||
#define STICK_ON_OFF_LIMIT 0.75f
|
||||
#define STICK_THRUST_RANGE 1.0f
|
||||
#define STICK_ON_OFF_HYSTERESIS_TIME_MS 1000
|
||||
#define STICK_ON_OFF_COUNTER_LIMIT (STICK_ON_OFF_HYSTERESIS_TIME_MS*COMMANDER_MONITORING_LOOPSPERMSEC)
|
||||
|
||||
#define GPS_FIX_TYPE_2D 2
|
||||
#define GPS_FIX_TYPE_3D 3
|
||||
#define GPS_QUALITY_GOOD_COUNTER_LIMIT 50
|
||||
#define GPS_QUALITY_GOOD_HYSTERIS_TIME_MS 5000
|
||||
#define GPS_QUALITY_GOOD_COUNTER_LIMIT (GPS_QUALITY_GOOD_HYSTERIS_TIME_MS*COMMANDER_MONITORING_LOOPSPERMSEC)
|
||||
|
||||
/* File descriptors */
|
||||
static int leds;
|
||||
|
@ -114,6 +117,8 @@ static orb_advert_t stat_pub;
|
|||
static uint16_t nofix_counter = 0;
|
||||
static uint16_t gotfix_counter = 0;
|
||||
|
||||
static unsigned int failsafe_lowlevel_timeout_ms;
|
||||
|
||||
static bool thread_should_exit = false; /**< Deamon exit flag */
|
||||
static bool thread_running = false; /**< Deamon status flag */
|
||||
static int deamon_task; /**< Handle of deamon task / thread */
|
||||
|
@ -1048,6 +1053,10 @@ int commander_thread_main(int argc, char *argv[])
|
|||
/* not yet initialized */
|
||||
commander_initialized = false;
|
||||
|
||||
/* set parameters */
|
||||
failsafe_lowlevel_timeout_ms = 0;
|
||||
param_get(param_find("SYS_FAILSAVE_LL"), &failsafe_lowlevel_timeout_ms);
|
||||
|
||||
/* welcome user */
|
||||
printf("[commander] I am in command now!\n");
|
||||
|
||||
|
@ -1119,10 +1128,15 @@ int commander_thread_main(int argc, char *argv[])
|
|||
|
||||
int gps_quality_good_counter = 0;
|
||||
|
||||
/* Subscribe to RC data */
|
||||
int rc_sub = orb_subscribe(ORB_ID(rc_channels));
|
||||
struct rc_channels_s rc;
|
||||
memset(&rc, 0, sizeof(rc));
|
||||
/* Subscribe to manual control data */
|
||||
int sp_man_sub = orb_subscribe(ORB_ID(manual_control_setpoint));
|
||||
struct manual_control_setpoint_s sp_man;
|
||||
memset(&sp_man, 0, sizeof(sp_man));
|
||||
|
||||
/* Subscribe to offboard control data */
|
||||
int sp_offboard_sub = orb_subscribe(ORB_ID(offboard_control_setpoint));
|
||||
struct offboard_control_setpoint_s sp_offboard;
|
||||
memset(&sp_offboard, 0, sizeof(sp_offboard));
|
||||
|
||||
int gps_sub = orb_subscribe(ORB_ID(vehicle_gps_position));
|
||||
struct vehicle_gps_position_s gps;
|
||||
|
@ -1141,11 +1155,15 @@ int commander_thread_main(int argc, char *argv[])
|
|||
commander_initialized = true;
|
||||
|
||||
uint64_t start_time = hrt_absolute_time();
|
||||
uint64_t failsave_ll_start_time = 0;
|
||||
|
||||
bool state_changed = true;
|
||||
|
||||
while (!thread_should_exit) {
|
||||
|
||||
/* Get current values */
|
||||
orb_copy(ORB_ID(rc_channels), rc_sub, &rc);
|
||||
orb_copy(ORB_ID(manual_control_setpoint), sp_man_sub, &sp_man);
|
||||
orb_copy(ORB_ID(offboard_control_setpoint), sp_offboard_sub, &sp_offboard);
|
||||
orb_copy(ORB_ID(vehicle_gps_position), gps_sub, &gps);
|
||||
orb_copy(ORB_ID(sensor_combined), sensor_sub, &sensors);
|
||||
|
||||
|
@ -1256,10 +1274,10 @@ int commander_thread_main(int argc, char *argv[])
|
|||
/* End battery voltage check */
|
||||
|
||||
/* Check if last transition deserved an audio event */
|
||||
#warning This code depends on state that is no longer? maintained
|
||||
#if 0
|
||||
trigger_audio_alarm(vehicle_mode_previous, vehicle_state_previous, current_status.mode, current_status.state_machine);
|
||||
#endif
|
||||
// #warning This code depends on state that is no longer? maintained
|
||||
// #if 0
|
||||
// trigger_audio_alarm(vehicle_mode_previous, vehicle_state_previous, current_status.mode, current_status.state_machine);
|
||||
// #endif
|
||||
|
||||
/* only check gps fix if we are outdoor */
|
||||
// if (flight_env == PX4_FLIGHT_ENVIRONMENT_OUTDOOR) {
|
||||
|
@ -1314,21 +1332,15 @@ int commander_thread_main(int argc, char *argv[])
|
|||
/* end: check gps */
|
||||
|
||||
|
||||
/* ignore RC signals if in offboard control mode */
|
||||
if (!current_status.offboard_control_signal_found_once) {
|
||||
/* Start RC state check */
|
||||
bool prev_lost = current_status.rc_signal_lost;
|
||||
|
||||
if (rc.chan_count > 4 && (hrt_absolute_time() - rc.timestamp) < 100000) {
|
||||
|
||||
/* quadrotor specific logic - check against system type in the future */
|
||||
|
||||
int16_t rc_yaw_scale = rc.chan[rc.function[YAW]].scale;
|
||||
int16_t rc_throttle_scale = rc.chan[rc.function[THROTTLE]].scale;
|
||||
int16_t mode_switch_rc_value = rc.chan[rc.function[OVERRIDE]].scale;
|
||||
/* Check the value of the rc channel of the mode switch */
|
||||
mode_switch_rc_value = rc.chan[rc.function[OVERRIDE]].scale;
|
||||
if ((hrt_absolute_time() - sp_man.timestamp) < 100000) {
|
||||
|
||||
/* check if left stick is in lower left position --> switch to standby state */
|
||||
if (rc_yaw_scale < -STICK_ON_OFF_LIMIT && rc_throttle_scale < STICK_THRUST_RANGE*0.2f) { //TODO: remove hardcoded values
|
||||
if ((sp_man.yaw < -STICK_ON_OFF_LIMIT) && sp_man.throttle < STICK_THRUST_RANGE*0.2f) { //TODO: remove hardcoded values
|
||||
if (stick_off_counter > STICK_ON_OFF_COUNTER_LIMIT) {
|
||||
update_state_machine_disarm(stat_pub, ¤t_status, mavlink_fd);
|
||||
stick_on_counter = 0;
|
||||
|
@ -1340,7 +1352,7 @@ int commander_thread_main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* check if left stick is in lower right position --> arm */
|
||||
if (rc_yaw_scale > STICK_ON_OFF_LIMIT && rc_throttle_scale < STICK_THRUST_RANGE*0.2f) { //TODO: remove hardcoded values
|
||||
if (sp_man.yaw > STICK_ON_OFF_LIMIT && sp_man.throttle < STICK_THRUST_RANGE*0.2f) { //TODO: remove hardcoded values
|
||||
if (stick_on_counter > STICK_ON_OFF_COUNTER_LIMIT) {
|
||||
update_state_machine_arm(stat_pub, ¤t_status, mavlink_fd);
|
||||
stick_on_counter = 0;
|
||||
|
@ -1352,21 +1364,24 @@ int commander_thread_main(int argc, char *argv[])
|
|||
}
|
||||
//printf("RC: y:%i/t:%i s:%i chans: %i\n", rc_yaw_scale, rc_throttle_scale, mode_switch_rc_value, rc.chan_count);
|
||||
|
||||
if (mode_switch_rc_value > STICK_ON_OFF_LIMIT) {
|
||||
if (sp_man.override_mode_switch > STICK_ON_OFF_LIMIT) {
|
||||
update_state_machine_mode_manual(stat_pub, ¤t_status, mavlink_fd);
|
||||
|
||||
} else if (mode_switch_rc_value < -STICK_ON_OFF_LIMIT) {
|
||||
} else if (sp_man.override_mode_switch < -STICK_ON_OFF_LIMIT) {
|
||||
update_state_machine_mode_auto(stat_pub, ¤t_status, mavlink_fd);
|
||||
|
||||
} else {
|
||||
update_state_machine_mode_stabilized(stat_pub, ¤t_status, mavlink_fd);
|
||||
}
|
||||
|
||||
/* Publish RC signal */
|
||||
|
||||
|
||||
/* handle the case where RC signal was regained */
|
||||
if (!current_status.rc_signal_found_once) {
|
||||
current_status.rc_signal_found_once = true;
|
||||
mavlink_log_critical(mavlink_fd, "[commander] DETECTED RC SIGNAL FIRST TIME.");
|
||||
} else {
|
||||
if (current_status.rc_signal_lost) mavlink_log_critical(mavlink_fd, "[commander] RECOVERY - RC SIGNAL GAINED!");
|
||||
}
|
||||
|
||||
current_status.rc_signal_lost = false;
|
||||
current_status.rc_signal_lost_interval = 0;
|
||||
|
||||
|
@ -1374,29 +1389,112 @@ int commander_thread_main(int argc, char *argv[])
|
|||
static uint64_t last_print_time = 0;
|
||||
/* print error message for first RC glitch and then every 5 s / 5000 ms) */
|
||||
if (!current_status.rc_signal_lost || ((hrt_absolute_time() - last_print_time) > 5000000)) {
|
||||
/* only complain if the offboard control is NOT active */
|
||||
mavlink_log_critical(mavlink_fd, "[commander] CRITICAL - NO REMOTE SIGNAL!");
|
||||
last_print_time = hrt_absolute_time();
|
||||
}
|
||||
/* flag as lost and update interval since when the signal was lost (to initiate RTL after some time) */
|
||||
current_status.rc_signal_cutting_off = true;
|
||||
current_status.rc_signal_lost_interval = hrt_absolute_time() - rc.timestamp;
|
||||
current_status.rc_signal_lost_interval = hrt_absolute_time() - sp_man.timestamp;
|
||||
|
||||
/* if the RC signal is gone for a full second, consider it lost */
|
||||
if (current_status.rc_signal_lost_interval > 1000000) current_status.rc_signal_lost = true;
|
||||
if (current_status.rc_signal_lost_interval > 1000000) {
|
||||
current_status.rc_signal_lost = true;
|
||||
current_status.failsave_lowlevel = true;
|
||||
}
|
||||
|
||||
// if (hrt_absolute_time() - current_status.failsave_ll_start_time > failsafe_lowlevel_timeout_ms*1000) {
|
||||
// publish_armed_status(¤t_status);
|
||||
// }
|
||||
}
|
||||
|
||||
/* Check if this is the first loss or first gain*/
|
||||
if ((!prev_lost && current_status.rc_signal_lost) ||
|
||||
prev_lost && !current_status.rc_signal_lost) {
|
||||
/* publish rc lost */
|
||||
(prev_lost && !current_status.rc_signal_lost)) {
|
||||
/* publish change */
|
||||
publish_armed_status(¤t_status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* End mode switch */
|
||||
|
||||
/* END RC state check */
|
||||
|
||||
|
||||
/* State machine update for offboard control */
|
||||
if (!current_status.rc_signal_found_once) {
|
||||
if ((hrt_absolute_time() - sp_offboard.timestamp) < 5000000) {
|
||||
|
||||
/* set up control mode */
|
||||
if (current_status.flag_control_attitude_enabled !=
|
||||
(sp_offboard.mode == OFFBOARD_CONTROL_MODE_DIRECT_ATTITUDE)) {
|
||||
current_status.flag_control_attitude_enabled = (sp_offboard.mode == OFFBOARD_CONTROL_MODE_DIRECT_ATTITUDE);
|
||||
state_changed = true;
|
||||
}
|
||||
|
||||
if (current_status.flag_control_rates_enabled !=
|
||||
(sp_offboard.mode == OFFBOARD_CONTROL_MODE_DIRECT_RATES)) {
|
||||
current_status.flag_control_attitude_enabled = (sp_offboard.mode == OFFBOARD_CONTROL_MODE_DIRECT_RATES);
|
||||
state_changed = true;
|
||||
}
|
||||
|
||||
/* handle the case where RC signal was regained */
|
||||
if (!current_status.offboard_control_signal_found_once) {
|
||||
current_status.offboard_control_signal_found_once = true;
|
||||
/* enable offboard control, disable manual input */
|
||||
current_status.flag_control_manual_enabled = false;
|
||||
current_status.flag_control_offboard_enabled = true;
|
||||
state_changed = true;
|
||||
|
||||
mavlink_log_critical(mavlink_fd, "[commander] DETECTED OFFBOARD CONTROL SIGNAL FIRST TIME.");
|
||||
} else {
|
||||
if (current_status.offboard_control_signal_lost) {
|
||||
mavlink_log_critical(mavlink_fd, "[commander] RECOVERY - OFFBOARD CONTROL SIGNAL GAINED!");
|
||||
state_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
current_status.offboard_control_signal_lost = false;
|
||||
current_status.offboard_control_signal_lost_interval = 0;
|
||||
|
||||
/* arm / disarm on request */
|
||||
if (sp_offboard.armed && !current_status.flag_system_armed) {
|
||||
update_state_machine_arm(stat_pub, ¤t_status, mavlink_fd);
|
||||
/* switch to stabilized mode = takeoff */
|
||||
update_state_machine_mode_stabilized(stat_pub, ¤t_status, mavlink_fd);
|
||||
} else if (!sp_offboard.armed && current_status.flag_system_armed) {
|
||||
update_state_machine_disarm(stat_pub, ¤t_status, mavlink_fd);
|
||||
}
|
||||
|
||||
} else {
|
||||
static uint64_t last_print_time = 0;
|
||||
/* print error message for first RC glitch and then every 5 s / 5000 ms) */
|
||||
if (!current_status.offboard_control_signal_lost || ((hrt_absolute_time() - last_print_time) > 5000000)) {
|
||||
/* only complain if the RC control is NOT active */
|
||||
mavlink_log_critical(mavlink_fd, "[commander] CRITICAL - NO OFFBOARD CONTROL SIGNAL!");
|
||||
last_print_time = hrt_absolute_time();
|
||||
}
|
||||
/* flag as lost and update interval since when the signal was lost (to initiate RTL after some time) */
|
||||
current_status.offboard_control_signal_lost_interval = hrt_absolute_time() - sp_offboard.timestamp;
|
||||
|
||||
/* if the signal is gone for 0.1 seconds, consider it lost */
|
||||
if (current_status.offboard_control_signal_lost_interval > 100000) {
|
||||
current_status.offboard_control_signal_lost = true;
|
||||
current_status.failsave_lowlevel_start_time = hrt_absolute_time();
|
||||
current_status.failsave_lowlevel = true;
|
||||
|
||||
/* kill motors after timeout */
|
||||
if (hrt_absolute_time() - current_status.failsave_lowlevel_start_time > failsafe_lowlevel_timeout_ms*1000) {
|
||||
state_changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
current_status.counter++;
|
||||
current_status.timestamp = hrt_absolute_time();
|
||||
|
||||
|
@ -1411,8 +1509,10 @@ int commander_thread_main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* publish at least with 1 Hz */
|
||||
if (counter % (1000000 / COMMANDER_MONITORING_INTERVAL) == 0) {
|
||||
if (counter % (1000000 / COMMANDER_MONITORING_INTERVAL) == 0 || state_changed) {
|
||||
publish_armed_status(¤t_status);
|
||||
orb_publish(ORB_ID(vehicle_status), stat_pub, ¤t_status);
|
||||
state_changed = false;
|
||||
}
|
||||
|
||||
/* Store old modes to detect and act on state transitions */
|
||||
|
@ -1430,7 +1530,8 @@ int commander_thread_main(int argc, char *argv[])
|
|||
/* close fds */
|
||||
led_deinit();
|
||||
buzzer_deinit();
|
||||
close(rc_sub);
|
||||
close(sp_man_sub);
|
||||
close(sp_offboard_sub);
|
||||
close(gps_sub);
|
||||
close(sensor_sub);
|
||||
|
||||
|
|
|
@ -223,7 +223,8 @@ void publish_armed_status(const struct vehicle_status_s *current_status) {
|
|||
/* lock down actuators if required */
|
||||
// XXX FIXME Currently any loss of RC will completely disable all actuators
|
||||
// needs proper failsafe
|
||||
armed.lockdown = (current_status->rc_signal_lost || current_status->flag_hil_enabled) ? true : false;
|
||||
armed.lockdown = ((current_status->rc_signal_lost && current_status->offboard_control_signal_lost)
|
||||
|| current_status->flag_hil_enabled) ? true : false;
|
||||
orb_advert_t armed_pub = orb_advertise(ORB_ID(actuator_armed), &armed);
|
||||
orb_publish(ORB_ID(actuator_armed), armed_pub, &armed);
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
#include <uORB/topics/vehicle_gps_position.h>
|
||||
#include <uORB/topics/vehicle_global_position.h>
|
||||
#include <uORB/topics/vehicle_status.h>
|
||||
#include <uORB/topics/vehicle_rates_setpoint.h>
|
||||
#include <uORB/topics/offboard_control_setpoint.h>
|
||||
#include <uORB/topics/vehicle_command.h>
|
||||
#include <uORB/topics/vehicle_local_position_setpoint.h>
|
||||
#include <uORB/topics/vehicle_global_position_setpoint.h>
|
||||
|
@ -126,7 +126,7 @@ static struct vehicle_attitude_s hil_attitude;
|
|||
|
||||
static struct vehicle_global_position_s hil_global_pos;
|
||||
|
||||
static struct vehicle_rates_setpoint_s vehicle_rates_sp;
|
||||
static struct offboard_control_setpoint_s offboard_control_sp;
|
||||
|
||||
static struct vehicle_command_s vcmd;
|
||||
|
||||
|
@ -188,9 +188,9 @@ static struct mavlink_subscriptions {
|
|||
};
|
||||
|
||||
static struct mavlink_publications {
|
||||
orb_advert_t vehicle_rates_sp_pub;
|
||||
orb_advert_t offboard_control_sp_pub;
|
||||
} mavlink_pubs = {
|
||||
.vehicle_rates_sp_pub = -1
|
||||
.offboard_control_sp_pub = -1
|
||||
};
|
||||
|
||||
|
||||
|
@ -1138,11 +1138,6 @@ mavlink_dev_ioctl(struct file *filep, int cmd, unsigned long arg)
|
|||
}
|
||||
}
|
||||
|
||||
#define MAVLINK_OFFBOARD_CONTROL_MODE_NONE 0
|
||||
#define MAVLINK_OFFBOARD_CONTROL_MODE_RATES 1
|
||||
#define MAVLINK_OFFBOARD_CONTROL_MODE_ATTITUDE 2
|
||||
#define MAVLINK_OFFBOARD_CONTROL_MODE_VELOCITY 3
|
||||
#define MAVLINK_OFFBOARD_CONTROL_MODE_POSITION 4
|
||||
#define MAVLINK_OFFBOARD_CONTROL_FLAG_ARMED 0x10
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -1254,81 +1249,105 @@ void handleMessage(mavlink_message_t *msg)
|
|||
// printf("got MAVLINK_MSG_ID_SET_QUAD_MOTORS_SETPOINT target_system=%u, sysid = %u\n", quad_motors_setpoint.target_system, mavlink_system.sysid);
|
||||
|
||||
if (mavlink_system.sysid < 4) {
|
||||
/* only send if RC is off */
|
||||
if (v_status.rc_signal_lost) {
|
||||
/*
|
||||
* rate control mode - defined by MAVLink
|
||||
*/
|
||||
|
||||
/* rate control mode */
|
||||
if (quad_motors_setpoint.mode == 1) {
|
||||
vehicle_rates_sp.roll = quad_motors_setpoint.roll[mavlink_system.sysid] / (float)INT16_MAX;
|
||||
vehicle_rates_sp.pitch = quad_motors_setpoint.pitch[mavlink_system.sysid] / (float)INT16_MAX;
|
||||
vehicle_rates_sp.yaw = quad_motors_setpoint.yaw[mavlink_system.sysid] / (float)INT16_MAX;
|
||||
vehicle_rates_sp.thrust = quad_motors_setpoint.thrust[mavlink_system.sysid] / (float)UINT16_MAX;
|
||||
uint8_t ml_mode = 0;
|
||||
bool ml_armed = false;
|
||||
|
||||
vehicle_rates_sp.timestamp = hrt_absolute_time();
|
||||
if (quad_motors_setpoint.mode & MAVLINK_OFFBOARD_CONTROL_FLAG_ARMED) {
|
||||
ml_armed = true;
|
||||
}
|
||||
|
||||
switch (quad_motors_setpoint.mode) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
ml_mode = OFFBOARD_CONTROL_MODE_DIRECT_RATES;
|
||||
break;
|
||||
case 2:
|
||||
ml_mode = OFFBOARD_CONTROL_MODE_DIRECT_ATTITUDE;
|
||||
break;
|
||||
case 3:
|
||||
ml_mode = OFFBOARD_CONTROL_MODE_DIRECT_VELOCITY;
|
||||
break;
|
||||
case 4:
|
||||
ml_mode = OFFBOARD_CONTROL_MODE_DIRECT_POSITION;
|
||||
break;
|
||||
}
|
||||
|
||||
offboard_control_sp.p1 = quad_motors_setpoint.roll[mavlink_system.sysid] / (float)INT16_MAX;
|
||||
offboard_control_sp.p2 = quad_motors_setpoint.pitch[mavlink_system.sysid] / (float)INT16_MAX;
|
||||
offboard_control_sp.p3= quad_motors_setpoint.yaw[mavlink_system.sysid] / (float)INT16_MAX;
|
||||
offboard_control_sp.p4 = quad_motors_setpoint.thrust[mavlink_system.sysid] / (float)UINT16_MAX;
|
||||
offboard_control_sp.armed = ml_armed;
|
||||
offboard_control_sp.mode = ml_mode;
|
||||
|
||||
offboard_control_sp.timestamp = hrt_absolute_time();
|
||||
|
||||
/* check if topic has to be advertised */
|
||||
if (mavlink_pubs.vehicle_rates_sp_pub <= 0) {
|
||||
mavlink_pubs.vehicle_rates_sp_pub = orb_advertise(ORB_ID(vehicle_rates_setpoint), &vehicle_rates_sp);
|
||||
}
|
||||
/* Publish */
|
||||
orb_publish(ORB_ID(vehicle_rates_setpoint), mavlink_pubs.vehicle_rates_sp_pub, &vehicle_rates_sp);
|
||||
|
||||
/* change armed status if required */
|
||||
bool cmd_armed = (quad_motors_setpoint.mode & MAVLINK_OFFBOARD_CONTROL_FLAG_ARMED);
|
||||
|
||||
bool cmd_generated = false;
|
||||
|
||||
if (v_status.flag_control_offboard_enabled != cmd_armed) {
|
||||
vcmd.param1 = cmd_armed;
|
||||
vcmd.param2 = 0;
|
||||
vcmd.param3 = 0;
|
||||
vcmd.param4 = 0;
|
||||
vcmd.param5 = 0;
|
||||
vcmd.param6 = 0;
|
||||
vcmd.param7 = 0;
|
||||
vcmd.command = MAV_CMD_COMPONENT_ARM_DISARM;
|
||||
vcmd.target_system = mavlink_system.sysid;
|
||||
vcmd.target_component = MAV_COMP_ID_ALL;
|
||||
vcmd.source_system = msg->sysid;
|
||||
vcmd.source_component = msg->compid;
|
||||
vcmd.confirmation = 1;
|
||||
|
||||
cmd_generated = true;
|
||||
}
|
||||
|
||||
/* check if input has to be enabled */
|
||||
if ((v_status.flag_control_rates_enabled != (quad_motors_setpoint.mode == MAVLINK_OFFBOARD_CONTROL_MODE_RATES)) ||
|
||||
(v_status.flag_control_attitude_enabled != (quad_motors_setpoint.mode == MAVLINK_OFFBOARD_CONTROL_MODE_ATTITUDE)) ||
|
||||
(v_status.flag_control_velocity_enabled != (quad_motors_setpoint.mode == MAVLINK_OFFBOARD_CONTROL_MODE_VELOCITY)) ||
|
||||
(v_status.flag_control_position_enabled != (quad_motors_setpoint.mode == MAVLINK_OFFBOARD_CONTROL_MODE_POSITION))) {
|
||||
vcmd.param1 = (quad_motors_setpoint.mode == MAVLINK_OFFBOARD_CONTROL_MODE_RATES);
|
||||
vcmd.param2 = (quad_motors_setpoint.mode == MAVLINK_OFFBOARD_CONTROL_MODE_ATTITUDE);
|
||||
vcmd.param3 = (quad_motors_setpoint.mode == MAVLINK_OFFBOARD_CONTROL_MODE_VELOCITY);
|
||||
vcmd.param4 = (quad_motors_setpoint.mode == MAVLINK_OFFBOARD_CONTROL_MODE_POSITION);
|
||||
vcmd.param5 = 0;
|
||||
vcmd.param6 = 0;
|
||||
vcmd.param7 = 0;
|
||||
vcmd.command = PX4_CMD_CONTROLLER_SELECTION;
|
||||
vcmd.target_system = mavlink_system.sysid;
|
||||
vcmd.target_component = MAV_COMP_ID_ALL;
|
||||
vcmd.source_system = msg->sysid;
|
||||
vcmd.source_component = msg->compid;
|
||||
vcmd.confirmation = 1;
|
||||
|
||||
cmd_generated = true;
|
||||
}
|
||||
|
||||
if (cmd_generated) {
|
||||
/* check if topic is advertised */
|
||||
if (cmd_pub <= 0) {
|
||||
cmd_pub = orb_advertise(ORB_ID(vehicle_command), &vcmd);
|
||||
if (mavlink_pubs.offboard_control_sp_pub <= 0) {
|
||||
mavlink_pubs.offboard_control_sp_pub = orb_advertise(ORB_ID(offboard_control_setpoint), &offboard_control_sp);
|
||||
} else {
|
||||
/* create command */
|
||||
orb_publish(ORB_ID(vehicle_command), cmd_pub, &vcmd);
|
||||
}
|
||||
}
|
||||
/* Publish */
|
||||
orb_publish(ORB_ID(offboard_control_setpoint), mavlink_pubs.offboard_control_sp_pub, &offboard_control_sp);
|
||||
}
|
||||
|
||||
// /* change armed status if required */
|
||||
// bool cmd_armed = (quad_motors_setpoint.mode & MAVLINK_OFFBOARD_CONTROL_FLAG_ARMED);
|
||||
|
||||
// bool cmd_generated = false;
|
||||
|
||||
// if (v_status.flag_control_offboard_enabled != cmd_armed) {
|
||||
// vcmd.param1 = cmd_armed;
|
||||
// vcmd.param2 = 0;
|
||||
// vcmd.param3 = 0;
|
||||
// vcmd.param4 = 0;
|
||||
// vcmd.param5 = 0;
|
||||
// vcmd.param6 = 0;
|
||||
// vcmd.param7 = 0;
|
||||
// vcmd.command = MAV_CMD_COMPONENT_ARM_DISARM;
|
||||
// vcmd.target_system = mavlink_system.sysid;
|
||||
// vcmd.target_component = MAV_COMP_ID_ALL;
|
||||
// vcmd.source_system = msg->sysid;
|
||||
// vcmd.source_component = msg->compid;
|
||||
// vcmd.confirmation = 1;
|
||||
|
||||
// cmd_generated = true;
|
||||
// }
|
||||
|
||||
// /* check if input has to be enabled */
|
||||
// if ((v_status.flag_control_rates_enabled != (quad_motors_setpoint.mode == MAVLINK_OFFBOARD_CONTROL_MODE_RATES)) ||
|
||||
// (v_status.flag_control_attitude_enabled != (quad_motors_setpoint.mode == MAVLINK_OFFBOARD_CONTROL_MODE_ATTITUDE)) ||
|
||||
// (v_status.flag_control_velocity_enabled != (quad_motors_setpoint.mode == MAVLINK_OFFBOARD_CONTROL_MODE_VELOCITY)) ||
|
||||
// (v_status.flag_control_position_enabled != (quad_motors_setpoint.mode == MAVLINK_OFFBOARD_CONTROL_MODE_POSITION))) {
|
||||
// vcmd.param1 = (quad_motors_setpoint.mode == MAVLINK_OFFBOARD_CONTROL_MODE_RATES);
|
||||
// vcmd.param2 = (quad_motors_setpoint.mode == MAVLINK_OFFBOARD_CONTROL_MODE_ATTITUDE);
|
||||
// vcmd.param3 = (quad_motors_setpoint.mode == MAVLINK_OFFBOARD_CONTROL_MODE_VELOCITY);
|
||||
// vcmd.param4 = (quad_motors_setpoint.mode == MAVLINK_OFFBOARD_CONTROL_MODE_POSITION);
|
||||
// vcmd.param5 = 0;
|
||||
// vcmd.param6 = 0;
|
||||
// vcmd.param7 = 0;
|
||||
// vcmd.command = PX4_CMD_CONTROLLER_SELECTION;
|
||||
// vcmd.target_system = mavlink_system.sysid;
|
||||
// vcmd.target_component = MAV_COMP_ID_ALL;
|
||||
// vcmd.source_system = msg->sysid;
|
||||
// vcmd.source_component = msg->compid;
|
||||
// vcmd.confirmation = 1;
|
||||
|
||||
// cmd_generated = true;
|
||||
// }
|
||||
|
||||
// if (cmd_generated) {
|
||||
// /* check if topic is advertised */
|
||||
// if (cmd_pub <= 0) {
|
||||
// cmd_pub = orb_advertise(ORB_ID(vehicle_command), &vcmd);
|
||||
// } else {
|
||||
// /* create command */
|
||||
// orb_publish(ORB_ID(vehicle_command), cmd_pub, &vcmd);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1542,7 +1561,7 @@ int mavlink_thread_main(int argc, char *argv[])
|
|||
memset(&rc, 0, sizeof(rc));
|
||||
memset(&hil_attitude, 0, sizeof(hil_attitude));
|
||||
memset(&hil_global_pos, 0, sizeof(hil_global_pos));
|
||||
memset(&vehicle_rates_sp, 0, sizeof(vehicle_rates_sp));
|
||||
memset(&offboard_control_sp, 0, sizeof(offboard_control_sp));
|
||||
memset(&vcmd, 0, sizeof(vcmd));
|
||||
|
||||
/* print welcome text */
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include <uORB/topics/vehicle_attitude.h>
|
||||
#include <uORB/topics/vehicle_attitude_setpoint.h>
|
||||
#include <uORB/topics/manual_control_setpoint.h>
|
||||
#include <uORB/topics/offboard_control_setpoint.h>
|
||||
#include <uORB/topics/vehicle_rates_setpoint.h>
|
||||
#include <uORB/topics/sensor_combined.h>
|
||||
#include <uORB/topics/actuator_controls.h>
|
||||
|
@ -94,6 +95,8 @@ mc_thread_main(int argc, char *argv[])
|
|||
memset(&manual, 0, sizeof(manual));
|
||||
struct sensor_combined_s raw;
|
||||
memset(&raw, 0, sizeof(raw));
|
||||
struct offboard_control_setpoint_s offboard_sp;
|
||||
memset(&offboard_sp, 0, sizeof(offboard_sp));
|
||||
struct vehicle_rates_setpoint_s rates_sp;
|
||||
memset(&rates_sp, 0, sizeof(rates_sp));
|
||||
|
||||
|
@ -102,7 +105,7 @@ mc_thread_main(int argc, char *argv[])
|
|||
/* subscribe to attitude, motor setpoints and system state */
|
||||
int att_sub = orb_subscribe(ORB_ID(vehicle_attitude));
|
||||
int att_setpoint_sub = orb_subscribe(ORB_ID(vehicle_attitude_setpoint));
|
||||
int setpoint_sub = orb_subscribe(ORB_ID(vehicle_rates_setpoint));
|
||||
int setpoint_sub = orb_subscribe(ORB_ID(offboard_control_setpoint));
|
||||
int state_sub = orb_subscribe(ORB_ID(vehicle_status));
|
||||
int manual_sub = orb_subscribe(ORB_ID(manual_control_setpoint));
|
||||
int sensor_sub = orb_subscribe(ORB_ID(sensor_combined));
|
||||
|
@ -150,7 +153,7 @@ mc_thread_main(int argc, char *argv[])
|
|||
bool updated;
|
||||
orb_check(setpoint_sub, &updated);
|
||||
if (updated) {
|
||||
orb_copy(ORB_ID(vehicle_rates_setpoint), setpoint_sub, &rates_sp);
|
||||
orb_copy(ORB_ID(offboard_control_setpoint), setpoint_sub, &offboard_sp);
|
||||
}
|
||||
/* get a local copy of the current sensor values */
|
||||
orb_copy(ORB_ID(sensor_combined), sensor_sub, &raw);
|
||||
|
@ -177,6 +180,17 @@ mc_thread_main(int argc, char *argv[])
|
|||
}
|
||||
} else if (state.flag_control_offboard_enabled) {
|
||||
/* offboard inputs */
|
||||
if (offboard_sp.mode == OFFBOARD_CONTROL_MODE_DIRECT_RATES) {
|
||||
rates_sp.roll = offboard_sp.p1;
|
||||
rates_sp.pitch = offboard_sp.p2;
|
||||
rates_sp.yaw = offboard_sp.p3;
|
||||
rates_sp.thrust = offboard_sp.p4;
|
||||
} else if (offboard_sp.mode == OFFBOARD_CONTROL_MODE_DIRECT_ATTITUDE) {
|
||||
att_sp.roll_body = offboard_sp.p1;
|
||||
att_sp.pitch_body = offboard_sp.p2;
|
||||
att_sp.yaw_body = offboard_sp.p3;
|
||||
att_sp.thrust = offboard_sp.p4;
|
||||
}
|
||||
|
||||
/* decide wether we want rate or position input */
|
||||
}
|
||||
|
|
|
@ -567,7 +567,7 @@ Sensors::accel_init()
|
|||
_fd_bma180 = open("/dev/bma180", O_RDONLY);
|
||||
if (_fd_bma180 < 0) {
|
||||
warn("/dev/bma180");
|
||||
errx(1, "FATAL: no accelerometer found");
|
||||
warn("FATAL: no accelerometer found");
|
||||
}
|
||||
|
||||
/* discard first (junk) reading */
|
||||
|
@ -600,7 +600,7 @@ Sensors::gyro_init()
|
|||
_fd_gyro_l3gd20 = open("/dev/l3gd20", O_RDONLY);
|
||||
if (_fd_gyro_l3gd20 < 0) {
|
||||
warn("/dev/l3gd20");
|
||||
errx(1, "FATAL: no gyro found");
|
||||
warn("FATAL: no gyro found");
|
||||
}
|
||||
|
||||
/* discard first (junk) reading */
|
||||
|
@ -988,6 +988,8 @@ Sensors::ppm_poll()
|
|||
_rc.chan_count = ppm_decoded_channels;
|
||||
_rc.timestamp = ppm_last_valid_decode;
|
||||
|
||||
manual_control.timestamp = ppm_last_valid_decode;
|
||||
|
||||
/* roll input - rolling right is stick-wise and rotation-wise positive */
|
||||
manual_control.roll = _rc.chan[_rc.function[ROLL]].scaled;
|
||||
if (manual_control.roll < -1.0f) manual_control.roll = -1.0f;
|
||||
|
@ -1090,7 +1092,7 @@ Sensors::task_main()
|
|||
/* advertise the manual_control topic */
|
||||
{
|
||||
struct manual_control_setpoint_s manual_control;
|
||||
manual_control.mode = ROLLPOS_PITCHPOS_YAWRATE_THROTTLE;
|
||||
manual_control.mode = MANUAL_CONTROL_MODE_ATT_YAW_RATE;
|
||||
manual_control.roll = 0.0f;
|
||||
manual_control.pitch = 0.0f;
|
||||
manual_control.yaw = 0.0f;
|
||||
|
|
|
@ -59,7 +59,6 @@ ORB_DEFINE(output_pwm, struct pwm_output_values);
|
|||
#include <drivers/drv_rc_input.h>
|
||||
ORB_DEFINE(input_rc, struct rc_input_values);
|
||||
|
||||
// XXX need to check wether these should be here
|
||||
#include "topics/vehicle_attitude.h"
|
||||
ORB_DEFINE(vehicle_attitude, struct vehicle_attitude_s);
|
||||
|
||||
|
@ -99,6 +98,9 @@ ORB_DEFINE(vehicle_attitude_setpoint, struct vehicle_attitude_setpoint_s);
|
|||
#include "topics/manual_control_setpoint.h"
|
||||
ORB_DEFINE(manual_control_setpoint, struct manual_control_setpoint_s);
|
||||
|
||||
#include "topics/offboard_control_setpoint.h"
|
||||
ORB_DEFINE(offboard_control_setpoint, struct offboard_control_setpoint_s);
|
||||
|
||||
#include "topics/optical_flow.h"
|
||||
ORB_DEFINE(optical_flow, struct optical_flow_s);
|
||||
|
||||
|
|
|
@ -57,28 +57,24 @@
|
|||
*/
|
||||
enum MANUAL_CONTROL_MODE
|
||||
{
|
||||
DIRECT = 0,
|
||||
ROLLPOS_PITCHPOS_YAWRATE_THROTTLE = 1,
|
||||
ROLLRATE_PITCHRATE_YAWRATE_THROTTLE = 2,
|
||||
ROLLPOS_PITCHPOS_YAWPOS_THROTTLE = 3
|
||||
MANUAL_CONTROL_MODE_DIRECT = 0,
|
||||
MANUAL_CONTROL_MODE_ATT_YAW_RATE = 1,
|
||||
MANUAL_CONTROL_MODE_ATT_YAW_POS = 2,
|
||||
MANUAL_CONTROL_MODE_MULTIROTOR_SIMPLE = 3 /**< roll / pitch rotated aligned to the takeoff orientation, throttle stabilized, yaw pos */
|
||||
};
|
||||
|
||||
struct manual_control_setpoint_s {
|
||||
uint64_t timestamp;
|
||||
|
||||
enum MANUAL_CONTROL_MODE mode; /**< The current control inputs mode */
|
||||
float roll; /**< roll / roll rate input */
|
||||
float pitch;
|
||||
float yaw;
|
||||
float throttle;
|
||||
float roll; /**< ailerons roll / roll rate input */
|
||||
float pitch; /**< elevator / pitch / pitch rate */
|
||||
float yaw; /**< rudder / yaw rate / yaw */
|
||||
float throttle; /**< throttle / collective thrust / altitude */
|
||||
|
||||
float override_mode_switch;
|
||||
|
||||
float ailerons;
|
||||
float elevator;
|
||||
float rudder;
|
||||
float flaps;
|
||||
|
||||
float aux1_cam_pan;
|
||||
float aux1_cam_pan_flaps;
|
||||
float aux2_cam_tilt;
|
||||
float aux3_cam_zoom;
|
||||
float aux4_cam_roll;
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2008-2012 PX4 Development Team. All rights reserved.
|
||||
* Author: @author Lorenz Meier <lm@inf.ethz.ch>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file offboard_control_setpoint.h
|
||||
* Definition of the manual_control_setpoint uORB topic.
|
||||
*/
|
||||
|
||||
#ifndef TOPIC_OFFBOARD_CONTROL_SETPOINT_H_
|
||||
#define TOPIC_OFFBOARD_CONTROL_SETPOINT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../uORB.h"
|
||||
|
||||
/**
|
||||
* @addtogroup topics
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Off-board control inputs.
|
||||
*
|
||||
* Typically sent by a ground control station / joystick or by
|
||||
* some off-board controller via C or SIMULINK.
|
||||
*/
|
||||
enum OFFBOARD_CONTROL_MODE
|
||||
{
|
||||
OFFBOARD_CONTROL_MODE_DIRECT = 0,
|
||||
OFFBOARD_CONTROL_MODE_DIRECT_RATES = 1,
|
||||
OFFBOARD_CONTROL_MODE_DIRECT_ATTITUDE = 2,
|
||||
OFFBOARD_CONTROL_MODE_DIRECT_VELOCITY = 3,
|
||||
OFFBOARD_CONTROL_MODE_DIRECT_POSITION = 4,
|
||||
OFFBOARD_CONTROL_MODE_ATT_YAW_RATE = 5,
|
||||
OFFBOARD_CONTROL_MODE_ATT_YAW_POS = 6,
|
||||
OFFBOARD_CONTROL_MODE_MULTIROTOR_SIMPLE = 7, /**< roll / pitch rotated aligned to the takeoff orientation, throttle stabilized, yaw pos */
|
||||
};
|
||||
|
||||
struct offboard_control_setpoint_s {
|
||||
uint64_t timestamp;
|
||||
|
||||
enum OFFBOARD_CONTROL_MODE mode; /**< The current control inputs mode */
|
||||
bool armed; /**< Armed flag set, yes / no */
|
||||
float p1; /**< ailerons roll / roll rate input */
|
||||
float p2; /**< elevator / pitch / pitch rate */
|
||||
float p3; /**< rudder / yaw rate / yaw */
|
||||
float p4; /**< throttle / collective thrust / altitude */
|
||||
|
||||
float override_mode_switch;
|
||||
|
||||
float aux1_cam_pan_flaps;
|
||||
float aux2_cam_tilt;
|
||||
float aux3_cam_zoom;
|
||||
float aux4_cam_roll;
|
||||
|
||||
}; /**< offboard control inputs */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* register this as object request broker structure */
|
||||
ORB_DECLARE(offboard_control_setpoint);
|
||||
|
||||
#endif
|
|
@ -47,7 +47,6 @@
|
|||
* @addtogroup topics
|
||||
* @{
|
||||
*/
|
||||
|
||||
struct vehicle_rates_setpoint_s
|
||||
{
|
||||
uint64_t timestamp; /**< in microseconds since system start */
|
||||
|
|
|
@ -110,6 +110,8 @@ struct vehicle_status_s
|
|||
|
||||
uint16_t counter; /**< incremented by the writing thread everytime new data is stored */
|
||||
uint64_t timestamp; /**< in microseconds since system start, is set whenever the writing thread stores new data */
|
||||
uint64_t failsave_lowlevel_start_time; /**< time when the lowlevel failsafe flag was set */
|
||||
//uint64_t failsave_highlevel_begin; TO BE COMPLETED
|
||||
|
||||
commander_state_machine_t state_machine; /**< current flight state, main state machine */
|
||||
enum VEHICLE_FLIGHT_MODE flight_mode; /**< current flight mode, as defined by mode switch */
|
||||
|
@ -134,10 +136,18 @@ struct vehicle_status_s
|
|||
bool flag_preflight_mag_calibration; /**< true if mag calibration is requested */
|
||||
bool flag_preflight_accel_calibration;
|
||||
|
||||
bool rc_signal_found_once;
|
||||
bool rc_signal_lost; /**< true if RC reception is terminally lost */
|
||||
bool rc_signal_cutting_off; /**< true if RC reception is weak / cutting off */
|
||||
uint64_t rc_signal_lost_interval; /**< interval in microseconds since when no RC signal is available */
|
||||
|
||||
bool offboard_control_signal_found_once;
|
||||
bool offboard_control_signal_lost;
|
||||
uint64_t offboard_control_signal_lost_interval; /**< interval in microseconds without an offboard control message */
|
||||
|
||||
bool failsave_lowlevel; /**< Set to true if low-level failsafe mode is enabled */
|
||||
//bool failsave_highlevel;
|
||||
|
||||
/* see SYS_STATUS mavlink message for the following */
|
||||
uint32_t onboard_control_sensors_present;
|
||||
uint32_t onboard_control_sensors_enabled;
|
||||
|
|
Loading…
Reference in New Issue