From 1998ce120514b808f4b8b5256302e05001b4e33c Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 Jan 2013 20:37:47 +0100 Subject: [PATCH 1/3] Battery-Warn-State added to struct Vehicle_Status --- apps/commander/commander.c | 3 +++ apps/uORB/topics/vehicle_status.h | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/apps/commander/commander.c b/apps/commander/commander.c index 17087ab8af..986266843a 100644 --- a/apps/commander/commander.c +++ b/apps/commander/commander.c @@ -1200,6 +1200,7 @@ int commander_thread_main(int argc, char *argv[]) /* mark all signals lost as long as they haven't been found */ current_status.rc_signal_lost = true; current_status.offboard_control_signal_lost = true; + current_status.battery_warning = VEHICLE_BATTERY_WARNING_NONE; /* advertise to ORB */ stat_pub = orb_advertise(ORB_ID(vehicle_status), ¤t_status); @@ -1393,6 +1394,7 @@ int commander_thread_main(int argc, char *argv[]) if (low_voltage_counter > LOW_VOLTAGE_BATTERY_COUNTER_LIMIT) { low_battery_voltage_actions_done = true; + current_status.battery_warning = VEHICLE_BATTERY_WARNING_WARNING; mavlink_log_critical(mavlink_fd, "[commander] WARNING! LOW BATTERY!"); } @@ -1403,6 +1405,7 @@ int commander_thread_main(int argc, char *argv[]) else if (battery_voltage_valid && (bat_remain < 0.1f /* XXX MAGIC NUMBER */) && (false == critical_battery_voltage_actions_done && true == low_battery_voltage_actions_done)) { if (critical_voltage_counter > CRITICAL_VOLTAGE_BATTERY_COUNTER_LIMIT) { critical_battery_voltage_actions_done = true; + current_status.battery_warning = VEHICLE_BATTERY_WARNING_ALERT; mavlink_log_critical(mavlink_fd, "[commander] EMERGENCY! CRITICAL BATTERY!"); state_machine_emergency(stat_pub, ¤t_status, mavlink_fd); } diff --git a/apps/uORB/topics/vehicle_status.h b/apps/uORB/topics/vehicle_status.h index 23172d7cf1..75c9ea0fc4 100644 --- a/apps/uORB/topics/vehicle_status.h +++ b/apps/uORB/topics/vehicle_status.h @@ -99,6 +99,13 @@ enum VEHICLE_ATTITUDE_MODE { VEHICLE_ATTITUDE_MODE_ATTITUDE /**< tait-bryan attitude control mode */ }; +enum VEHICLE_BATTERY_WARNING { + VEHICLE_BATTERY_WARNING_NONE = 0, /**< no battery low voltage warning active */ + VEHICLE_BATTERY_WARNING_WARNING, /**< warning of low voltage 1. stage */ + VEHICLE_BATTERY_WARNING_ALERT /**< aleting of low voltage 2. stage */ +}; + + /** * state machine / state of vehicle. * @@ -157,6 +164,7 @@ struct vehicle_status_s float voltage_battery; float current_battery; float battery_remaining; + enum VEHICLE_BATTERY_WARNING battery_warning; /**< current battery warning mode, as defined by VEHICLE_BATTERY_WARNING enum */ uint16_t drop_rate_comm; uint16_t errors_comm; uint16_t errors_count1; From b48f99b601f96321f7200971550ba07177bad5a1 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 8 Jan 2013 22:22:22 +0100 Subject: [PATCH 2/3] Updated state switching to most recent state machine rev --- apps/controllib/fixedwing.cpp | 44 ++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/apps/controllib/fixedwing.cpp b/apps/controllib/fixedwing.cpp index 6956537145..03da35a0a5 100644 --- a/apps/controllib/fixedwing.cpp +++ b/apps/controllib/fixedwing.cpp @@ -293,17 +293,20 @@ void BlockMultiModeBacksideAutopilot::update() for (unsigned i = 4; i < NUM_ACTUATOR_CONTROLS; i++) _actuators.control[i] = 0.0f; - // handle autopilot modes - if (_status.state_machine == SYSTEM_STATE_STABILIZED) { - _stabilization.update( - _ratesCmd.roll, _ratesCmd.pitch, _ratesCmd.yaw, - _att.rollspeed, _att.pitchspeed, _att.yawspeed); - _actuators.control[CH_AIL] = _stabilization.getAileron(); - _actuators.control[CH_ELV] = _stabilization.getElevator(); - _actuators.control[CH_RDR] = _stabilization.getRudder(); - _actuators.control[CH_THR] = _manual.throttle; + // only update guidance in auto mode + if (_status.state_machine == SYSTEM_STATE_AUTO) { + // update guidance + _guide.update(_pos, _att, _posCmd, _lastPosCmd); + } + + // XXX handle STABILIZED (loiter on spot) as well + // once the system switches from manual or auto to stabilized + // the setpoint should update to loitering around this position + + // handle autopilot modes + if (_status.state_machine == SYSTEM_STATE_AUTO || + _status.state_machine == SYSTEM_STATE_STABILIZED) { - } else if (_status.state_machine == SYSTEM_STATE_AUTO) { // update guidance _guide.update(_pos, _att, _posCmd, _lastPosCmd); @@ -325,10 +328,23 @@ void BlockMultiModeBacksideAutopilot::update() _actuators.control[CH_THR] = _backsideAutopilot.getThrottle(); } else if (_status.state_machine == SYSTEM_STATE_MANUAL) { - _actuators.control[CH_AIL] = _manual.roll; - _actuators.control[CH_ELV] = _manual.pitch; - _actuators.control[CH_RDR] = _manual.yaw; - _actuators.control[CH_THR] = _manual.throttle; + + if (_status.manual_control_mode == VEHICLE_MANUAL_CONTROL_MODE_DIRECT) { + + _actuators.control[CH_AIL] = _manual.roll; + _actuators.control[CH_ELV] = _manual.pitch; + _actuators.control[CH_RDR] = _manual.yaw; + _actuators.control[CH_THR] = _manual.throttle; + + } else if (_status.manual_control_mode == VEHICLE_MANUAL_CONTROL_MODE_SAS) { + _stabilization.update( + _ratesCmd.roll, _ratesCmd.pitch, _ratesCmd.yaw, + _att.rollspeed, _att.pitchspeed, _att.yawspeed); + _actuators.control[CH_AIL] = _stabilization.getAileron(); + _actuators.control[CH_ELV] = _stabilization.getElevator(); + _actuators.control[CH_RDR] = _stabilization.getRudder(); + _actuators.control[CH_THR] = _manual.throttle; + } } // update all publications From b5424a4d024e92dc10b82c3db1637f858e2689ad Mon Sep 17 00:00:00 2001 From: px4dev Date: Tue, 8 Jan 2013 14:40:20 -0800 Subject: [PATCH 3/3] Fix the CMSIS DSP_Lib include path specification. This avoids some scary messages from 'make depend'. --- apps/mathlib/CMSIS/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/mathlib/CMSIS/Makefile b/apps/mathlib/CMSIS/Makefile index 0b67944709..fa5de668af 100644 --- a/apps/mathlib/CMSIS/Makefile +++ b/apps/mathlib/CMSIS/Makefile @@ -38,7 +38,7 @@ # # Find sources # -DSPLIB_SRCDIR = $(dir $(lastword $(MAKEFILE_LIST))) +DSPLIB_SRCDIR := $(dir $(lastword $(MAKEFILE_LIST))) CSRCS := $(wildcard $(DSPLIB_SRCDIR)/DSP_Lib/Source/*/*.c) INCLUDES += $(DSPLIB_SRCDIR)/Include \