mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 01:53:35 +08:00
Merge branch 'master' of https://github.com/PX4/Firmware
Conflicts: apps/commander/commander.c apps/multirotor_att_control/multirotor_att_control_main.c apps/multirotor_att_control/multirotor_rate_control.c
This commit is contained in:
@@ -293,7 +293,7 @@ void do_mag_calibration(int status_pub, struct vehicle_status_s *status)
|
||||
struct sensor_combined_s raw;
|
||||
|
||||
/* 30 seconds */
|
||||
const uint64_t calibration_interval_us = 45 * 1000000;
|
||||
int calibration_interval_ms = 30 * 1000;
|
||||
unsigned int calibration_counter = 0;
|
||||
|
||||
float mag_max[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX};
|
||||
@@ -312,10 +312,10 @@ void do_mag_calibration(int status_pub, struct vehicle_status_s *status)
|
||||
warn("WARNING: failed to set scale / offsets for mag");
|
||||
close(fd);
|
||||
|
||||
mavlink_log_info(mavlink_fd, "[commander] Please rotate around all axes.");
|
||||
mavlink_log_info(mavlink_fd, "[commander] Please rotate around X");
|
||||
|
||||
uint64_t calibration_start = hrt_absolute_time();
|
||||
while ((hrt_absolute_time() - calibration_start) < calibration_interval_us) {
|
||||
while ((hrt_absolute_time() - calibration_start)/1000 < calibration_interval_ms) {
|
||||
|
||||
/* wait blocking for new data */
|
||||
struct pollfd fds[1] = { { .fd = sub_sensor_combined, .events = POLLIN } };
|
||||
@@ -348,11 +348,13 @@ void do_mag_calibration(int status_pub, struct vehicle_status_s *status)
|
||||
calibration_counter++;
|
||||
} else {
|
||||
/* any poll failure for 1s is a reason to abort */
|
||||
mavlink_log_info(mavlink_fd, "[commander] mag calibration aborted, please retry.");
|
||||
mavlink_log_info(mavlink_fd, "[commander] mag cal canceled");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mavlink_log_info(mavlink_fd, "[commander] mag calibration done");
|
||||
|
||||
/* disable calibration mode */
|
||||
status->flag_preflight_mag_calibration = false;
|
||||
state_machine_publish(status_pub, status, mavlink_fd);
|
||||
@@ -1307,19 +1309,12 @@ 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 (sp_man.override_mode_switch > STICK_ON_OFF_LIMIT) {
|
||||
current_status.flag_control_attitude_enabled = false;
|
||||
current_status.flag_control_rates_enabled = true;
|
||||
update_state_machine_mode_manual(stat_pub, ¤t_status, mavlink_fd);
|
||||
|
||||
} else if (sp_man.override_mode_switch < -STICK_ON_OFF_LIMIT) {
|
||||
current_status.flag_control_attitude_enabled = false;
|
||||
current_status.flag_control_rates_enabled = true;
|
||||
update_state_machine_mode_manual(stat_pub, ¤t_status, mavlink_fd);
|
||||
//update_state_machine_mode_auto(stat_pub, ¤t_status, mavlink_fd);
|
||||
update_state_machine_mode_auto(stat_pub, ¤t_status, mavlink_fd);
|
||||
|
||||
} else {
|
||||
current_status.flag_control_attitude_enabled = false;
|
||||
current_status.flag_control_rates_enabled = true;
|
||||
update_state_machine_mode_stabilized(stat_pub, ¤t_status, mavlink_fd);
|
||||
}
|
||||
|
||||
|
||||
@@ -501,9 +501,10 @@ void update_state_machine_mode_manual(int status_pub, struct vehicle_status_s *c
|
||||
{
|
||||
int old_mode = current_status->flight_mode;
|
||||
current_status->flight_mode = VEHICLE_FLIGHT_MODE_MANUAL;
|
||||
current_status->flag_control_manual_enabled = true;
|
||||
current_status->flag_control_manual_enabled = true; //XXX
|
||||
/* enable attitude control per default */
|
||||
current_status->flag_control_attitude_enabled = true;
|
||||
current_status->flag_control_attitude_enabled = false;
|
||||
current_status->flag_control_rates_enabled = true;
|
||||
if (old_mode != current_status->flight_mode) state_machine_publish(status_pub, current_status, mavlink_fd);
|
||||
|
||||
if (current_status->state_machine == SYSTEM_STATE_GROUND_READY || current_status->state_machine == SYSTEM_STATE_STABILIZED || current_status->state_machine == SYSTEM_STATE_AUTO) {
|
||||
@@ -516,7 +517,9 @@ void update_state_machine_mode_stabilized(int status_pub, struct vehicle_status_
|
||||
{
|
||||
int old_mode = current_status->flight_mode;
|
||||
current_status->flight_mode = VEHICLE_FLIGHT_MODE_STABILIZED;
|
||||
current_status->flag_control_manual_enabled = true;
|
||||
current_status->flag_control_manual_enabled = true; //XXX
|
||||
current_status->flag_control_attitude_enabled = false;
|
||||
current_status->flag_control_rates_enabled = true;
|
||||
if (old_mode != current_status->flight_mode) state_machine_publish(status_pub, current_status, mavlink_fd);
|
||||
|
||||
if (current_status->state_machine == SYSTEM_STATE_GROUND_READY || current_status->state_machine == SYSTEM_STATE_MANUAL || current_status->state_machine == SYSTEM_STATE_AUTO) {
|
||||
@@ -529,7 +532,9 @@ void update_state_machine_mode_auto(int status_pub, struct vehicle_status_s *cur
|
||||
{
|
||||
int old_mode = current_status->flight_mode;
|
||||
current_status->flight_mode = VEHICLE_FLIGHT_MODE_AUTO;
|
||||
current_status->flag_control_manual_enabled = true;
|
||||
current_status->flag_control_manual_enabled = true; //XXX
|
||||
current_status->flag_control_attitude_enabled = false;
|
||||
current_status->flag_control_rates_enabled = true;
|
||||
if (old_mode != current_status->flight_mode) state_machine_publish(status_pub, current_status, mavlink_fd);
|
||||
|
||||
if (current_status->state_machine == SYSTEM_STATE_GROUND_READY || current_status->state_machine == SYSTEM_STATE_MANUAL || current_status->state_machine == SYSTEM_STATE_STABILIZED) {
|
||||
|
||||
Reference in New Issue
Block a user