From 396db730a6e6fdd72fc7a1a3dae1d8591b0d568f Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Thu, 9 Jul 2015 23:58:11 +0200 Subject: [PATCH 001/174] FMUv1: Enable PX4 FLOW driver --- makefiles/config_px4fmu-v1_default.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/makefiles/config_px4fmu-v1_default.mk b/makefiles/config_px4fmu-v1_default.mk index 2e4829958e..26ee983ced 100644 --- a/makefiles/config_px4fmu-v1_default.mk +++ b/makefiles/config_px4fmu-v1_default.mk @@ -37,6 +37,7 @@ MODULES += drivers/ets_airspeed MODULES += drivers/meas_airspeed MODULES += drivers/frsky_telemetry MODULES += modules/sensors +MODULES += drivers/px4flow # # System commands From 4465c029f54e1c412848a54bdfacc6431c6b3680 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 10 Jul 2015 09:50:36 +0200 Subject: [PATCH 002/174] commander: Add new params for home initialization. --- src/modules/commander/commander_params.c | 76 ++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 6 deletions(-) diff --git a/src/modules/commander/commander_params.c b/src/modules/commander/commander_params.c index 6e8e22b5cd..10284ab250 100644 --- a/src/modules/commander/commander_params.c +++ b/src/modules/commander/commander_params.c @@ -1,7 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2013 PX4 Development Team. All rights reserved. - * Author: Lorenz Meier + * Copyright (c) 2013-2015 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -37,16 +36,54 @@ * * Parameters defined by the sensors task. * - * @author Lorenz Meier - * @author Thomas Gubler - * @author Julian Oes + * @author Lorenz Meier + * @author Thomas Gubler + * @author Julian Oes */ #include #include +/** + * Roll trim + * + * The trim value is the actuator control value the system needs + * for straight and level flight. It can be calibrated by + * flying manually straight and level using the RC trims and + * copying them using the GCS. + * + * @group Radio Calibration + * @min -0.25 + * @max 0.25 + */ PARAM_DEFINE_FLOAT(TRIM_ROLL, 0.0f); + +/** + * Pitch trim + * + * The trim value is the actuator control value the system needs + * for straight and level flight. It can be calibrated by + * flying manually straight and level using the RC trims and + * copying them using the GCS. + * + * @group Radio Calibration + * @min -0.25 + * @max 0.25 + */ PARAM_DEFINE_FLOAT(TRIM_PITCH, 0.0f); + +/** + * Yaw trim + * + * The trim value is the actuator control value the system needs + * for straight and level flight. It can be calibrated by + * flying manually straight and level using the RC trims and + * copying them using the GCS. + * + * @group Radio Calibration + * @min -0.25 + * @max 0.25 + */ PARAM_DEFINE_FLOAT(TRIM_YAW, 0.0f); /** @@ -77,6 +114,7 @@ PARAM_DEFINE_FLOAT(BAT_V_CHARGED, 4.2f); * * @group Battery Calibration * @unit V + * @min 0.0f */ PARAM_DEFINE_FLOAT(BAT_V_LOAD_DROP, 0.07f); @@ -87,6 +125,8 @@ PARAM_DEFINE_FLOAT(BAT_V_LOAD_DROP, 0.07f); * * @group Battery Calibration * @unit S + * @min 1 + * @max 10 */ PARAM_DEFINE_INT32(BAT_N_CELLS, 3); @@ -182,7 +222,31 @@ PARAM_DEFINE_FLOAT(COM_EF_TIME, 10.0f); * @min 0 * @max 35 */ -PARAM_DEFINE_FLOAT(COM_RC_LOSS_T, 0.5); +PARAM_DEFINE_FLOAT(COM_RC_LOSS_T, 0.5f); + +/** + * Home set horizontal threshold + * + * The home position will be set if the estimated positioning accuracy is below the threshold. + * + * @group Commander + * @unit meter + * @min 2 + * @max 15 + */ +PARAM_DEFINE_FLOAT(COM_HOME_H_T, 5.0f); + +/** + * Home set vertical threshold + * + * The home position will be set if the estimated positioning accuracy is below the threshold. + * + * @group Commander + * @unit meter + * @min 5 + * @max 25 + */ +PARAM_DEFINE_FLOAT(COM_HOME_V_T, 10.0f); /** * Autosaving of params From fc5b8ee12d28016a50947cdb67e93e340ead37b1 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 10 Jul 2015 09:50:56 +0200 Subject: [PATCH 003/174] Commander: Use new params for home set thresholds --- src/modules/commander/commander.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp index f6fa5e6813..f7ef1ec8e2 100644 --- a/src/modules/commander/commander.cpp +++ b/src/modules/commander/commander.cpp @@ -870,6 +870,8 @@ int commander_thread_main(int argc, char *argv[]) param_t _param_autostart_id = param_find("SYS_AUTOSTART"); param_t _param_autosave_params = param_find("COM_AUTOS_PAR"); param_t _param_rc_in_off = param_find("COM_RC_IN_MODE"); + param_t _param_eph = param_find("COM_HOME_H_T"); + param_t _param_epv = param_find("COM_HOME_V_T"); const char *main_states_str[vehicle_status_s::MAIN_STATE_MAX]; main_states_str[vehicle_status_s::MAIN_STATE_MANUAL] = "MANUAL"; @@ -1293,6 +1295,10 @@ int commander_thread_main(int argc, char *argv[]) /* Parameter autosave setting */ param_get(_param_autosave_params, &autosave_params); + + /* EPH / EPV */ + param_get(_param_eph, &eph_threshold); + param_get(_param_epv, &epv_threshold); } /* Set flag to autosave parameters if necessary */ From 614c397762eddb986242c81f2baabaf412c8a379 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 11 Jul 2015 22:08:36 +0200 Subject: [PATCH 004/174] MPU6K self-test: Be more forgiving on offset values --- src/drivers/mpu6000/mpu6000.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/drivers/mpu6000/mpu6000.cpp b/src/drivers/mpu6000/mpu6000.cpp index 9880544ecb..86fe334345 100644 --- a/src/drivers/mpu6000/mpu6000.cpp +++ b/src/drivers/mpu6000/mpu6000.cpp @@ -913,10 +913,14 @@ MPU6000::gyro_self_test() /* * Maximum deviation of 20 degrees, according to - * http://www.invensense.com/mems/gyro/documents/PS-MPU-6000A-00v3.4.pdf + * http://www.farnell.com/datasheets/1788002.pdf * Section 6.1, initial ZRO tolerance + * + * 20 dps (0.34 rad/s) initial offset + * and 20 dps temperature drift, so 0.34 rad/s * 2 */ - const float max_offset = 0.34f; + const float max_offset = 2.0f * 0.34f; + /* 30% scale error is chosen to catch completely faulty units but * to let some slight scale error pass. Requires a rate table or correlation * with mag rotations + data fit to From 9b6259c64f102287ec301b15a281f5fbcb0e7b10 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 12 Jul 2015 15:51:20 +0200 Subject: [PATCH 005/174] Header generator: Only get active for no output files or when output older than input --- Tools/px_generate_uorb_topic_headers.py | 34 ++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/Tools/px_generate_uorb_topic_headers.py b/Tools/px_generate_uorb_topic_headers.py index 4f821b0608..6be0e19163 100755 --- a/Tools/px_generate_uorb_topic_headers.py +++ b/Tools/px_generate_uorb_topic_headers.py @@ -93,6 +93,29 @@ def convert_dir(inputdir, outputdir, templatedir): """ Converts all .msg files in inputdir to uORB header files """ + + # Find the most recent modification time in input dir + maxinputtime = 0 + for f in os.listdir(inputdir): + fni = os.path.join(inputdir, f) + if os.path.isfile(fni): + it = os.path.getmtime(fni) + if it > maxinputtime: + maxinputtime = it; + + # Find the most recent modification time in output dir + maxouttime = 0 + for f in os.listdir(outputdir): + fni = os.path.join(outputdir, f) + if os.path.isfile(fni): + it = os.path.getmtime(fni) + if it > maxouttime: + maxouttime = it; + + # Do not generate if nothing changed on the input + if (maxinputtime != 0 and maxouttime != 0 and maxinputtime < maxouttime): + return False + includepath = incl_default + [':'.join([package, inputdir])] for f in os.listdir(inputdir): fn = os.path.join(inputdir, f) @@ -103,6 +126,8 @@ def convert_dir(inputdir, outputdir, templatedir): templatedir, includepath) + return True + def copy_changed(inputdir, outputdir, prefix=''): """ @@ -139,10 +164,11 @@ def convert_dir_save(inputdir, outputdir, templatedir, temporarydir, prefix): Unchanged existing files are not overwritten. """ # Create new headers in temporary output directory - convert_dir(inputdir, temporarydir, templatedir) - - # Copy changed headers from temporary dir to output dir - copy_changed(temporarydir, outputdir, prefix) + if (convert_dir(inputdir, temporarydir, templatedir)): + # Copy changed headers from temporary dir to output dir + copy_changed(temporarydir, outputdir, prefix) + else: + print('No changes.') if __name__ == "__main__": parser = argparse.ArgumentParser( From cdc17f1fdd8dfa3c315bd907dab8ca14f3f0cf8e Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 12 Jul 2015 15:51:43 +0200 Subject: [PATCH 006/174] Keep temporary topic files to avoid constant re-generation, but delete them on clean --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index aedf595aef..804e1c3c3c 100644 --- a/Makefile +++ b/Makefile @@ -275,6 +275,7 @@ TOPICS_DIR = $(PX4_BASE)src/modules/uORB/topics MULTIPLATFORM_HEADER_DIR = $(PX4_BASE)src/platforms/nuttx/px4_messages MULTIPLATFORM_PREFIX = px4_ TOPICHEADER_TEMP_DIR = $(BUILD_DIR)topics_temporary +MULTI_TOPICHEADER_TEMP_DIR = $(BUILD_DIR)multi_topics_temporary GENMSG_PYTHONPATH = $(PX4_BASE)Tools/genmsg/src GENCPP_PYTHONPATH = $(PX4_BASE)Tools/gencpp/src @@ -287,9 +288,7 @@ generateuorbtopicheaders: checksubmodules @$(ECHO) "Generating multiplatform uORB topic wrapper headers" $(Q) (PYTHONPATH=$(GENMSG_PYTHONPATH):$(GENCPP_PYTHONPATH):$(PYTHONPATH) $(PYTHON) \ $(PX4_BASE)Tools/px_generate_uorb_topic_headers.py \ - -d $(MSG_DIR) -o $(MULTIPLATFORM_HEADER_DIR) -e $(MULTIPLATFORM_TEMPLATE_DIR) -t $(TOPICHEADER_TEMP_DIR) -p $(MULTIPLATFORM_PREFIX)) -# clean up temporary files - $(Q) (rm -r $(TOPICHEADER_TEMP_DIR)) + -d $(MSG_DIR) -o $(MULTIPLATFORM_HEADER_DIR) -e $(MULTIPLATFORM_TEMPLATE_DIR) -t $(MULTI_TOPICHEADER_TEMP_DIR) -p $(MULTIPLATFORM_PREFIX)) # # Testing targets @@ -320,6 +319,8 @@ clean: $(Q) $(RMDIR) $(BUILD_DIR)*.build $(Q) $(RMDIR) $(PX4_VERSIONING_DIR) $(Q) $(REMOVE) $(IMAGE_DIR)*.px4 + $(Q) $(RMDIR) $(TOPICHEADER_TEMP_DIR) + $(Q) $(RMDIR) $(MULTI_TOPICHEADER_TEMP_DIR) .PHONY: distclean distclean: clean From 17471eab65194bdc83549d195d4f15c4688fbe6e Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 12 Jul 2015 17:13:31 +0200 Subject: [PATCH 007/174] Topic generation: Accept non-existing output directory --- Tools/px_generate_uorb_topic_headers.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Tools/px_generate_uorb_topic_headers.py b/Tools/px_generate_uorb_topic_headers.py index 6be0e19163..f1b2ff9ae0 100755 --- a/Tools/px_generate_uorb_topic_headers.py +++ b/Tools/px_generate_uorb_topic_headers.py @@ -105,12 +105,13 @@ def convert_dir(inputdir, outputdir, templatedir): # Find the most recent modification time in output dir maxouttime = 0 - for f in os.listdir(outputdir): - fni = os.path.join(outputdir, f) - if os.path.isfile(fni): - it = os.path.getmtime(fni) - if it > maxouttime: - maxouttime = it; + if os.path.isdir(outputdir) + for f in os.listdir(outputdir): + fni = os.path.join(outputdir, f) + if os.path.isfile(fni): + it = os.path.getmtime(fni) + if it > maxouttime: + maxouttime = it; # Do not generate if nothing changed on the input if (maxinputtime != 0 and maxouttime != 0 and maxinputtime < maxouttime): From 3c3abc078f1735a10a389fa8ac576a0db4821940 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 12 Jul 2015 17:23:11 +0200 Subject: [PATCH 008/174] Topic generation: Fix compile error --- Tools/px_generate_uorb_topic_headers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/px_generate_uorb_topic_headers.py b/Tools/px_generate_uorb_topic_headers.py index f1b2ff9ae0..92d7dc1ef1 100755 --- a/Tools/px_generate_uorb_topic_headers.py +++ b/Tools/px_generate_uorb_topic_headers.py @@ -105,7 +105,7 @@ def convert_dir(inputdir, outputdir, templatedir): # Find the most recent modification time in output dir maxouttime = 0 - if os.path.isdir(outputdir) + if os.path.isdir(outputdir): for f in os.listdir(outputdir): fni = os.path.join(outputdir, f) if os.path.isfile(fni): From 9efc37a3ad672d88f76f2c82289bbc479251e7d0 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 12 Jul 2015 20:13:05 +0200 Subject: [PATCH 009/174] Fix topic generation logic for different board targets --- Tools/px_generate_uorb_topic_headers.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Tools/px_generate_uorb_topic_headers.py b/Tools/px_generate_uorb_topic_headers.py index 92d7dc1ef1..221aa3ae38 100755 --- a/Tools/px_generate_uorb_topic_headers.py +++ b/Tools/px_generate_uorb_topic_headers.py @@ -149,14 +149,16 @@ def copy_changed(inputdir, outputdir, prefix=''): shutil.copy(fni, fno) print("{0}: new header file".format(f)) continue - # The file exists in inputdir and outputdir - # only copy if contents do not match - if not filecmp.cmp(fni, fno): - shutil.copy(fni, fno) - print("{0}: updated".format(f)) - continue - print("{0}: unchanged".format(f)) + if os.path.getmtime(fni) > os.path.getmtime(fno): + # The file exists in inputdir and outputdir + # only copy if contents do not match + if not filecmp.cmp(fni, fno): + shutil.copy(fni, fno) + print("{0}: updated".format(f)) + continue + + #print("{0}: unchanged".format(f)) def convert_dir_save(inputdir, outputdir, templatedir, temporarydir, prefix): @@ -165,11 +167,9 @@ def convert_dir_save(inputdir, outputdir, templatedir, temporarydir, prefix): Unchanged existing files are not overwritten. """ # Create new headers in temporary output directory - if (convert_dir(inputdir, temporarydir, templatedir)): - # Copy changed headers from temporary dir to output dir - copy_changed(temporarydir, outputdir, prefix) - else: - print('No changes.') + convert_dir(inputdir, temporarydir, templatedir) + # Copy changed headers from temporary dir to output dir + copy_changed(temporarydir, outputdir, prefix) if __name__ == "__main__": parser = argparse.ArgumentParser( From 482641e40313eb1a7e810021c72b0610d3b7882c Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 13 Jul 2015 09:36:14 +0200 Subject: [PATCH 010/174] MAVLink: Crank onboard attitude rate up to 250 Hz --- src/modules/mavlink/mavlink_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index 1f43031be2..91c9ce7db3 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -1455,7 +1455,7 @@ Mavlink::task_main(int argc, char *argv[]) case MAVLINK_MODE_ONBOARD: configure_stream("SYS_STATUS", 1.0f); - configure_stream("ATTITUDE", 50.0f); + configure_stream("ATTITUDE", 250.0f); configure_stream("HIGHRES_IMU", 50.0f); configure_stream("GPS_RAW_INT", 5.0f); configure_stream("GLOBAL_POSITION_INT", 50.0f); From 253b8f50ce4df336df49b24df84430456ef7aa0a Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 17 Jul 2015 20:35:07 +0200 Subject: [PATCH 011/174] Load missions correctly after restart. Fixes #2564 --- src/modules/navigator/mission.cpp | 65 ++++++++++++++++++++++--------- src/modules/navigator/mission.h | 8 +++- 2 files changed, 53 insertions(+), 20 deletions(-) diff --git a/src/modules/navigator/mission.cpp b/src/modules/navigator/mission.cpp index 4944ebe789..bedfc35d32 100644 --- a/src/modules/navigator/mission.cpp +++ b/src/modules/navigator/mission.cpp @@ -70,8 +70,8 @@ Mission::Mission(Navigator *navigator, const char *name) : _param_dist_1wp(this, "MIS_DIST_1WP", false), _param_altmode(this, "MIS_ALTMODE", false), _param_yawmode(this, "MIS_YAWMODE", false), - _onboard_mission({0}), - _offboard_mission({0}), + _onboard_mission{}, + _offboard_mission{}, _current_onboard_mission_index(-1), _current_offboard_mission_index(-1), _need_takeoff(true), @@ -110,32 +110,31 @@ Mission::on_inactive() update_offboard_mission(); } - /* check if the home position became valid in the meantime */ - if ((_mission_type == MISSION_TYPE_NONE || _mission_type == MISSION_TYPE_OFFBOARD) && - !_home_inited && _navigator->home_position_valid()) { + } else { - dm_item_t dm_current = DM_KEY_WAYPOINTS_OFFBOARD(_offboard_mission.dataman_id); + /* load missions from storage */ + mission_s mission_state; - _navigator->get_mission_result()->valid = _missionFeasiblityChecker.checkMissionFeasible(_navigator->get_mavlink_fd(), _navigator->get_vstatus()->is_rotary_wing, - dm_current, (size_t) _offboard_mission.count, _navigator->get_geofence(), - _navigator->get_home_position()->alt, _navigator->home_position_valid(), - _navigator->get_global_position()->lat, _navigator->get_global_position()->lon, - _param_dist_1wp.get(), _navigator->get_mission_result()->warning); + dm_lock(DM_KEY_MISSION_STATE); - _navigator->increment_mission_instance_count(); - _navigator->set_mission_result_updated(); + /* read current state */ + int read_res = dm_read(DM_KEY_MISSION_STATE, 0, &mission_state, sizeof(mission_s)); - _home_inited = true; + dm_unlock(DM_KEY_MISSION_STATE); + + if (read_res == sizeof(mission_s)) { + _offboard_mission.dataman_id = mission_state.dataman_id; + _offboard_mission.count = mission_state.count; + _current_offboard_mission_index = mission_state.current_seq; + + warnx("LOADED MISSION STATE FROM STORAGE"); } - } else { - /* read mission topics on initialization */ _inited = true; - - update_onboard_mission(); - update_offboard_mission(); } + check_mission_valid(); + /* require takeoff after non-loiter or landing */ if (!_navigator->get_can_loiter_at_sp() || _navigator->get_vstatus()->condition_landed) { _need_takeoff = true; @@ -151,6 +150,8 @@ Mission::on_activation() void Mission::on_active() { + check_mission_valid(); + /* check if anything has changed */ bool onboard_updated = false; orb_check(_navigator->get_onboard_mission_sub(), &onboard_updated); @@ -272,6 +273,8 @@ Mission::update_offboard_mission() _offboard_mission.count = 0; _offboard_mission.current_seq = 0; _current_offboard_mission_index = 0; + + warnx("mission check failed"); } set_current_offboard_mission_item(); @@ -652,6 +655,7 @@ Mission::read_mission_item(bool onboard, bool is_current, struct mission_item_s if (*mission_index_ptr < 0 || *mission_index_ptr >= (int)mission->count) { /* mission item index out of bounds */ + warnx("err: index: %d, max: %d", *mission_index_ptr, (int)mission->count); return false; } @@ -795,3 +799,26 @@ Mission::set_mission_finished() _navigator->get_mission_result()->finished = true; _navigator->set_mission_result_updated(); } + +bool +Mission::check_mission_valid() +{ + /* check if the home position became valid in the meantime */ + if (!_home_inited && _navigator->home_position_valid()) { + + dm_item_t dm_current = DM_KEY_WAYPOINTS_OFFBOARD(_offboard_mission.dataman_id); + + _navigator->get_mission_result()->valid = _missionFeasiblityChecker.checkMissionFeasible(_navigator->get_mavlink_fd(), _navigator->get_vstatus()->is_rotary_wing, + dm_current, (size_t) _offboard_mission.count, _navigator->get_geofence(), + _navigator->get_home_position()->alt, _navigator->home_position_valid(), + _navigator->get_global_position()->lat, _navigator->get_global_position()->lon, + _param_dist_1wp.get(), _navigator->get_mission_result()->warning); + + _navigator->increment_mission_instance_count(); + _navigator->set_mission_result_updated(); + + _home_inited = true; + } + + return _navigator->get_mission_result()->valid; +} diff --git a/src/modules/navigator/mission.h b/src/modules/navigator/mission.h index d77f461574..f367da1c7d 100644 --- a/src/modules/navigator/mission.h +++ b/src/modules/navigator/mission.h @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2013-2014 PX4 Development Team. All rights reserved. + * Copyright (c) 2013-2015 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -39,6 +39,7 @@ * @author Thomas Gubler * @author Anton Babushkin * @author Ban Siesta + * @author Lorenz Meier */ #ifndef NAVIGATOR_MISSION_H @@ -165,6 +166,11 @@ private: */ void set_mission_finished(); + /** + * Check wether a mission is ready to go + */ + bool check_mission_valid(); + control::BlockParamInt _param_onboard_enabled; control::BlockParamFloat _param_takeoff_alt; control::BlockParamFloat _param_dist_1wp; From d8a54f5018d3f282e8e083a637258ece64a69bd5 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 17 Jul 2015 20:59:39 +0200 Subject: [PATCH 012/174] Navigator: fix feedback on success / fail --- src/modules/navigator/mission.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/modules/navigator/mission.cpp b/src/modules/navigator/mission.cpp index bedfc35d32..b9e6e69439 100644 --- a/src/modules/navigator/mission.cpp +++ b/src/modules/navigator/mission.cpp @@ -126,8 +126,6 @@ Mission::on_inactive() _offboard_mission.dataman_id = mission_state.dataman_id; _offboard_mission.count = mission_state.count; _current_offboard_mission_index = mission_state.current_seq; - - warnx("LOADED MISSION STATE FROM STORAGE"); } _inited = true; @@ -655,7 +653,7 @@ Mission::read_mission_item(bool onboard, bool is_current, struct mission_item_s if (*mission_index_ptr < 0 || *mission_index_ptr >= (int)mission->count) { /* mission item index out of bounds */ - warnx("err: index: %d, max: %d", *mission_index_ptr, (int)mission->count); + mavlink_log_critical(_navigator->get_mavlink_fd(), "[wpm] err: index: %d, max: %d", *mission_index_ptr, (int)mission->count); return false; } From d9f0baf4dcde62a143d2a9b111a30cac14a1382a Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 17 Jul 2015 21:19:32 +0200 Subject: [PATCH 013/174] GPS driver: Only let the driver publish reports if it really found a GPS receiver --- src/drivers/gps/gps.cpp | 48 ++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/src/drivers/gps/gps.cpp b/src/drivers/gps/gps.cpp index 30fbdfd8d2..79719361a6 100644 --- a/src/drivers/gps/gps.cpp +++ b/src/drivers/gps/gps.cpp @@ -310,7 +310,7 @@ GPS::task_main() _report_gps_pos.cog_rad = 0.0f; _report_gps_pos.vel_ned_valid = true; - //no time and satellite information simulated + /* no time and satellite information simulated */ if (!(_pub_blocked)) { @@ -351,28 +351,46 @@ GPS::task_main() unlock(); + /* the Ashtech driver lies about successful configuration and the + * MTK driver is not well tested, so we really only trust the UBX + * driver for an advance publication + */ if (_Helper->configure(_baudrate) == 0) { unlock(); - //Publish initial report that we have access to a GPS - //Make sure to clear any stale data in case driver is reset + /* reset report */ memset(&_report_gps_pos, 0, sizeof(_report_gps_pos)); - _report_gps_pos.timestamp_position = hrt_absolute_time(); - _report_gps_pos.timestamp_variance = hrt_absolute_time(); - _report_gps_pos.timestamp_velocity = hrt_absolute_time(); - _report_gps_pos.timestamp_time = hrt_absolute_time(); - if (!(_pub_blocked)) { - if (_report_gps_pos_pub > 0) { - orb_publish(ORB_ID(vehicle_gps_position), _report_gps_pos_pub, &_report_gps_pos); + if (_mode == GPS_DRIVER_MODE_UBX) { + /* Publish initial report that we have access to a GPS, + * but set all critical state fields to indicate we have + * no valid position lock + */ - } else { - _report_gps_pos_pub = orb_advertise(ORB_ID(vehicle_gps_position), &_report_gps_pos); + _report_gps_pos.timestamp_time = hrt_absolute_time(); + + /* reset the timestamps for data, because we have no data yet */ + _report_gps_pos.timestamp_position = 0; + _report_gps_pos.timestamp_variance = 0; + _report_gps_pos.timestamp_velocity = 0; + + /* set a massive variance */ + _report_gps_pos.eph = 10000.0f; + _report_gps_pos.epv = 10000.0f; + _report_gps_pos.fix_type = 0; + + if (!(_pub_blocked)) { + if (_report_gps_pos_pub > 0) { + orb_publish(ORB_ID(vehicle_gps_position), _report_gps_pos_pub, &_report_gps_pos); + + } else { + _report_gps_pos_pub = orb_advertise(ORB_ID(vehicle_gps_position), &_report_gps_pos); + } } - } - // GPS is obviously detected successfully, reset statistics - _Helper->reset_update_rates(); + /* GPS is obviously detected successfully, reset statistics */ + _Helper->reset_update_rates(); + } int helper_ret; while ((helper_ret = _Helper->receive(TIMEOUT_5HZ)) > 0 && !_task_should_exit) { From ec21a71b369ff609fa74ccb5b71a4d275e9e5068 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 17 Jul 2015 23:41:00 +0200 Subject: [PATCH 014/174] Commander: increase mag cal timeout --- src/modules/commander/mag_calibration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/commander/mag_calibration.cpp b/src/modules/commander/mag_calibration.cpp index 36cc0cdd5d..7570b8b0f4 100644 --- a/src/modules/commander/mag_calibration.cpp +++ b/src/modules/commander/mag_calibration.cpp @@ -223,7 +223,7 @@ static calibrate_return mag_calibration_worker(detect_orientation_return orienta * for a good result, so we're not constraining the user more than we have to. */ - hrt_abstime detection_deadline = hrt_absolute_time() + worker_data->calibration_interval_perside_useconds; + hrt_abstime detection_deadline = hrt_absolute_time() + worker_data->calibration_interval_perside_useconds * 2; hrt_abstime last_gyro = 0; float gyro_x_integral = 0.0f; float gyro_y_integral = 0.0f; From 116bd9a03e007c938263781b305507f035884f16 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 18 Jul 2015 11:36:42 +0200 Subject: [PATCH 015/174] MC pos control: Code style fixes --- src/modules/mc_pos_control/mc_pos_control_main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/modules/mc_pos_control/mc_pos_control_main.cpp b/src/modules/mc_pos_control/mc_pos_control_main.cpp index 54c7608632..59caa27ef7 100644 --- a/src/modules/mc_pos_control/mc_pos_control_main.cpp +++ b/src/modules/mc_pos_control/mc_pos_control_main.cpp @@ -119,15 +119,15 @@ private: int _control_task; /**< task handle for task */ int _mavlink_fd; /**< mavlink fd */ - int _vehicle_status_sub; /**< vehicle status subscription */ - int _att_sub; /**< vehicle attitude subscription */ + int _vehicle_status_sub; /**< vehicle status subscription */ + int _att_sub; /**< vehicle attitude subscription */ int _att_sp_sub; /**< vehicle attitude setpoint */ int _control_mode_sub; /**< vehicle control mode subscription */ int _params_sub; /**< notification of parameter updates */ int _manual_sub; /**< notification of manual control updates */ int _arming_sub; /**< arming status of outputs */ int _local_pos_sub; /**< vehicle local position */ - int _pos_sp_triplet_sub; /**< position setpoint triplet */ + int _pos_sp_triplet_sub; /**< position setpoint triplet */ int _local_pos_sp_sub; /**< offboard local position setpoint */ int _global_vel_sp_sub; /**< offboard global velocity setpoint */ @@ -135,16 +135,16 @@ private: orb_advert_t _local_pos_sp_pub; /**< vehicle local position setpoint publication */ orb_advert_t _global_vel_sp_pub; /**< vehicle global velocity setpoint publication */ - struct vehicle_status_s _vehicle_status; /**< vehicle status */ + struct vehicle_status_s _vehicle_status; /**< vehicle status */ struct vehicle_attitude_s _att; /**< vehicle attitude */ struct vehicle_attitude_setpoint_s _att_sp; /**< vehicle attitude setpoint */ struct manual_control_setpoint_s _manual; /**< r/c channel data */ - struct vehicle_control_mode_s _control_mode; /**< vehicle control mode */ + struct vehicle_control_mode_s _control_mode; /**< vehicle control mode */ struct actuator_armed_s _arming; /**< actuator arming status */ struct vehicle_local_position_s _local_pos; /**< vehicle local position */ struct position_setpoint_triplet_s _pos_sp_triplet; /**< vehicle global position setpoint triplet */ struct vehicle_local_position_setpoint_s _local_pos_sp; /**< vehicle local position setpoint */ - struct vehicle_global_velocity_setpoint_s _global_vel_sp; /**< vehicle global velocity setpoint */ + struct vehicle_global_velocity_setpoint_s _global_vel_sp; /**< vehicle global velocity setpoint */ struct { @@ -210,7 +210,7 @@ private: /** * Update our local parameter cache. */ - int parameters_update(bool force); + int parameters_update(bool force); /** * Update control outputs From fb8236e6b99eee6f8517798d1fcb6105a7a14ffd Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 19 Jul 2015 16:00:45 +0200 Subject: [PATCH 016/174] sdlog: Default to require GPS for time stamping --- src/modules/sdlog2/sdlog2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/sdlog2/sdlog2.c b/src/modules/sdlog2/sdlog2.c index 76fd47cc15..bedd854af6 100644 --- a/src/modules/sdlog2/sdlog2.c +++ b/src/modules/sdlog2/sdlog2.c @@ -156,7 +156,7 @@ PARAM_DEFINE_INT32(SDLOG_EXT, -1); * @max 1 * @group SD Logging */ -PARAM_DEFINE_INT32(SDLOG_GPSTIME, 0); +PARAM_DEFINE_INT32(SDLOG_GPSTIME, 1); #define LOGBUFFER_WRITE_AND_COUNT(_msg) if (logbuffer_write(&lb, &log_msg, LOG_PACKET_SIZE(_msg))) { \ log_msgs_written++; \ From 06c45aadfbca55d88ff643a1ca526065a1d357e7 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 19 Jul 2015 16:03:08 +0200 Subject: [PATCH 017/174] FW attitude control: Increase default integrator gains to compensate common airframe trim issues --- src/modules/fw_att_control/fw_att_control_params.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/fw_att_control/fw_att_control_params.c b/src/modules/fw_att_control/fw_att_control_params.c index 234ff0c3fb..aa8787b623 100644 --- a/src/modules/fw_att_control/fw_att_control_params.c +++ b/src/modules/fw_att_control/fw_att_control_params.c @@ -84,11 +84,11 @@ PARAM_DEFINE_FLOAT(FW_PR_P, 0.08f); * This gain defines how much control response will result out of a steady * state error. It trims any constant error. * - * @min 0.0 - * @max 50.0 + * @min 0.005 + * @max 0.5 * @group FW Attitude Control */ -PARAM_DEFINE_FLOAT(FW_PR_I, 0.005f); +PARAM_DEFINE_FLOAT(FW_PR_I, 0.01f); /** * Maximum positive / up pitch rate. @@ -157,11 +157,11 @@ PARAM_DEFINE_FLOAT(FW_RR_P, 0.05f); * This gain defines how much control response will result out of a steady * state error. It trims any constant error. * - * @min 0.0 - * @max 100.0 + * @min 0.005 + * @max 0.2 * @group FW Attitude Control */ -PARAM_DEFINE_FLOAT(FW_RR_I, 0.005f); +PARAM_DEFINE_FLOAT(FW_RR_I, 0.01f); /** * Roll Integrator Anti-Windup From 3ccc6823a2e1d9dca4952049878605005f096377 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 19 Jul 2015 16:03:48 +0200 Subject: [PATCH 018/174] ROMFS: Remove integral gains from default configs as they are fine with the default value --- ROMFS/px4fmu_common/init.d/3030_io_camflyer | 2 -- ROMFS/px4fmu_common/init.d/3031_phantom | 2 -- ROMFS/px4fmu_common/init.d/3100_tbs_caipirinha | 2 -- 3 files changed, 6 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/3030_io_camflyer b/ROMFS/px4fmu_common/init.d/3030_io_camflyer index 040b78dc77..9fe5002de9 100644 --- a/ROMFS/px4fmu_common/init.d/3030_io_camflyer +++ b/ROMFS/px4fmu_common/init.d/3030_io_camflyer @@ -17,11 +17,9 @@ then param set FW_LND_TLALT 5 param set FW_THR_LND_MAX 0 param set FW_PR_FF 0.35 - param set FW_PR_I 0.005 param set FW_PR_IMAX 0.4 param set FW_PR_P 0.08 param set FW_RR_FF 0.6 - param set FW_RR_I 0.005 param set FW_RR_IMAX 0.2 param set FW_RR_P 0.04 fi diff --git a/ROMFS/px4fmu_common/init.d/3031_phantom b/ROMFS/px4fmu_common/init.d/3031_phantom index c7dd1dfc5c..43db1ed6de 100644 --- a/ROMFS/px4fmu_common/init.d/3031_phantom +++ b/ROMFS/px4fmu_common/init.d/3031_phantom @@ -16,14 +16,12 @@ then param set FW_L1_DAMPING 0.75 param set FW_L1_PERIOD 15 param set FW_PR_FF 0.2 - param set FW_PR_I 0.005 param set FW_PR_IMAX 0.2 param set FW_PR_P 0.03 param set FW_P_LIM_MAX 50 param set FW_P_LIM_MIN -50 param set FW_P_ROLLFF 1 param set FW_RR_FF 0.5 - param set FW_RR_I 0.02 param set FW_RR_IMAX 0.2 param set FW_RR_P 0.08 param set FW_R_LIM 50 diff --git a/ROMFS/px4fmu_common/init.d/3100_tbs_caipirinha b/ROMFS/px4fmu_common/init.d/3100_tbs_caipirinha index 8a661f25e2..5fce4ed226 100644 --- a/ROMFS/px4fmu_common/init.d/3100_tbs_caipirinha +++ b/ROMFS/px4fmu_common/init.d/3100_tbs_caipirinha @@ -22,11 +22,9 @@ then param set FW_LND_TLALT 5 param set FW_THR_LND_MAX 0 param set FW_PR_FF 0.35 - param set FW_PR_I 0.01 param set FW_PR_IMAX 0.4 param set FW_PR_P 0.08 param set FW_RR_FF 0.6 - param set FW_RR_I 0.01 param set FW_RR_IMAX 0.2 param set FW_RR_P 0.04 param set SYS_COMPANION 157600 From 9f322a395e6abf0624dfd7cd6dc67e1e7fe93b90 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 19 Jul 2015 18:30:52 +0200 Subject: [PATCH 019/174] Make land detector more robust during initial spool-up --- .../land_detector/FixedwingLandDetector.cpp | 15 +++++++- .../land_detector/FixedwingLandDetector.h | 16 +++++--- src/modules/land_detector/LandDetector.cpp | 5 ++- src/modules/land_detector/LandDetector.h | 7 ++-- .../land_detector/MulticopterLandDetector.cpp | 37 +++++++++++++------ .../land_detector/MulticopterLandDetector.h | 14 +++---- 6 files changed, 65 insertions(+), 29 deletions(-) diff --git a/src/modules/land_detector/FixedwingLandDetector.cpp b/src/modules/land_detector/FixedwingLandDetector.cpp index 741bc02ad4..dad71be4ae 100644 --- a/src/modules/land_detector/FixedwingLandDetector.cpp +++ b/src/modules/land_detector/FixedwingLandDetector.cpp @@ -49,7 +49,11 @@ FixedwingLandDetector::FixedwingLandDetector() : LandDetector(), _vehicleLocalPositionSub(-1), _vehicleLocalPosition({}), _airspeedSub(-1), - _airspeed({}), + _vehicleStatusSub(-1), + _armingSub(-1), + _airspeed{}, + _vehicleStatus{}, + _arming{}, _parameterSub(-1), _velocity_xy_filtered(0.0f), _velocity_z_filtered(0.0f), @@ -66,6 +70,8 @@ void FixedwingLandDetector::initialize() // Subscribe to local position and airspeed data _vehicleLocalPositionSub = orb_subscribe(ORB_ID(vehicle_local_position)); _airspeedSub = orb_subscribe(ORB_ID(airspeed)); + _vehicleStatusSub = orb_subscribe(ORB_ID(vehicle_status)); + _armingSub = orb_subscribe(ORB_ID(actuator_armed)); updateParameterCache(true); } @@ -74,6 +80,8 @@ void FixedwingLandDetector::updateSubscriptions() { orb_update(ORB_ID(vehicle_local_position), _vehicleLocalPositionSub, &_vehicleLocalPosition); orb_update(ORB_ID(airspeed), _airspeedSub, &_airspeed); + orb_update(ORB_ID(vehicle_status), _vehicleStatusSub, &_vehicleStatus); + orb_update(ORB_ID(actuator_armed), _armingSub, &_arming); } bool FixedwingLandDetector::update() @@ -81,6 +89,11 @@ bool FixedwingLandDetector::update() // First poll for new data from our subscriptions updateSubscriptions(); + // only trigger flight conditions if we are armed + if (!_arming.armed) { + return true; + } + const uint64_t now = hrt_absolute_time(); bool landDetected = false; diff --git a/src/modules/land_detector/FixedwingLandDetector.h b/src/modules/land_detector/FixedwingLandDetector.h index 0e9c092ee0..325faee794 100644 --- a/src/modules/land_detector/FixedwingLandDetector.h +++ b/src/modules/land_detector/FixedwingLandDetector.h @@ -44,7 +44,9 @@ #include "LandDetector.h" #include #include +#include #include +#include #include class FixedwingLandDetector : public LandDetector @@ -90,11 +92,15 @@ private: } _params; private: - int _vehicleLocalPositionSub; /**< notification of local position */ - struct vehicle_local_position_s _vehicleLocalPosition; /**< the result from local position subscription */ - int _airspeedSub; - struct airspeed_s _airspeed; - int _parameterSub; + int _vehicleLocalPositionSub; /**< notification of local position */ + struct vehicle_local_position_s _vehicleLocalPosition; /**< the result from local position subscription */ + int _airspeedSub; + int _vehicleStatusSub; + int _armingSub; + struct airspeed_s _airspeed; + struct vehicle_status_s _vehicleStatus; + struct actuator_armed_s _arming; + int _parameterSub; float _velocity_xy_filtered; float _velocity_z_filtered; diff --git a/src/modules/land_detector/LandDetector.cpp b/src/modules/land_detector/LandDetector.cpp index 7c830fc072..ba6211de64 100644 --- a/src/modules/land_detector/LandDetector.cpp +++ b/src/modules/land_detector/LandDetector.cpp @@ -46,8 +46,9 @@ LandDetector::LandDetector() : _landDetectedPub(-1), _landDetected({0, false}), - _taskShouldExit(false), - _taskIsRunning(false) + _arming_time(0), + _taskShouldExit(false), + _taskIsRunning(false) { // ctor } diff --git a/src/modules/land_detector/LandDetector.h b/src/modules/land_detector/LandDetector.h index 68f96288cd..20d124fdfa 100644 --- a/src/modules/land_detector/LandDetector.h +++ b/src/modules/land_detector/LandDetector.h @@ -96,10 +96,11 @@ protected: static constexpr uint64_t LAND_DETECTOR_TRIGGER_TIME = 2000000; /**< usec that landing conditions have to hold before triggering a land */ + static constexpr uint64_t LAND_DETECTOR_ARM_PHASE_TIME = 1000000; /**< time interval in which wider acceptance thresholds are used after arming */ -protected: - orb_advert_t _landDetectedPub; /**< publisher for position in local frame */ - struct vehicle_land_detected_s _landDetected; /**< local vehicle position */ + orb_advert_t _landDetectedPub; /**< publisher for position in local frame */ + struct vehicle_land_detected_s _landDetected; /**< local vehicle position */ + uint64_t _arming_time; /**< timestamp of arming time */ private: bool _taskShouldExit; /**< true if it is requested that this task should exit */ diff --git a/src/modules/land_detector/MulticopterLandDetector.cpp b/src/modules/land_detector/MulticopterLandDetector.cpp index 5391f7769a..1d0a6b92dc 100644 --- a/src/modules/land_detector/MulticopterLandDetector.cpp +++ b/src/modules/land_detector/MulticopterLandDetector.cpp @@ -53,12 +53,12 @@ MulticopterLandDetector::MulticopterLandDetector() : LandDetector(), _actuatorsSub(-1), _armingSub(-1), _parameterSub(-1), - _attitudeSub(-1), - _vehicleGlobalPosition({}), - _vehicleStatus({}), - _actuators({}), - _arming({}), - _vehicleAttitude({}), + _attitudeSub(-1), + _vehicleGlobalPosition{}, + _vehicleStatus{}, + _actuators{}, + _arming{}, + _vehicleAttitude{}, _landTimer(0) { _paramHandle.maxRotation = param_find("LNDMC_ROT_MAX"); @@ -97,7 +97,10 @@ bool MulticopterLandDetector::update() // only trigger flight conditions if we are armed if (!_arming.armed) { + _arming_time = 0; return true; + } else if (_arming_time == 0) { + _arming_time = hrt_absolute_time(); } // return status based on armed state if no position lock is available @@ -110,8 +113,18 @@ bool MulticopterLandDetector::update() const uint64_t now = hrt_absolute_time(); - // check if we are moving vertically - bool verticalMovement = fabsf(_vehicleGlobalPosition.vel_d) > _params.maxClimbRate; + float armThresholdFactor = 1.0f; + + // Widen acceptance thresholds for landed state right after arming + // so that motor spool-up and other effects do not trigger false negatives + if (hrt_elapsed_time(&_arming_time) < LAND_DETECTOR_ARM_PHASE_TIME) { + armThresholdFactor = 2.5f; + } + + // check if we are moving vertically - this might see a spike after arming due to + // throttle-up vibration. If accelerating fast the throttle thresholds will still give + // an accurate in-air indication + bool verticalMovement = fabsf(_vehicleGlobalPosition.vel_d) > _params.maxClimbRate * armThresholdFactor; // check if we are moving horizontally bool horizontalMovement = sqrtf(_vehicleGlobalPosition.vel_n * _vehicleGlobalPosition.vel_n @@ -119,9 +132,11 @@ bool MulticopterLandDetector::update() && _vehicleStatus.condition_global_position_valid; // next look if all rotation angles are not moving - bool rotating = fabsf(_vehicleAttitude.rollspeed) > _params.maxRotation || - fabsf(_vehicleAttitude.pitchspeed) > _params.maxRotation || - fabsf(_vehicleAttitude.yawspeed) > _params.maxRotation; + float maxRotationScaled = _params.maxRotation * armThresholdFactor; + + bool rotating = (fabsf(_vehicleAttitude.rollspeed) > maxRotationScaled) || + (fabsf(_vehicleAttitude.pitchspeed) > maxRotationScaled) || + (fabsf(_vehicleAttitude.yawspeed) > maxRotationScaled); // check if thrust output is minimal (about half of default) bool minimalThrust = _actuators.control[3] <= _params.maxThrottle; diff --git a/src/modules/land_detector/MulticopterLandDetector.h b/src/modules/land_detector/MulticopterLandDetector.h index 8c57416b56..d001be4e7f 100644 --- a/src/modules/land_detector/MulticopterLandDetector.h +++ b/src/modules/land_detector/MulticopterLandDetector.h @@ -97,20 +97,20 @@ private: } _params; private: - int _vehicleGlobalPositionSub; /**< notification of global position */ + int _vehicleGlobalPositionSub; /**< notification of global position */ int _vehicleStatusSub; int _actuatorsSub; int _armingSub; int _parameterSub; int _attitudeSub; - struct vehicle_global_position_s _vehicleGlobalPosition; /**< the result from global position subscription */ - struct vehicle_status_s _vehicleStatus; - struct actuator_controls_s _actuators; - struct actuator_armed_s _arming; - struct vehicle_attitude_s _vehicleAttitude; + struct vehicle_global_position_s _vehicleGlobalPosition; /**< the result from global position subscription */ + struct vehicle_status_s _vehicleStatus; + struct actuator_controls_s _actuators; + struct actuator_armed_s _arming; + struct vehicle_attitude_s _vehicleAttitude; - uint64_t _landTimer; /**< timestamp in microseconds since a possible land was detected*/ + uint64_t _landTimer; /**< timestamp in microseconds since a possible land was detected*/ }; #endif //__MULTICOPTER_LAND_DETECTOR_H__ From 0321f416a0f31e75234b32d86094b6898d77439c Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 19 Jul 2015 18:33:14 +0200 Subject: [PATCH 020/174] Increase allowance for vertical velocity in landed mode --- src/modules/land_detector/land_detector_params.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/land_detector/land_detector_params.c b/src/modules/land_detector/land_detector_params.c index 77bac2ad74..57e616169b 100644 --- a/src/modules/land_detector/land_detector_params.c +++ b/src/modules/land_detector/land_detector_params.c @@ -49,7 +49,7 @@ * * @group Land Detector */ -PARAM_DEFINE_FLOAT(LNDMC_Z_VEL_MAX, 0.60f); +PARAM_DEFINE_FLOAT(LNDMC_Z_VEL_MAX, 0.70f); /** * Multicopter max horizontal velocity From d0d46c97138edbc2583866a0da9e12df2ca1cd0b Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 20 Jul 2015 10:16:05 +0200 Subject: [PATCH 021/174] MAVLink app: Use better default rates --- src/modules/mavlink/mavlink_main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index 91c9ce7db3..3a2acd07c3 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -1440,15 +1440,15 @@ Mavlink::task_main(int argc, char *argv[]) case MAVLINK_MODE_NORMAL: configure_stream("SYS_STATUS", 1.0f); configure_stream("GPS_GLOBAL_ORIGIN", 0.5f); - configure_stream("HIGHRES_IMU", 1.0f); - configure_stream("ATTITUDE", 10.0f); + configure_stream("HIGHRES_IMU", 2.0f); + configure_stream("ATTITUDE", 20.0f); configure_stream("VFR_HUD", 8.0f); configure_stream("GPS_RAW_INT", 1.0f); configure_stream("GLOBAL_POSITION_INT", 3.0f); configure_stream("LOCAL_POSITION_NED", 3.0f); - configure_stream("RC_CHANNELS_RAW", 1.0f); + configure_stream("RC_CHANNELS_RAW", 4.0f); configure_stream("POSITION_TARGET_GLOBAL_INT", 3.0f); - configure_stream("ATTITUDE_TARGET", 3.0f); + configure_stream("ATTITUDE_TARGET", 8.0f); configure_stream("DISTANCE_SENSOR", 0.5f); configure_stream("OPTICAL_FLOW_RAD", 5.0f); break; From 006dfbb14f658b23c0a760229bac05e861db48dd Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 20 Jul 2015 10:43:12 +0200 Subject: [PATCH 022/174] Commander: Speed up airspeed calibration --- src/modules/commander/airspeed_calibration.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/commander/airspeed_calibration.cpp b/src/modules/commander/airspeed_calibration.cpp index 837a3f1e83..32077d5f3b 100644 --- a/src/modules/commander/airspeed_calibration.cpp +++ b/src/modules/commander/airspeed_calibration.cpp @@ -72,12 +72,12 @@ int do_airspeed_calibration(int mavlink_fd) { int result = OK; unsigned calibration_counter = 0; - const unsigned maxcount = 3000; + const unsigned maxcount = 2400; /* give directions */ mavlink_log_info(mavlink_fd, CAL_QGC_STARTED_MSG, sensor_name); - const unsigned calibration_count = 2000; + const unsigned calibration_count = (maxcount * 2) / 3; int diff_pres_sub = orb_subscribe(ORB_ID(differential_pressure)); struct differential_pressure_s diff_pres; @@ -201,10 +201,10 @@ int do_airspeed_calibration(int mavlink_fd) /* just take a few samples and make sure pitot tubes are not reversed, timeout after ~30 seconds */ while (calibration_counter < maxcount) { - if (calibrate_cancel_check(mavlink_fd, cancel_sub)) { - goto error_return; - } - + if (calibrate_cancel_check(mavlink_fd, cancel_sub)) { + goto error_return; + } + /* wait blocking for new data */ struct pollfd fds[1]; fds[0].fd = diff_pres_sub; From 6d096401b57b3c0a1c6ae9898c792140d84785f5 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 20 Jul 2015 10:44:09 +0200 Subject: [PATCH 023/174] Commander: Turn calibration warnings into critical (voice) output --- src/modules/commander/calibration_routines.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/commander/calibration_routines.cpp b/src/modules/commander/calibration_routines.cpp index 045dbb032d..44ab9054d2 100644 --- a/src/modules/commander/calibration_routines.cpp +++ b/src/modules/commander/calibration_routines.cpp @@ -469,8 +469,8 @@ calibrate_return calibrate_from_orientation(int mavlink_fd, /* inform user about already handled side */ if (side_data_collected[orient]) { orientation_failures++; - mavlink_and_console_log_info(mavlink_fd, "[cal] %s side completed or not needed", detect_orientation_str(orient)); - mavlink_and_console_log_info(mavlink_fd, "[cal] rotate to a pending side"); + mavlink_and_console_log_critical(mavlink_fd, "%s side already completed", detect_orientation_str(orient)); + mavlink_and_console_log_critical(mavlink_fd, "rotate to a pending side"); continue; } From 0d90cf19dd80586934b4710b80ed28b166fe04e6 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 20 Jul 2015 10:45:15 +0200 Subject: [PATCH 024/174] Mag calibration: Reduce time required to complete calibration significantly --- src/modules/commander/mag_calibration.cpp | 30 +++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/modules/commander/mag_calibration.cpp b/src/modules/commander/mag_calibration.cpp index 7570b8b0f4..8f8891bc0c 100644 --- a/src/modules/commander/mag_calibration.cpp +++ b/src/modules/commander/mag_calibration.cpp @@ -64,9 +64,11 @@ static const int ERROR = -1; static const char *sensor_name = "mag"; -static const unsigned max_mags = 3; +static constexpr unsigned max_mags = 3; static constexpr float mag_sphere_radius = 0.2f; -static const unsigned int calibration_sides = 6; +static constexpr unsigned int calibration_sides = 6; ///< The total number of sides +static constexpr unsigned int calibration_total_points = 240; ///< The total points per magnetometer +static constexpr unsigned int calibraton_duration_seconds = 42; ///< The total duration the routine is allowed to take calibrate_return mag_calibrate_all(int mavlink_fd, int32_t (&device_ids)[max_mags]); @@ -204,6 +206,10 @@ static bool reject_sample(float sx, float sy, float sz, float x[], float y[], fl return false; } +static unsigned progress_percentage(mag_worker_data_t* worker_data) { + return 100 * ((float)worker_data->done_count) / calibration_sides; +} + static calibrate_return mag_calibration_worker(detect_orientation_return orientation, int cancel_sub, void* data) { calibrate_return result = calibrate_return_ok; @@ -223,7 +229,7 @@ static calibrate_return mag_calibration_worker(detect_orientation_return orienta * for a good result, so we're not constraining the user more than we have to. */ - hrt_abstime detection_deadline = hrt_absolute_time() + worker_data->calibration_interval_perside_useconds * 2; + hrt_abstime detection_deadline = hrt_absolute_time() + worker_data->calibration_interval_perside_useconds * 5; hrt_abstime last_gyro = 0; float gyro_x_integral = 0.0f; float gyro_y_integral = 0.0f; @@ -344,8 +350,8 @@ static calibrate_return mag_calibration_worker(detect_orientation_return orienta // Progress indicator for side mavlink_and_console_log_info(worker_data->mavlink_fd, "[cal] %s side calibration: progress <%u>", - detect_orientation_str(orientation), - (unsigned)(100 * ((float)calibration_counter_side / (float)worker_data->calibration_points_perside))); + detect_orientation_str(orientation), progress_percentage(worker_data) + + (unsigned)((100 / calibration_sides) * ((float)calibration_counter_side / (float)worker_data->calibration_points_perside))); } } else { poll_errcount++; @@ -362,7 +368,7 @@ static calibrate_return mag_calibration_worker(detect_orientation_return orienta mavlink_and_console_log_info(worker_data->mavlink_fd, "[cal] %s side done, rotate to a different side", detect_orientation_str(orientation)); worker_data->done_count++; - mavlink_and_console_log_info(worker_data->mavlink_fd, CAL_QGC_PROGRESS_MSG, 34 * worker_data->done_count); + mavlink_and_console_log_info(worker_data->mavlink_fd, CAL_QGC_PROGRESS_MSG, progress_percentage(worker_data)); } return result; @@ -376,8 +382,8 @@ calibrate_return mag_calibrate_all(int mavlink_fd, int32_t (&device_ids)[max_mag worker_data.mavlink_fd = mavlink_fd; worker_data.done_count = 0; - worker_data.calibration_points_perside = 40; - worker_data.calibration_interval_perside_seconds = 20; + worker_data.calibration_points_perside = calibration_total_points / calibration_sides; + worker_data.calibration_interval_perside_seconds = calibraton_duration_seconds / calibration_sides; worker_data.calibration_interval_perside_useconds = worker_data.calibration_interval_perside_seconds * 1000 * 1000; // Collect: Right-side up, Left Side, Nose down @@ -496,6 +502,10 @@ calibrate_return mag_calibrate_all(int mavlink_fd, int32_t (&device_ids)[max_mag printf("RAW DATA:\n--------------------\n"); for (size_t cur_mag = 0; cur_mag < max_mags; cur_mag++) { + if (worker_data.calibration_counter_total[cur_mag] == 0) { + continue; + } + printf("RAW: MAG %u with %u samples:\n", cur_mag, worker_data.calibration_counter_total[cur_mag]); for (size_t i = 0; i < worker_data.calibration_counter_total[cur_mag]; i++) { @@ -511,6 +521,10 @@ calibrate_return mag_calibrate_all(int mavlink_fd, int32_t (&device_ids)[max_mag printf("CALIBRATED DATA:\n--------------------\n"); for (size_t cur_mag = 0; cur_mag < max_mags; cur_mag++) { + if (worker_data.calibration_counter_total[cur_mag] == 0) { + continue; + } + printf("Calibrated: MAG %u with %u samples:\n", cur_mag, worker_data.calibration_counter_total[cur_mag]); for (size_t i = 0; i < worker_data.calibration_counter_total[cur_mag]; i++) { From fbb68443d946fc385e514b8cbd93896b45b4b4c0 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 20 Jul 2015 10:50:23 +0200 Subject: [PATCH 025/174] F330 config: Allow the use of PWM_ params --- ROMFS/px4fmu_common/init.d/4010_dji_f330 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/4010_dji_f330 b/ROMFS/px4fmu_common/init.d/4010_dji_f330 index 512ad132be..f297e270a0 100644 --- a/ROMFS/px4fmu_common/init.d/4010_dji_f330 +++ b/ROMFS/px4fmu_common/init.d/4010_dji_f330 @@ -21,7 +21,11 @@ then param set MC_YAWRATE_P 0.2 param set MC_YAWRATE_I 0.1 param set MC_YAWRATE_D 0.0 + param set PWM_DISARMED 900 + param set PWM_MIN 1230 + param set PWM_MAX 1950 fi -set PWM_MIN 1200 -set PWM_MAX 1950 +set PWM_DISARMED p:PWM_DISARMED +set PWM_MIN p:PWM_MIN +set PWM_MAX p:PWM_MAX From 08032179fe694221b98b4b50c5efc4b3a6f4ca2b Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 20 Jul 2015 10:50:46 +0200 Subject: [PATCH 026/174] F450 config: Allow the use of PWM_ params --- ROMFS/px4fmu_common/init.d/4011_dji_f450 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/4011_dji_f450 b/ROMFS/px4fmu_common/init.d/4011_dji_f450 index 2a77f13866..3682381a19 100644 --- a/ROMFS/px4fmu_common/init.d/4011_dji_f450 +++ b/ROMFS/px4fmu_common/init.d/4011_dji_f450 @@ -22,7 +22,11 @@ then param set MC_YAWRATE_P 0.3 param set MC_YAWRATE_I 0.1 param set MC_YAWRATE_D 0.0 + param set PWM_DISARMED 900 + param set PWM_MIN 1230 + param set PWM_MAX 1950 fi -set PWM_MIN 1230 -set PWM_MAX 1950 +set PWM_DISARMED p:PWM_DISARMED +set PWM_MIN p:PWM_MIN +set PWM_MAX p:PWM_MAX From dd48b950efdc3a701ea71df48c1d05e296a62e2e Mon Sep 17 00:00:00 2001 From: Mark Whitehorn Date: Mon, 20 Jul 2015 07:55:46 -0600 Subject: [PATCH 027/174] fix units metadata for SENS_BOARD_?_OFF parameters --- src/modules/sensors/sensor_params.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/sensors/sensor_params.c b/src/modules/sensors/sensor_params.c index 8940f0b271..08c38de525 100644 --- a/src/modules/sensors/sensor_params.c +++ b/src/modules/sensors/sensor_params.c @@ -680,7 +680,7 @@ PARAM_DEFINE_INT32(SENS_FLOW_ROT, 0); * This parameter defines a rotational offset in degrees around the Y (Pitch) axis. It allows the user * to fine tune the board offset in the event of misalignment. * - * @unit radians + * @unit degrees * @group Sensor Calibration */ PARAM_DEFINE_FLOAT(SENS_BOARD_Y_OFF, 0.0f); @@ -691,7 +691,7 @@ PARAM_DEFINE_FLOAT(SENS_BOARD_Y_OFF, 0.0f); * This parameter defines a rotational offset in degrees around the X (Roll) axis It allows the user * to fine tune the board offset in the event of misalignment. * - * @unit radians + * @unit degrees * @group Sensor Calibration */ PARAM_DEFINE_FLOAT(SENS_BOARD_X_OFF, 0.0f); @@ -702,7 +702,7 @@ PARAM_DEFINE_FLOAT(SENS_BOARD_X_OFF, 0.0f); * This parameter defines a rotational offset in degrees around the Z (Yaw) axis. It allows the user * to fine tune the board offset in the event of misalignment. * - * @unit radians + * @unit degrees * @group Sensor Calibration */ PARAM_DEFINE_FLOAT(SENS_BOARD_Z_OFF, 0.0f); From 1834cf1cb9fbcd88366434ffcbc6d48d2d552251 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 22 Jul 2015 09:39:12 +0200 Subject: [PATCH 028/174] VTOL: Use the right attitude estimator --- ROMFS/px4fmu_common/init.d/rc.vtol_apps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ROMFS/px4fmu_common/init.d/rc.vtol_apps b/ROMFS/px4fmu_common/init.d/rc.vtol_apps index 23ade6d78b..265364fac8 100644 --- a/ROMFS/px4fmu_common/init.d/rc.vtol_apps +++ b/ROMFS/px4fmu_common/init.d/rc.vtol_apps @@ -4,7 +4,7 @@ # att & pos estimator, att & pos control. # -attitude_estimator_ekf start +attitude_estimator_q start #ekf_att_pos_estimator start position_estimator_inav start From a1fd088e8f29d6803404ab6b1e12c525cdb95c79 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 22 Jul 2015 10:03:45 +0200 Subject: [PATCH 029/174] MAVLink app: Rely on booted state, not on timeout for parameters. This fixes any param timing issues for good. --- src/modules/mavlink/mavlink_main.cpp | 6 ++++++ src/modules/mavlink/mavlink_main.h | 11 +++++++++++ src/modules/mavlink/mavlink_parameters.cpp | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index 3a2acd07c3..a23b3f8736 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -115,6 +115,8 @@ extern mavlink_system_t mavlink_system; static void usage(void); +bool Mavlink::_boot_complete = false; + Mavlink::Mavlink() : _device_name(DEFAULT_DEVICE_NAME), _task_should_exit(false), @@ -1909,6 +1911,10 @@ int mavlink_main(int argc, char *argv[]) } else if (!strcmp(argv[1], "stream")) { return Mavlink::stream_command(argc, argv); + } else if (!strcmp(argv[1], "boot_complete")) { + Mavlink::set_boot_complete(); + return 0; + } else { usage(); exit(1); diff --git a/src/modules/mavlink/mavlink_main.h b/src/modules/mavlink/mavlink_main.h index 777836f688..5ecf8e6956 100644 --- a/src/modules/mavlink/mavlink_main.h +++ b/src/modules/mavlink/mavlink_main.h @@ -145,6 +145,14 @@ public: bool get_forwarding_on() { return _forwarding_on; } + /** + * Set the boot complete flag on all instances + * + * Setting the flag unblocks parameter transmissions, which are gated + * beforehand to ensure that the system is fully initialized. + */ + static void set_boot_complete() { _boot_complete = true; } + /** * Get the free space in the transmit buffer * @@ -294,6 +302,8 @@ public: unsigned get_system_type() { return _system_type; } + static bool boot_complete() { return _boot_complete; } + protected: Mavlink *next; @@ -302,6 +312,7 @@ private: int _mavlink_fd; bool _task_running; + static bool _boot_complete; /* states */ bool _hil_enabled; /**< Hardware In the Loop mode */ diff --git a/src/modules/mavlink/mavlink_parameters.cpp b/src/modules/mavlink/mavlink_parameters.cpp index 73d7580d21..66c6a87176 100644 --- a/src/modules/mavlink/mavlink_parameters.cpp +++ b/src/modules/mavlink/mavlink_parameters.cpp @@ -193,7 +193,7 @@ void MavlinkParametersManager::send(const hrt_abstime t) { /* send all parameters if requested, but only after the system has booted */ - if (_send_all_index >= 0 && t > 4 * 1000 * 1000) { + if (_send_all_index >= 0 && _mavlink->boot_complete()) { /* skip if no space is available */ if (_mavlink->get_free_tx_buf() < get_size()) { From e7833fe06f43025097437a3afb94604c2be19832 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 22 Jul 2015 10:04:13 +0200 Subject: [PATCH 030/174] Tell MAVLink app once we are fully booted and ready to communicate. --- ROMFS/px4fmu_common/init.d/rcS | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index 0a4887a639..81b301fe18 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -697,7 +697,7 @@ then fi unset EXIT_ON_END - # Run no SD alarm last + # Run no SD alarm if [ $LOG_FILE == /dev/null ] then echo "[i] No microSD card found" @@ -705,6 +705,9 @@ then tone_alarm error fi + # Boot is complete, inform MAVLink app(s) that the system is now fully up and running + mavlink boot_complete + # End of autostart fi From cc2f1d16fb671ed841b30a49fe28322dd3ef1870 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 22 Jul 2015 12:17:27 +0200 Subject: [PATCH 031/174] Caipi: Add default PWM min/max/disarmed params --- ROMFS/px4fmu_common/init.d/3100_tbs_caipirinha | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ROMFS/px4fmu_common/init.d/3100_tbs_caipirinha b/ROMFS/px4fmu_common/init.d/3100_tbs_caipirinha index 5fce4ed226..4f3c593cab 100644 --- a/ROMFS/px4fmu_common/init.d/3100_tbs_caipirinha +++ b/ROMFS/px4fmu_common/init.d/3100_tbs_caipirinha @@ -30,6 +30,9 @@ then param set SYS_COMPANION 157600 param set PWM_MAIN_REV0 1 param set PWM_MAIN_REV1 1 + param set PWM_DISARMED 0 + param set PWM_MIN 900 + param set PWM_MAX 2100 fi set PWM_DISARMED p:PWM_DISARMED From ffc9668d5b24a9db9784ac192262624b98d6cebf Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 22 Jul 2015 12:24:37 +0200 Subject: [PATCH 032/174] PWM params: Doc fixes --- src/modules/sensors/sensor_params.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/sensors/sensor_params.c b/src/modules/sensors/sensor_params.c index 08c38de525..2a9852ab57 100644 --- a/src/modules/sensors/sensor_params.c +++ b/src/modules/sensors/sensor_params.c @@ -2273,7 +2273,7 @@ PARAM_DEFINE_INT32(SENS_EN_LL40LS, 0); * REBOOT IN ORDER TO APPLY THE CHANGES. COMPLETELY POWER-CYCLE * THE SYSTEM TO PUT CHANGES INTO EFFECT. * - * Set to 1000 for default or 900 to increase servo travel + * Set to 1000 for industry default or 900 to increase servo travel. * * @min 800 * @max 1400 @@ -2289,7 +2289,7 @@ PARAM_DEFINE_INT32(PWM_MIN, 1000); * REBOOT IN ORDER TO APPLY THE CHANGES. COMPLETELY POWER-CYCLE * THE SYSTEM TO PUT CHANGES INTO EFFECT. * - * Set to 2000 for default or 2100 to increase servo travel + * Set to 2000 for industry default or 2100 to increase servo travel. * * @min 1600 * @max 2200 From 0a44efa3c546ffa970037781199dcae76a0b94d3 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 22 Jul 2015 12:24:56 +0200 Subject: [PATCH 033/174] ROMFS: Doc fixes --- ROMFS/px4fmu_common/init.d/rc.mc_defaults | 1 + 1 file changed, 1 insertion(+) diff --git a/ROMFS/px4fmu_common/init.d/rc.mc_defaults b/ROMFS/px4fmu_common/init.d/rc.mc_defaults index 6506ed8c3e..3482078165 100644 --- a/ROMFS/px4fmu_common/init.d/rc.mc_defaults +++ b/ROMFS/px4fmu_common/init.d/rc.mc_defaults @@ -16,6 +16,7 @@ then param set RTL_DESCEND_ALT 10.0 fi +# set environment variables (!= parameters) set PWM_RATE 400 set PWM_DISARMED 900 set PWM_MIN 1075 From 19ba7be43d2f249b22a9dc3f64a07398efac7522 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 22 Jul 2015 12:25:24 +0200 Subject: [PATCH 034/174] F330 config: Force params to sane values if set to default --- ROMFS/px4fmu_common/init.d/4010_dji_f330 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ROMFS/px4fmu_common/init.d/4010_dji_f330 b/ROMFS/px4fmu_common/init.d/4010_dji_f330 index f297e270a0..50b8320613 100644 --- a/ROMFS/px4fmu_common/init.d/4010_dji_f330 +++ b/ROMFS/px4fmu_common/init.d/4010_dji_f330 @@ -26,6 +26,20 @@ then param set PWM_MAX 1950 fi +# Transitional support: ensure suitable PWM min/max param values +if param compare PWM_MIN 1000 +then + param set PWM_MIN 1230 +fi +if param compare PWM_MAX 2000 +then + param set PWM_MAX 1950 +fi +if param compare PWM_DISARMED 0 +then + param set PWM_DISARMED 900 +fi + set PWM_DISARMED p:PWM_DISARMED set PWM_MIN p:PWM_MIN set PWM_MAX p:PWM_MAX From fb85723e6b37395c710c420f0f0484f5c4f450b0 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 22 Jul 2015 12:28:13 +0200 Subject: [PATCH 035/174] F450 config: Force params to sane values if set to default --- ROMFS/px4fmu_common/init.d/4011_dji_f450 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ROMFS/px4fmu_common/init.d/4011_dji_f450 b/ROMFS/px4fmu_common/init.d/4011_dji_f450 index 3682381a19..1075a5376f 100644 --- a/ROMFS/px4fmu_common/init.d/4011_dji_f450 +++ b/ROMFS/px4fmu_common/init.d/4011_dji_f450 @@ -27,6 +27,20 @@ then param set PWM_MAX 1950 fi +# Transitional support: ensure suitable PWM min/max param values +if param compare PWM_MIN 1000 +then + param set PWM_MIN 1230 +fi +if param compare PWM_MAX 2000 +then + param set PWM_MAX 1950 +fi +if param compare PWM_DISARMED 0 +then + param set PWM_DISARMED 900 +fi + set PWM_DISARMED p:PWM_DISARMED set PWM_MIN p:PWM_MIN set PWM_MAX p:PWM_MAX From 033c512fbf45cacc59262a6cb1cad9c437270122 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 18 Jul 2015 11:53:58 +0200 Subject: [PATCH 036/174] Add separate params for manual throttle control --- .../mc_pos_control/mc_pos_control_params.c | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/modules/mc_pos_control/mc_pos_control_params.c b/src/modules/mc_pos_control/mc_pos_control_params.c index a3793b0cc0..d29d11c65d 100644 --- a/src/modules/mc_pos_control/mc_pos_control_params.c +++ b/src/modules/mc_pos_control/mc_pos_control_params.c @@ -41,7 +41,32 @@ #include /** - * Minimum thrust + * Minimum thrust in auto thrust control + * + * It's recommended to set it > 0 to avoid free fall with zero thrust. + * + * @min 0.05 + * @max 1.0 + * @group Multicopter Position Control + */ +PARAM_DEFINE_FLOAT(MPC_THR_MIN, 0.12f); + +/** + * Maximum thrust in auto thrust control + * + * Limit max allowed thrust. Setting a value of one can put + * the system into actuator saturation as no spread between + * the motors is possible any more. A value of 0.8 - 0.9 + * is recommended. + * + * @min 0.0 + * @max 0.95 + * @group Multicopter Position Control + */ +PARAM_DEFINE_FLOAT(MPC_THR_MAX, 0.9f); + +/** + * Minimum manual thrust * * Minimum vertical thrust. It's recommended to set it > 0 to avoid free fall with zero thrust. * @@ -49,10 +74,10 @@ * @max 1.0 * @group Multicopter Position Control */ -PARAM_DEFINE_FLOAT(MPC_THR_MIN, 0.12f); +PARAM_DEFINE_FLOAT(MPC_MANTHR_MIN, 0.12f); /** - * Maximum thrust + * Maximum manual thrust * * Limit max allowed thrust. Setting a value of one can put * the system into actuator saturation as no spread between @@ -63,7 +88,7 @@ PARAM_DEFINE_FLOAT(MPC_THR_MIN, 0.12f); * @max 1.0 * @group Multicopter Position Control */ -PARAM_DEFINE_FLOAT(MPC_THR_MAX, 0.9f); +PARAM_DEFINE_FLOAT(MPC_MANTHR_MAX, 0.9f); /** * Proportional gain for vertical position error From d94f2aa407741a86256e1971197e5efb3ec93ddc Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 18 Jul 2015 11:54:35 +0200 Subject: [PATCH 037/174] MC pos control: Use separate params for manual control --- .../mc_pos_control/mc_pos_control_main.cpp | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/modules/mc_pos_control/mc_pos_control_main.cpp b/src/modules/mc_pos_control/mc_pos_control_main.cpp index 59caa27ef7..ae41685178 100644 --- a/src/modules/mc_pos_control/mc_pos_control_main.cpp +++ b/src/modules/mc_pos_control/mc_pos_control_main.cpp @@ -80,6 +80,9 @@ #include #include +#include +#include + #define TILT_COS_MAX 0.7f #define SIGMA 0.000001f #define MIN_DIST 0.01f @@ -92,7 +95,7 @@ */ extern "C" __EXPORT int mc_pos_control_main(int argc, char *argv[]); -class MulticopterPositionControl +class MulticopterPositionControl : public control::SuperBlock { public: /** @@ -146,6 +149,8 @@ private: struct vehicle_local_position_setpoint_s _local_pos_sp; /**< vehicle local position setpoint */ struct vehicle_global_velocity_setpoint_s _global_vel_sp; /**< vehicle global velocity setpoint */ + control::BlockParamFloat _manual_thr_min; + control::BlockParamFloat _manual_thr_max; struct { param_t thr_min; @@ -290,7 +295,7 @@ MulticopterPositionControl *g_control; } MulticopterPositionControl::MulticopterPositionControl() : - + SuperBlock(NULL, "MPC"), _task_should_exit(false), _control_task(-1), _mavlink_fd(-1), @@ -310,7 +315,8 @@ MulticopterPositionControl::MulticopterPositionControl() : _att_sp_pub(-1), _local_pos_sp_pub(-1), _global_vel_sp_pub(-1), - + _manual_thr_min(this, "MANTHR_MIN"), + _manual_thr_max(this, "MANTHR_MAX"), _ref_alt(0.0f), _ref_timestamp(0), @@ -410,6 +416,10 @@ MulticopterPositionControl::parameters_update(bool force) } if (updated || force) { + /* update C++ param system */ + updateParams(); + + /* update legacy C interface params */ param_get(_params_handles.thr_min, &_params.thr_min); param_get(_params_handles.thr_max, &_params.thr_max); param_get(_params_handles.tilt_max_air, &_params.tilt_max_air); @@ -1413,11 +1423,11 @@ MulticopterPositionControl::task_main() /* control throttle directly if no climb rate controller is active */ if (!_control_mode.flag_control_climb_rate_enabled) { - _att_sp.thrust = math::min(_manual.z, _params.thr_max); + _att_sp.thrust = math::min(_manual.z, _manual_thr_max.get()); /* enforce minimum throttle if not landed */ if (!_vehicle_status.condition_landed) { - _att_sp.thrust = math::max(_att_sp.thrust, _params.thr_min); + _att_sp.thrust = math::max(_att_sp.thrust, _manual_thr_min.get()); } } From 7b7ec672b9e5023d60168a53a1d3ecc94709004e Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 22 Jul 2015 12:42:29 +0200 Subject: [PATCH 038/174] Add prearm state to actuator armed topic --- msg/actuator_armed.msg | 1 + 1 file changed, 1 insertion(+) diff --git a/msg/actuator_armed.msg b/msg/actuator_armed.msg index c8098724e8..f307e366ae 100644 --- a/msg/actuator_armed.msg +++ b/msg/actuator_armed.msg @@ -1,6 +1,7 @@ uint64 timestamp # Microseconds since system boot bool armed # Set to true if system is armed +bool prearmed # Set to true if the actuator safety is disabled but motors are not armed bool ready_to_arm # Set to true if system is ready to be armed bool lockdown # Set to true if actuators are forced to being disabled (due to emergency or HIL) bool force_failsafe # Set to true if the actuators are forced to the failsafe position From fb9dcfc4a16bcf31f2a863756e37c05443b3831b Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 22 Jul 2015 12:42:50 +0200 Subject: [PATCH 039/174] commander: populate prearmed field --- src/modules/commander/commander.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp index f7ef1ec8e2..f045cb4b04 100644 --- a/src/modules/commander/commander.cpp +++ b/src/modules/commander/commander.cpp @@ -2144,6 +2144,19 @@ int commander_thread_main(int argc, char *argv[]) orb_publish(ORB_ID(vehicle_status), status_pub, &status); armed.timestamp = now; + + /* set prearmed state if safety is off, or safety is not present and 5 seconds passed */ + if (safety.safety_switch_available) { + + /* safety is off, go into prearmed */ + armed.prearmed = safety.safety_off; + } else { + /* safety is not present, go into prearmed + * (all output drivers should be started / unlocked last in the boot process + * when the rest of the system is fully initialized) + */ + armed.prearmed = (hrt_elapsed_time(&commander_boot_timestamp) > 5 * 1000 * 1000); + } orb_publish(ORB_ID(actuator_armed), armed_pub, &armed); } From f94e2c8136375440c7398e51379252ee936534ef Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 22 Jul 2015 12:43:21 +0200 Subject: [PATCH 040/174] FMU driver: Rely on prearmed field to pre-arm --- src/drivers/px4fmu/fmu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/drivers/px4fmu/fmu.cpp b/src/drivers/px4fmu/fmu.cpp index b1766f7390..c55289fc54 100644 --- a/src/drivers/px4fmu/fmu.cpp +++ b/src/drivers/px4fmu/fmu.cpp @@ -165,7 +165,7 @@ private: unsigned _num_failsafe_set; unsigned _num_disarmed_set; - static bool arm_nothrottle() { return (_armed.ready_to_arm && !_armed.armed); } + static bool arm_nothrottle() { return (_armed.prearmed && !_armed.armed); } static void task_main_trampoline(int argc, char *argv[]); void task_main(); @@ -733,7 +733,7 @@ PX4FMU::task_main() orb_copy(ORB_ID(actuator_armed), _armed_sub, &_armed); /* update the armed status and check that we're not locked down */ - bool set_armed = (_armed.armed || _armed.ready_to_arm) && !_armed.lockdown; + bool set_armed = (_armed.armed || _armed.prearmed) && !_armed.lockdown; if (_servo_armed != set_armed) { _servo_armed = set_armed; From 97e9f44d357f35c31a313812acec699f38e74a18 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 22 Jul 2015 22:22:41 +0200 Subject: [PATCH 041/174] TECS: Reset integrator states on first run or when DT is large --- src/lib/external_lgpl/tecs/tecs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/external_lgpl/tecs/tecs.cpp b/src/lib/external_lgpl/tecs/tecs.cpp index d13673ec9b..33beac14bb 100644 --- a/src/lib/external_lgpl/tecs/tecs.cpp +++ b/src/lib/external_lgpl/tecs/tecs.cpp @@ -45,7 +45,7 @@ void TECS::update_50hz(float baro_altitude, float airspeed, const math::Matrix<3 // DT, baro_altitude, airspeed, rotMat(0, 0), rotMat(1, 1), accel_body(0), accel_body(1), accel_body(2), // accel_earth(0), accel_earth(1), accel_earth(2)); - if (DT > 1.0f) { + if (_update_50hz_last_usec == 0 || DT > 1.0f) { _integ3_state = baro_altitude; _integ2_state = 0.0f; _integ1_state = 0.0f; From e84d97b387fdbdb041194fcf2fbe58028f9cc364 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 22 Jul 2015 22:23:13 +0200 Subject: [PATCH 042/174] Only update TECS filter if auto is enabled. This forces the internal TECS logic to reset between auto runs --- src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp b/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp index 8856dd829d..2f915c711f 100644 --- a/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp +++ b/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp @@ -1054,8 +1054,9 @@ FixedwingPositionControl::control_position(const math::Vector<2> ¤t_positi math::Vector<3> accel_body(_sensor_combined.accelerometer_m_s2); math::Vector<3> accel_earth = _R_nb * accel_body; - if (!_mTecs.getEnabled() && !_vehicle_status.condition_landed) { - _tecs.update_50hz(_global_pos.alt /* XXX might switch to alt err here */, _airspeed.indicated_airspeed_m_s, _R_nb, accel_body, accel_earth); + /* update TECS filters, but only if in auto mode. */ + if (_control_mode.flag_control_auto_enabled && (_global_pos.timestamp > 0) && !_mTecs.getEnabled() && !_vehicle_status.condition_landed) { + _tecs.update_50hz(_global_pos.alt, _airspeed.indicated_airspeed_m_s, _R_nb, accel_body, accel_earth); } /* define altitude error */ From 509b8c1c2497bcb52b67638d68063a2cf3883fd8 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 26 Jul 2015 10:52:09 +0200 Subject: [PATCH 043/174] MC: Move all multicopter configs to PWM min/max params --- ROMFS/px4fmu_common/init.d/4010_dji_f330 | 17 ++-------------- ROMFS/px4fmu_common/init.d/4011_dji_f450 | 17 ++-------------- ROMFS/px4fmu_common/init.d/rc.mc_defaults | 24 ++++++++++++++++++++--- 3 files changed, 25 insertions(+), 33 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/4010_dji_f330 b/ROMFS/px4fmu_common/init.d/4010_dji_f330 index 50b8320613..a530d75ba9 100644 --- a/ROMFS/px4fmu_common/init.d/4010_dji_f330 +++ b/ROMFS/px4fmu_common/init.d/4010_dji_f330 @@ -21,25 +21,12 @@ then param set MC_YAWRATE_P 0.2 param set MC_YAWRATE_I 0.1 param set MC_YAWRATE_D 0.0 - param set PWM_DISARMED 900 + # DJI ESCs do not support calibration and need a higher min param set PWM_MIN 1230 - param set PWM_MAX 1950 fi # Transitional support: ensure suitable PWM min/max param values -if param compare PWM_MIN 1000 +if param compare PWM_MIN 1075 then param set PWM_MIN 1230 fi -if param compare PWM_MAX 2000 -then - param set PWM_MAX 1950 -fi -if param compare PWM_DISARMED 0 -then - param set PWM_DISARMED 900 -fi - -set PWM_DISARMED p:PWM_DISARMED -set PWM_MIN p:PWM_MIN -set PWM_MAX p:PWM_MAX diff --git a/ROMFS/px4fmu_common/init.d/4011_dji_f450 b/ROMFS/px4fmu_common/init.d/4011_dji_f450 index 1075a5376f..dafa3bf7bf 100644 --- a/ROMFS/px4fmu_common/init.d/4011_dji_f450 +++ b/ROMFS/px4fmu_common/init.d/4011_dji_f450 @@ -22,25 +22,12 @@ then param set MC_YAWRATE_P 0.3 param set MC_YAWRATE_I 0.1 param set MC_YAWRATE_D 0.0 - param set PWM_DISARMED 900 + # DJI ESCs do not support calibration and need a higher min param set PWM_MIN 1230 - param set PWM_MAX 1950 fi # Transitional support: ensure suitable PWM min/max param values -if param compare PWM_MIN 1000 +if param compare PWM_MIN 1075 then param set PWM_MIN 1230 fi -if param compare PWM_MAX 2000 -then - param set PWM_MAX 1950 -fi -if param compare PWM_DISARMED 0 -then - param set PWM_DISARMED 900 -fi - -set PWM_DISARMED p:PWM_DISARMED -set PWM_MIN p:PWM_MIN -set PWM_MAX p:PWM_MAX diff --git a/ROMFS/px4fmu_common/init.d/rc.mc_defaults b/ROMFS/px4fmu_common/init.d/rc.mc_defaults index 3482078165..eccee07e7b 100644 --- a/ROMFS/px4fmu_common/init.d/rc.mc_defaults +++ b/ROMFS/px4fmu_common/init.d/rc.mc_defaults @@ -14,13 +14,31 @@ then param set NAV_ACC_RAD 2.0 param set RTL_RETURN_ALT 30.0 param set RTL_DESCEND_ALT 10.0 + param set PWM_DISARMED 900 + param set PWM_MIN 1075 + param set PWM_MAX 1950 +fi + +# Transitional support: ensure suitable PWM min/max param values +if param compare PWM_MIN 1000 +then + param set PWM_MIN 1075 +fi +if param compare PWM_MAX 2000 +then + param set PWM_MAX 1950 +fi +if param compare PWM_DISARMED 0 +then + param set PWM_DISARMED 900 fi # set environment variables (!= parameters) set PWM_RATE 400 -set PWM_DISARMED 900 -set PWM_MIN 1075 -set PWM_MAX 2000 +# tell the mixer to use parameters for these instead +set PWM_DISARMED p:PWM_DISARMED +set PWM_MIN p:PWM_MIN +set PWM_MAX p:PWM_MAX # This is the gimbal pass mixer set MIXER_AUX pass From 09da389558fa82965334c9e699b5c5dd84788482 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 27 Jul 2015 10:10:15 +0200 Subject: [PATCH 044/174] TECS: Add in-air state and trigger filter state resets when not flying to ensure correct filter state initialization --- src/lib/external_lgpl/tecs/tecs.cpp | 41 +++++++++++++++++++++-------- src/lib/external_lgpl/tecs/tecs.h | 10 ++++++- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/lib/external_lgpl/tecs/tecs.cpp b/src/lib/external_lgpl/tecs/tecs.cpp index 33beac14bb..53380d75da 100644 --- a/src/lib/external_lgpl/tecs/tecs.cpp +++ b/src/lib/external_lgpl/tecs/tecs.cpp @@ -27,7 +27,8 @@ using namespace math; * */ -void TECS::update_50hz(float baro_altitude, float airspeed, const math::Matrix<3,3> &rotMat, const math::Vector<3> &accel_body, const math::Vector<3> &accel_earth) +void TECS::update_state(float baro_altitude, float airspeed, const math::Matrix<3,3> &rotMat, + const math::Vector<3> &accel_body, const math::Vector<3> &accel_earth, bool altitude_lock, bool in_air) { // Implement third order complementary filter for height and height rate // estimted height rate = _integ2_state @@ -45,12 +46,24 @@ void TECS::update_50hz(float baro_altitude, float airspeed, const math::Matrix<3 // DT, baro_altitude, airspeed, rotMat(0, 0), rotMat(1, 1), accel_body(0), accel_body(1), accel_body(2), // accel_earth(0), accel_earth(1), accel_earth(2)); - if (_update_50hz_last_usec == 0 || DT > 1.0f) { + bool reset_altitude = false; + + _in_air = in_air; + + if (_update_50hz_last_usec == 0 || DT > DT_MAX) { + DT = 0.02f; // when first starting TECS, use a + // small time constant + reset_altitude = true; + } + + if (!altitude_lock || !in_air) { + reset_altitude = true; + } + + if (reset_altitude) { _integ3_state = baro_altitude; _integ2_state = 0.0f; _integ1_state = 0.0f; - DT = 0.02f; // when first starting TECS, use a - // small time constant } _update_50hz_last_usec = now; @@ -70,7 +83,7 @@ void TECS::update_50hz(float baro_altitude, float airspeed, const math::Matrix<3 // If more than 1 second has elapsed since last update then reset the integrator state // to the measured height - if (DT > 1.0f) { + if (reset_altitude) { _integ3_state = baro_altitude; } else { @@ -95,6 +108,8 @@ void TECS::update_50hz(float baro_altitude, float airspeed, const math::Matrix<3 _vel_dot = 0.0f; } + _states_initalized = true; + } void TECS::_update_speed(float airspeed_demand, float indicated_airspeed, @@ -103,7 +118,6 @@ void TECS::_update_speed(float airspeed_demand, float indicated_airspeed, // Calculate time in seconds since last update uint64_t now = ecl_absolute_time(); float DT = max((now - _update_speed_last_usec), 0ULL) * 1.0e-6f; - _update_speed_last_usec = now; // Convert equivalent airspeeds to true airspeeds @@ -113,7 +127,7 @@ void TECS::_update_speed(float airspeed_demand, float indicated_airspeed, _TASmin = indicated_airspeed_min * EAS2TAS; // Reset states of time since last update is too large - if (DT > 1.0f) { + if (_update_speed_last_usec == 0 || DT > 1.0f || !_in_air) { _integ5_state = (_EAS * EAS2TAS); _integ4_state = 0.0f; DT = 0.1f; // when first starting TECS, use a @@ -146,7 +160,7 @@ void TECS::_update_speed(float airspeed_demand, float indicated_airspeed, _integ5_state = _integ5_state + integ5_input * DT; // limit the airspeed to a minimum of 3 m/s _integ5_state = max(_integ5_state, 3.0f); - + _update_speed_last_usec = now; } void TECS::_update_speed_demand(void) @@ -471,7 +485,7 @@ void TECS::_update_pitch(void) void TECS::_initialise_states(float pitch, float throttle_cruise, float baro_altitude, float ptchMinCO_rad) { // Initialise states and variables if DT > 1 second or in climbout - if (_DT > 1.0f) { + if (_update_pitch_throttle_last_usec == 0 || _DT > 1.0f || !_in_air) { _integ6_state = 0.0f; _integ7_state = 0.0f; _last_throttle_dem = throttle_cruise; @@ -484,7 +498,7 @@ void TECS::_initialise_states(float pitch, float throttle_cruise, float baro_alt _TAS_dem_adj = _TAS_dem; _underspeed = false; _badDescent = false; - _DT = 0.1f; // when first starting TECS, use a + _DT = DT_MIN; // when first starting TECS, use a // small time constant } else if (_climbOutDem) { @@ -512,10 +526,13 @@ void TECS::update_pitch_throttle(const math::Matrix<3,3> &rotMat, float pitch, f float throttle_min, float throttle_max, float throttle_cruise, float pitch_limit_min, float pitch_limit_max) { + if (!_states_initalized) { + return; + } + // Calculate time in seconds since last update uint64_t now = ecl_absolute_time(); _DT = max((now - _update_pitch_throttle_last_usec), 0ULL) * 1.0e-6f; - _update_pitch_throttle_last_usec = now; // printf("tecs in: dt:%10.6f pitch: %6.2f baro_alt: %6.2f alt sp: %6.2f\neas sp: %6.2f eas: %6.2f, eas2tas: %6.2f\n %s pitch min C0: %6.2f thr min: %6.2f, thr max: %6.2f thr cruis: %6.2f pt min: %6.2f, pt max: %6.2f\n", // _DT, pitch, baro_altitude, hgt_dem, EAS_dem, indicated_airspeed, EAS2TAS, (climbOutDem) ? "climb" : "level", ptchMinCO, throttle_min, throttle_max, throttle_cruise, pitch_limit_min, pitch_limit_max); @@ -583,4 +600,6 @@ void TECS::update_pitch_throttle(const math::Matrix<3,3> &rotMat, float pitch, f _tecs_state.ptch = _pitch_dem; _tecs_state.dspd_dem = _TAS_rate_dem; + _update_pitch_throttle_last_usec = now; + } diff --git a/src/lib/external_lgpl/tecs/tecs.h b/src/lib/external_lgpl/tecs/tecs.h index eb45237b7d..81a5e2d691 100644 --- a/src/lib/external_lgpl/tecs/tecs.h +++ b/src/lib/external_lgpl/tecs/tecs.h @@ -80,6 +80,8 @@ public: _SPEdot(0.0f), _SKEdot(0.0f), _airspeed_enabled(false), + _states_initalized(false), + _in_air(false), _throttle_slewrate(0.0f) { } @@ -95,7 +97,8 @@ public: // Update of the estimated height and height rate internal state // Update of the inertial speed rate internal state // Should be called at 50Hz or greater - void update_50hz(float baro_altitude, float airspeed, const math::Matrix<3,3> &rotMat, const math::Vector<3> &accel_body, const math::Vector<3> &accel_earth); + void update_state(float baro_altitude, float airspeed, const math::Matrix<3,3> &rotMat, + const math::Vector<3> &accel_body, const math::Vector<3> &accel_earth, bool altitude_lock, bool in_air); // Update the control loop calculations void update_pitch_throttle(const math::Matrix<3,3> &rotMat, float pitch, float baro_altitude, float hgt_dem, float EAS_dem, float indicated_airspeed, float EAS2TAS, bool climbOutDem, float ptchMinCO, @@ -376,7 +379,12 @@ private: // Time since last update of main TECS loop (seconds) float _DT; + static constexpr float DT_MIN = 0.1f; + static constexpr float DT_MAX = 1.0f; + bool _airspeed_enabled; + bool _states_initalized; + bool _in_air; float _throttle_slewrate; float _indicated_airspeed_min; float _indicated_airspeed_max; From 75085dc5d610f03b53ccbd89fcd93048d748657b Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 27 Jul 2015 10:16:48 +0200 Subject: [PATCH 045/174] Condition TECS properly on any altitude control mode --- .../fw_pos_control_l1_main.cpp | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp b/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp index 2f915c711f..33a78f3141 100644 --- a/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp +++ b/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp @@ -1037,7 +1037,7 @@ bool FixedwingPositionControl::control_position(const math::Vector<2> ¤t_position, const math::Vector<3> &ground_speed, const struct position_setpoint_triplet_s &pos_sp_triplet) { - float dt = FLT_MIN; // Using non zero value to a avoid division by zero + float dt = 0.01; // Using non zero value to a avoid division by zero if (_control_position_last_called > 0) { dt = (float)hrt_elapsed_time(&_control_position_last_called) * 1e-6f; } @@ -1045,20 +1045,27 @@ FixedwingPositionControl::control_position(const math::Vector<2> ¤t_positi bool setpoint = true; - math::Vector<2> ground_speed_2d = {ground_speed(0), ground_speed(1)}; - calculate_gndspeed_undershoot(current_position, ground_speed_2d, pos_sp_triplet); - float eas2tas = 1.0f; // XXX calculate actual number based on current measurements /* filter speed and altitude for controller */ math::Vector<3> accel_body(_sensor_combined.accelerometer_m_s2); math::Vector<3> accel_earth = _R_nb * accel_body; - /* update TECS filters, but only if in auto mode. */ - if (_control_mode.flag_control_auto_enabled && (_global_pos.timestamp > 0) && !_mTecs.getEnabled() && !_vehicle_status.condition_landed) { - _tecs.update_50hz(_global_pos.alt, _airspeed.indicated_airspeed_m_s, _R_nb, accel_body, accel_earth); + /* tell TECS to update its state, but let it know when it cannot actually control the plane */ + bool in_air_alt_control = (!_vehicle_status.condition_landed && + (_control_mode.flag_control_auto_enabled || + _control_mode.flag_control_velocity_enabled || + _control_mode.flag_control_altitude_enabled)); + + /* update TECS filters */ + if (!_mTecs.getEnabled()) { + _tecs.update_state(_global_pos.alt, _airspeed.indicated_airspeed_m_s, _R_nb, + accel_body, accel_earth, (_global_pos.timestamp > 0), in_air_alt_control); } + math::Vector<2> ground_speed_2d = {ground_speed(0), ground_speed(1)}; + calculate_gndspeed_undershoot(current_position, ground_speed_2d, pos_sp_triplet); + /* define altitude error */ float altitude_error = _pos_sp_triplet.current.alt - _global_pos.alt; From 455c449a02d59d2c72b5b86c95409bd1d2f6b4ae Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 28 Jul 2015 23:45:30 +0200 Subject: [PATCH 046/174] Build system: Add support for airframes config file --- Tools/airframes.xml | 12 ++++++++++++ Tools/px_mkfw.py | 6 ++++++ makefiles/firmware.mk | 3 +++ 3 files changed, 21 insertions(+) create mode 100644 Tools/airframes.xml diff --git a/Tools/airframes.xml b/Tools/airframes.xml new file mode 100644 index 0000000000..f167c51dd7 --- /dev/null +++ b/Tools/airframes.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/Tools/px_mkfw.py b/Tools/px_mkfw.py index 152444f84b..2f07fa1e73 100755 --- a/Tools/px_mkfw.py +++ b/Tools/px_mkfw.py @@ -74,6 +74,7 @@ parser.add_argument("--summary", action="store", help="set a brief description") parser.add_argument("--description", action="store", help="set a longer description") parser.add_argument("--git_identity", action="store", help="the working directory to check for git identity") parser.add_argument("--parameter_xml", action="store", help="the parameters.xml file") +parser.add_argument("--airframe_xml", action="store", help="the airframes.xml file") parser.add_argument("--image", action="store", help="the firmware image") args = parser.parse_args() @@ -107,6 +108,11 @@ if args.parameter_xml != None: bytes = f.read() desc['parameter_xml_size'] = len(bytes) desc['parameter_xml'] = base64.b64encode(zlib.compress(bytes,9)).decode('utf-8') +if args.airframe_xml != None: + f = open(args.airframe_xml, "rb") + bytes = f.read() + desc['airframe_xml_size'] = len(bytes) + desc['airframe_xml'] = base64.b64encode(zlib.compress(bytes,9)).decode('utf-8') if args.image != None: f = open(args.image, "rb") bytes = f.read() diff --git a/makefiles/firmware.mk b/makefiles/firmware.mk index ebe7a09c20..5163a4c9f3 100644 --- a/makefiles/firmware.mk +++ b/makefiles/firmware.mk @@ -463,6 +463,7 @@ PRODUCT_BUNDLE = $(WORK_DIR)firmware.px4 PRODUCT_BIN = $(WORK_DIR)firmware.bin PRODUCT_ELF = $(WORK_DIR)firmware.elf PRODUCT_PARAMXML = $(WORK_DIR)/parameters.xml +PRODUCT_AIRFRAMEXML = $(WORK_DIR)/airframes.xml .PHONY: firmware firmware: $(PRODUCT_BUNDLE) @@ -495,9 +496,11 @@ $(PRODUCT_BUNDLE): $(PRODUCT_BIN) @$(ECHO) %% Generating $@ ifdef GEN_PARAM_XML $(Q) $(PYTHON) $(PX4_BASE)/Tools/px_process_params.py --src-path $(PX4_BASE)/src --board CONFIG_ARCH_BOARD_$(CONFIG_BOARD) --xml + $(Q) $(COPY) $(PX4_BASE)/Tools/airframes.xml $(WORK_DIR)/airframes.xml $(Q) $(MKFW) --prototype $(IMAGE_DIR)/$(BOARD).prototype \ --git_identity $(PX4_BASE) \ --parameter_xml $(PRODUCT_PARAMXML) \ + --airframe_xml $(PRODUCT_AIRFRAMEXML) \ --image $< > $@ else $(Q) $(MKFW) --prototype $(IMAGE_DIR)/$(BOARD).prototype \ From d6290d8f5d00660be73d3e04a78ff4ed99fce104 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 28 Jul 2015 23:58:50 +0200 Subject: [PATCH 047/174] Airframe Configs: Add version field --- Tools/airframes.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/Tools/airframes.xml b/Tools/airframes.xml index f167c51dd7..db327e5037 100644 --- a/Tools/airframes.xml +++ b/Tools/airframes.xml @@ -1,5 +1,6 @@ + 1 From 6dff0b5ebf212f70b3dd37387ab97548a0251847 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 00:03:41 +0200 Subject: [PATCH 048/174] Add airframe icons --- Tools/airframes.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/airframes.xml b/Tools/airframes.xml index db327e5037..1a68e23878 100644 --- a/Tools/airframes.xml +++ b/Tools/airframes.xml @@ -1,11 +1,11 @@ 1 - + - + From 68aa8fed9ec97059e70dd9f59446e0036fc418c9 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:13:28 +0200 Subject: [PATCH 049/174] Add airframe config parser --- Tools/px4airframes/README.md | 1 + Tools/px4airframes/__init__.py | 1 + Tools/px4airframes/srcparser.py | 342 +++++++++++++++++++++++++++++++ Tools/px4airframes/srcscanner.py | 37 ++++ Tools/px4airframes/xmlout.py | 60 ++++++ 5 files changed, 441 insertions(+) create mode 100644 Tools/px4airframes/README.md create mode 100644 Tools/px4airframes/__init__.py create mode 100644 Tools/px4airframes/srcparser.py create mode 100644 Tools/px4airframes/srcscanner.py create mode 100644 Tools/px4airframes/xmlout.py diff --git a/Tools/px4airframes/README.md b/Tools/px4airframes/README.md new file mode 100644 index 0000000000..50dcd2e296 --- /dev/null +++ b/Tools/px4airframes/README.md @@ -0,0 +1 @@ +This folder contains a python library used by px_process_params.py diff --git a/Tools/px4airframes/__init__.py b/Tools/px4airframes/__init__.py new file mode 100644 index 0000000000..3a9f1e2c6d --- /dev/null +++ b/Tools/px4airframes/__init__.py @@ -0,0 +1 @@ +__all__ = ["srcscanner", "srcparser", "xmlout", "dokuwikiout", "dokuwikirpc"] \ No newline at end of file diff --git a/Tools/px4airframes/srcparser.py b/Tools/px4airframes/srcparser.py new file mode 100644 index 0000000000..7b6def6834 --- /dev/null +++ b/Tools/px4airframes/srcparser.py @@ -0,0 +1,342 @@ +import sys +import re + +class ParameterGroup(object): + """ + Single parameter group + """ + def __init__(self, name): + self.name = name + self.params = [] + + def AddParameter(self, param): + """ + Add parameter to the group + """ + self.params.append(param) + + def GetName(self): + """ + Get parameter group name + """ + return self.name + + def GetParams(self): + """ + Returns the parsed list of parameters. Every parameter is a Parameter + object. Note that returned object is not a copy. Modifications affect + state of the parser. + """ + return sorted(self.params, + key=lambda x: x.GetFieldValue("code")) + +class Parameter(object): + """ + Single parameter + """ + + # Define sorting order of the fields + priority = { + "board": 9, + "short_desc": 8, + "long_desc": 7, + "min": 5, + "max": 4, + "unit": 3, + # all others == 0 (sorted alphabetically) + } + + def __init__(self, name, airframe_type, airframe_id, maintainer): + self.fields = {} + self.outputs = {} + self.name = name + self.type = airframe_type + self.id = airframe_id + self.maintainer = maintainer + + def GetName(self): + return self.name + + def GetType(self): + return self.type + + def GetId(self): + return self.id + + def GetMaintainer(self): + return self.maintainer + + def SetField(self, code, value): + """ + Set named field value + """ + self.fields[code] = value + + def SetOutput(self, code, value): + """ + Set named output value + """ + self.outputs[code] = value + + def GetFieldCodes(self): + """ + Return list of existing field codes in convenient order + """ + keys = self.fields.keys() + keys = sorted(keys) + keys = sorted(keys, key=lambda x: self.priority.get(x, 0), reverse=True) + return keys + + def GetFieldValue(self, code): + """ + Return value of the given field code or None if not found. + """ + fv = self.fields.get(code) + if not fv: + # required because python 3 sorted does not accept None + return "" + return self.fields.get(code) + + def GetOutputCodes(self): + """ + Return list of existing output codes in convenient order + """ + keys = self.outputs.keys() + keys = sorted(keys) + keys = sorted(keys, key=lambda x: self.priority.get(x, 0), reverse=True) + return keys + + def GetOutputValue(self, code): + """ + Return value of the given output code or None if not found. + """ + fv = self.outputs.get(code) + if not fv: + # required because python 3 sorted does not accept None + return "" + return self.outputs.get(code) + +class SourceParser(object): + """ + Parses provided data and stores all found parameters internally. + """ + + re_split_lines = re.compile(r'[\r\n]+') + re_comment_start = re.compile(r'^\#\s') + re_comment_content = re.compile(r'^\#\s*(.*)') + re_comment_tag = re.compile(r'@([a-zA-Z][a-zA-Z0-9_]*)\s*(.*)') + re_comment_end = re.compile(r'(.*?)\s*\#\n/') + re_cut_type_specifier = re.compile(r'[a-z]+$') + re_is_a_number = re.compile(r'^-?[0-9\.]') + re_remove_dots = re.compile(r'\.+$') + re_remove_carriage_return = re.compile('\n+') + + valid_tags = set(["url", "maintainer", "output", "name", "type"]) + + # Order of parameter groups + priority = { + # All other groups = 0 (sort alphabetically) + "Miscellaneous": -10 + } + + def __init__(self): + self.param_groups = {} + + def GetSupportedExtensions(self): + """ + Returns list of supported file extensions that can be parsed by this + parser. The parser uses any extension. + """ + return [""] + + def Parse(self, path, contents): + """ + Incrementally parse program contents and append all found airframes + to the list. + """ + + airframe_id = None + airframe_id = path.rsplit('/',1)[1].split('_',1)[0] + + # Skip if not numeric + if (not self.IsNumber(airframe_id)): + return True + + # This code is essentially a comment-parsing grammar. "state" + # represents parser state. It contains human-readable state + # names. + state = None + tags = {} + outputs = {} + for line in self.re_split_lines.split(contents): + line = line.strip() + # Ignore empty lines + if line == "": + continue + if state is None and self.re_comment_start.match(line): + state = "wait-short" + short_desc = None + long_desc = None + if state is not None and state != "comment-processed": + m = self.re_comment_end.search(line) + if m: + line = m.group(1) + last_comment_line = True + else: + last_comment_line = False + m = self.re_comment_content.match(line) + if m: + comment_content = m.group(1) + if comment_content == "": + # When short comment ends with empty comment line, + # start waiting for the next part - long comment. + if state == "wait-short-end": + state = "wait-long" + else: + m = self.re_comment_tag.match(comment_content) + if m: + tag, desc = m.group(1, 2) + if (tag == "output"): + key, text = desc.split(' ', 1) + outputs[key] = text; + else: + tags[tag] = desc + current_tag = tag + state = "wait-tag-end" + elif state == "wait-short": + # Store first line of the short description + short_desc = comment_content + state = "wait-short-end" + elif state == "wait-short-end": + # Append comment line to the short description + short_desc += "\n" + comment_content + elif state == "wait-long": + # Store first line of the long description + long_desc = comment_content + state = "wait-long-end" + elif state == "wait-long-end": + # Append comment line to the long description + long_desc += "\n" + comment_content + elif state == "wait-tag-end": + # Append comment line to the tag text + tags[current_tag] += "\n" + comment_content + else: + raise AssertionError( + "Invalid parser state: %s" % state) + elif not last_comment_line: + # Invalid comment line (inside comment, but not starting with + # "*" or "*/". Reset parsed content. + state = None + if last_comment_line: + state = "comment-processed" + else: + state = None + + # Process parsed content + airframe_type = None + maintainer = "John Doe " + airframe_name = None + + # Done with file, store + for tag in tags: + if tag == "maintainer": + maintainer = tags[tag] + if tag == "type": + airframe_type = tags[tag] + if tag == "name": + airframe_name = tags[tag] + elif tag not in self.valid_tags: + sys.stderr.write("Aborting due to invalid documentation tag: '%s'\n" % tag) + return False + + # Sanity check + if airframe_type == None: + sys.stderr.write("Aborting due to missing @type tag in file: '%s'\n" % path) + return False + + if airframe_name == None: + sys.stderr.write("Aborting due to missing @name tag in file: '%s'\n" % path) + return False + + # We already know this is an airframe config, so add it + param = Parameter(airframe_name, airframe_type, airframe_id, maintainer) + + # Done with file, store + for tag in tags: + if tag == "maintainer": + maintainer = tags[tag] + if tag == "type": + airframe_type = tags[tag] + if tag == "name": + airframe_name = tags[tag] + else: + param.SetField(tag, tags[tag]) + + # Store outputs + for output in outputs: + param.SetOutput(output, outputs[output]) + + # Store the parameter + if airframe_type not in self.param_groups: + self.param_groups[airframe_type] = ParameterGroup(airframe_type) + self.param_groups[airframe_type].AddParameter(param) + + return True + + def IsNumber(self, numberString): + try: + float(numberString) + return True + except ValueError: + return False + + def Validate(self): + """ + Validates the airframe meta data. + """ + seenParamNames = [] + for group in self.GetParamGroups(): + for param in group.GetParams(): + name = param.GetName() + board = param.GetFieldValue("board") + # Check for duplicates + name_plus_board = name + "+" + board + for seenParamName in seenParamNames: + if seenParamName == name_plus_board: + sys.stderr.write("Duplicate parameter definition: {0}\n".format(name_plus_board)) + return False + seenParamNames.append(name_plus_board) + # Validate values + default = param.GetDefault() + min = param.GetFieldValue("min") + max = param.GetFieldValue("max") + #sys.stderr.write("{0} default:{1} min:{2} max:{3}\n".format(name, default, min, max)) + if default != "" and not self.IsNumber(default): + sys.stderr.write("Default value not number: {0} {1}\n".format(name, default)) + return False + if min != "": + if not self.IsNumber(min): + sys.stderr.write("Min value not number: {0} {1}\n".format(name, min)) + return False + if default != "" and float(default) < float(min): + sys.stderr.write("Default value is smaller than min: {0} default:{1} min:{2}\n".format(name, default, min)) + return False + if max != "": + if not self.IsNumber(max): + sys.stderr.write("Max value not number: {0} {1}\n".format(name, max)) + return False + if default != "" and float(default) > float(max): + sys.stderr.write("Default value is larger than max: {0} default:{1} max:{2}\n".format(name, default, max)) + return False + return True + + def GetParamGroups(self): + """ + Returns the parsed list of parameters. Every parameter is a Parameter + object. Note that returned object is not a copy. Modifications affect + state of the parser. + """ + groups = self.param_groups.values() + groups = sorted(groups, key=lambda x: x.GetName()) + groups = sorted(groups, key=lambda x: self.priority.get(x.GetName(), 0), reverse=True) + return groups diff --git a/Tools/px4airframes/srcscanner.py b/Tools/px4airframes/srcscanner.py new file mode 100644 index 0000000000..c1f280668d --- /dev/null +++ b/Tools/px4airframes/srcscanner.py @@ -0,0 +1,37 @@ +import os +import re +import codecs + +class SourceScanner(object): + """ + Traverses directory tree, reads all source files, and passes their contents + to the Parser. + """ + + def ScanDir(self, srcdir, parser): + """ + Scans provided path and passes all found contents to the parser using + parser.Parse method. + """ + extensions = tuple(parser.GetSupportedExtensions()) + for dirname, dirnames, filenames in os.walk(srcdir): + for filename in filenames: + if filename.endswith(extensions): + path = os.path.join(dirname, filename) + if not self.ScanFile(path, parser): + return False + return True + + def ScanFile(self, path, parser): + """ + Scans provided file and passes its contents to the parser using + parser.Parse method. + """ + with codecs.open(path, 'r', 'utf-8') as f: + try: + contents = f.read() + except: + contents = '' + print('Failed reading file: %s, skipping content.' % path) + pass + return parser.Parse(path, contents) diff --git a/Tools/px4airframes/xmlout.py b/Tools/px4airframes/xmlout.py new file mode 100644 index 0000000000..e295f091f8 --- /dev/null +++ b/Tools/px4airframes/xmlout.py @@ -0,0 +1,60 @@ +import xml.etree.ElementTree as ET +import codecs + +def indent(elem, level=0): + i = "\n" + level*" " + if len(elem): + if not elem.text or not elem.text.strip(): + elem.text = i + " " + if not elem.tail or not elem.tail.strip(): + elem.tail = i + for elem in elem: + indent(elem, level+1) + if not elem.tail or not elem.tail.strip(): + elem.tail = i + else: + if level and (not elem.tail or not elem.tail.strip()): + elem.tail = i + +class XMLOutput(): + + def __init__(self, groups, board): + xml_parameters = ET.Element("airframes") + xml_version = ET.SubElement(xml_parameters, "version") + xml_version.text = "1" + last_param_name = "" + board_specific_param_set = False + for group in groups: + xml_group = ET.SubElement(xml_parameters, "airframe_group") + xml_group.attrib["name"] = group.GetName() + for param in group.GetParams(): + if (last_param_name == param.GetName() and not board_specific_param_set) or last_param_name != param.GetName(): + xml_param = ET.SubElement(xml_group, "airframe") + xml_param.attrib["name"] = param.GetName() + xml_param.attrib["id"] = param.GetId() + xml_param.attrib["maintainer"] = param.GetMaintainer() + last_param_name = param.GetName() + for code in param.GetFieldCodes(): + value = param.GetFieldValue(code) + if code == "board": + if value == board: + board_specific_param_set = True + xml_field = ET.SubElement(xml_param, code) + xml_field.text = value + else: + xml_group.remove(xml_param) + else: + xml_field = ET.SubElement(xml_param, code) + xml_field.text = value + for code in param.GetOutputCodes(): + value = param.GetOutputValue(code) + xml_field = ET.SubElement(xml_param, "output") + xml_field.attrib["name"] = code + xml_field.text = value + if last_param_name != param.GetName(): + board_specific_param_set = False + indent(xml_parameters) + self.xml_document = ET.ElementTree(xml_parameters) + + def Save(self, filename): + self.xml_document.write(filename, encoding="UTF-8") From 315d2ef87c3e50f5fdbe476c403c849b1ebf9a78 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:13:50 +0200 Subject: [PATCH 050/174] Add airframe main parser --- Tools/px_process_airframes.py | 100 ++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100755 Tools/px_process_airframes.py diff --git a/Tools/px_process_airframes.py b/Tools/px_process_airframes.py new file mode 100755 index 0000000000..50aaa699ef --- /dev/null +++ b/Tools/px_process_airframes.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python +############################################################################ +# +# Copyright (C) 2013-2015 PX4 Development Team. All rights reserved. +# +# 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. +# +############################################################################ + +# +# PX4 airframe config processor (main executable file) +# +# This tool scans the PX4 source code for declarations of airframes +# +# Currently supported formats are: +# * XML for the parametric UI generator +# +# + +from __future__ import print_function +import sys +import os +import argparse +from px4airframes import srcscanner, srcparser, xmlout + +def main(): + # Parse command line arguments + parser = argparse.ArgumentParser(description="Process airframe documentation.") + parser.add_argument("-a", "--airframes-path", + default="../ROMFS/px4fmu_common", + metavar="PATH", + help="path to source files to scan for parameters") + parser.add_argument("-x", "--xml", + nargs='?', + const="airframes.xml", + metavar="FILENAME", + help="Create XML file" + " (default FILENAME: airframes.xml)") + parser.add_argument("-b", "--board", + nargs='?', + const="", + metavar="BOARD", + help="Board to create airframes xml for") + args = parser.parse_args() + + # Check for valid command + if not (args.xml): + print("Error: You need to specify at least one output method!\n") + parser.print_usage() + sys.exit(1) + + # Initialize source scanner and parser + scanner = srcscanner.SourceScanner() + parser = srcparser.SourceParser() + + # Scan directories, and parse the files + print("Scanning source path " + args.airframes_path) + if not scanner.ScanDir(args.airframes_path, parser): + sys.exit(1) + # We can't validate yet + # if not parser.Validate(): + # sys.exit(1) + param_groups = parser.GetParamGroups() + + # Output to XML file + if args.xml: + print("Creating XML file " + args.xml) + out = xmlout.XMLOutput(param_groups, args.board) + out.Save(args.xml) + + print("All done!") + + +if __name__ == "__main__": + main() From 2ab720c557a02154b43949947bbf6f4659516526 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:14:37 +0200 Subject: [PATCH 051/174] Add meta info to octo + config --- ROMFS/px4fmu_common/init.d/9001_octo_+ | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/9001_octo_+ b/ROMFS/px4fmu_common/init.d/9001_octo_+ index 5d608d593c..d0db57cf17 100644 --- a/ROMFS/px4fmu_common/init.d/9001_octo_+ +++ b/ROMFS/px4fmu_common/init.d/9001_octo_+ @@ -1,8 +1,14 @@ #!nsh # -# Generic 10" Octo + geometry +# @name Generic Octocopter + geometry # -# Anton Babushkin +# @type Octorotor + +# +# @output AUX1 feed-through of RC AUX1 channel +# @output AUX2 feed-through of RC AUX2 channel +# @output AUX3 feed-through of RC AUX3 channel +# +# @maintainer Anton Babushkin # sh /etc/init.d/rc.mc_defaults From 52cd988ca3ec67471687036852bebee884e40813 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:14:53 +0200 Subject: [PATCH 052/174] Add meta info to octo x config --- ROMFS/px4fmu_common/init.d/8001_octo_x | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/8001_octo_x b/ROMFS/px4fmu_common/init.d/8001_octo_x index 7cbb3ddfcd..272e093550 100644 --- a/ROMFS/px4fmu_common/init.d/8001_octo_x +++ b/ROMFS/px4fmu_common/init.d/8001_octo_x @@ -1,8 +1,14 @@ #!nsh # -# Generic 10" Octo X geometry +# @name Generic Octocopter X geometry # -# Anton Babushkin +# @type Octorotor x +# +# @output AUX1 feed-through of RC AUX1 channel +# @output AUX2 feed-through of RC AUX2 channel +# @output AUX3 feed-through of RC AUX3 channel +# +# @maintainer Anton Babushkin # sh /etc/init.d/rc.mc_defaults From 7ce51d823d850fdabe2b2221bdaf033ccae145e1 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:15:07 +0200 Subject: [PATCH 053/174] Add meta info to hexa + config --- ROMFS/px4fmu_common/init.d/7001_hexa_+ | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/7001_hexa_+ b/ROMFS/px4fmu_common/init.d/7001_hexa_+ index dd9589d614..11d732471a 100644 --- a/ROMFS/px4fmu_common/init.d/7001_hexa_+ +++ b/ROMFS/px4fmu_common/init.d/7001_hexa_+ @@ -1,8 +1,14 @@ #!nsh # -# Generic 10" Hexa + geometry +# @name Generic Hexarotor + geometry # -# Anton Babushkin +# @type Hexarotor + +# +# @output AUX1 feed-through of RC AUX1 channel +# @output AUX2 feed-through of RC AUX2 channel +# @output AUX3 feed-through of RC AUX3 channel +# +# @maintainer Anton Babushkin # sh /etc/init.d/rc.mc_defaults From 597ec59c015fa4fdbe71ac13a8a90dfe74393f31 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:15:22 +0200 Subject: [PATCH 054/174] Add meta info to hexa x config --- ROMFS/px4fmu_common/init.d/6001_hexa_x | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/6001_hexa_x b/ROMFS/px4fmu_common/init.d/6001_hexa_x index 7a6dda648a..584c4a381c 100644 --- a/ROMFS/px4fmu_common/init.d/6001_hexa_x +++ b/ROMFS/px4fmu_common/init.d/6001_hexa_x @@ -1,8 +1,14 @@ #!nsh # -# Generic 10" Hexa X geometry +# @name Generic Hexarotor x geometry # -# Anton Babushkin +# @type Hexarotor x +# +# @output AUX1 feed-through of RC AUX1 channel +# @output AUX2 feed-through of RC AUX2 channel +# @output AUX3 feed-through of RC AUX3 channel +# +# @maintainer Anton Babushkin # sh /etc/init.d/rc.mc_defaults From c04fa3963866d38b2411a57fb5a4a8da36d9f030 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:15:39 +0200 Subject: [PATCH 055/174] Add meta info to quad + config --- ROMFS/px4fmu_common/init.d/5001_quad_+ | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/5001_quad_+ b/ROMFS/px4fmu_common/init.d/5001_quad_+ index e51f9cf89d..8c5eed28cd 100644 --- a/ROMFS/px4fmu_common/init.d/5001_quad_+ +++ b/ROMFS/px4fmu_common/init.d/5001_quad_+ @@ -1,8 +1,10 @@ #!nsh # -# Generic 10" Quad + geometry +# @name Generic 10" Quad + geometry # -# Anton Babushkin +# @type Quadrotor + +# +# @maintainer Anton Babushkin # sh /etc/init.d/rc.mc_defaults From 3f363b1dfda498efea8434ec690a32cef0d70d36 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:15:57 +0200 Subject: [PATCH 056/174] Add meta info to rover config --- ROMFS/px4fmu_common/init.d/50001_axialracing_ax10 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ROMFS/px4fmu_common/init.d/50001_axialracing_ax10 b/ROMFS/px4fmu_common/init.d/50001_axialracing_ax10 index a36bac5cc8..8b60805a2f 100644 --- a/ROMFS/px4fmu_common/init.d/50001_axialracing_ax10 +++ b/ROMFS/px4fmu_common/init.d/50001_axialracing_ax10 @@ -1,5 +1,9 @@ #!nsh # +# @name Axial Racing AX10 +# +# @type Rover +# # loading default values for the axialracing ax10 # From 7553d331068a7a772855a20a3eda72ad5167590d Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:16:15 +0200 Subject: [PATCH 057/174] Add meta info to HK micro config --- ROMFS/px4fmu_common/init.d/4020_hk_micro_pcb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/4020_hk_micro_pcb b/ROMFS/px4fmu_common/init.d/4020_hk_micro_pcb index aec0c62f8f..4fd3a50c28 100644 --- a/ROMFS/px4fmu_common/init.d/4020_hk_micro_pcb +++ b/ROMFS/px4fmu_common/init.d/4020_hk_micro_pcb @@ -1,11 +1,12 @@ #!nsh # -# Hobbyking Micro Integrated PCB Quadcopter +# @name Hobbyking Micro Integrated PCB Quadcopter # with SimonK ESC firmware and Mystery A1510 motors # -# Thomas Gubler +# @type Quadrotor x +# +# @maintainer Thomas Gubler # -echo "HK Micro PCB Quad" sh /etc/init.d/4001_quad_x From 51f9880d903cf1fe88956286e121edf6fde80ab6 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:16:29 +0200 Subject: [PATCH 058/174] Add meta into to easystar config --- ROMFS/px4fmu_common/init.d/1000_rc_fw_easystar.hil | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/1000_rc_fw_easystar.hil b/ROMFS/px4fmu_common/init.d/1000_rc_fw_easystar.hil index 1e3dc6c5f6..242fc0d81d 100644 --- a/ROMFS/px4fmu_common/init.d/1000_rc_fw_easystar.hil +++ b/ROMFS/px4fmu_common/init.d/1000_rc_fw_easystar.hil @@ -1,7 +1,15 @@ #!nsh # -# HILStar -# +# @name HILStar (XPlane) +# +# @type Simulation +# +# @output MAIN1 aileron +# @output MAIN2 elevator +# @output MAIN3 rudder +# @output MAIN4 throttle +# +# @maintainer Lorenz Meier # sh /etc/init.d/rc.fw_defaults From 42c5af806c727d953067d0454fb5116e4b30fb25 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:16:45 +0200 Subject: [PATCH 059/174] Add meta info to TBS disco config --- ROMFS/px4fmu_common/init.d/10015_tbs_discovery | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/10015_tbs_discovery b/ROMFS/px4fmu_common/init.d/10015_tbs_discovery index 0dd4837644..ce5e1c71dc 100644 --- a/ROMFS/px4fmu_common/init.d/10015_tbs_discovery +++ b/ROMFS/px4fmu_common/init.d/10015_tbs_discovery @@ -1,8 +1,10 @@ #!nsh # -# Team Blacksheep Discovery Quadcopter +# @name Team Blacksheep Discovery Quadcopter # -# Anton Babushkin , Simon Wilks +# @type Quadrotor Wide +# +# @maintainer Anton Babushkin , Simon Wilks # sh /etc/init.d/rc.mc_defaults From d7022a37a6f856407a5c76347ab9f8bcb4e70173 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:17:01 +0200 Subject: [PATCH 060/174] Add meta info to 3DR Iris config --- ROMFS/px4fmu_common/init.d/10016_3dr_iris | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/10016_3dr_iris b/ROMFS/px4fmu_common/init.d/10016_3dr_iris index 68428be6f6..a2536e5418 100644 --- a/ROMFS/px4fmu_common/init.d/10016_3dr_iris +++ b/ROMFS/px4fmu_common/init.d/10016_3dr_iris @@ -1,8 +1,10 @@ #!nsh # -# 3DR Iris Quadcopter +# @name 3DR Iris Quadrotor # -# Anton Babushkin +# @type Quadrotor Wide +# +# @maintainer Anton Babushkin # sh /etc/init.d/rc.mc_defaults From 109d7e2cd2fa1c6dd10a745bf24141ea6e2aa31c Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:17:17 +0200 Subject: [PATCH 061/174] Add meta info to steadidrone config --- ROMFS/px4fmu_common/init.d/10017_steadidrone_qu4d | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/10017_steadidrone_qu4d b/ROMFS/px4fmu_common/init.d/10017_steadidrone_qu4d index 36d387c759..7e27043156 100644 --- a/ROMFS/px4fmu_common/init.d/10017_steadidrone_qu4d +++ b/ROMFS/px4fmu_common/init.d/10017_steadidrone_qu4d @@ -1,8 +1,10 @@ #!nsh # -# Steadidrone QU4D +# @name Steadidrone QU4D # -# Thomas Gubler +# @type Quadrotor Wide +# +# @maintainer Thomas Gubler # sh /etc/init.d/rc.mc_defaults From 52b21ae458e05b8b5902ccc15b74a7c1a8354597 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:17:32 +0200 Subject: [PATCH 062/174] Add meta info to TBS endurance config --- ROMFS/px4fmu_common/init.d/10018_tbs_endurance | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/10018_tbs_endurance b/ROMFS/px4fmu_common/init.d/10018_tbs_endurance index e83a864d8d..fd74e17807 100644 --- a/ROMFS/px4fmu_common/init.d/10018_tbs_endurance +++ b/ROMFS/px4fmu_common/init.d/10018_tbs_endurance @@ -1,10 +1,12 @@ #!nsh # -# Team Blacksheep Discovery Long Range Quadcopter +# @name Team Blacksheep Discovery Long Range Quadcopter # # Setup: 15 x 5" Props, 6S 4000mAh TBS LiPo, TBS 30A ESCs, TBS 400kV Motors # -# Simon Wilks +# @type Quadrotor Wide +# +# @maintainer Simon Wilks # sh /etc/init.d/rc.mc_defaults From 0ef724af5ad16e438669b5c54be401215f73df9f Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:17:45 +0200 Subject: [PATCH 063/174] Add meta info to F450 config --- ROMFS/px4fmu_common/init.d/10019_sk450_deadcat | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/10019_sk450_deadcat b/ROMFS/px4fmu_common/init.d/10019_sk450_deadcat index b91de228c5..4f22ddc436 100644 --- a/ROMFS/px4fmu_common/init.d/10019_sk450_deadcat +++ b/ROMFS/px4fmu_common/init.d/10019_sk450_deadcat @@ -1,8 +1,10 @@ #!nsh # -# HobbyKing SK450 DeadCat modification +# @name HobbyKing SK450 DeadCat modification # -# Anton Matosov +# @type Quadrotor Wide +# +# @maintainer Anton Matosov # sh /etc/init.d/rc.mc_defaults From 7d8af662dc1a9792a5319b5e62ff7a1d1d8d5f5b Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:18:01 +0200 Subject: [PATCH 064/174] Add meta info to HIL quad X config --- ROMFS/px4fmu_common/init.d/1001_rc_quad_x.hil | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/1001_rc_quad_x.hil b/ROMFS/px4fmu_common/init.d/1001_rc_quad_x.hil index 03b6b30d27..e1f2cdfe8d 100644 --- a/ROMFS/px4fmu_common/init.d/1001_rc_quad_x.hil +++ b/ROMFS/px4fmu_common/init.d/1001_rc_quad_x.hil @@ -1,8 +1,10 @@ #!nsh # -# HIL Quadcopter X +# @name HIL Quadcopter X # -# Anton Babushkin +# @type Simulation +# +# @maintainer Anton Babushkin # sh /etc/init.d/rc.mc_defaults From 987454135c110e217b7263651fff7a099fb8b9cd Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:18:16 +0200 Subject: [PATCH 065/174] Add meta info to HIL quad + config --- ROMFS/px4fmu_common/init.d/1003_rc_quad_+.hil | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/1003_rc_quad_+.hil b/ROMFS/px4fmu_common/init.d/1003_rc_quad_+.hil index 7e651216d0..7aa888c763 100644 --- a/ROMFS/px4fmu_common/init.d/1003_rc_quad_+.hil +++ b/ROMFS/px4fmu_common/init.d/1003_rc_quad_+.hil @@ -1,8 +1,10 @@ #!nsh # -# HIL Quadcopter + +# @name HIL Quadcopter + # -# Anton Babushkin +# @type Simulation +# +# @maintainer Anton Babushkin # sh /etc/init.d/rc.mc_defaults From 7a0e6f905724f628bafa5b014683af8ccd119fc4 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:18:42 +0200 Subject: [PATCH 066/174] Add Rascal HIL config --- ROMFS/px4fmu_common/init.d/1004_rc_fw_Rascal110.hil | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/1004_rc_fw_Rascal110.hil b/ROMFS/px4fmu_common/init.d/1004_rc_fw_Rascal110.hil index 0909208478..57bcd24d02 100644 --- a/ROMFS/px4fmu_common/init.d/1004_rc_fw_Rascal110.hil +++ b/ROMFS/px4fmu_common/init.d/1004_rc_fw_Rascal110.hil @@ -1,8 +1,10 @@ #!nsh # -# HIL Rascal 110 (Flightgear) +# @name HIL Rascal 110 (Flightgear) # -# Thomas Gubler +# @type Simulation +# +# @maintainer Thomas Gubler # sh /etc/init.d/rc.fw_defaults From 4a6b0d90ed59278cb0c25482cfc8b2a21b4ab693 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:18:58 +0200 Subject: [PATCH 067/174] Add Malolo meta info --- ROMFS/px4fmu_common/init.d/1005_rc_fw_Malolo1.hil | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/1005_rc_fw_Malolo1.hil b/ROMFS/px4fmu_common/init.d/1005_rc_fw_Malolo1.hil index 15e5cf21d8..5e0b6cd746 100644 --- a/ROMFS/px4fmu_common/init.d/1005_rc_fw_Malolo1.hil +++ b/ROMFS/px4fmu_common/init.d/1005_rc_fw_Malolo1.hil @@ -1,8 +1,10 @@ #!nsh # -# HIL Malolo 1 (Flightgear) +# @name HIL Malolo 1 (Flightgear) # -# Thomas Gubler +# @type Simulation +# +# @maintainer Thomas Gubler # sh /etc/init.d/rc.fw_defaults From 99274d07f2a781de24154284ecbe7739e172f6aa Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:19:15 +0200 Subject: [PATCH 068/174] Add meta info to Hexa coaxial config --- ROMFS/px4fmu_common/init.d/11001_hexa_cox | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ROMFS/px4fmu_common/init.d/11001_hexa_cox b/ROMFS/px4fmu_common/init.d/11001_hexa_cox index 0bb8cb52ee..16d34ecab6 100644 --- a/ROMFS/px4fmu_common/init.d/11001_hexa_cox +++ b/ROMFS/px4fmu_common/init.d/11001_hexa_cox @@ -1,6 +1,8 @@ #!nsh # -# Generic 10" Hexa coaxial geometry +# @name Generic Hexa coaxial geometry +# +# @type Hexarotor Coaxial # # Lorenz Meier # From f45e977ea314ca9e346da9e89bd0a69b969d7315 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:19:31 +0200 Subject: [PATCH 069/174] Add meta info to Octo coaxial config --- ROMFS/px4fmu_common/init.d/12001_octo_cox | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/12001_octo_cox b/ROMFS/px4fmu_common/init.d/12001_octo_cox index 16e86fd5fa..431d883155 100644 --- a/ROMFS/px4fmu_common/init.d/12001_octo_cox +++ b/ROMFS/px4fmu_common/init.d/12001_octo_cox @@ -1,8 +1,10 @@ #!nsh # -# Generic 10" Octo coaxial geometry +# @name Generic 10" Octo coaxial geometry # -# Lorenz Meier +# @type Octorotor Coaxial +# +# @maintainer Lorenz Meier # sh /etc/init.d/rc.mc_defaults From 0c3fc6676a23b7f274c66d223c1527b1f036fb57 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:19:50 +0200 Subject: [PATCH 070/174] Add meta info to Caipi VTOL config --- ROMFS/px4fmu_common/init.d/13001_caipirinha_vtol | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/13001_caipirinha_vtol b/ROMFS/px4fmu_common/init.d/13001_caipirinha_vtol index 912202f962..e9f48d401b 100644 --- a/ROMFS/px4fmu_common/init.d/13001_caipirinha_vtol +++ b/ROMFS/px4fmu_common/init.d/13001_caipirinha_vtol @@ -1,7 +1,12 @@ +#!nsh # -# Generic configuration file for caipirinha VTOL version +# @name Duorotor Tailsitter # -# Roman Bapst +# Generic configuration file for a tailsitter with motors in tandem configuration. +# +# @type VTOL Tailsitter +# +# @maintainer Roman Bapst # sh /etc/init.d/rc.vtol_defaults From e9f47f59b39e5e7f5df242f2b0c35673df3f8106 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:20:09 +0200 Subject: [PATCH 071/174] Add meta info to FireFly Y6 VTOL config --- ROMFS/px4fmu_common/init.d/13002_firefly6 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/13002_firefly6 b/ROMFS/px4fmu_common/init.d/13002_firefly6 index 963341d138..1ec65dff3e 100644 --- a/ROMFS/px4fmu_common/init.d/13002_firefly6 +++ b/ROMFS/px4fmu_common/init.d/13002_firefly6 @@ -1,8 +1,10 @@ #!nsh # -# Generic configuration file for BirdsEyeView Aerobotics FireFly6 +# @name BirdsEyeView Aerobotics FireFly6 # -# Roman Bapst +# @type VTOL Tiltrotor +# +# @maintainer Roman Bapst # sh /etc/init.d/rc.vtol_defaults From 18d4aeffc8ca9cfa866b51cb00f2a102e0f7cd48 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:20:26 +0200 Subject: [PATCH 072/174] Add meta info to Quad X tailsitter config --- ROMFS/px4fmu_common/init.d/13003_quad_tailsitter | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ROMFS/px4fmu_common/init.d/13003_quad_tailsitter b/ROMFS/px4fmu_common/init.d/13003_quad_tailsitter index 17560526a3..b41ad749cf 100644 --- a/ROMFS/px4fmu_common/init.d/13003_quad_tailsitter +++ b/ROMFS/px4fmu_common/init.d/13003_quad_tailsitter @@ -1,7 +1,12 @@ +#!nsh +# +# @name Quadrotor X Tailsitter # # Generic configuration file for a tailsitter with motors in X configuration. # -# Roman Bapst +# @type VTOL Tailsitter +# +# @maintainer Roman Bapst # sh /etc/init.d/rc.vtol_defaults From 2a9928f04259c1e342298ce1ca5a7a70d233bd36 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:20:45 +0200 Subject: [PATCH 073/174] Add Tri yaw+ config meta info --- ROMFS/px4fmu_common/init.d/14001_tri_y_yaw+ | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/14001_tri_y_yaw+ b/ROMFS/px4fmu_common/init.d/14001_tri_y_yaw+ index 3bb68ecf3f..4a85405199 100644 --- a/ROMFS/px4fmu_common/init.d/14001_tri_y_yaw+ +++ b/ROMFS/px4fmu_common/init.d/14001_tri_y_yaw+ @@ -1,9 +1,12 @@ #!nsh # -# Generic Tricopter Y Geometry +# @name Generic Tricopter Y Geometry +# # Yaw Servo +Output ==> +Yaw Vehicle Rotation # -# Trent Lukaczyk +# @type Tricopter Y+ +# +# @maintainer Trent Lukaczyk # sh /etc/init.d/rc.mc_defaults From ff8790d67a2a57dc7bb49fc8e0a35a83ed3c8a90 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:20:59 +0200 Subject: [PATCH 074/174] Add Tri yaw-config meta info --- ROMFS/px4fmu_common/init.d/14002_tri_y_yaw- | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/14002_tri_y_yaw- b/ROMFS/px4fmu_common/init.d/14002_tri_y_yaw- index fd4d476476..a3443e43ad 100644 --- a/ROMFS/px4fmu_common/init.d/14002_tri_y_yaw- +++ b/ROMFS/px4fmu_common/init.d/14002_tri_y_yaw- @@ -1,9 +1,12 @@ #!nsh # -# Generic Tricopter Y Geometry +# @name Generic Tricopter Y Geometry +# # Yaw Servo +Output ==> -Yaw Vehicle Rotation # -# Trent Lukaczyk +# @type Tricopter Y- +# +# @maintainer Trent Lukaczyk # sh /etc/init.d/rc.mc_defaults From 8ce11ef699b04e3612ea4d36d3c7863434d4ae6d Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:21:13 +0200 Subject: [PATCH 075/174] Add meta info to easystar config --- ROMFS/px4fmu_common/init.d/2100_mpx_easystar | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ROMFS/px4fmu_common/init.d/2100_mpx_easystar b/ROMFS/px4fmu_common/init.d/2100_mpx_easystar index 3ab2ac3d1a..12c12aec92 100644 --- a/ROMFS/px4fmu_common/init.d/2100_mpx_easystar +++ b/ROMFS/px4fmu_common/init.d/2100_mpx_easystar @@ -1,6 +1,10 @@ #!nsh # -# MPX EasyStar Plane +# @name Multiplex Easystar +# +# @type Standard Plane +# +# @maintainer Lorenz Meier # sh /etc/init.d/rc.fw_defaults From 1658c4b9dc389321f9dffdf2cd4e5dc0ba8c1b49 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:21:31 +0200 Subject: [PATCH 076/174] Add meta info to AERT generic config --- ROMFS/px4fmu_common/init.d/2101_fw_AERT | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ROMFS/px4fmu_common/init.d/2101_fw_AERT b/ROMFS/px4fmu_common/init.d/2101_fw_AERT index 05ee57ffa0..19a47cda8c 100644 --- a/ROMFS/px4fmu_common/init.d/2101_fw_AERT +++ b/ROMFS/px4fmu_common/init.d/2101_fw_AERT @@ -1,4 +1,21 @@ #!nsh +# +# @name Standard AERT Plane +# +# @type Standard Plane +# +# @output MAIN1 aileron +# @output MAIN2 elevator +# @output MAIN4 rudder +# @output MAIN3 throttle +# @output MAIN5 flaps +# +# @output AUX1 feed-through of RC AUX1 channel +# @output AUX2 feed-through of RC AUX2 channel +# @output AUX3 feed-through of RC AUX3 channel +# +# @maintainer Lorenz Meier +# sh /etc/init.d/rc.fw_defaults From 09ee5dc21a80bdcece38ab62199f744f4989a80d Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:21:47 +0200 Subject: [PATCH 077/174] Add meta info to AETR generic config --- ROMFS/px4fmu_common/init.d/2104_fw_AETR | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ROMFS/px4fmu_common/init.d/2104_fw_AETR b/ROMFS/px4fmu_common/init.d/2104_fw_AETR index bb4390b1d3..083eb42330 100644 --- a/ROMFS/px4fmu_common/init.d/2104_fw_AETR +++ b/ROMFS/px4fmu_common/init.d/2104_fw_AETR @@ -1,4 +1,21 @@ #!nsh +# +# @name Standard AETR Plane +# +# @type Standard Plane +# +# @output MAIN1 aileron +# @output MAIN2 elevator +# @output MAIN3 throttle +# @output MAIN4 rudder +# @output MAIN5 flaps +# +# @output AUX1 feed-through of RC AUX1 channel +# @output AUX2 feed-through of RC AUX2 channel +# @output AUX3 feed-through of RC AUX3 channel +# +# @maintainer Lorenz Meier +# sh /etc/init.d/rc.fw_defaults From 7c055a0cf3d6afbf2e438f5cb9eee24ffcfc6838 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:22:03 +0200 Subject: [PATCH 078/174] Add meta info to 3DR Skywalker config --- ROMFS/px4fmu_common/init.d/2102_3dr_skywalker | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ROMFS/px4fmu_common/init.d/2102_3dr_skywalker b/ROMFS/px4fmu_common/init.d/2102_3dr_skywalker index 906f4b1ccf..e2e1b307f4 100644 --- a/ROMFS/px4fmu_common/init.d/2102_3dr_skywalker +++ b/ROMFS/px4fmu_common/init.d/2102_3dr_skywalker @@ -1,4 +1,21 @@ #!nsh +# +# @name Skywalker (3DR or Generic) +# +# @type Standard Plane +# +# @output MAIN1 aileron +# @output MAIN2 elevator +# @output MAIN4 rudder +# @output MAIN3 throttle +# @output MAIN5 flaps +# +# @output AUX1 feed-through of RC AUX1 channel +# @output AUX2 feed-through of RC AUX2 channel +# @output AUX3 feed-through of RC AUX3 channel +# +# @maintainer Lorenz Meier +# sh /etc/init.d/rc.fw_defaults From d0ebf68302b3be36d99a58ab0494d7e7d5060a51 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:22:16 +0200 Subject: [PATCH 079/174] Add meta info to skyhunter config --- ROMFS/px4fmu_common/init.d/2103_skyhunter_1800 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ROMFS/px4fmu_common/init.d/2103_skyhunter_1800 b/ROMFS/px4fmu_common/init.d/2103_skyhunter_1800 index 2433ab4f40..133ffe5722 100644 --- a/ROMFS/px4fmu_common/init.d/2103_skyhunter_1800 +++ b/ROMFS/px4fmu_common/init.d/2103_skyhunter_1800 @@ -1,4 +1,19 @@ #!nsh +# +# @name Skyhunter 1800 +# +# @type Standard Plane +# +# @output MAIN1 aileron +# @output MAIN2 elevator +# @output MAIN4 throttle +# +# @output AUX1 feed-through of RC AUX1 channel +# @output AUX2 feed-through of RC AUX2 channel +# @output AUX3 feed-through of RC AUX3 channel +# +# @maintainer Lorenz Meier +# sh /etc/init.d/rc.fw_defaults From afd5c56c16809b43b8c4a9b0c523f615b2362093 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:22:28 +0200 Subject: [PATCH 080/174] Add meta info to camflyer config --- ROMFS/px4fmu_common/init.d/3030_io_camflyer | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ROMFS/px4fmu_common/init.d/3030_io_camflyer b/ROMFS/px4fmu_common/init.d/3030_io_camflyer index 9fe5002de9..7452ed708e 100644 --- a/ROMFS/px4fmu_common/init.d/3030_io_camflyer +++ b/ROMFS/px4fmu_common/init.d/3030_io_camflyer @@ -1,4 +1,21 @@ #!nsh +# +# @name IO Camflyer +# +# @url https://pixhawk.org/platforms/planes/z-84_wing_wing +# +# @type Flying Wing +# +# @output MAIN1 left aileron +# @output MAIN2 right aileron +# @output MAIN4 throttle +# +# @output AUX1 feed-through of RC AUX1 channel +# @output AUX2 feed-through of RC AUX2 channel +# @output AUX3 feed-through of RC AUX3 channel +# +# @maintainer Simon Wilks +# sh /etc/init.d/rc.fw_defaults From 2d5bfae6471399fae5fecdedd2ea2a2a7b108f50 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:22:41 +0200 Subject: [PATCH 081/174] Add meta info to phantom config --- ROMFS/px4fmu_common/init.d/3031_phantom | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/3031_phantom b/ROMFS/px4fmu_common/init.d/3031_phantom index 43db1ed6de..84d9a9f39e 100644 --- a/ROMFS/px4fmu_common/init.d/3031_phantom +++ b/ROMFS/px4fmu_common/init.d/3031_phantom @@ -1,8 +1,20 @@ #!nsh # -# Phantom FPV Flying Wing +# @name Phantom FPV Flying Wing # -# Simon Wilks +# @url https://pixhawk.org/platforms/planes/z-84_wing_wing +# +# @type Flying Wing +# +# @output MAIN1 left aileron +# @output MAIN2 right aileron +# @output MAIN4 throttle +# +# @output AUX1 feed-through of RC AUX1 channel +# @output AUX2 feed-through of RC AUX2 channel +# @output AUX3 feed-through of RC AUX3 channel +# +# @maintainer Simon Wilks # sh /etc/init.d/rc.fw_defaults From 272a719f182d33f1004bd52af0a908d4fb894782 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:29:10 +0200 Subject: [PATCH 082/174] Add meta info to X5 config --- ROMFS/px4fmu_common/init.d/3032_skywalker_x5 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/3032_skywalker_x5 b/ROMFS/px4fmu_common/init.d/3032_skywalker_x5 index 4950c3183f..d39afccf52 100644 --- a/ROMFS/px4fmu_common/init.d/3032_skywalker_x5 +++ b/ROMFS/px4fmu_common/init.d/3032_skywalker_x5 @@ -1,8 +1,20 @@ #!nsh # -# Skywalker X5 Flying Wing +# @name Skywalker X5 Flying Wing # -# Thomas Gubler , Julian Oes +# @url https://pixhawk.org/platforms/planes/z-84_wing_wing +# +# @type Flying Wing +# +# @output MAIN1 left aileron +# @output MAIN2 right aileron +# @output MAIN4 throttle +# +# @output AUX1 feed-through of RC AUX1 channel +# @output AUX2 feed-through of RC AUX2 channel +# @output AUX3 feed-through of RC AUX3 channel +# +# @maintainer Thomas Gubler , Julian Oes # sh /etc/init.d/rc.fw_defaults From 670257868e8411924ec10c7702761c04db5f82b7 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:29:25 +0200 Subject: [PATCH 083/174] Add meta info to wing wing config --- ROMFS/px4fmu_common/init.d/3033_wingwing | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/3033_wingwing b/ROMFS/px4fmu_common/init.d/3033_wingwing index 3c2312fc7d..25a14312f3 100644 --- a/ROMFS/px4fmu_common/init.d/3033_wingwing +++ b/ROMFS/px4fmu_common/init.d/3033_wingwing @@ -1,8 +1,20 @@ #!nsh # -# Wing Wing (aka Z-84) Flying Wing +# @name Wing Wing (aka Z-84) Flying Wing # -# Simon Wilks +# @url https://pixhawk.org/platforms/planes/z-84_wing_wing +# +# @type Flying Wing +# +# @output MAIN1 left aileron +# @output MAIN2 right aileron +# @output MAIN4 throttle +# +# @output AUX1 feed-through of RC AUX1 channel +# @output AUX2 feed-through of RC AUX2 channel +# @output AUX3 feed-through of RC AUX3 channel +# +# @maintainer Simon Wilks # sh /etc/init.d/rc.fw_defaults From 14db4e512edcf2c91f4ca3b14d310e714aa7849f Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:40:20 +0200 Subject: [PATCH 084/174] Add meta info to FX79 config --- ROMFS/px4fmu_common/init.d/3034_fx79 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/3034_fx79 b/ROMFS/px4fmu_common/init.d/3034_fx79 index 9f45c636b0..353da2ffc4 100644 --- a/ROMFS/px4fmu_common/init.d/3034_fx79 +++ b/ROMFS/px4fmu_common/init.d/3034_fx79 @@ -1,8 +1,10 @@ #!nsh # -# FX-79 Buffalo Flying Wing +# @name FX-79 Buffalo Flying Wing # -# Simon Wilks +# @type Flying Wing +# +# @maintainer Simon Wilks # sh /etc/init.d/rc.fw_defaults From 3ca6f26cc6d2fe601a05ba705301129bf2213be0 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:40:32 +0200 Subject: [PATCH 085/174] Add meta info to Viper config --- ROMFS/px4fmu_common/init.d/3035_viper | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/3035_viper b/ROMFS/px4fmu_common/init.d/3035_viper index 0f5f5502aa..c216abf7b2 100644 --- a/ROMFS/px4fmu_common/init.d/3035_viper +++ b/ROMFS/px4fmu_common/init.d/3035_viper @@ -1,8 +1,11 @@ +# #!nsh # -# Viper +# @name Viper # -# Simon Wilks +# @type Flying Wing +# +# @maintainer Simon Wilks # sh /etc/init.d/rc.fw_defaults From 6505cdfd943b4c1ff3bb2f10107781bb9cbb8b5f Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:40:44 +0200 Subject: [PATCH 086/174] Add meta info to Caipi config --- ROMFS/px4fmu_common/init.d/3100_tbs_caipirinha | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/3100_tbs_caipirinha b/ROMFS/px4fmu_common/init.d/3100_tbs_caipirinha index 4f3c593cab..5aa004db1b 100644 --- a/ROMFS/px4fmu_common/init.d/3100_tbs_caipirinha +++ b/ROMFS/px4fmu_common/init.d/3100_tbs_caipirinha @@ -1,8 +1,10 @@ #!nsh # -# TBS Caipirinha +# @name TBS Caipirinha # -# Lorenz Meier +# @type Flying Wing +# +# @maintainer Lorenz Meier # sh /etc/init.d/rc.fw_defaults From dd5efcbe0dcddaff1bc9f959c6177da90a614208 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:40:58 +0200 Subject: [PATCH 087/174] Add meta info to quad X config --- ROMFS/px4fmu_common/init.d/4001_quad_x | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/4001_quad_x b/ROMFS/px4fmu_common/init.d/4001_quad_x index e0538160f0..8f7c8da356 100644 --- a/ROMFS/px4fmu_common/init.d/4001_quad_x +++ b/ROMFS/px4fmu_common/init.d/4001_quad_x @@ -1,8 +1,14 @@ #!nsh # -# Generic 10" Quad X geometry +# @name Generic Quadrotor X config # -# Lorenz Meier +# @type Quadrotor x +# +# @output AUX1 feed-through of RC AUX1 channel +# @output AUX2 feed-through of RC AUX2 channel +# @output AUX3 feed-through of RC AUX3 channel +# +# @maintainer Lorenz Meier # sh /etc/init.d/rc.mc_defaults From 10b4401d403779c774c9d8747ccc5e6ed3767aee Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:41:11 +0200 Subject: [PATCH 088/174] Add meta info to AR.Drone config --- ROMFS/px4fmu_common/init.d/4008_ardrone | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ROMFS/px4fmu_common/init.d/4008_ardrone b/ROMFS/px4fmu_common/init.d/4008_ardrone index c3358ef4c8..9d3e4427be 100644 --- a/ROMFS/px4fmu_common/init.d/4008_ardrone +++ b/ROMFS/px4fmu_common/init.d/4008_ardrone @@ -1,6 +1,10 @@ #!nsh # -# ARDrone +# @name AR.Drone Frame +# +# @type Quadrotor x +# +# @maintainer Lorenz Meier # sh /etc/init.d/rc.mc_defaults From 6aef84dd561b31c4b1e146125399d7cd5ba74568 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:42:46 +0200 Subject: [PATCH 089/174] F330: Add meta info --- ROMFS/px4fmu_common/init.d/4010_dji_f330 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/4010_dji_f330 b/ROMFS/px4fmu_common/init.d/4010_dji_f330 index a530d75ba9..4303320ffe 100644 --- a/ROMFS/px4fmu_common/init.d/4010_dji_f330 +++ b/ROMFS/px4fmu_common/init.d/4010_dji_f330 @@ -1,8 +1,14 @@ #!nsh # -# DJI Flame Wheel F330 +# @name DJI Flame Wheel F330 # -# Anton Babushkin +# @type Quadrotor x +# +# @output AUX1 feed-through of RC AUX1 channel +# @output AUX2 feed-through of RC AUX2 channel +# @output AUX3 feed-through of RC AUX3 channel +# +# @maintainer Lorenz Meier # sh /etc/init.d/4001_quad_x From ae13c105b9ad7c6f0af59ac6b27b68920fa0514a Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:42:59 +0200 Subject: [PATCH 090/174] Add meta info to F450 config --- ROMFS/px4fmu_common/init.d/4011_dji_f450 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/4011_dji_f450 b/ROMFS/px4fmu_common/init.d/4011_dji_f450 index dafa3bf7bf..55e5237945 100644 --- a/ROMFS/px4fmu_common/init.d/4011_dji_f450 +++ b/ROMFS/px4fmu_common/init.d/4011_dji_f450 @@ -1,8 +1,14 @@ #!nsh # -# DJI Flame Wheel F450 +# @name DJI Flame Wheel F450 # -# Lorenz Meier +# @type Quadrotor x +# +# @output AUX1 feed-through of RC AUX1 channel +# @output AUX2 feed-through of RC AUX2 channel +# @output AUX3 feed-through of RC AUX3 channel +# +# @maintainer Lorenz Meier # sh /etc/init.d/4001_quad_x From ed5431ea827c5309eabce09c05a54572acd72ac8 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:43:15 +0200 Subject: [PATCH 091/174] Add meta info to Quad CAN config --- ROMFS/px4fmu_common/init.d/4012_quad_x_can | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/4012_quad_x_can b/ROMFS/px4fmu_common/init.d/4012_quad_x_can index c6341a4f74..1ffffea22b 100644 --- a/ROMFS/px4fmu_common/init.d/4012_quad_x_can +++ b/ROMFS/px4fmu_common/init.d/4012_quad_x_can @@ -1,8 +1,10 @@ #!nsh # -# F450-sized quadrotor with CAN +# @name F450-sized quadrotor with CAN # -# Pavel Kirienko +# @type Quadrotor x +# +# @maintainer Pavel Kirienko # sh /etc/init.d/4001_quad_x From 02c439c557021e3c7b5876c9f35bf71ad7d80658 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:43:37 +0200 Subject: [PATCH 092/174] XML output: Inject image paths for GCS presentation --- Tools/px4airframes/xmlout.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Tools/px4airframes/xmlout.py b/Tools/px4airframes/xmlout.py index e295f091f8..f5d254bbc0 100644 --- a/Tools/px4airframes/xmlout.py +++ b/Tools/px4airframes/xmlout.py @@ -27,6 +27,28 @@ class XMLOutput(): for group in groups: xml_group = ET.SubElement(xml_parameters, "airframe_group") xml_group.attrib["name"] = group.GetName() + if (group.GetName() == "Standard Plane"): + xml_group.attrib["image"] = "AirframeStandardPlane.png" + elif (group.GetName() == "Flying Wing"): + xml_group.attrib["image"] = "AirframeFlyingWing.png" + elif (group.GetName() == "Quadrotor x"): + xml_group.attrib["image"] = "AirframeQuadRotorX.png" + elif (group.GetName() == "Quadrotor +"): + xml_group.attrib["image"] = "AirframeQuadRotorPlus.png" + elif (group.GetName() == "Hexa x"): + xml_group.attrib["image"] = "AirframeHexaRotorX.png" + elif (group.GetName() == "Hexa +"): + xml_group.attrib["image"] = "AirframeHexaRotorPlus.png" + elif (group.GetName() == "Octo +"): + xml_group.attrib["image"] = "AirframeOctoRotorPlus.png" + elif (group.GetName() == "Octo X"): + xml_group.attrib["image"] = "AirframeOctoRotorX.png" + elif (group.GetName() == "Quadrotor H"): + xml_group.attrib["image"] = "AirframeQuadRotorH.png" + elif (group.GetName() == "Simulation"): + xml_group.attrib["image"] = "AirframeSimulation.png" + else: + xml_group.attrib["image"] = "AirframeStandardPlane.png" for param in group.GetParams(): if (last_param_name == param.GetName() and not board_specific_param_set) or last_param_name != param.GetName(): xml_param = ET.SubElement(xml_group, "airframe") From 07830ffaff822f982b9ae779cc60faec775f447b Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:44:35 +0200 Subject: [PATCH 093/174] Build system: Enable airframe XML generation and checking --- makefiles/firmware.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefiles/firmware.mk b/makefiles/firmware.mk index 5163a4c9f3..8ab53089ed 100644 --- a/makefiles/firmware.mk +++ b/makefiles/firmware.mk @@ -496,7 +496,7 @@ $(PRODUCT_BUNDLE): $(PRODUCT_BIN) @$(ECHO) %% Generating $@ ifdef GEN_PARAM_XML $(Q) $(PYTHON) $(PX4_BASE)/Tools/px_process_params.py --src-path $(PX4_BASE)/src --board CONFIG_ARCH_BOARD_$(CONFIG_BOARD) --xml - $(Q) $(COPY) $(PX4_BASE)/Tools/airframes.xml $(WORK_DIR)/airframes.xml + $(Q) $(PYTHON) $(PX4_BASE)/Tools/px_process_airframes.py -a $(PX4_BASE)/ROMFS/px4fmu_common/init.d --board CONFIG_ARCH_BOARD_$(CONFIG_BOARD) --xml $(Q) $(MKFW) --prototype $(IMAGE_DIR)/$(BOARD).prototype \ --git_identity $(PX4_BASE) \ --parameter_xml $(PRODUCT_PARAMXML) \ From cfd43f0045787def029950ca0b3d4237fb8f71d6 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:44:52 +0200 Subject: [PATCH 094/174] Add quad + tailsitter config --- .../init.d/13004_quad+_tailsitter | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 ROMFS/px4fmu_common/init.d/13004_quad+_tailsitter diff --git a/ROMFS/px4fmu_common/init.d/13004_quad+_tailsitter b/ROMFS/px4fmu_common/init.d/13004_quad+_tailsitter new file mode 100644 index 0000000000..672a809354 --- /dev/null +++ b/ROMFS/px4fmu_common/init.d/13004_quad+_tailsitter @@ -0,0 +1,23 @@ +#!nsh +# +# @name Quadrotor + Tailsitter +# +# Generic configuration file for a tailsitter with motors in X configuration. +# +# @type VTOL Tailsitter +# +# @maintainer Roman Bapst +# + +sh /etc/init.d/rc.vtol_defaults + +set MIXER quad_+_vtol + +set PWM_OUT 1234 +set PWM_MAX 2000 +set PWM_RATE 400 +set MAV_TYPE 20 +param set VT_MOT_COUNT 4 +param set VT_IDLE_PWM_MC 1080 +param set VT_TYPE 0 +param set VT_ELEV_MC_LOCK 1 From c5e3aab083158a43b688507bdfd40fa002df1ab7 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:45:09 +0200 Subject: [PATCH 095/174] Add VTOL + tailsitter mixer --- .../px4fmu_common/mixers/quad_+_vtol.main.mix | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 ROMFS/px4fmu_common/mixers/quad_+_vtol.main.mix diff --git a/ROMFS/px4fmu_common/mixers/quad_+_vtol.main.mix b/ROMFS/px4fmu_common/mixers/quad_+_vtol.main.mix new file mode 100644 index 0000000000..1f79661f9a --- /dev/null +++ b/ROMFS/px4fmu_common/mixers/quad_+_vtol.main.mix @@ -0,0 +1,28 @@ +Mixer for Tailsitter with + motor configuration and elevons +=========================================================== + +This file defines a single mixer for tailsitter with motors in X configuration. All controls +are mixed 100%. + +R: 4+ 10000 10000 10000 0 + +# mixer for the elevons +M: 2 +O: 10000 10000 0 -10000 10000 +S: 1 0 10000 10000 0 -10000 10000 +S: 1 1 10000 10000 0 -10000 10000 + +M: 2 +O: 10000 10000 0 -10000 10000 +S: 1 0 10000 10000 0 -10000 10000 +S: 1 1 -10000 -10000 0 -10000 10000 + +# mixer for canard surface +M: 2 +O: 10000 10000 0 -10000 10000 +S: 1 1 -10000 -10000 0 -10000 10000 + +# mixer for rudder +M: 2 +O: 10000 10000 0 -10000 10000 +S: 1 2 -10000 -10000 0 -10000 10000 From 4221fd5f120f878ad475ae33b0f5a004a8236446 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 19:45:24 +0200 Subject: [PATCH 096/174] Add tailsitter to autostart --- ROMFS/px4fmu_common/init.d/rc.autostart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ROMFS/px4fmu_common/init.d/rc.autostart b/ROMFS/px4fmu_common/init.d/rc.autostart index ec405accac..0bb66a4b49 100644 --- a/ROMFS/px4fmu_common/init.d/rc.autostart +++ b/ROMFS/px4fmu_common/init.d/rc.autostart @@ -282,6 +282,14 @@ then sh /etc/init.d/13003_quad_tailsitter fi +# +# Tailsitter with 4 motors in + config +# +if param compare SYS_AUTOSTART 13004 +then + sh /etc/init.d/13004_quad+_tailsitter +fi + # # TriCopter Y Yaw+ # From 82543e1b16029c41a363ba672d892d587a03004c Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 21:21:37 +0200 Subject: [PATCH 097/174] Easystar config: fix space --- ROMFS/px4fmu_common/init.d/1000_rc_fw_easystar.hil | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ROMFS/px4fmu_common/init.d/1000_rc_fw_easystar.hil b/ROMFS/px4fmu_common/init.d/1000_rc_fw_easystar.hil index 242fc0d81d..7938c47bae 100644 --- a/ROMFS/px4fmu_common/init.d/1000_rc_fw_easystar.hil +++ b/ROMFS/px4fmu_common/init.d/1000_rc_fw_easystar.hil @@ -9,7 +9,7 @@ # @output MAIN3 rudder # @output MAIN4 throttle # -# @maintainer Lorenz Meier +# @maintainer Lorenz Meier # sh /etc/init.d/rc.fw_defaults From c2eb194ef6d9714741007e7c74183b74356fb0ec Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 21:21:59 +0200 Subject: [PATCH 098/174] Camflyer config: Fix URL --- ROMFS/px4fmu_common/init.d/3030_io_camflyer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ROMFS/px4fmu_common/init.d/3030_io_camflyer b/ROMFS/px4fmu_common/init.d/3030_io_camflyer index 7452ed708e..a15d0ac6d0 100644 --- a/ROMFS/px4fmu_common/init.d/3030_io_camflyer +++ b/ROMFS/px4fmu_common/init.d/3030_io_camflyer @@ -2,7 +2,7 @@ # # @name IO Camflyer # -# @url https://pixhawk.org/platforms/planes/z-84_wing_wing +# @url https://pixhawk.org/platforms/planes/bormatec_camflyer_q # # @type Flying Wing # From 63901a2cde3a5134f4bd32be4d8dd5058c49c403 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 21:22:14 +0200 Subject: [PATCH 099/174] Skywalker config: Fix URL --- ROMFS/px4fmu_common/init.d/3032_skywalker_x5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ROMFS/px4fmu_common/init.d/3032_skywalker_x5 b/ROMFS/px4fmu_common/init.d/3032_skywalker_x5 index d39afccf52..3dedf8170d 100644 --- a/ROMFS/px4fmu_common/init.d/3032_skywalker_x5 +++ b/ROMFS/px4fmu_common/init.d/3032_skywalker_x5 @@ -2,7 +2,7 @@ # # @name Skywalker X5 Flying Wing # -# @url https://pixhawk.org/platforms/planes/z-84_wing_wing +# @url https://pixhawk.org/platforms/planes/skywalker_x5 # # @type Flying Wing # From a0b792792fad925641aacbb3c03a62bb1ce732ef Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Wed, 29 Jul 2015 21:22:41 +0200 Subject: [PATCH 100/174] Airframe config parser: Move to combined elif statement --- Tools/px4airframes/srcparser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/px4airframes/srcparser.py b/Tools/px4airframes/srcparser.py index 7b6def6834..130b0f24cf 100644 --- a/Tools/px4airframes/srcparser.py +++ b/Tools/px4airframes/srcparser.py @@ -241,9 +241,9 @@ class SourceParser(object): for tag in tags: if tag == "maintainer": maintainer = tags[tag] - if tag == "type": + elif tag == "type": airframe_type = tags[tag] - if tag == "name": + elif tag == "name": airframe_name = tags[tag] elif tag not in self.valid_tags: sys.stderr.write("Aborting due to invalid documentation tag: '%s'\n" % tag) From 2bdf76eeabf3e8b0637d11f75d943221a9b29958 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Thu, 30 Jul 2015 15:59:42 +0200 Subject: [PATCH 101/174] Fix typo for Quad + mixer --- ROMFS/px4fmu_common/mixers/quad_+_vtol.main.mix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/mixers/quad_+_vtol.main.mix b/ROMFS/px4fmu_common/mixers/quad_+_vtol.main.mix index 1f79661f9a..3021221d80 100644 --- a/ROMFS/px4fmu_common/mixers/quad_+_vtol.main.mix +++ b/ROMFS/px4fmu_common/mixers/quad_+_vtol.main.mix @@ -18,11 +18,11 @@ S: 1 0 10000 10000 0 -10000 10000 S: 1 1 -10000 -10000 0 -10000 10000 # mixer for canard surface -M: 2 +M: 1 O: 10000 10000 0 -10000 10000 S: 1 1 -10000 -10000 0 -10000 10000 # mixer for rudder -M: 2 +M: 1 O: 10000 10000 0 -10000 10000 S: 1 2 -10000 -10000 0 -10000 10000 From 844c37e7ea1e157a5e25ceab621f059c07c52908 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 11:27:43 +0200 Subject: [PATCH 102/174] Remove static airframe xml file --- Tools/airframes.xml | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 Tools/airframes.xml diff --git a/Tools/airframes.xml b/Tools/airframes.xml deleted file mode 100644 index 1a68e23878..0000000000 --- a/Tools/airframes.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - 1 - - - - - - - - - - From ac0e645ab6371cf66408aabb465580edaf1054c8 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 11:28:10 +0200 Subject: [PATCH 103/174] XML out: Fix mapping of image file names --- Tools/px4airframes/xmlout.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Tools/px4airframes/xmlout.py b/Tools/px4airframes/xmlout.py index f5d254bbc0..a70e5dfbd7 100644 --- a/Tools/px4airframes/xmlout.py +++ b/Tools/px4airframes/xmlout.py @@ -35,14 +35,16 @@ class XMLOutput(): xml_group.attrib["image"] = "AirframeQuadRotorX.png" elif (group.GetName() == "Quadrotor +"): xml_group.attrib["image"] = "AirframeQuadRotorPlus.png" - elif (group.GetName() == "Hexa x"): + elif (group.GetName() == "Hexarotor x"): xml_group.attrib["image"] = "AirframeHexaRotorX.png" - elif (group.GetName() == "Hexa +"): + elif (group.GetName() == "Hexarotor +"): xml_group.attrib["image"] = "AirframeHexaRotorPlus.png" - elif (group.GetName() == "Octo +"): + elif (group.GetName() == "Octorotor +"): xml_group.attrib["image"] = "AirframeOctoRotorPlus.png" - elif (group.GetName() == "Octo X"): + elif (group.GetName() == "Octorotor x"): xml_group.attrib["image"] = "AirframeOctoRotorX.png" + elif (group.GetName() == "Quadrotor Wide"): + xml_group.attrib["image"] = "AirframeQuadRotorH.png" elif (group.GetName() == "Quadrotor H"): xml_group.attrib["image"] = "AirframeQuadRotorH.png" elif (group.GetName() == "Simulation"): From fde0c65d7749a1a951a1dc3389c2d1dcfba2d09d Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 12:10:31 +0200 Subject: [PATCH 104/174] Airframe generator: Also generate autostart listing --- Tools/px4airframes/__init__.py | 2 +- Tools/px4airframes/rcout.py | 55 +++++++++++++++++++++++++++++++++ Tools/px4airframes/srcparser.py | 8 +++-- Tools/px4airframes/xmlout.py | 2 +- Tools/px_process_airframes.py | 14 +++++++-- 5 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 Tools/px4airframes/rcout.py diff --git a/Tools/px4airframes/__init__.py b/Tools/px4airframes/__init__.py index 3a9f1e2c6d..43e82d2643 100644 --- a/Tools/px4airframes/__init__.py +++ b/Tools/px4airframes/__init__.py @@ -1 +1 @@ -__all__ = ["srcscanner", "srcparser", "xmlout", "dokuwikiout", "dokuwikirpc"] \ No newline at end of file +__all__ = ["srcscanner", "srcparser", "xmlout", "rcout"] \ No newline at end of file diff --git a/Tools/px4airframes/rcout.py b/Tools/px4airframes/rcout.py new file mode 100644 index 0000000000..83bd047560 --- /dev/null +++ b/Tools/px4airframes/rcout.py @@ -0,0 +1,55 @@ +from xml.sax.saxutils import escape +import codecs + +class RCOutput(): + def __init__(self, groups, board): + result = ( "#\n" + "#\n" + "# THIS FILE IS AUTO-GENERATED. DO NOT EDIT!\n" + "#\n" + "#\n" + "# SYS_AUTOSTART = 0 means no autostart (default)\n" + "#\n" + "# AUTOSTART PARTITION:\n" + "# 0 .. 999 Reserved (historical)\n" + "# 1000 .. 1999 Simulation setups\n" + "# 2000 .. 2999 Standard planes\n" + "# 3000 .. 3999 Flying wing\n" + "# 4000 .. 4999 Quadrotor x\n" + "# 5000 .. 5999 Quadrotor +\n" + "# 6000 .. 6999 Hexarotor x\n" + "# 7000 .. 7999 Hexarotor +\n" + "# 8000 .. 8999 Octorotor x\n" + "# 9000 .. 9999 Octorotor +\n" + "# 10000 .. 10999 Quadrotor Wide arm / H frame\n" + "# 11000 .. 11999 Hexa Cox\n" + "# 12000 .. 12999 Octo Cox\n" + "# 13000 .. 13999 VTOL\n" + "# 14000 .. 14999 Tri Y\n" + "\n") + for group in groups: + result += "# GROUP: %s \n\n" % group.GetName() + for param in group.GetParams(): + name = param.GetName() + path = param.GetPath().rsplit('/', 1)[1] + id_val = param.GetId() + name = param.GetFieldValue("short_desc") + long_desc = param.GetFieldValue("long_desc") + + result += "#\n" + result += "# %s\n" % name + result += "if param compare SYS_AUTOSTART %s\n" % id_val + result += "then\n" + result += " sh /etc/init.d/%s\n" % path + result += "fi\n" + + #if long_desc is not None: + # result += "# %s\n" % long_desc + result += "\n" + + result += "\n" + self.output = result; + + def Save(self, filename): + with codecs.open(filename, 'w', 'utf-8') as f: + f.write(self.output) diff --git a/Tools/px4airframes/srcparser.py b/Tools/px4airframes/srcparser.py index 130b0f24cf..699a2cdc3b 100644 --- a/Tools/px4airframes/srcparser.py +++ b/Tools/px4airframes/srcparser.py @@ -46,14 +46,18 @@ class Parameter(object): # all others == 0 (sorted alphabetically) } - def __init__(self, name, airframe_type, airframe_id, maintainer): + def __init__(self, path, name, airframe_type, airframe_id, maintainer): self.fields = {} self.outputs = {} + self.path = path self.name = name self.type = airframe_type self.id = airframe_id self.maintainer = maintainer + def GetPath(self): + return self.path + def GetName(self): return self.name @@ -259,7 +263,7 @@ class SourceParser(object): return False # We already know this is an airframe config, so add it - param = Parameter(airframe_name, airframe_type, airframe_id, maintainer) + param = Parameter(path, airframe_name, airframe_type, airframe_id, maintainer) # Done with file, store for tag in tags: diff --git a/Tools/px4airframes/xmlout.py b/Tools/px4airframes/xmlout.py index a70e5dfbd7..427b1090a2 100644 --- a/Tools/px4airframes/xmlout.py +++ b/Tools/px4airframes/xmlout.py @@ -50,7 +50,7 @@ class XMLOutput(): elif (group.GetName() == "Simulation"): xml_group.attrib["image"] = "AirframeSimulation.png" else: - xml_group.attrib["image"] = "AirframeStandardPlane.png" + xml_group.attrib["image"] = "" for param in group.GetParams(): if (last_param_name == param.GetName() and not board_specific_param_set) or last_param_name != param.GetName(): xml_param = ET.SubElement(xml_group, "airframe") diff --git a/Tools/px_process_airframes.py b/Tools/px_process_airframes.py index 50aaa699ef..7d7d28a2b2 100755 --- a/Tools/px_process_airframes.py +++ b/Tools/px_process_airframes.py @@ -46,7 +46,7 @@ from __future__ import print_function import sys import os import argparse -from px4airframes import srcscanner, srcparser, xmlout +from px4airframes import srcscanner, srcparser, xmlout, rcout def main(): # Parse command line arguments @@ -61,6 +61,11 @@ def main(): metavar="FILENAME", help="Create XML file" " (default FILENAME: airframes.xml)") + parser.add_argument("-s", "--start-script", + nargs='?', + const="rc.autostart", + metavar="FILENAME", + help="Create start script file") parser.add_argument("-b", "--board", nargs='?', const="", @@ -69,7 +74,7 @@ def main(): args = parser.parse_args() # Check for valid command - if not (args.xml): + if not (args.xml) and not (args.start_script): print("Error: You need to specify at least one output method!\n") parser.print_usage() sys.exit(1) @@ -93,6 +98,11 @@ def main(): out = xmlout.XMLOutput(param_groups, args.board) out.Save(args.xml) + if args.start_script: + print("Creating start script " + args.start_script) + out = rcout.RCOutput(param_groups, args.board) + out.Save(args.start_script) + print("All done!") From d26cb08b3bdf4618600f3fa191587181e7ae9f95 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 12:10:56 +0200 Subject: [PATCH 105/174] Firmware makefile: Generate autostart listing automatically --- makefiles/firmware.mk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/makefiles/firmware.mk b/makefiles/firmware.mk index 8ab53089ed..0aff25cfea 100644 --- a/makefiles/firmware.mk +++ b/makefiles/firmware.mk @@ -350,6 +350,9 @@ ROMFS_OBJ = $(ROMFS_CSRC:.c=.o) LIBS += $(ROMFS_OBJ) LINK_DEPS += $(ROMFS_OBJ) +# Add autostart script +ROMFS_AUTOSTART = $(PX4_BASE)/Tools/px_process_airframes.py + # Remove all comments from startup and mixer files ROMFS_PRUNER = $(PX4_BASE)/Tools/px_romfs_pruner.py @@ -372,6 +375,10 @@ ifneq ($(ROMFS_EXTRA_FILES),) $(Q) $(MKDIR) -p $(ROMFS_SCRATCH)/extras $(Q) $(COPY) $(ROMFS_EXTRA_FILES) $(ROMFS_SCRATCH)/extras endif + $(Q) $(PYTHON) -u $(ROMFS_AUTOSTART) -a $(ROMFS_ROOT)/init.d -s $(ROMFS_SCRATCH)/init.d/rc.autostart + # Execute in standard dir as well + # so developers notice the generated file + $(Q) $(PYTHON) -u $(ROMFS_AUTOSTART) -a $(ROMFS_ROOT)/init.d -s $(ROMFS_ROOT)/init.d/rc.autostart $(Q) $(PYTHON) -u $(ROMFS_PRUNER) --folder $(ROMFS_SCRATCH) EXTRA_CLEANS += $(ROMGS_OBJ) $(ROMFS_IMG) From af2f3547ce7390500f0dffdd71b5311d1be0940e Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 12:11:12 +0200 Subject: [PATCH 106/174] Disco config: Documentation fixes --- ROMFS/px4fmu_common/init.d/10015_tbs_discovery | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ROMFS/px4fmu_common/init.d/10015_tbs_discovery b/ROMFS/px4fmu_common/init.d/10015_tbs_discovery index ce5e1c71dc..2058d10091 100644 --- a/ROMFS/px4fmu_common/init.d/10015_tbs_discovery +++ b/ROMFS/px4fmu_common/init.d/10015_tbs_discovery @@ -1,6 +1,6 @@ #!nsh # -# @name Team Blacksheep Discovery Quadcopter +# @name Team Blacksheep Discovery # # @type Quadrotor Wide # From e71c7611f83e438b89a98a2a1892b7e77d922af6 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 12:11:26 +0200 Subject: [PATCH 107/174] TBS config: Doc fixes --- ROMFS/px4fmu_common/init.d/10018_tbs_endurance | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/10018_tbs_endurance b/ROMFS/px4fmu_common/init.d/10018_tbs_endurance index fd74e17807..e26e2a8105 100644 --- a/ROMFS/px4fmu_common/init.d/10018_tbs_endurance +++ b/ROMFS/px4fmu_common/init.d/10018_tbs_endurance @@ -1,8 +1,6 @@ #!nsh # -# @name Team Blacksheep Discovery Long Range Quadcopter -# -# Setup: 15 x 5" Props, 6S 4000mAh TBS LiPo, TBS 30A ESCs, TBS 400kV Motors +# @name Team Blacksheep Discovery Endurance # # @type Quadrotor Wide # From f4c9e4db14c21ae9c3c8a10586a8619deee08278 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 12:11:39 +0200 Subject: [PATCH 108/174] Hexa config: Doc fixes --- ROMFS/px4fmu_common/init.d/11001_hexa_cox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ROMFS/px4fmu_common/init.d/11001_hexa_cox b/ROMFS/px4fmu_common/init.d/11001_hexa_cox index 16d34ecab6..f85b06f87d 100644 --- a/ROMFS/px4fmu_common/init.d/11001_hexa_cox +++ b/ROMFS/px4fmu_common/init.d/11001_hexa_cox @@ -4,7 +4,7 @@ # # @type Hexarotor Coaxial # -# Lorenz Meier +# @maintainer Lorenz Meier # sh /etc/init.d/rc.mc_defaults From a1431d5e209308010ddc44f4986151c19c78daa5 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 12:11:54 +0200 Subject: [PATCH 109/174] Caipi config: Doc fixes --- ROMFS/px4fmu_common/init.d/13001_caipirinha_vtol | 2 -- 1 file changed, 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/13001_caipirinha_vtol b/ROMFS/px4fmu_common/init.d/13001_caipirinha_vtol index e9f48d401b..a9e7ff35b2 100644 --- a/ROMFS/px4fmu_common/init.d/13001_caipirinha_vtol +++ b/ROMFS/px4fmu_common/init.d/13001_caipirinha_vtol @@ -2,8 +2,6 @@ # # @name Duorotor Tailsitter # -# Generic configuration file for a tailsitter with motors in tandem configuration. -# # @type VTOL Tailsitter # # @maintainer Roman Bapst From 096f77835ae23e9b1f855d19c30985d5671dfc97 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 12:12:11 +0200 Subject: [PATCH 110/174] Quad tailsitter config: Doc fixes --- ROMFS/px4fmu_common/init.d/13003_quad_tailsitter | 2 -- 1 file changed, 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/13003_quad_tailsitter b/ROMFS/px4fmu_common/init.d/13003_quad_tailsitter index b41ad749cf..016f13816f 100644 --- a/ROMFS/px4fmu_common/init.d/13003_quad_tailsitter +++ b/ROMFS/px4fmu_common/init.d/13003_quad_tailsitter @@ -2,8 +2,6 @@ # # @name Quadrotor X Tailsitter # -# Generic configuration file for a tailsitter with motors in X configuration. -# # @type VTOL Tailsitter # # @maintainer Roman Bapst From 0fe58f1dc256febbb0eab3a684f79d3a01b353f9 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 12:12:28 +0200 Subject: [PATCH 111/174] Quad + tailsitter config: Doc fixes --- ROMFS/px4fmu_common/init.d/13004_quad+_tailsitter | 2 -- 1 file changed, 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/13004_quad+_tailsitter b/ROMFS/px4fmu_common/init.d/13004_quad+_tailsitter index 672a809354..dcf2fc8679 100644 --- a/ROMFS/px4fmu_common/init.d/13004_quad+_tailsitter +++ b/ROMFS/px4fmu_common/init.d/13004_quad+_tailsitter @@ -2,8 +2,6 @@ # # @name Quadrotor + Tailsitter # -# Generic configuration file for a tailsitter with motors in X configuration. -# # @type VTOL Tailsitter # # @maintainer Roman Bapst From 30914e5a8c09233123039e6461510e45587b0b7d Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 12:12:42 +0200 Subject: [PATCH 112/174] Tri config: Doc fixes --- ROMFS/px4fmu_common/init.d/14001_tri_y_yaw+ | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/14001_tri_y_yaw+ b/ROMFS/px4fmu_common/init.d/14001_tri_y_yaw+ index 4a85405199..b4c7885dab 100644 --- a/ROMFS/px4fmu_common/init.d/14001_tri_y_yaw+ +++ b/ROMFS/px4fmu_common/init.d/14001_tri_y_yaw+ @@ -1,8 +1,6 @@ #!nsh # -# @name Generic Tricopter Y Geometry -# -# Yaw Servo +Output ==> +Yaw Vehicle Rotation +# @name Generic Tricopter Y+ Geometry # # @type Tricopter Y+ # From 73012a86e351d6c3f3d9ce65aa7912860b513f34 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 12:12:56 +0200 Subject: [PATCH 113/174] Tri - config: Doc fixes --- ROMFS/px4fmu_common/init.d/14002_tri_y_yaw- | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/14002_tri_y_yaw- b/ROMFS/px4fmu_common/init.d/14002_tri_y_yaw- index a3443e43ad..7fa0af009a 100644 --- a/ROMFS/px4fmu_common/init.d/14002_tri_y_yaw- +++ b/ROMFS/px4fmu_common/init.d/14002_tri_y_yaw- @@ -1,8 +1,6 @@ #!nsh # -# @name Generic Tricopter Y Geometry -# -# Yaw Servo +Output ==> -Yaw Vehicle Rotation +# @name Generic Tricopter Y- Geometry # # @type Tricopter Y- # From 7ba7527d49544e05946c2032e90586be7eb2c50d Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 12:13:12 +0200 Subject: [PATCH 114/174] Skywalker / 3DR Aero config: Doc fixes --- ROMFS/px4fmu_common/init.d/2102_3dr_skywalker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ROMFS/px4fmu_common/init.d/2102_3dr_skywalker b/ROMFS/px4fmu_common/init.d/2102_3dr_skywalker index e2e1b307f4..d2347c98c8 100644 --- a/ROMFS/px4fmu_common/init.d/2102_3dr_skywalker +++ b/ROMFS/px4fmu_common/init.d/2102_3dr_skywalker @@ -1,6 +1,6 @@ #!nsh # -# @name Skywalker (3DR or Generic) +# @name Skywalker (3DR Aero) # # @type Standard Plane # From a37d450bf19b688c53bf9b516442c329e1480c57 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 12:13:26 +0200 Subject: [PATCH 115/174] HK quad config: Doc fixes --- ROMFS/px4fmu_common/init.d/4020_hk_micro_pcb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/4020_hk_micro_pcb b/ROMFS/px4fmu_common/init.d/4020_hk_micro_pcb index 4fd3a50c28..a6a31a30a9 100644 --- a/ROMFS/px4fmu_common/init.d/4020_hk_micro_pcb +++ b/ROMFS/px4fmu_common/init.d/4020_hk_micro_pcb @@ -1,7 +1,6 @@ #!nsh # -# @name Hobbyking Micro Integrated PCB Quadcopter -# with SimonK ESC firmware and Mystery A1510 motors +# @name Hobbyking Micro PCB # # @type Quadrotor x # From 021417703f0b1bcd348a9913cfb8bbabd83733fc Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 12:14:46 +0200 Subject: [PATCH 116/174] Rover config: Doc fixes --- ROMFS/px4fmu_common/init.d/50001_axialracing_ax10 | 3 --- 1 file changed, 3 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/50001_axialracing_ax10 b/ROMFS/px4fmu_common/init.d/50001_axialracing_ax10 index 8b60805a2f..b3e7f0978e 100644 --- a/ROMFS/px4fmu_common/init.d/50001_axialracing_ax10 +++ b/ROMFS/px4fmu_common/init.d/50001_axialracing_ax10 @@ -4,10 +4,7 @@ # # @type Rover # -# loading default values for the axialracing ax10 -# -#load some defaults e.g. PWM values sh /etc/init.d/rc.axialracing_ax10_defaults #choose a mixer, for rover control we need a plain passthrough to the servos From 50a9e41dbd54cab17e28ee2f37ce61378db2515b Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 12:17:31 +0200 Subject: [PATCH 117/174] Fix RC out --- Tools/px4airframes/rcout.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Tools/px4airframes/rcout.py b/Tools/px4airframes/rcout.py index 83bd047560..de5af0f305 100644 --- a/Tools/px4airframes/rcout.py +++ b/Tools/px4airframes/rcout.py @@ -28,19 +28,18 @@ class RCOutput(): "# 14000 .. 14999 Tri Y\n" "\n") for group in groups: - result += "# GROUP: %s \n\n" % group.GetName() + result += "# GROUP: %s\n\n" % group.GetName() for param in group.GetParams(): - name = param.GetName() path = param.GetPath().rsplit('/', 1)[1] id_val = param.GetId() name = param.GetFieldValue("short_desc") long_desc = param.GetFieldValue("long_desc") result += "#\n" - result += "# %s\n" % name + result += "# %s\n" % param.GetName() result += "if param compare SYS_AUTOSTART %s\n" % id_val result += "then\n" - result += " sh /etc/init.d/%s\n" % path + result += "\tsh /etc/init.d/%s\n" % path result += "fi\n" #if long_desc is not None: From 193e02ebe601143100bec240508047935aa780af Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 12:19:01 +0200 Subject: [PATCH 118/174] Remove rc.autostart, as it is generated now --- ROMFS/px4fmu_common/init.d/rc.autostart | 318 ------------------------ 1 file changed, 318 deletions(-) delete mode 100644 ROMFS/px4fmu_common/init.d/rc.autostart diff --git a/ROMFS/px4fmu_common/init.d/rc.autostart b/ROMFS/px4fmu_common/init.d/rc.autostart deleted file mode 100644 index 0bb66a4b49..0000000000 --- a/ROMFS/px4fmu_common/init.d/rc.autostart +++ /dev/null @@ -1,318 +0,0 @@ -# -# SYS_AUTOSTART = 0 means no autostart (default) -# -# AUTOSTART PARTITION: -# 0 .. 999 Reserved (historical) -# 1000 .. 1999 Simulation setups -# 2000 .. 2999 Standard planes -# 3000 .. 3999 Flying wing -# 4000 .. 4999 Quad X -# 5000 .. 5999 Quad + -# 6000 .. 6999 Hexa X -# 7000 .. 7999 Hexa + -# 8000 .. 8999 Octo X -# 9000 .. 9999 Octo + -# 10000 .. 10999 Wide arm / H frame -# 11000 .. 11999 Hexa Cox -# 12000 .. 12999 Octo Cox -# 13000 .. 13999 VTOL -# 14000 .. 14999 Tri Y - -# -# Simulation -# - -if param compare SYS_AUTOSTART 901 -then - sh /etc/init.d/901_bottle_drop_test.hil - set MODE custom -fi - -if param compare SYS_AUTOSTART 1000 -then - sh /etc/init.d/1000_rc_fw_easystar.hil -fi - -if param compare SYS_AUTOSTART 1001 -then - sh /etc/init.d/1001_rc_quad_x.hil -fi - -if param compare SYS_AUTOSTART 1003 -then - sh /etc/init.d/1003_rc_quad_+.hil -fi - -if param compare SYS_AUTOSTART 1004 -then - sh /etc/init.d/1004_rc_fw_Rascal110.hil -fi - -if param compare SYS_AUTOSTART 1005 -then - sh /etc/init.d/1005_rc_fw_Malolo1.hil -fi - -# -# Plane -# - -if param compare SYS_AUTOSTART 2100 100 -then - sh /etc/init.d/2100_mpx_easystar - set MODE custom -fi - -if param compare SYS_AUTOSTART 2101 101 -then - sh /etc/init.d/2101_fw_AERT - set MODE custom -fi - -if param compare SYS_AUTOSTART 2102 102 -then - sh /etc/init.d/2102_3dr_skywalker - set MODE custom -fi - -if param compare SYS_AUTOSTART 2103 103 -then - sh /etc/init.d/2103_skyhunter_1800 - set MODE custom -fi - -if param compare SYS_AUTOSTART 2104 -then - sh /etc/init.d/2104_fw_AETR - set MODE custom -fi - -# -# Flying wing -# - -if param compare SYS_AUTOSTART 3030 30 -then - sh /etc/init.d/3030_io_camflyer -fi - -if param compare SYS_AUTOSTART 3031 31 -then - sh /etc/init.d/3031_phantom -fi - -if param compare SYS_AUTOSTART 3032 32 -then - sh /etc/init.d/3032_skywalker_x5 -fi - -if param compare SYS_AUTOSTART 3033 33 -then - sh /etc/init.d/3033_wingwing -fi - -if param compare SYS_AUTOSTART 3034 34 -then - sh /etc/init.d/3034_fx79 -fi - -if param compare SYS_AUTOSTART 3035 35 -then - sh /etc/init.d/3035_viper -fi - -if param compare SYS_AUTOSTART 3100 -then - sh /etc/init.d/3100_tbs_caipirinha -fi - -# -# Quad X -# - -if param compare SYS_AUTOSTART 4001 -then - sh /etc/init.d/4001_quad_x -fi - -# -# ARDrone -# - -if param compare SYS_AUTOSTART 4008 8 -then - sh /etc/init.d/4008_ardrone -fi - -if param compare SYS_AUTOSTART 4010 10 -then - sh /etc/init.d/4010_dji_f330 -fi - -if param compare SYS_AUTOSTART 4011 11 -then - sh /etc/init.d/4011_dji_f450 -fi - -if param compare SYS_AUTOSTART 4012 -then - sh /etc/init.d/4012_quad_x_can -fi - -if param compare SYS_AUTOSTART 4020 -then - sh /etc/init.d/4020_hk_micro_pcb -fi - -# -# Quad + -# - -if param compare SYS_AUTOSTART 5001 -then - sh /etc/init.d/5001_quad_+ -fi - -# -# Hexa X -# - -if param compare SYS_AUTOSTART 6001 -then - sh /etc/init.d/6001_hexa_x -fi - -# -# Hexa + -# - -if param compare SYS_AUTOSTART 7001 -then - sh /etc/init.d/7001_hexa_+ -fi - -# -# Octo X -# - -if param compare SYS_AUTOSTART 8001 -then - sh /etc/init.d/8001_octo_x -fi - -# -# Octo + -# - -if param compare SYS_AUTOSTART 9001 -then - sh /etc/init.d/9001_octo_+ -fi - -# -# Wide arm / H frame -# - -if param compare SYS_AUTOSTART 10015 15 -then - sh /etc/init.d/10015_tbs_discovery -fi - -if param compare SYS_AUTOSTART 10016 16 -then - sh /etc/init.d/10016_3dr_iris -fi - -if param compare SYS_AUTOSTART 10017 -then - sh /etc/init.d/10017_steadidrone_qu4d -fi - -if param compare SYS_AUTOSTART 10018 18 -then - sh /etc/init.d/10018_tbs_endurance -fi - -if param compare SYS_AUTOSTART 10019 -then - sh /etc/init.d/10019_sk450_deadcat -fi - -# -# Hexa Coaxial -# - -if param compare SYS_AUTOSTART 11001 -then - sh /etc/init.d/11001_hexa_cox -fi - -# -# Octo Coaxial -# - -if param compare SYS_AUTOSTART 12001 -then - sh /etc/init.d/12001_octo_cox -fi - -# 13000 is historically reserved for the quadshot - -# -# VTOL Caipririnha (Tailsitter) -# -if param compare SYS_AUTOSTART 13001 -then - sh /etc/init.d/13001_caipirinha_vtol -fi - -# -# VTOL BirdsEyeView FireFly x6 (Tilt-Rotor) -# -if param compare SYS_AUTOSTART 13002 -then - sh /etc/init.d/13002_firefly6 -fi - -# -# Tailsitter with 4 motors in x config -# -if param compare SYS_AUTOSTART 13003 -then - sh /etc/init.d/13003_quad_tailsitter -fi - -# -# Tailsitter with 4 motors in + config -# -if param compare SYS_AUTOSTART 13004 -then - sh /etc/init.d/13004_quad+_tailsitter -fi - -# -# TriCopter Y Yaw+ -# -if param compare SYS_AUTOSTART 14001 -then - sh /etc/init.d/14001_tri_y_yaw+ -fi - -# -# TriCopter Y Yaw- -# -if param compare SYS_AUTOSTART 14002 -then - sh /etc/init.d/14002_tri_y_yaw- -fi - - - -# -# Ground Rover AxialRacing AX10 -# -if param compare SYS_AUTOSTART 50001 -then - sh /etc/init.d/50001_axialracing_ax10 -fi - From 54ac1d9548711448a972a78d2bd0830ece23cc89 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 12:19:17 +0200 Subject: [PATCH 119/174] Add rc.autostart to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index bd835e271f..68d385950e 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,4 @@ unittests/build .vagrant *.pretty xcode +ROMFS/*/*/rc.autostart From 32b93547830fc5b5ddece760a34e44e73b521c4d Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 15:36:13 +0200 Subject: [PATCH 120/174] Accel calibration: Show better error message if cal fails --- src/modules/commander/accelerometer_calibration.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/modules/commander/accelerometer_calibration.cpp b/src/modules/commander/accelerometer_calibration.cpp index f250eef475..6c377ccfe6 100644 --- a/src/modules/commander/accelerometer_calibration.cpp +++ b/src/modules/commander/accelerometer_calibration.cpp @@ -559,6 +559,7 @@ int do_level_calibration(int mavlink_fd) { const unsigned cal_time = 5; const unsigned cal_hz = 100; const unsigned settle_time = 30; + bool success = false; int att_sub = orb_subscribe(ORB_ID(vehicle_attitude)); struct vehicle_attitude_s att; memset(&att, 0, sizeof(att)); @@ -597,7 +598,15 @@ int do_level_calibration(int mavlink_fd) { start = hrt_absolute_time(); // average attitude for 5 seconds while(hrt_elapsed_time(&start) < cal_time * 1000000) { - poll(&fds[0], (sizeof(fds) / sizeof(fds[0])), 100); + int pollret = poll(&fds[0], (sizeof(fds) / sizeof(fds[0])), 100); + + if (pollret <= 0) { + // attitude estimator is not running + mavlink_and_console_log_critical(mavlink_fd, "attitude estimator not running - check system boot"); + mavlink_and_console_log_critical(mavlink_fd, CAL_QGC_FAILED_MSG, "level"); + goto out; + } + orb_copy(ORB_ID(vehicle_attitude), att_sub, &att); roll_mean += att.roll; pitch_mean += att.pitch; @@ -606,7 +615,6 @@ int do_level_calibration(int mavlink_fd) { mavlink_and_console_log_info(mavlink_fd, CAL_QGC_PROGRESS_MSG, 100); - bool success = false; if (counter > (cal_time * cal_hz / 2 )) { roll_mean /= counter; pitch_mean /= counter; From d19718a23bc0fb757002fadc5fa50393daf7e911 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 20:05:59 +0200 Subject: [PATCH 121/174] MAVLink: Reduce default link data rates --- ROMFS/px4fmu_common/init.d/10020_3dr_quad | 37 +++++++++++++++++++++++ ROMFS/px4fmu_common/init.d/rcS | 4 +-- 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 ROMFS/px4fmu_common/init.d/10020_3dr_quad diff --git a/ROMFS/px4fmu_common/init.d/10020_3dr_quad b/ROMFS/px4fmu_common/init.d/10020_3dr_quad new file mode 100644 index 0000000000..0dbffba00f --- /dev/null +++ b/ROMFS/px4fmu_common/init.d/10020_3dr_quad @@ -0,0 +1,37 @@ +#!nsh +# +# @name 3DR Iris Quadrotor +# +# @type Quadrotor Wide +# +# @maintainer Anton Babushkin +# + +sh /etc/init.d/rc.mc_defaults + +if [ $AUTOCNF == yes ] +then + # TODO tune roll/pitch separately + param set MC_ROLL_P 7.0 + param set MC_ROLLRATE_P 0.13 + param set MC_ROLLRATE_I 0.05 + param set MC_ROLLRATE_D 0.004 + param set MC_PITCH_P 7.0 + param set MC_PITCHRATE_P 0.13 + param set MC_PITCHRATE_I 0.05 + param set MC_PITCHRATE_D 0.004 + param set MC_YAW_P 2.5 + param set MC_YAWRATE_P 0.25 + param set MC_YAWRATE_I 0.25 + param set MC_YAWRATE_D 0.0 + + param set BAT_V_SCALING 0.00989 + param set BAT_C_SCALING 0.0124 +fi + +set MIXER quad_x + +set PWM_OUT 1234 + +set PWM_MIN 1100 +set PWM_MAX 1950 diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index 81b301fe18..e158cb3dba 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -457,13 +457,13 @@ then if [ $TTYS1_BUSY == yes ] then # Start MAVLink on ttyS0, because FMU ttyS1 pins configured as something else - set MAVLINK_F "-r 5000 -d /dev/ttyS0" + set MAVLINK_F "-r 1200 -d /dev/ttyS0" # Exit from nsh to free port for mavlink set EXIT_ON_END yes else # Start MAVLink on default port: ttyS1 - set MAVLINK_F "-r 5000" + set MAVLINK_F "-r 1200" fi fi From 10a6a5949809c8735aefee4dcf5e15161ddde6aa Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 31 Jul 2015 20:06:23 +0200 Subject: [PATCH 122/174] MAVLink app: Make bandwidth scaling depending on the TX error as well --- src/modules/mavlink/mavlink_main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index a23b3f8736..655a918844 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -1232,6 +1232,7 @@ Mavlink::update_rate_mult() float const_rate = 0.0f; float rate = 0.0f; + /* scale down rates if their theoretical bandwidth is exceeding the link bandwidth */ MavlinkStream *stream; LL_FOREACH(_streams, stream) { if (stream->const_rate()) { @@ -1244,6 +1245,11 @@ Mavlink::update_rate_mult() /* don't scale up rates, only scale down if needed */ _rate_mult = fminf(1.0f, ((float)_datarate - const_rate) / rate); + + /* scale down if we have a TX err rate suggesting link congestion */ + if (_rate_txerr > 0.0f) { + _rate_mult = (_rate_tx) / (_rate_tx + _rate_txerr); + } } int From a93f1032fd8bccb49b743a6741489b9682c82b39 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 1 Aug 2015 09:34:05 +0200 Subject: [PATCH 123/174] Set flight-tested values for 3DR quad --- ROMFS/px4fmu_common/init.d/10020_3dr_quad | 26 +++++++++-------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/10020_3dr_quad b/ROMFS/px4fmu_common/init.d/10020_3dr_quad index 0dbffba00f..896d9bd9c7 100644 --- a/ROMFS/px4fmu_common/init.d/10020_3dr_quad +++ b/ROMFS/px4fmu_common/init.d/10020_3dr_quad @@ -1,10 +1,10 @@ #!nsh # -# @name 3DR Iris Quadrotor +# @name 3DR Iris DIY Quad # -# @type Quadrotor Wide +# @type Quadrotor x # -# @maintainer Anton Babushkin +# @maintainer Lorenz Meier # sh /etc/init.d/rc.mc_defaults @@ -12,21 +12,15 @@ sh /etc/init.d/rc.mc_defaults if [ $AUTOCNF == yes ] then # TODO tune roll/pitch separately - param set MC_ROLL_P 7.0 - param set MC_ROLLRATE_P 0.13 - param set MC_ROLLRATE_I 0.05 + param set MC_ROLL_P 6.5 + param set MC_ROLLRATE_P 0.08 + param set MC_ROLLRATE_I 0.1 param set MC_ROLLRATE_D 0.004 - param set MC_PITCH_P 7.0 - param set MC_PITCHRATE_P 0.13 - param set MC_PITCHRATE_I 0.05 + param set MC_PITCH_P 6.0 + param set MC_PITCHRATE_P 0.16 + param set MC_PITCHRATE_I 0.09 param set MC_PITCHRATE_D 0.004 - param set MC_YAW_P 2.5 - param set MC_YAWRATE_P 0.25 - param set MC_YAWRATE_I 0.25 - param set MC_YAWRATE_D 0.0 - - param set BAT_V_SCALING 0.00989 - param set BAT_C_SCALING 0.0124 + param set MC_YAW_P 4 fi set MIXER quad_x From aa0679ab93cbe0d0921ea91027f96ff95c882048 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 1 Aug 2015 09:49:53 +0200 Subject: [PATCH 124/174] Startup: Set decent default MAV_TYPE guesses is no valid type present. Set correct vehicle types for tricopters and rovers. --- ROMFS/px4fmu_common/init.d/rcS | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index e158cb3dba..608ac95ef9 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -564,7 +564,7 @@ then fi if [ $MIXER == tri_y_yaw- -o $MIXER == tri_y_yaw+ ] then - set MAV_TYPE 2 + set MAV_TYPE 15 fi if [ $MIXER == hexa_x -o $MIXER == hexa_+ ] then @@ -588,6 +588,7 @@ then if [ $MAV_TYPE == none ] then echo "Unknown MAV_TYPE" + param set MAV_TYPE 2 else param set MAV_TYPE $MAV_TYPE fi @@ -631,6 +632,7 @@ then if [ $MAV_TYPE == none ] then echo "Unknown MAV_TYPE" + param set MAV_TYPE 19 else param set MAV_TYPE $MAV_TYPE fi @@ -661,6 +663,8 @@ then then sh /etc/init.d/rc.axialracing_ax10_apps fi + + param set MAV_TYPE 10 fi unset MIXER From 79910ce7e04f45ab28bf6dbae17f9d6224215ce2 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 1 Aug 2015 12:48:11 +0200 Subject: [PATCH 125/174] MAVLink app: Add radio based software flow control, default to hardware flow control if available and operational --- src/modules/mavlink/mavlink_main.cpp | 48 ++++++++++++++++++++++++++-- src/modules/mavlink/mavlink_main.h | 5 +++ 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index 655a918844..5df0c47272 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -152,6 +152,7 @@ Mavlink::Mavlink() : _datarate(1000), _datarate_events(500), _rate_mult(1.0f), + _last_hw_rate_timestamp(0), _mavlink_param_queue_index(0), mavlink_link_termination_allowed(false), _subscribe_to_stream(nullptr), @@ -1244,12 +1245,53 @@ Mavlink::update_rate_mult() } /* don't scale up rates, only scale down if needed */ - _rate_mult = fminf(1.0f, ((float)_datarate - const_rate) / rate); + float bandwidth_mult = fminf(1.0f, ((float)_datarate - const_rate) / rate); + + /* check if we have radio feedback */ + struct telemetry_status_s &tstatus = get_rx_status(); + + bool radio_critical = false; + bool radio_found = false; + + /* 2nd pass: Now check hardware limits */ + if (tstatus.type == TELEMETRY_STATUS_RADIO_TYPE_3DR_RADIO) { + + radio_found = true; + + if (tstatus.txbuf < RADIO_BUFFER_LOW_PERCENTAGE) { + radio_critical = true; + } + } + + float hardware_mult = _rate_mult; /* scale down if we have a TX err rate suggesting link congestion */ - if (_rate_txerr > 0.0f) { - _rate_mult = (_rate_tx) / (_rate_tx + _rate_txerr); + if (_rate_txerr > 0.0f && !radio_critical) { + hardware_mult = (_rate_tx) / (_rate_tx + _rate_txerr); + warnx("RTS limiting"); + } else if (radio_found && tstatus.timestamp != _last_hw_rate_timestamp) { + + if (tstatus.txbuf < RADIO_BUFFER_CRITICAL_LOW_PERCENTAGE) { + /* this indicates link congestion, reduce rate by 20% */ + hardware_mult *= 0.80f; + } else if (tstatus.txbuf < RADIO_BUFFER_LOW_PERCENTAGE) { + /* this indicates link congestion, reduce rate by 2.5% */ + hardware_mult *= 0.975f; + } else if (tstatus.txbuf > RADIO_BUFFER_HALF_PERCENTAGE) { + /* this indicates spare bandwidth, increase by 2.5% */ + hardware_mult *= 1.025f; + /* limit to a max multiplier of 1 */ + hardware_mult = fminf(1.0f, hardware_mult); + } } + + _last_hw_rate_timestamp = tstatus.timestamp; + + /* pick the minimum from bandwidth mult and hardware mult as limit */ + _rate_mult = fminf(bandwidth_mult, hardware_mult); + + /* ensure the rate multiplier never drops below 5% so that something is always sent */ + _rate_mult = fmaxf(0.05f, _rate_mult); } int diff --git a/src/modules/mavlink/mavlink_main.h b/src/modules/mavlink/mavlink_main.h index 5ecf8e6956..a484558579 100644 --- a/src/modules/mavlink/mavlink_main.h +++ b/src/modules/mavlink/mavlink_main.h @@ -351,6 +351,7 @@ private: int _datarate; ///< data rate for normal streams (attitude, position, etc.) int _datarate_events; ///< data rate for params, waypoints, text messages float _rate_mult; + hrt_abstime _last_hw_rate_timestamp; /** * If the queue index is not at 0, the queue sending @@ -409,6 +410,10 @@ private: static unsigned int interval_from_rate(float rate); + static constexpr unsigned RADIO_BUFFER_CRITICAL_LOW_PERCENTAGE = 25; + static constexpr unsigned RADIO_BUFFER_LOW_PERCENTAGE = 35; + static constexpr unsigned RADIO_BUFFER_HALF_PERCENTAGE = 50; + int configure_stream(const char *stream_name, const float rate); /** From 09f6b8865102b6e2582061855e88a4c435927eb3 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 1 Aug 2015 16:12:03 +0200 Subject: [PATCH 126/174] MAVLink app: Implement switch toggling for simulated RC link --- src/modules/mavlink/mavlink_receiver.cpp | 68 ++++++++++++++++++------ src/modules/mavlink/mavlink_receiver.h | 32 ++++++++--- 2 files changed, 77 insertions(+), 23 deletions(-) diff --git a/src/modules/mavlink/mavlink_receiver.cpp b/src/modules/mavlink/mavlink_receiver.cpp index 8ebbe47052..cf638ca043 100644 --- a/src/modules/mavlink/mavlink_receiver.cpp +++ b/src/modules/mavlink/mavlink_receiver.cpp @@ -35,9 +35,9 @@ * @file mavlink_receiver.cpp * MAVLink protocol message receive and dispatch * - * @author Lorenz Meier - * @author Anton Babushkin - * @author Thomas Gubler + * @author Lorenz Meier + * @author Anton Babushkin + * @author Thomas Gubler */ /* XXX trim includes */ @@ -133,7 +133,9 @@ MavlinkReceiver::MavlinkReceiver(Mavlink *parent) : _att_sp{}, _rates_sp{}, _time_offset_avg_alpha(0.6), - _time_offset(0) + _time_offset(0), + _mom_switch_pos{}, + _mom_switch_state(0) { } @@ -904,15 +906,45 @@ MavlinkReceiver::handle_message_radio_status(mavlink_message_t *msg) } } -static switch_pos_t decode_switch_pos(uint16_t buttons, int sw) { +switch_pos_t +MavlinkReceiver::decode_switch_pos(uint16_t buttons, unsigned sw) +{ + // XXX non-standard 3 pos switch decoding return (buttons >> (sw * 2)) & 3; } -static int decode_switch_pos_n(uint16_t buttons, int sw) { - if (buttons & (1 << sw)) { - return 1; +int +MavlinkReceiver::decode_switch_pos_n(uint16_t buttons, unsigned sw) +{ + + bool on = (buttons & (1 << sw)); + + if (sw < MOM_SWITCH_COUNT) { + + bool last_on = (_mom_switch_state & (1 << sw)); + + /* first switch is 2-pos, rest is 2 pos */ + unsigned state_count = (sw == 0) ? 3 : 2; + + /* only transition on low state */ + if (!on && (on != last_on)) { + + _mom_switch_pos[sw]++; + if (_mom_switch_pos[sw] == state_count) { + _mom_switch_pos[sw] = 0; + } + } + + /* state_count - 1 is the number of intervals and 1000 is the range, + * with 2 states 0 becomes 0, 1 becomes 1000. With + * 3 states 0 becomes 0, 1 becomes 500, 2 becomes 1000, + * and so on for more states. + */ + return (_mom_switch_pos[sw] * 1000) / (state_count - 1) + 1000; + } else { - return 0; + /* return the current state */ + return on * 1000 + 1000; } } @@ -1009,12 +1041,18 @@ MavlinkReceiver::handle_message_manual_control(mavlink_message_t *msg) rc.values[3] = 1000; } - rc.values[4] = decode_switch_pos_n(man.buttons, 0) * 1000 + 1000; - rc.values[5] = decode_switch_pos_n(man.buttons, 1) * 1000 + 1000; - rc.values[6] = decode_switch_pos_n(man.buttons, 2) * 1000 + 1000; - rc.values[7] = decode_switch_pos_n(man.buttons, 3) * 1000 + 1000; - rc.values[8] = decode_switch_pos_n(man.buttons, 4) * 1000 + 1000; - rc.values[9] = decode_switch_pos_n(man.buttons, 5) * 1000 + 1000; + /* decode all switches which fit into the channel mask */ + unsigned max_switch = (sizeof(man.buttons) * 8); + unsigned max_channels = (sizeof(rc.values) / sizeof(rc.values[0])); + if (max_switch > (max_channels - 4)) { + max_switch = (max_channels - 4); + } + + /* fill all channels */ + for (unsigned i = 0; i < max_switch; i++) { + rc.values[i + 4] = decode_switch_pos_n(man.buttons, i); + } + _mom_switch_state = man.buttons; if (_rc_pub <= 0) { _rc_pub = orb_advertise(ORB_ID(input_rc), &rc); diff --git a/src/modules/mavlink/mavlink_receiver.h b/src/modules/mavlink/mavlink_receiver.h index 18a3dc208a..e7668c10f3 100644 --- a/src/modules/mavlink/mavlink_receiver.h +++ b/src/modules/mavlink/mavlink_receiver.h @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2012-2014 PX4 Development Team. All rights reserved. + * Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,8 +35,8 @@ * @file mavlink_orb_listener.h * MAVLink 1.0 uORB listener definition * - * @author Lorenz Meier - * @author Anton Babushkin + * @author Lorenz Meier + * @author Anton Babushkin */ #pragma once @@ -139,15 +139,26 @@ private: void *receive_thread(void *arg); /** - * Convert remote timestamp to local hrt time (usec) - * Use timesync if available, monotonic boot time otherwise - */ + * Convert remote timestamp to local hrt time (usec) + * Use timesync if available, monotonic boot time otherwise + */ uint64_t sync_stamp(uint64_t usec); + /** - * Exponential moving average filter to smooth time offset - */ + * Exponential moving average filter to smooth time offset + */ void smooth_time_offset(uint64_t offset_ns); + /** + * Decode a switch position from a bitfield + */ + switch_pos_t decode_switch_pos(uint16_t buttons, unsigned sw); + + /** + * Decode a switch position from a bitfield and state + */ + int decode_switch_pos_n(uint16_t buttons, unsigned sw); + mavlink_status_t status; struct vehicle_local_position_s hil_local_pos; struct vehicle_land_detected_s hil_land_detector; @@ -192,6 +203,11 @@ private: double _time_offset_avg_alpha; uint64_t _time_offset; + static constexpr unsigned MOM_SWITCH_COUNT = 8; + + uint8_t _mom_switch_pos[MOM_SWITCH_COUNT]; + uint16_t _mom_switch_state; + /* do not allow copying this class */ MavlinkReceiver(const MavlinkReceiver &); MavlinkReceiver operator=(const MavlinkReceiver &); From c38c58291e9db5425414b1466e5ed2e1254067b1 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 1 Aug 2015 17:15:10 +0200 Subject: [PATCH 127/174] GPS: silence verbose boot messages --- src/drivers/gps/ubx.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/drivers/gps/ubx.cpp b/src/drivers/gps/ubx.cpp index 064ce20e5f..81b580892b 100644 --- a/src/drivers/gps/ubx.cpp +++ b/src/drivers/gps/ubx.cpp @@ -83,7 +83,7 @@ /**** Warning macros, disable to save memory */ #define UBX_WARN(s, ...) {warnx(s, ## __VA_ARGS__);} - +#define UBX_DEBUG(s, ...) {/*warnx(s, ## __VA_ARGS__);*/} UBX::UBX(const int &fd, struct vehicle_gps_position_s *gps_position, struct satellite_info_s *satellite_info) : _fd(fd), @@ -212,7 +212,7 @@ UBX::configure(unsigned &baudrate) } else { _use_nav_pvt = true; } - UBX_WARN("%susing NAV-PVT", _use_nav_pvt ? "" : "not "); + UBX_DEBUG("%susing NAV-PVT", _use_nav_pvt ? "" : "not "); if (!_use_nav_pvt) { configure_message_rate(UBX_MSG_NAV_TIMEUTC, 5); @@ -271,9 +271,9 @@ UBX::wait_for_ack(const uint16_t msg, const unsigned timeout, const bool report) ret = 0; // ACK received ok } else if (report) { if (_ack_state == UBX_ACK_GOT_NAK) { - UBX_WARN("ubx msg 0x%04x NAK", SWAP16((unsigned)msg)); + UBX_DEBUG("ubx msg 0x%04x NAK", SWAP16((unsigned)msg)); } else { - UBX_WARN("ubx msg 0x%04x ACK timeout", SWAP16((unsigned)msg)); + UBX_DEBUG("ubx msg 0x%04x ACK timeout", SWAP16((unsigned)msg)); } } @@ -566,7 +566,7 @@ UBX::payload_rx_init() break; case UBX_RXMSG_DISABLE: // disable unexpected messages - UBX_WARN("ubx msg 0x%04x len %u unexpected", SWAP16((unsigned)_rx_msg), (unsigned)_rx_payload_length); + UBX_DEBUG("ubx msg 0x%04x len %u unexpected", SWAP16((unsigned)_rx_msg), (unsigned)_rx_payload_length); { hrt_abstime t = hrt_absolute_time(); @@ -574,7 +574,7 @@ UBX::payload_rx_init() if (t > _disable_cmd_last + DISABLE_MSG_INTERVAL) { /* don't attempt for every message to disable, some might not be disabled */ _disable_cmd_last = t; - UBX_WARN("ubx disabling msg 0x%04x", SWAP16((unsigned)_rx_msg)); + UBX_DEBUG("ubx disabling msg 0x%04x", SWAP16((unsigned)_rx_msg)); configure_message_rate(_rx_msg, 0); } } @@ -677,16 +677,16 @@ UBX::payload_rx_add_mon_ver(const uint8_t b) // Part 1 complete: decode Part 1 buffer and calculate hash for SW&HW version strings _ubx_version = fnv1_32_str(_buf.payload_rx_mon_ver_part1.swVersion, FNV1_32_INIT); _ubx_version = fnv1_32_str(_buf.payload_rx_mon_ver_part1.hwVersion, _ubx_version); - UBX_WARN("VER hash 0x%08x", _ubx_version); - UBX_WARN("VER hw \"%10s\"", _buf.payload_rx_mon_ver_part1.hwVersion); - UBX_WARN("VER sw \"%30s\"", _buf.payload_rx_mon_ver_part1.swVersion); + UBX_DEBUG("VER hash 0x%08x", _ubx_version); + UBX_DEBUG("VER hw \"%10s\"", _buf.payload_rx_mon_ver_part1.hwVersion); + UBX_DEBUG("VER sw \"%30s\"", _buf.payload_rx_mon_ver_part1.swVersion); } // fill Part 2 buffer unsigned buf_index = (_rx_payload_index - sizeof(ubx_payload_rx_mon_ver_part1_t)) % sizeof(ubx_payload_rx_mon_ver_part2_t); _buf.raw[buf_index] = b; if (buf_index == sizeof(ubx_payload_rx_mon_ver_part2_t) - 1) { // Part 2 complete: decode Part 2 buffer - UBX_WARN("VER ext \" %30s\"", _buf.payload_rx_mon_ver_part2.extension); + UBX_DEBUG("VER ext \" %30s\"", _buf.payload_rx_mon_ver_part2.extension); } } From 3679c2512501a99e14d5610191ed9236d2694b00 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 1 Aug 2015 17:15:25 +0200 Subject: [PATCH 128/174] PX4 FLOW: Silence alarming messages on a normal boot --- src/drivers/px4flow/px4flow.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/drivers/px4flow/px4flow.cpp b/src/drivers/px4flow/px4flow.cpp index 8ee365d8df..ddc5c61094 100644 --- a/src/drivers/px4flow/px4flow.cpp +++ b/src/drivers/px4flow/px4flow.cpp @@ -602,7 +602,7 @@ bool start_in_progress = false; const int START_RETRY_COUNT = 5; const int START_RETRY_TIMEOUT = 1000; -void start(); +int start(); void stop(); void test(); void reset(); @@ -611,22 +611,26 @@ void info(); /** * Start the driver. */ -void +int start() { int fd; /* entry check: */ if (start_in_progress) { - errx(1, "start in progress"); + warnx("start already in progress"); + return 1; } start_in_progress = true; if (g_dev != nullptr) { start_in_progress = false; - errx(1, "already started"); + warnx("already started"); + return 1; } + warnx("scanning I2C buses for device.."); + int retry_nr = 0; while (1) { const int busses_to_try[] = { @@ -684,11 +688,12 @@ start() /* success! */ start_in_progress = false; - exit(0); + return 0; } if (retry_nr < START_RETRY_COUNT) { - warnx("PX4FLOW not found on I2C busses. Retrying in %d ms. Giving up in %d retries.", START_RETRY_TIMEOUT, START_RETRY_COUNT - retry_nr); + /* lets not be too verbose */ + // warnx("PX4FLOW not found on I2C busses. Retrying in %d ms. Giving up in %d retries.", START_RETRY_TIMEOUT, START_RETRY_COUNT - retry_nr); usleep(START_RETRY_TIMEOUT * 1000); retry_nr++; } else { @@ -702,7 +707,7 @@ start() } start_in_progress = false; - errx(1, "PX4FLOW could not be started over I2C"); + return 1; } /** @@ -852,7 +857,7 @@ px4flow_main(int argc, char *argv[]) * Start/load the driver. */ if (!strcmp(argv[1], "start")) { - px4flow::start(); + return px4flow::start(); } /* From a446cb6b2f7736c1f38032c8a72cd5027c6799fb Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 1 Aug 2015 17:15:38 +0200 Subject: [PATCH 129/174] FMU driver: Disable debug mode --- src/drivers/px4fmu/fmu.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/drivers/px4fmu/fmu.cpp b/src/drivers/px4fmu/fmu.cpp index c55289fc54..f2ec0285be 100644 --- a/src/drivers/px4fmu/fmu.cpp +++ b/src/drivers/px4fmu/fmu.cpp @@ -295,7 +295,8 @@ PX4FMU::PX4FMU() : memset(_controls, 0, sizeof(_controls)); memset(_poll_fds, 0, sizeof(_poll_fds)); - _debug_enabled = true; + /* only enable this during development */ + _debug_enabled = false; } PX4FMU::~PX4FMU() @@ -342,9 +343,9 @@ PX4FMU::init() _class_instance = register_class_devname(PWM_OUTPUT_BASE_DEVICE_PATH); if (_class_instance == CLASS_DEVICE_PRIMARY) { - log("default PWM output device"); + /* lets not be too verbose */ } else if (_class_instance < 0) { - log("FAILED registering class device"); + warnx("FAILED registering class device"); } /* reset GPIOs */ @@ -536,11 +537,11 @@ PX4FMU::subscribe() _poll_fds_num = 0; for (unsigned i = 0; i < actuator_controls_s::NUM_ACTUATOR_CONTROL_GROUPS; i++) { if (sub_groups & (1 << i)) { - warnx("subscribe to actuator_controls_%d", i); + debug("subscribe to actuator_controls_%d", i); _control_subs[i] = orb_subscribe(_control_topics[i]); } if (unsub_groups & (1 << i)) { - warnx("unsubscribe from actuator_controls_%d", i); + debug("unsubscribe from actuator_controls_%d", i); ::close(_control_subs[i]); _control_subs[i] = -1; } From 283bca90d6dcf4ea7a92ed8ba2ac6836bb670bcf Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 1 Aug 2015 17:32:31 +0200 Subject: [PATCH 130/174] MAVLink: Remove leftover debug comment --- src/modules/mavlink/mavlink_main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index 5df0c47272..b4474f96dc 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -1268,7 +1268,6 @@ Mavlink::update_rate_mult() /* scale down if we have a TX err rate suggesting link congestion */ if (_rate_txerr > 0.0f && !radio_critical) { hardware_mult = (_rate_tx) / (_rate_tx + _rate_txerr); - warnx("RTS limiting"); } else if (radio_found && tstatus.timestamp != _last_hw_rate_timestamp) { if (tstatus.txbuf < RADIO_BUFFER_CRITICAL_LOW_PERCENTAGE) { From c00b9885b586b906ca59d60d8ed9468cbbb9b11a Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 1 Aug 2015 17:46:28 +0200 Subject: [PATCH 131/174] Enable RC gamepad input in all HIL configs by default --- ROMFS/px4fmu_common/init.d/1000_rc_fw_easystar.hil | 3 +++ ROMFS/px4fmu_common/init.d/1001_rc_quad_x.hil | 3 +++ ROMFS/px4fmu_common/init.d/1003_rc_quad_+.hil | 3 +++ ROMFS/px4fmu_common/init.d/1004_rc_fw_Rascal110.hil | 3 +++ ROMFS/px4fmu_common/init.d/1005_rc_fw_Malolo1.hil | 3 +++ 5 files changed, 15 insertions(+) diff --git a/ROMFS/px4fmu_common/init.d/1000_rc_fw_easystar.hil b/ROMFS/px4fmu_common/init.d/1000_rc_fw_easystar.hil index 7938c47bae..4100cdb4a3 100644 --- a/ROMFS/px4fmu_common/init.d/1000_rc_fw_easystar.hil +++ b/ROMFS/px4fmu_common/init.d/1000_rc_fw_easystar.hil @@ -39,5 +39,8 @@ then param set FW_RR_P 0.3 fi +# Enable gamepad / joystick support +param set COM_RC_IN_MODE 2 + set HIL yes set MIXER AERT diff --git a/ROMFS/px4fmu_common/init.d/1001_rc_quad_x.hil b/ROMFS/px4fmu_common/init.d/1001_rc_quad_x.hil index e1f2cdfe8d..52c512ed8c 100644 --- a/ROMFS/px4fmu_common/init.d/1001_rc_quad_x.hil +++ b/ROMFS/px4fmu_common/init.d/1001_rc_quad_x.hil @@ -11,4 +11,7 @@ sh /etc/init.d/rc.mc_defaults set MIXER quad_x +# Enable gamepad / joystick support +param set COM_RC_IN_MODE 2 + set HIL yes diff --git a/ROMFS/px4fmu_common/init.d/1003_rc_quad_+.hil b/ROMFS/px4fmu_common/init.d/1003_rc_quad_+.hil index 7aa888c763..c590f9ac86 100644 --- a/ROMFS/px4fmu_common/init.d/1003_rc_quad_+.hil +++ b/ROMFS/px4fmu_common/init.d/1003_rc_quad_+.hil @@ -11,4 +11,7 @@ sh /etc/init.d/rc.mc_defaults set MIXER quad_+ +# Enable gamepad / joystick support +param set COM_RC_IN_MODE 2 + set HIL yes diff --git a/ROMFS/px4fmu_common/init.d/1004_rc_fw_Rascal110.hil b/ROMFS/px4fmu_common/init.d/1004_rc_fw_Rascal110.hil index 57bcd24d02..0369da5980 100644 --- a/ROMFS/px4fmu_common/init.d/1004_rc_fw_Rascal110.hil +++ b/ROMFS/px4fmu_common/init.d/1004_rc_fw_Rascal110.hil @@ -11,4 +11,7 @@ sh /etc/init.d/rc.fw_defaults set HIL yes +# Enable gamepad / joystick support +param set COM_RC_IN_MODE 2 + set MIXER AERT diff --git a/ROMFS/px4fmu_common/init.d/1005_rc_fw_Malolo1.hil b/ROMFS/px4fmu_common/init.d/1005_rc_fw_Malolo1.hil index 5e0b6cd746..278df193aa 100644 --- a/ROMFS/px4fmu_common/init.d/1005_rc_fw_Malolo1.hil +++ b/ROMFS/px4fmu_common/init.d/1005_rc_fw_Malolo1.hil @@ -36,5 +36,8 @@ fi set HIL yes +# Enable gamepad / joystick support +param set COM_RC_IN_MODE 2 + # Set the AERT mixer for HIL (even if the malolo is a flying wing) set MIXER AERT From 3d8c628efa50b7495d499523702ffcc757df51b3 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 2 Aug 2015 00:41:58 +0200 Subject: [PATCH 132/174] FW pos control: Comment and clean up altitude setpoint handling --- .../fw_pos_control_l1_main.cpp | 49 +++++++++++++------ 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp b/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp index 33a78f3141..4f3fdac91c 100644 --- a/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp +++ b/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp @@ -179,6 +179,8 @@ private: float _hdg_hold_yaw; /**< hold heading for velocity mode */ bool _hdg_hold_enabled; /**< heading hold enabled */ bool _yaw_lock_engaged; /**< yaw is locked for heading hold */ + float _althold_epv; /**< the position estimate accuracy when engaging alt hold */ + bool _was_in_deadband; /**< wether the last stick input was in althold deadband */ struct position_setpoint_s _hdg_hold_prev_wp; /**< position where heading hold started */ struct position_setpoint_s _hdg_hold_curr_wp; /**< position to which heading hold flies */ hrt_abstime _control_position_last_called; /** deadBand) { - float pitch = (_manual.x - deadBand) / factor; - _hold_alt -= (_parameters.max_climb_rate * dt) * pitch; - was_in_deadband = false; - climbout_mode = (fabsf(_manual.x) > MANUAL_THROTTLE_CLIMBOUT_THRESH); + /* pitching down */ + float pitch = -(_manual.x - deadBand) / factor; + _hold_alt += (_parameters.max_sink_rate * dt) * pitch; + _was_in_deadband = false; } else if (_manual.x < - deadBand) { - float pitch = (_manual.x + deadBand) / factor; - _hold_alt -= (_parameters.max_sink_rate * dt) * pitch; - was_in_deadband = false; - } else if (!was_in_deadband) { + /* pitching up */ + float pitch = -(_manual.x + deadBand) / factor; + _hold_alt += (_parameters.max_climb_rate * dt) * pitch; + _was_in_deadband = false; + climbout_mode = (pitch > MANUAL_THROTTLE_CLIMBOUT_THRESH); + } else if (!_was_in_deadband) { /* store altitude at which manual.x was inside deadBand * The aircraft should immediately try to fly at this altitude * as this is what the pilot expects when he moves the stick to the center */ _hold_alt = _global_pos.alt; _althold_epv = _global_pos.epv; - was_in_deadband = true; + _was_in_deadband = true; } return climbout_mode; From f3ae231dad5b6c8f4415056c44ea711b3b2de99b Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 2 Aug 2015 01:23:00 +0200 Subject: [PATCH 133/174] TECS: Fix manual climbout --- src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp b/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp index 4f3fdac91c..ceea71fca9 100644 --- a/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp +++ b/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp @@ -1502,7 +1502,7 @@ FixedwingPositionControl::control_position(const math::Vector<2> ¤t_positi throttle_max, _parameters.throttle_cruise, climbout_requested, - pitch_limit_min, + ((climbout_requested) ? math::radians(10.0f) : pitch_limit_min), _global_pos.alt, ground_speed, tecs_status_s::TECS_MODE_NORMAL); @@ -1612,7 +1612,7 @@ FixedwingPositionControl::control_position(const math::Vector<2> ¤t_positi throttle_max, _parameters.throttle_cruise, climbout_requested, - pitch_limit_min, + ((climbout_requested) ? math::radians(10.0f) : pitch_limit_min), _global_pos.alt, ground_speed, tecs_status_s::TECS_MODE_NORMAL); From 0d9d5d1fa5d443cb397a14751105213304b173ba Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Thu, 30 Jul 2015 11:44:34 +0200 Subject: [PATCH 134/174] TECS: Limit rate demands --- src/lib/external_lgpl/tecs/tecs.cpp | 117 +++++++++++++++------------- 1 file changed, 64 insertions(+), 53 deletions(-) diff --git a/src/lib/external_lgpl/tecs/tecs.cpp b/src/lib/external_lgpl/tecs/tecs.cpp index 53380d75da..e80c418b14 100644 --- a/src/lib/external_lgpl/tecs/tecs.cpp +++ b/src/lib/external_lgpl/tecs/tecs.cpp @@ -48,8 +48,6 @@ void TECS::update_state(float baro_altitude, float airspeed, const math::Matrix< bool reset_altitude = false; - _in_air = in_air; - if (_update_50hz_last_usec == 0 || DT > DT_MAX) { DT = 0.02f; // when first starting TECS, use a // small time constant @@ -69,6 +67,8 @@ void TECS::update_state(float baro_altitude, float airspeed, const math::Matrix< _update_50hz_last_usec = now; _EAS = airspeed; + _in_air = in_air; + // Get height acceleration float hgt_ddot_mea = -(accel_earth(2) + CONSTANTS_ONE_G); // Perform filter calculation using backwards Euler integration @@ -108,7 +108,9 @@ void TECS::update_state(float baro_altitude, float airspeed, const math::Matrix< _vel_dot = 0.0f; } - _states_initalized = true; + if (!_in_air) { + _states_initalized = false; + } } @@ -179,40 +181,38 @@ void TECS::_update_speed_demand(void) // calculate velocity rate limits based on physical performance limits // provision to use a different rate limit if bad descent or underspeed condition exists - // Use 50% of maximum energy rate to allow margin for total energy contgroller -// float velRateMax; -// float velRateMin; -// -// if ((_badDescent) || (_underspeed)) { -// velRateMax = 0.5f * _STEdot_max / _integ5_state; -// velRateMin = 0.5f * _STEdot_min / _integ5_state; -// -// } else { -// velRateMax = 0.5f * _STEdot_max / _integ5_state; -// velRateMin = 0.5f * _STEdot_min / _integ5_state; -// } -// + // Use 50% of maximum energy rate to allow margin for total energy controller + float velRateMax; + float velRateMin; + + if ((_badDescent) || (_underspeed)) { + velRateMax = 0.5f * _STEdot_max / _integ5_state; + velRateMin = 0.5f * _STEdot_min / _integ5_state; + + } else { + velRateMax = 0.5f * _STEdot_max / _integ5_state; + velRateMin = 0.5f * _STEdot_min / _integ5_state; + } + // // Apply rate limit -// if ((_TAS_dem - _TAS_dem_adj) > (velRateMax * 0.1f)) { -// _TAS_dem_adj = _TAS_dem_adj + velRateMax * 0.1f; +// if ((_TAS_dem - _TAS_dem_adj) > (velRateMax * _DT)) { +// _TAS_dem_adj = _TAS_dem_adj + velRateMax * _DT; // _TAS_rate_dem = velRateMax; // -// } else if ((_TAS_dem - _TAS_dem_adj) < (velRateMin * 0.1f)) { -// _TAS_dem_adj = _TAS_dem_adj + velRateMin * 0.1f; +// } else if ((_TAS_dem - _TAS_dem_adj) < (velRateMin * _DT)) { +// _TAS_dem_adj = _TAS_dem_adj + velRateMin * _DT; // _TAS_rate_dem = velRateMin; // // } else { // _TAS_dem_adj = _TAS_dem; // // -// _TAS_rate_dem = (_TAS_dem - _TAS_dem_last) / 0.1f; +// _TAS_rate_dem = (_TAS_dem - _TAS_dem_last) / _DT; // } - _TAS_dem_adj = _TAS_dem; - _TAS_rate_dem = (_TAS_dem_adj-_integ5_state)*_speedrate_p; //xxx: using a p loop for now + _TAS_dem_adj = constrain(_TAS_dem, _TASmin, _TASmax);; + _TAS_rate_dem = constrain((_TAS_dem_adj - _integ5_state) * _speedrate_p, velRateMin, velRateMax); //xxx: using a p loop for now - // Constrain speed demand again to protect against bad values on initialisation. - _TAS_dem_adj = constrain(_TAS_dem_adj, _TASmin, _TASmax); // _TAS_dem_last = _TAS_dem; // warnx("_TAS_rate_dem: %.1f, _TAS_dem_adj %.1f, _integ5_state %.1f, _badDescent %u , _underspeed %u, velRateMin %.1f", @@ -223,23 +223,29 @@ void TECS::_update_speed_demand(void) void TECS::_update_height_demand(float demand, float state) { -// // Apply 2 point moving average to demanded height -// // This is required because height demand is only updated at 5Hz -// _hgt_dem = 0.5f * (demand + _hgt_dem_in_old); -// _hgt_dem_in_old = _hgt_dem; -// -// // printf("hgt_dem: %6.2f hgt_dem_last: %6.2f max_climb_rate: %6.2f\n", _hgt_dem, _hgt_dem_prev, -// // _maxClimbRate); -// -// // Limit height rate of change -// if ((_hgt_dem - _hgt_dem_prev) > (_maxClimbRate * 0.1f)) { -// _hgt_dem = _hgt_dem_prev + _maxClimbRate * 0.1f; -// -// } else if ((_hgt_dem - _hgt_dem_prev) < (-_maxSinkRate * 0.1f)) { -// _hgt_dem = _hgt_dem_prev - _maxSinkRate * 0.1f; -// } -// -// _hgt_dem_prev = _hgt_dem; + // Handle initialization + if (isfinite(demand) && fabsf(_hgt_dem_in_old) < 0.1f) { + _hgt_dem_in_old = demand; + } + // Apply 2 point moving average to demanded height + // This is required because height demand is updated in steps + if (isfinite(demand)) { + _hgt_dem = 0.5f * (demand + _hgt_dem_in_old); + } else { + _hgt_dem = _hgt_dem_in_old; + } + _hgt_dem_in_old = _hgt_dem; + + // Limit height demand + // this is important to avoid a windup + if ((_hgt_dem - _hgt_dem_prev) > (_maxClimbRate * _DT)) { + _hgt_dem = _hgt_dem_prev + _maxClimbRate * _DT; + + } else if ((_hgt_dem - _hgt_dem_prev) < (-_maxSinkRate * _DT)) { + _hgt_dem = _hgt_dem_prev - _maxSinkRate * _DT; + } + + _hgt_dem_prev = _hgt_dem; // // // Apply first order lag to height demand // _hgt_dem_adj = 0.05f * _hgt_dem + 0.95f * _hgt_dem_adj_last; @@ -249,9 +255,9 @@ void TECS::_update_height_demand(float demand, float state) // // printf("hgt_dem: %6.2f hgt_dem_adj: %6.2f hgt_dem_last: %6.2f hgt_rate_dem: %6.2f\n", _hgt_dem, _hgt_dem_adj, _hgt_dem_adj_last, // // _hgt_rate_dem); - _hgt_dem_adj = demand;//0.025f * demand + 0.975f * _hgt_dem_adj_last; - _hgt_rate_dem = (_hgt_dem_adj-state)*_heightrate_p + _heightrate_ff * (_hgt_dem_adj - _hgt_dem_adj_last)/_DT; + _hgt_dem_adj = _hgt_dem; //0.025f * _hgt_dem + 0.975f * _hgt_dem_adj_last; _hgt_dem_adj_last = _hgt_dem_adj; + _hgt_rate_dem = (_hgt_dem_adj - state) * _heightrate_p + _heightrate_ff * (_hgt_dem_adj - _hgt_dem_adj_last) / _DT; // Limit height rate of change if (_hgt_rate_dem > _maxClimbRate) { @@ -485,7 +491,7 @@ void TECS::_update_pitch(void) void TECS::_initialise_states(float pitch, float throttle_cruise, float baro_altitude, float ptchMinCO_rad) { // Initialise states and variables if DT > 1 second or in climbout - if (_update_pitch_throttle_last_usec == 0 || _DT > 1.0f || !_in_air) { + if (_update_pitch_throttle_last_usec == 0 || _DT > 1.0f || !_in_air || !_states_initalized) { _integ6_state = 0.0f; _integ7_state = 0.0f; _last_throttle_dem = throttle_cruise; @@ -498,8 +504,10 @@ void TECS::_initialise_states(float pitch, float throttle_cruise, float baro_alt _TAS_dem_adj = _TAS_dem; _underspeed = false; _badDescent = false; - _DT = DT_MIN; // when first starting TECS, use a - // small time constant + + if (_DT > 1.0f || _DT < 0.001f) { + _DT = DT_MIN; + } } else if (_climbOutDem) { _PITCHminf = ptchMinCO_rad; @@ -512,6 +520,8 @@ void TECS::_initialise_states(float pitch, float throttle_cruise, float baro_alt _underspeed = false; _badDescent = false; } + + _states_initalized = true; } void TECS::_update_STE_rate_lim(void) @@ -526,9 +536,6 @@ void TECS::update_pitch_throttle(const math::Matrix<3,3> &rotMat, float pitch, f float throttle_min, float throttle_max, float throttle_cruise, float pitch_limit_min, float pitch_limit_max) { - if (!_states_initalized) { - return; - } // Calculate time in seconds since last update uint64_t now = ecl_absolute_time(); @@ -537,9 +544,6 @@ void TECS::update_pitch_throttle(const math::Matrix<3,3> &rotMat, float pitch, f // printf("tecs in: dt:%10.6f pitch: %6.2f baro_alt: %6.2f alt sp: %6.2f\neas sp: %6.2f eas: %6.2f, eas2tas: %6.2f\n %s pitch min C0: %6.2f thr min: %6.2f, thr max: %6.2f thr cruis: %6.2f pt min: %6.2f, pt max: %6.2f\n", // _DT, pitch, baro_altitude, hgt_dem, EAS_dem, indicated_airspeed, EAS2TAS, (climbOutDem) ? "climb" : "level", ptchMinCO, throttle_min, throttle_max, throttle_cruise, pitch_limit_min, pitch_limit_max); - // Update the speed estimate using a 2nd order complementary filter - _update_speed(EAS_dem, indicated_airspeed, _indicated_airspeed_min, _indicated_airspeed_max, EAS2TAS); - // Convert inputs _THRmaxf = throttle_max; _THRminf = throttle_min; @@ -550,6 +554,13 @@ void TECS::update_pitch_throttle(const math::Matrix<3,3> &rotMat, float pitch, f // initialise selected states and variables if DT > 1 second or in climbout _initialise_states(pitch, throttle_cruise, baro_altitude, ptchMinCO); + if (!_in_air) { + return; + } + + // Update the speed estimate using a 2nd order complementary filter + _update_speed(EAS_dem, indicated_airspeed, _indicated_airspeed_min, _indicated_airspeed_max, EAS2TAS); + // Calculate Specific Total Energy Rate Limits _update_STE_rate_lim(); From e443a3f3be42ed9ebfcf0ca588d7b0a4d359f582 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 2 Aug 2015 01:34:00 +0200 Subject: [PATCH 135/174] Harmonize FW default gains, increase TECS height rate default gain considerably --- ROMFS/px4fmu_common/init.d/rc.fw_defaults | 4 ---- src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/rc.fw_defaults b/ROMFS/px4fmu_common/init.d/rc.fw_defaults index f1b92112a3..408707ec0b 100644 --- a/ROMFS/px4fmu_common/init.d/rc.fw_defaults +++ b/ROMFS/px4fmu_common/init.d/rc.fw_defaults @@ -11,10 +11,6 @@ then param set NAV_RTL_ALT 100 param set NAV_RTL_LAND_T -1 param set NAV_ACC_RAD 50 - param set FW_T_HRATE_P 0.01 - param set FW_T_RLL2THR 15 - param set FW_T_SRATE_P 0.01 - param set FW_T_TIME_CONST 5 param set PE_VELNE_NOISE 0.3 param set PE_VELD_NOISE 0.35 diff --git a/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c b/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c index 78d66afe1e..98ce1fa1de 100644 --- a/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c +++ b/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c @@ -327,7 +327,7 @@ PARAM_DEFINE_FLOAT(FW_T_SPD_OMEGA, 2.0f); * * @group Fixed Wing TECS */ -PARAM_DEFINE_FLOAT(FW_T_RLL2THR, 10.0f); +PARAM_DEFINE_FLOAT(FW_T_RLL2THR, 15.0f); /** * Speed <--> Altitude priority From c0d2b22d00b88206110f6445354fad2c97a1a8c1 Mon Sep 17 00:00:00 2001 From: Mark Whitehorn Date: Sun, 2 Aug 2015 06:35:37 -0600 Subject: [PATCH 136/174] cosmetic: fix typos in comments --- src/modules/fw_pos_control_l1/mtecs/mTecs.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/fw_pos_control_l1/mtecs/mTecs.cpp b/src/modules/fw_pos_control_l1/mtecs/mTecs.cpp index a855e4092f..cfba54d452 100644 --- a/src/modules/fw_pos_control_l1/mtecs/mTecs.cpp +++ b/src/modules/fw_pos_control_l1/mtecs/mTecs.cpp @@ -204,7 +204,7 @@ int mTecs::updateFlightPathAngleAcceleration(float flightPathAngle, float flight mode = tecs_status_s::TECS_MODE_UNDERSPEED; } - /* Set special ouput limiters if we are not in TECS_MODE_NORMAL */ + /* Set special output limiters if we are not in TECS_MODE_NORMAL */ BlockOutputLimiter *outputLimiterThrottle = &_controlTotalEnergy.getOutputLimiter(); BlockOutputLimiter *outputLimiterPitch = &_controlEnergyDistribution.getOutputLimiter(); if (mode == tecs_status_s::TECS_MODE_TAKEOFF) { @@ -221,7 +221,7 @@ int mTecs::updateFlightPathAngleAcceleration(float flightPathAngle, float flight outputLimiterPitch = &_BlockOutputLimiterUnderspeedPitch; } - /* Apply overrride given by the limitOverride argument (this is used for limits which are not given by + /* Apply override given by the limitOverride argument (this is used for limits which are not given by * parameters such as pitch limits with takeoff waypoints or throttle limits when the launchdetector * is running) */ limitOverride.applyOverride(*outputLimiterThrottle, *outputLimiterPitch); @@ -253,7 +253,7 @@ int mTecs::updateFlightPathAngleAcceleration(float flightPathAngle, float flight (double)accelerationLongitudinalSp, (double)airspeedDerivative); } - /* publish status messge */ + /* publish status message */ _status.update(); /* clean up */ From b066a79ca6057294babe244a3155a6cc099b70af Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 2 Aug 2015 14:50:36 +0200 Subject: [PATCH 137/174] TECS lib: Low-pass height demand to avoid using the motor as a mechanical low-pass filter --- src/lib/external_lgpl/tecs/tecs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/external_lgpl/tecs/tecs.cpp b/src/lib/external_lgpl/tecs/tecs.cpp index e80c418b14..6f049d4f52 100644 --- a/src/lib/external_lgpl/tecs/tecs.cpp +++ b/src/lib/external_lgpl/tecs/tecs.cpp @@ -255,7 +255,7 @@ void TECS::_update_height_demand(float demand, float state) // // printf("hgt_dem: %6.2f hgt_dem_adj: %6.2f hgt_dem_last: %6.2f hgt_rate_dem: %6.2f\n", _hgt_dem, _hgt_dem_adj, _hgt_dem_adj_last, // // _hgt_rate_dem); - _hgt_dem_adj = _hgt_dem; //0.025f * _hgt_dem + 0.975f * _hgt_dem_adj_last; + _hgt_dem_adj = 0.1f * _hgt_dem + 0.9f * _hgt_dem_adj_last; _hgt_dem_adj_last = _hgt_dem_adj; _hgt_rate_dem = (_hgt_dem_adj - state) * _heightrate_p + _heightrate_ff * (_hgt_dem_adj - _hgt_dem_adj_last) / _DT; From fbc1b78b3819beeec9f5327ef40fc3de1d599808 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 2 Aug 2015 14:51:09 +0200 Subject: [PATCH 138/174] Attitude control: Enforce rate limits by default to prevent jittery control outputs / steps --- src/modules/fw_att_control/fw_att_control_params.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/fw_att_control/fw_att_control_params.c b/src/modules/fw_att_control/fw_att_control_params.c index aa8787b623..7975a3b3c3 100644 --- a/src/modules/fw_att_control/fw_att_control_params.c +++ b/src/modules/fw_att_control/fw_att_control_params.c @@ -101,7 +101,7 @@ PARAM_DEFINE_FLOAT(FW_PR_I, 0.01f); * @max 90.0 * @group FW Attitude Control */ -PARAM_DEFINE_FLOAT(FW_P_RMAX_POS, 0.0f); +PARAM_DEFINE_FLOAT(FW_P_RMAX_POS, 60.0f); /** * Maximum negative / down pitch rate. @@ -114,7 +114,7 @@ PARAM_DEFINE_FLOAT(FW_P_RMAX_POS, 0.0f); * @max 90.0 * @group FW Attitude Control */ -PARAM_DEFINE_FLOAT(FW_P_RMAX_NEG, 0.0f); +PARAM_DEFINE_FLOAT(FW_P_RMAX_NEG, 60.0f); /** * Pitch rate integrator limit @@ -185,7 +185,7 @@ PARAM_DEFINE_FLOAT(FW_RR_IMAX, 0.2f); * @max 90.0 * @group FW Attitude Control */ -PARAM_DEFINE_FLOAT(FW_R_RMAX, 0.0f); +PARAM_DEFINE_FLOAT(FW_R_RMAX, 70.0f); /** * Yaw rate proportional gain From 4e1faafc9bd5643a638c202ea42596e1cbff8e4c Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 2 Aug 2015 14:51:36 +0200 Subject: [PATCH 139/174] Remove unused variables --- src/modules/fw_att_control/fw_att_control_main.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/modules/fw_att_control/fw_att_control_main.cpp b/src/modules/fw_att_control/fw_att_control_main.cpp index 9cbbe80cc3..43c44aaeac 100644 --- a/src/modules/fw_att_control/fw_att_control_main.cpp +++ b/src/modules/fw_att_control/fw_att_control_main.cpp @@ -163,7 +163,6 @@ private: struct { float tconst; float p_p; - float p_d; float p_i; float p_ff; float p_rmax_pos; @@ -171,7 +170,6 @@ private: float p_integrator_max; float p_roll_feedforward; float r_p; - float r_d; float r_i; float r_ff; float r_integrator_max; @@ -208,7 +206,6 @@ private: param_t tconst; param_t p_p; - param_t p_d; param_t p_i; param_t p_ff; param_t p_rmax_pos; @@ -216,7 +213,6 @@ private: param_t p_integrator_max; param_t p_roll_feedforward; param_t r_p; - param_t r_d; param_t r_i; param_t r_ff; param_t r_integrator_max; From 90e4fa8a33f234bfdf8e5294203f2537e416751f Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 2 Aug 2015 14:59:40 +0200 Subject: [PATCH 140/174] TECS: Weight down speed gain --- src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c b/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c index 98ce1fa1de..ee982b8b8d 100644 --- a/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c +++ b/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c @@ -378,7 +378,7 @@ PARAM_DEFINE_FLOAT(FW_T_HRATE_FF, 0.0f); * * @group Fixed Wing TECS */ -PARAM_DEFINE_FLOAT(FW_T_SRATE_P, 0.05f); +PARAM_DEFINE_FLOAT(FW_T_SRATE_P, 0.02f); /** * Landing slope angle From 5b3449e75bec1d74737d72b39a6481a84894de04 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 2 Aug 2015 15:00:05 +0200 Subject: [PATCH 141/174] FW Att control: Crank up pitch default gains --- src/modules/fw_att_control/fw_att_control_params.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/fw_att_control/fw_att_control_params.c b/src/modules/fw_att_control/fw_att_control_params.c index 7975a3b3c3..62cd5b1556 100644 --- a/src/modules/fw_att_control/fw_att_control_params.c +++ b/src/modules/fw_att_control/fw_att_control_params.c @@ -88,7 +88,7 @@ PARAM_DEFINE_FLOAT(FW_PR_P, 0.08f); * @max 0.5 * @group FW Attitude Control */ -PARAM_DEFINE_FLOAT(FW_PR_I, 0.01f); +PARAM_DEFINE_FLOAT(FW_PR_I, 0.02f); /** * Maximum positive / up pitch rate. @@ -258,7 +258,7 @@ PARAM_DEFINE_FLOAT(FW_RR_FF, 0.5f); * @max 10.0 * @group FW Attitude Control */ -PARAM_DEFINE_FLOAT(FW_PR_FF, 0.4f); +PARAM_DEFINE_FLOAT(FW_PR_FF, 0.5f); /** * Yaw rate feed forward From 74607242422269e4d492437dafeaddf943dd5f01 Mon Sep 17 00:00:00 2001 From: Andreas Antener Date: Tue, 4 Aug 2015 11:37:08 +0200 Subject: [PATCH 142/174] fix current scaling for mavlink message --- src/modules/mavlink/mavlink_messages.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/mavlink/mavlink_messages.cpp b/src/modules/mavlink/mavlink_messages.cpp index cb56331e95..0b6dfcab5f 100644 --- a/src/modules/mavlink/mavlink_messages.cpp +++ b/src/modules/mavlink/mavlink_messages.cpp @@ -537,7 +537,7 @@ protected: msg.onboard_control_sensors_health = status.onboard_control_sensors_health; msg.load = status.load * 1000.0f; msg.voltage_battery = status.battery_voltage * 1000.0f; - msg.current_battery = status.battery_current / 10.0f; + msg.current_battery = status.battery_current * 100.0f; msg.drop_rate_comm = status.drop_rate_comm; msg.errors_comm = status.errors_comm; msg.errors_count1 = status.errors_count1; @@ -562,7 +562,7 @@ protected: bat_msg.voltages[i] = 0; } } - bat_msg.current_battery = status.battery_current / 10.0f; + bat_msg.current_battery = status.battery_current * 100.0f; bat_msg.current_consumed = status.battery_discharged_mah; bat_msg.energy_consumed = -1.0f; bat_msg.battery_remaining = (status.battery_voltage > 0) ? From fc1924deeca434b8ac668f5d56b1aace2dbd82f1 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 4 Aug 2015 23:26:54 +0200 Subject: [PATCH 143/174] Support the SYS_USE_IO=0 operation mode even with AUX mixer file present --- ROMFS/px4fmu_common/init.d/rc.interface | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ROMFS/px4fmu_common/init.d/rc.interface b/ROMFS/px4fmu_common/init.d/rc.interface index 71b670888e..571e808b6f 100644 --- a/ROMFS/px4fmu_common/init.d/rc.interface +++ b/ROMFS/px4fmu_common/init.d/rc.interface @@ -98,6 +98,13 @@ then fi # check if should load secondary mixer +set OUTPUT_AUX_DEV /dev/pwm_output1 +if [ -f $OUTPUT_AUX_DEV ] +then +else + set MIXER_AUX none +fi + if [ $MIXER_AUX != none ] then # @@ -105,7 +112,6 @@ then # set MIXER_AUX_FILE none - set OUTPUT_AUX_DEV /dev/pwm_output1 if [ -f $SDCARD_MIXERS_PATH/$MIXER_AUX.aux.mix ] then @@ -169,3 +175,4 @@ then fi fi unset OUTPUT_DEV +unset OUTPUT_AUX_DEV From 9918ff9bd43493d59e4bc40b74adc624acc9eb26 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Thu, 6 Aug 2015 00:12:14 +0200 Subject: [PATCH 144/174] Fix AUX ports, still retain successful boot for systems without IO --- ROMFS/px4fmu_common/init.d/rc.interface | 25 +++++++++++++------------ ROMFS/px4fmu_common/init.d/rcS | 14 +++++++------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/rc.interface b/ROMFS/px4fmu_common/init.d/rc.interface index 571e808b6f..61abda3427 100644 --- a/ROMFS/px4fmu_common/init.d/rc.interface +++ b/ROMFS/px4fmu_common/init.d/rc.interface @@ -97,14 +97,6 @@ then fi fi -# check if should load secondary mixer -set OUTPUT_AUX_DEV /dev/pwm_output1 -if [ -f $OUTPUT_AUX_DEV ] -then -else - set MIXER_AUX none -fi - if [ $MIXER_AUX != none ] then # @@ -112,6 +104,7 @@ then # set MIXER_AUX_FILE none + set OUTPUT_AUX_DEV /dev/pwm_output1 if [ -f $SDCARD_MIXERS_PATH/$MIXER_AUX.aux.mix ] then @@ -128,16 +121,24 @@ then then if fmu mode_pwm then - if mixer load $OUTPUT_AUX_DEV $MIXER_AUX_FILE + if [ -f $OUTPUT_AUX_DEV ] then - echo "[i] Mixer: $MIXER_AUX_FILE on $OUTPUT_AUX_DEV" + if mixer load $OUTPUT_AUX_DEV $MIXER_AUX_FILE + then + echo "[i] Mixer: $MIXER_AUX_FILE on $OUTPUT_AUX_DEV" + else + echo "[i] Error loading mixer: $MIXER_AUX_FILE" + echo "ERROR: Could not load mixer: $MIXER_AUX_FILE" >> $LOG_FILE + fi else - echo "[i] Error loading mixer: $MIXER_AUX_FILE" - echo "ERROR: Could not load mixer: $MIXER_AUX_FILE" >> $LOG_FILE + set PWM_AUX_OUT none + set FAILSAFE_AUX none fi else echo "ERROR: Could not start: fmu mode_pwm" >> $LOG_FILE tone_alarm $TUNE_ERR + set PWM_AUX_OUT none + set FAILSAFE_AUX none fi if [ $PWM_AUX_OUT != none ] diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index 608ac95ef9..ad9a311ab4 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -694,13 +694,6 @@ then fi unset FEXTRAS - if [ $EXIT_ON_END == yes ] - then - echo "Exit from nsh" - exit - fi - unset EXIT_ON_END - # Run no SD alarm if [ $LOG_FILE == /dev/null ] then @@ -712,6 +705,13 @@ then # Boot is complete, inform MAVLink app(s) that the system is now fully up and running mavlink boot_complete + if [ $EXIT_ON_END == yes ] + then + echo "Exit from nsh" + exit + fi + unset EXIT_ON_END + # End of autostart fi From e2c657ede0049d372b7171b696ba1ef64f309ba4 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Thu, 6 Aug 2015 00:13:09 +0200 Subject: [PATCH 145/174] MAVLink params: Eventually time out to make QGC happy, but let the user know that the boot failed. --- src/modules/mavlink/mavlink_parameters.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/mavlink/mavlink_parameters.cpp b/src/modules/mavlink/mavlink_parameters.cpp index 66c6a87176..6903ebfc8c 100644 --- a/src/modules/mavlink/mavlink_parameters.cpp +++ b/src/modules/mavlink/mavlink_parameters.cpp @@ -215,6 +215,10 @@ MavlinkParametersManager::send(const hrt_abstime t) if ((p == PARAM_INVALID) || (_send_all_index >= (int) param_count())) { _send_all_index = -1; } + } else if (_send_all_index == 0 && hrt_absolute_time() > 20 * 1000 * 1000) { + /* the boot did not seem to ever complete, warn user and set boot complete */ + _mavlink->send_statustext_critical("WARNING: SYSTEM BOOT INCOMPLETE. CHECK CONFIG."); + _mavlink->set_boot_complete(); } } From 003a3b0b3663b03b07bdb2f6771b80b2a190a7d0 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Thu, 6 Aug 2015 09:38:15 +0200 Subject: [PATCH 146/174] Fix file presence operator (thanks to @sjwilks) --- ROMFS/px4fmu_common/init.d/rc.interface | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ROMFS/px4fmu_common/init.d/rc.interface b/ROMFS/px4fmu_common/init.d/rc.interface index 61abda3427..f3761200a1 100644 --- a/ROMFS/px4fmu_common/init.d/rc.interface +++ b/ROMFS/px4fmu_common/init.d/rc.interface @@ -121,7 +121,7 @@ then then if fmu mode_pwm then - if [ -f $OUTPUT_AUX_DEV ] + if [ -e $OUTPUT_AUX_DEV ] then if mixer load $OUTPUT_AUX_DEV $MIXER_AUX_FILE then From 35f204249b4cf53c2539efd69b42713eba73c039 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Thu, 6 Aug 2015 20:48:53 +0200 Subject: [PATCH 147/174] Fix TBS disco default gains --- ROMFS/px4fmu_common/init.d/10015_tbs_discovery | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/10015_tbs_discovery b/ROMFS/px4fmu_common/init.d/10015_tbs_discovery index 2058d10091..fabe12703f 100644 --- a/ROMFS/px4fmu_common/init.d/10015_tbs_discovery +++ b/ROMFS/px4fmu_common/init.d/10015_tbs_discovery @@ -12,12 +12,12 @@ sh /etc/init.d/rc.mc_defaults if [ $AUTOCNF == yes ] then # TODO review MC_YAWRATE_I - param set MC_ROLL_P 8.0 - param set MC_ROLLRATE_P 0.07 + param set MC_ROLL_P 6.5 + param set MC_ROLLRATE_P 0.1 param set MC_ROLLRATE_I 0.05 param set MC_ROLLRATE_D 0.0017 - param set MC_PITCH_P 8.0 - param set MC_PITCHRATE_P 0.1 + param set MC_PITCH_P 6.5 + param set MC_PITCHRATE_P 0.14 param set MC_PITCHRATE_I 0.1 param set MC_PITCHRATE_D 0.0025 param set MC_YAW_P 2.8 From e0870d09cd98a5329f45c279142e14abd20018e6 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Thu, 6 Aug 2015 22:08:34 +0200 Subject: [PATCH 148/174] TBS disco config: Yaw rate looking good --- ROMFS/px4fmu_common/init.d/10015_tbs_discovery | 1 - 1 file changed, 1 deletion(-) diff --git a/ROMFS/px4fmu_common/init.d/10015_tbs_discovery b/ROMFS/px4fmu_common/init.d/10015_tbs_discovery index fabe12703f..0acb4088f4 100644 --- a/ROMFS/px4fmu_common/init.d/10015_tbs_discovery +++ b/ROMFS/px4fmu_common/init.d/10015_tbs_discovery @@ -11,7 +11,6 @@ sh /etc/init.d/rc.mc_defaults if [ $AUTOCNF == yes ] then - # TODO review MC_YAWRATE_I param set MC_ROLL_P 6.5 param set MC_ROLLRATE_P 0.1 param set MC_ROLLRATE_I 0.05 From ebb061764a23d075dfd22a7d6fc3a8e03f048ae9 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Thu, 6 Aug 2015 22:09:09 +0200 Subject: [PATCH 149/174] MC attitude control: Limit yaw rate further to avoid mixer saturation in the first place --- src/modules/mc_att_control/mc_att_control_params.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/mc_att_control/mc_att_control_params.c b/src/modules/mc_att_control/mc_att_control_params.c index 42c7bc3d04..9af68a4e1e 100644 --- a/src/modules/mc_att_control/mc_att_control_params.c +++ b/src/modules/mc_att_control/mc_att_control_params.c @@ -232,14 +232,16 @@ PARAM_DEFINE_FLOAT(MC_PITCHRATE_MAX, 360.0f); /** * Max yaw rate * - * Limit for yaw rate, has effect for large rotations in autonomous mode, to avoid large control output and mixer saturation. + * Limit for yaw rate, has effect for large rotations in autonomous mode, + * to avoid large control output and mixer saturation. A value of significantly + * over 60 degrees per second can already lead to mixer saturation. * * @unit deg/s * @min 0.0 * @max 360.0 * @group Multicopter Attitude Control */ -PARAM_DEFINE_FLOAT(MC_YAWRATE_MAX, 120.0f); +PARAM_DEFINE_FLOAT(MC_YAWRATE_MAX, 60.0f); /** * Max acro roll rate From 8b7f1cf560220f649001d2927e4831dd9504be31 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Thu, 6 Aug 2015 22:09:35 +0200 Subject: [PATCH 150/174] MC multi attitude control: Limit yaw rate to avoid mixer saturation. --- .../mc_att_control_multiplatform/mc_att_control_params.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/mc_att_control_multiplatform/mc_att_control_params.h b/src/modules/mc_att_control_multiplatform/mc_att_control_params.h index c3b71715bb..bb7f7360e4 100644 --- a/src/modules/mc_att_control_multiplatform/mc_att_control_params.h +++ b/src/modules/mc_att_control_multiplatform/mc_att_control_params.h @@ -56,7 +56,7 @@ #define PARAM_MP_YAWRATE_I_DEFAULT 0.0f #define PARAM_MP_YAWRATE_D_DEFAULT 0.0f #define PARAM_MP_YAW_FF_DEFAULT 0.5f -#define PARAM_MP_YAWRATE_MAX_DEFAULT 120.0f +#define PARAM_MP_YAWRATE_MAX_DEFAULT 60.0f #define PARAM_MP_ACRO_R_MAX_DEFAULT 35.0f #define PARAM_MP_ACRO_P_MAX_DEFAULT 35.0f #define PARAM_MP_ACRO_Y_MAX_DEFAULT 120.0f From 08c1123c4901186b4c8d5191ba56e50f593e278b Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 7 Aug 2015 14:40:18 +0200 Subject: [PATCH 151/174] Airframes meta scanner: Do not require particular file ending --- Tools/px4airframes/srcscanner.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Tools/px4airframes/srcscanner.py b/Tools/px4airframes/srcscanner.py index c1f280668d..cb31906a30 100644 --- a/Tools/px4airframes/srcscanner.py +++ b/Tools/px4airframes/srcscanner.py @@ -16,10 +16,9 @@ class SourceScanner(object): extensions = tuple(parser.GetSupportedExtensions()) for dirname, dirnames, filenames in os.walk(srcdir): for filename in filenames: - if filename.endswith(extensions): - path = os.path.join(dirname, filename) - if not self.ScanFile(path, parser): - return False + path = os.path.join(dirname, filename) + if not self.ScanFile(path, parser): + return False return True def ScanFile(self, path, parser): From f4d5149a842bfbcc73262b5b8659a207a3dae160 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 7 Aug 2015 15:49:23 +0200 Subject: [PATCH 152/174] Fix airframe generation by adding missing slash (Windows) --- makefiles/firmware.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefiles/firmware.mk b/makefiles/firmware.mk index 0aff25cfea..2d971e1c58 100644 --- a/makefiles/firmware.mk +++ b/makefiles/firmware.mk @@ -503,7 +503,7 @@ $(PRODUCT_BUNDLE): $(PRODUCT_BIN) @$(ECHO) %% Generating $@ ifdef GEN_PARAM_XML $(Q) $(PYTHON) $(PX4_BASE)/Tools/px_process_params.py --src-path $(PX4_BASE)/src --board CONFIG_ARCH_BOARD_$(CONFIG_BOARD) --xml - $(Q) $(PYTHON) $(PX4_BASE)/Tools/px_process_airframes.py -a $(PX4_BASE)/ROMFS/px4fmu_common/init.d --board CONFIG_ARCH_BOARD_$(CONFIG_BOARD) --xml + $(Q) $(PYTHON) $(PX4_BASE)/Tools/px_process_airframes.py -a $(PX4_BASE)/ROMFS/px4fmu_common/init.d/ --board CONFIG_ARCH_BOARD_$(CONFIG_BOARD) --xml $(Q) $(MKFW) --prototype $(IMAGE_DIR)/$(BOARD).prototype \ --git_identity $(PX4_BASE) \ --parameter_xml $(PRODUCT_PARAMXML) \ From 7d07fc98ba392e0f65321cc75442837ce336477d Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 7 Aug 2015 17:46:23 +0200 Subject: [PATCH 153/174] Fix boot script handling --- makefiles/firmware.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/makefiles/firmware.mk b/makefiles/firmware.mk index 2d971e1c58..44c0de62ad 100644 --- a/makefiles/firmware.mk +++ b/makefiles/firmware.mk @@ -375,10 +375,10 @@ ifneq ($(ROMFS_EXTRA_FILES),) $(Q) $(MKDIR) -p $(ROMFS_SCRATCH)/extras $(Q) $(COPY) $(ROMFS_EXTRA_FILES) $(ROMFS_SCRATCH)/extras endif - $(Q) $(PYTHON) -u $(ROMFS_AUTOSTART) -a $(ROMFS_ROOT)/init.d -s $(ROMFS_SCRATCH)/init.d/rc.autostart + $(Q) $(PYTHON) -u $(ROMFS_AUTOSTART) -a $(ROMFS_ROOT)/init.d/ -s $(ROMFS_SCRATCH)/init.d/rc.autostart # Execute in standard dir as well # so developers notice the generated file - $(Q) $(PYTHON) -u $(ROMFS_AUTOSTART) -a $(ROMFS_ROOT)/init.d -s $(ROMFS_ROOT)/init.d/rc.autostart + $(Q) $(PYTHON) -u $(ROMFS_AUTOSTART) -a $(ROMFS_ROOT)/init.d/ -s $(ROMFS_ROOT)/init.d/rc.autostart $(Q) $(PYTHON) -u $(ROMFS_PRUNER) --folder $(ROMFS_SCRATCH) EXTRA_CLEANS += $(ROMGS_OBJ) $(ROMFS_IMG) From e829eb0670447abd57e17c16c66039f3906d2004 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 8 Aug 2015 00:07:09 +0200 Subject: [PATCH 154/174] MAVLink app: Fix for hardware multiplier resetting to 1 once limitation was overcome. --- src/modules/mavlink/mavlink_main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index b4474f96dc..1e0b3ddb3e 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -1282,6 +1282,9 @@ Mavlink::update_rate_mult() /* limit to a max multiplier of 1 */ hardware_mult = fminf(1.0f, hardware_mult); } + } else { + /* no limitation, set hardware to 1 */ + hardware_mult = 1.0f; } _last_hw_rate_timestamp = tstatus.timestamp; From 0cae5f224c1beed8a98b7c06f18b65da533f6acf Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 8 Aug 2015 00:08:14 +0200 Subject: [PATCH 155/174] Commander: Trigger preflight check on every reconnect, but not when armed. Make RC regained and other messages non-critical. Implement param reset method. --- src/modules/commander/commander.cpp | 36 +++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp index f045cb4b04..57e175ed19 100644 --- a/src/modules/commander/commander.cpp +++ b/src/modules/commander/commander.cpp @@ -1348,10 +1348,15 @@ int commander_thread_main(int argc, char *argv[]) orb_copy(telemetry_status_orb_id[i], telemetry_subs[i], &telemetry); /* perform system checks when new telemetry link connected */ - if (mavlink_fd && - telemetry_last_heartbeat[i] == 0 && + if ( + /* we actually have a way to talk to the user */ + mavlink_fd && + /* we first connect a link or re-connect a link after loosing it */ + (telemetry_last_heartbeat[i] == 0 || (hrt_elapsed_time(&telemetry_last_heartbeat[i]) > 3 * 1000 * 1000)) && + /* and this link has a communication partner */ telemetry.heartbeat_time > 0 && - hrt_elapsed_time(&telemetry.heartbeat_time) < datalink_loss_timeout * 1e6) { + /* and the system is not already armed (and potentially flying) */ + !armed.armed) { bool chAirspeed = false; /* Perform airspeed check only if circuit breaker is not @@ -1823,7 +1828,7 @@ int commander_thread_main(int argc, char *argv[]) } else { if (status.rc_signal_lost) { - mavlink_log_critical(mavlink_fd, "RC SIGNAL REGAINED after %llums", + mavlink_log_info(mavlink_fd, "RC SIGNAL REGAINED after %llums", (hrt_absolute_time() - status.rc_signal_lost_timestamp) / 1000); status_changed = true; } @@ -1950,7 +1955,7 @@ int commander_thread_main(int argc, char *argv[]) /* only report a regain */ if (telemetry_last_dl_loss[i] > 0) { - mavlink_and_console_log_critical(mavlink_fd, "data link #%i regained", i); + mavlink_and_console_log_info(mavlink_fd, "data link #%i regained", i); } telemetry_lost[i] = false; @@ -1968,7 +1973,7 @@ int commander_thread_main(int argc, char *argv[]) /* only reset the timestamp to a different time on state change */ telemetry_last_dl_loss[i] = hrt_absolute_time(); - mavlink_and_console_log_critical(mavlink_fd, "data link #%i lost", i); + mavlink_and_console_log_info(mavlink_fd, "data link #%i lost", i); telemetry_lost[i] = true; } } @@ -1983,7 +1988,9 @@ int commander_thread_main(int argc, char *argv[]) } else { if (!status.data_link_lost) { - mavlink_and_console_log_critical(mavlink_fd, "ALL DATA LINKS LOST"); + if (armed.armed) { + mavlink_and_console_log_critical(mavlink_fd, "ALL DATA LINKS LOST"); + } status.data_link_lost = true; status.data_link_lost_counter++; status_changed = true; @@ -2978,6 +2985,21 @@ void *commander_low_prio_loop(void *arg) mavlink_log_critical(mavlink_fd, "ERROR: %s", strerror(ret)); } + answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_FAILED); + } + } else if (((int)(cmd.param1)) == 2) { + + /* reset parameters and save empty file */ + param_reset_all(); + int ret = param_save_default(); + + if (ret == OK) { + /* do not spam MAVLink, but provide the answer / green led mechanism */ + mavlink_log_critical(mavlink_fd, "onboard parameters reset"); + answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED); + + } else { + mavlink_log_critical(mavlink_fd, "param reset error"); answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_FAILED); } } From bdeca34830f48e75c048b763660d9691eef9cbbb Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 8 Aug 2015 00:10:01 +0200 Subject: [PATCH 156/174] Mark boot complete in all conditions, not just if autostart has been configured already. --- ROMFS/px4fmu_common/init.d/rcS | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index ad9a311ab4..dfa270b048 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -702,19 +702,19 @@ then tone_alarm error fi - # Boot is complete, inform MAVLink app(s) that the system is now fully up and running - mavlink boot_complete - - if [ $EXIT_ON_END == yes ] - then - echo "Exit from nsh" - exit - fi - unset EXIT_ON_END - # End of autostart fi +# Boot is complete, inform MAVLink app(s) that the system is now fully up and running +mavlink boot_complete + +if [ $EXIT_ON_END == yes ] +then + echo "Exit from nsh" + exit +fi +unset EXIT_ON_END + # There is no further processing, so we can free some RAM # XXX potentially unset all script variables. unset TUNE_ERR From e09771be17d8965f8928b6d577e4222c01e67fa6 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 8 Aug 2015 11:31:58 +0200 Subject: [PATCH 157/174] NSH terminal: Increase hold-off time to ensure USB is up and running --- src/systemcmds/nshterm/nshterm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/systemcmds/nshterm/nshterm.c b/src/systemcmds/nshterm/nshterm.c index 50547a5626..bdfd26a64d 100644 --- a/src/systemcmds/nshterm/nshterm.c +++ b/src/systemcmds/nshterm/nshterm.c @@ -68,8 +68,8 @@ nshterm_main(int argc, char *argv[]) int armed_fd = orb_subscribe(ORB_ID(actuator_armed)); struct actuator_armed_s armed; - /* back off 800 ms to avoid running into the USB setup timing */ - while (hrt_absolute_time() < 800U * 1000U) { + /* back off 1500 ms to avoid running into the USB setup timing */ + while (hrt_absolute_time() < 1500U * 1000U) { usleep(50000); } From 4cfad588ffadcb4beb0358bff91a6bef2ae80263 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 8 Aug 2015 23:49:18 +0200 Subject: [PATCH 158/174] IO: Add param for S.BUS output --- src/drivers/px4io/px4io_params.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/drivers/px4io/px4io_params.c b/src/drivers/px4io/px4io_params.c index 057bcaf150..51d39e97ba 100644 --- a/src/drivers/px4io/px4io_params.c +++ b/src/drivers/px4io/px4io_params.c @@ -129,3 +129,14 @@ PARAM_DEFINE_INT32(PWM_MAIN_REV7, 0); * @group PWM Outputs */ PARAM_DEFINE_INT32(PWM_MAIN_REV8, 0); + +/** + * Enable S.BUS out + * + * Set to 1 to enable S.BUS version 1 output instead of RSSI. + * + * @min 0 + * @max 1 + * @group PWM Outputs + */ +PARAM_DEFINE_INT32(PWM_SBUS_MODE, 0); From e07e4743c5bd10e582f2d64f341ad0da051a2308 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 8 Aug 2015 23:50:05 +0200 Subject: [PATCH 159/174] PX4IO: Enable S.BUS if config param is set, ignore if no param present --- src/drivers/px4io/px4io.cpp | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp index be3c2e1375..716a89d254 100644 --- a/src/drivers/px4io/px4io.cpp +++ b/src/drivers/px4io/px4io.cpp @@ -1116,25 +1116,42 @@ PX4IO::task_main() (void)io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_PWM_REVERSE, pwm_invert_mask); float trim_val; - param_t trim_parm; + param_t parm_handle; - trim_parm = param_find("TRIM_ROLL"); - if (trim_parm != PARAM_INVALID) { - param_get(trim_parm, &trim_val); + parm_handle = param_find("TRIM_ROLL"); + if (parm_handle != PARAM_INVALID) { + param_get(parm_handle, &trim_val); (void)io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_TRIM_ROLL, FLOAT_TO_REG(trim_val)); } - trim_parm = param_find("TRIM_PITCH"); - if (trim_parm != PARAM_INVALID) { - param_get(trim_parm, &trim_val); + parm_handle = param_find("TRIM_PITCH"); + if (parm_handle != PARAM_INVALID) { + param_get(parm_handle, &trim_val); (void)io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_TRIM_PITCH, FLOAT_TO_REG(trim_val)); } - trim_parm = param_find("TRIM_YAW"); - if (trim_parm != PARAM_INVALID) { - param_get(trim_parm, &trim_val); + parm_handle = param_find("TRIM_YAW"); + if (parm_handle != PARAM_INVALID) { + param_get(parm_handle, &trim_val); (void)io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_TRIM_YAW, FLOAT_TO_REG(trim_val)); } + + /* S.BUS output */ + int sbus_mode; + parm_handle = param_find("PWM_SBUS_MODE"); + if (parm_handle != PARAM_INVALID) { + param_get(parm_handle, &sbus_mode); + if (sbus_mode == 1) { + /* enable S.BUS 1 */ + (void)io_reg_modify(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_FEATURES, 0, PX4IO_P_SETUP_FEATURES_SBUS1_OUT); + } else if (sbus_mode == 2) { + /* enable S.BUS 2 */ + (void)io_reg_modify(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_FEATURES, 0, PX4IO_P_SETUP_FEATURES_SBUS2_OUT); + } else { + /* disable S.BUS */ + (void)io_reg_modify(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_FEATURES, (PX4IO_P_SETUP_FEATURES_SBUS1_OUT | PX4IO_P_SETUP_FEATURES_SBUS2_OUT), 0); + } + } } } From 4c79f8d4a2aac61db8f4c80ae3459cc87c103914 Mon Sep 17 00:00:00 2001 From: Simon Wilks Date: Sat, 8 Aug 2015 16:15:11 +0200 Subject: [PATCH 160/174] Backported VTOL to beta branch. --- ROMFS/px4fmu_common/init.d/13002_firefly6 | 14 +++-- ROMFS/px4fmu_common/init.d/rcS | 4 ++ ROMFS/px4fmu_common/mixers/firefly6.aux.mix | 6 +- .../fw_att_control/fw_att_control_main.cpp | 9 +-- src/modules/vtol_att_control/module.mk | 4 +- src/modules/vtol_att_control/tiltrotor.cpp | 58 ++++++++----------- src/modules/vtol_att_control/tiltrotor.h | 3 +- .../vtol_att_control/tiltrotor_params.c | 39 +------------ .../vtol_att_control_main.cpp | 6 ++ .../vtol_att_control/vtol_att_control_main.h | 2 + .../vtol_att_control_params.c | 48 ++++++++++++++- src/modules/vtol_att_control/vtol_type.h | 4 +- 12 files changed, 109 insertions(+), 88 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/13002_firefly6 b/ROMFS/px4fmu_common/init.d/13002_firefly6 index 1ec65dff3e..52c6258c39 100644 --- a/ROMFS/px4fmu_common/init.d/13002_firefly6 +++ b/ROMFS/px4fmu_common/init.d/13002_firefly6 @@ -12,21 +12,25 @@ sh /etc/init.d/rc.vtol_defaults if [ $AUTOCNF == yes ] then param set MC_ROLL_P 7.0 - param set MC_ROLLRATE_P 0.15 + param set MC_ROLLRATE_P 0.17 param set MC_ROLLRATE_I 0.002 - param set MC_ROLLRATE_D 0.003 + param set MC_ROLLRATE_D 0.004 param set MC_ROLLRATE_FF 0.0 param set MC_PITCH_P 7.0 - param set MC_PITCHRATE_P 0.12 + param set MC_PITCHRATE_P 0.14 param set MC_PITCHRATE_I 0.002 - param set MC_PITCHRATE_D 0.003 + param set MC_PITCHRATE_D 0.004 param set MC_PITCHRATE_FF 0.0 - param set MC_YAW_P 2.8 + param set MC_YAW_P 3.8 param set MC_YAW_FF 0.5 param set MC_YAWRATE_P 0.22 param set MC_YAWRATE_I 0.02 param set MC_YAWRATE_D 0.0 param set MC_YAWRATE_FF 0.0 + + param set VT_TILT_MC 0.08 + param set VT_TILT_TRANS 0.5 + param set VT_TILT_FW 0.9 fi set MIXER firefly6 diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index dfa270b048..d45cb7c97a 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -626,6 +626,10 @@ then then set MAV_TYPE 21 fi + if [ $MIXER == quad_x_pusher_vtol ] + then + set MAV_TYPE 22 + fi fi # Still no MAV_TYPE found diff --git a/ROMFS/px4fmu_common/mixers/firefly6.aux.mix b/ROMFS/px4fmu_common/mixers/firefly6.aux.mix index 22dc2a69ce..8e31007ff1 100644 --- a/ROMFS/px4fmu_common/mixers/firefly6.aux.mix +++ b/ROMFS/px4fmu_common/mixers/firefly6.aux.mix @@ -5,18 +5,18 @@ Tilt mechanism servo mixer --------------------------- M: 1 O: 10000 10000 0 -10000 10000 -S: 1 4 10000 10000 0 -10000 10000 +S: 1 4 0 20000 -10000 -10000 10000 Elevon mixers ------------- M: 2 O: 10000 10000 0 -10000 10000 -S: 1 0 -7500 -7500 0 -10000 10000 +S: 1 0 -7500 -7500 0 -10000 10000 S: 1 1 8000 8000 0 -10000 10000 M: 2 O: 10000 10000 0 -10000 10000 -S: 1 0 -7500 -7500 0 -10000 10000 +S: 1 0 -7500 -7500 0 -10000 10000 S: 1 1 -8000 -8000 0 -10000 10000 Landing gear mixer diff --git a/src/modules/fw_att_control/fw_att_control_main.cpp b/src/modules/fw_att_control/fw_att_control_main.cpp index 43c44aaeac..9a92f5c70e 100644 --- a/src/modules/fw_att_control/fw_att_control_main.cpp +++ b/src/modules/fw_att_control/fw_att_control_main.cpp @@ -695,7 +695,6 @@ FixedwingAttitudeControl::task_main() /* only run controller if attitude changed */ if (fds[1].revents & POLLIN) { - static uint64_t last_run = 0; float deltaT = (hrt_absolute_time() - last_run) / 1000000.0f; last_run = hrt_absolute_time(); @@ -799,6 +798,11 @@ FixedwingAttitudeControl::task_main() //warnx("_actuators_airframe.control[1] = -1.0f;"); } + /* if we are in rotary wing mode, do nothing */ + if (_vehicle_status.is_rotary_wing && !_vehicle_status.is_vtol) { + continue; + } + /* default flaps to center */ float flaps_control = 0.0f; @@ -808,11 +812,8 @@ FixedwingAttitudeControl::task_main() } /* decide if in stabilized or full manual control */ - if (_vcontrol_mode.flag_control_attitude_enabled) { - /* scale around tuning airspeed */ - float airspeed; /* if airspeed is not updating, we assume the normal average speed */ diff --git a/src/modules/vtol_att_control/module.mk b/src/modules/vtol_att_control/module.mk index ad6efd2b27..d3f9326b04 100644 --- a/src/modules/vtol_att_control/module.mk +++ b/src/modules/vtol_att_control/module.mk @@ -42,6 +42,8 @@ SRCS = vtol_att_control_main.cpp \ tiltrotor_params.c \ tiltrotor.cpp \ vtol_type.cpp \ - tailsitter.cpp + tailsitter.cpp \ + standard_params.c \ + standard.cpp EXTRACXXFLAGS = -Wno-write-strings diff --git a/src/modules/vtol_att_control/tiltrotor.cpp b/src/modules/vtol_att_control/tiltrotor.cpp index 2cf074fe42..e7ebab58e9 100644 --- a/src/modules/vtol_att_control/tiltrotor.cpp +++ b/src/modules/vtol_att_control/tiltrotor.cpp @@ -194,7 +194,7 @@ void Tiltrotor::update_mc_state() void Tiltrotor::process_mc_data() { - fill_mc_att_control_output(); + fill_att_control_output(); } void Tiltrotor::update_fw_state() @@ -222,19 +222,22 @@ void Tiltrotor::process_mc_data() void Tiltrotor::process_fw_data() { - fill_fw_att_control_output(); + fill_att_control_output(); } void Tiltrotor::update_transition_state() { if (_vtol_schedule.flight_mode == TRANSITION_FRONT_P1) { // tilt rotors forward up to certain angle - if (_tilt_control <= _params_tiltrotor.tilt_transition) { - _tilt_control = _params_tiltrotor.tilt_mc + fabsf(_params_tiltrotor.tilt_transition - _params_tiltrotor.tilt_mc)*(float)hrt_elapsed_time(&_vtol_schedule.transition_start)/(_params_tiltrotor.front_trans_dur*1000000.0f); + if (_params_tiltrotor.front_trans_dur <= 0.0f) { + _tilt_control = _params_tiltrotor.tilt_transition; + } else if (_tilt_control <= _params_tiltrotor.tilt_transition) { + _tilt_control = _params_tiltrotor.tilt_mc + fabsf(_params_tiltrotor.tilt_transition - _params_tiltrotor.tilt_mc) * + (float) hrt_elapsed_time(&_vtol_schedule.transition_start) / (_params_tiltrotor.front_trans_dur * 1000000.0f); } // do blending of mc and fw controls - if (_airspeed->true_airspeed_m_s >= ARSP_BLEND_START) { + if (_airspeed->true_airspeed_m_s >= ARSP_BLEND_START && _params_tiltrotor.airspeed_trans - ARSP_BLEND_START > 0.0f) { _roll_weight_mc = 1.0f - (_airspeed->true_airspeed_m_s - ARSP_BLEND_START) / (_params_tiltrotor.airspeed_trans - ARSP_BLEND_START); } else { // at low speeds give full weight to mc @@ -244,13 +247,14 @@ void Tiltrotor::update_transition_state() _roll_weight_mc = math::constrain(_roll_weight_mc, 0.0f, 1.0f); } else if (_vtol_schedule.flight_mode == TRANSITION_FRONT_P2) { - _tilt_control = _params_tiltrotor.tilt_transition + fabsf(_params_tiltrotor.tilt_fw - _params_tiltrotor.tilt_transition)*(float)hrt_elapsed_time(&_vtol_schedule.transition_start)/(0.5f*1000000.0f); + _tilt_control = _params_tiltrotor.tilt_transition + fabsf(_params_tiltrotor.tilt_fw - _params_tiltrotor.tilt_transition) * + (float) hrt_elapsed_time(&_vtol_schedule.transition_start) / (0.5f * 1000000.0f); _roll_weight_mc = 0.0f; } else if (_vtol_schedule.flight_mode == TRANSITION_BACK) { // tilt rotors forward up to certain angle - float progress = (float)hrt_elapsed_time(&_vtol_schedule.transition_start)/(_params_tiltrotor.back_trans_dur*1000000.0f); + float progress = (float) hrt_elapsed_time(&_vtol_schedule.transition_start) / (_params_tiltrotor.back_trans_dur * 1000000.0f); if (_tilt_control > _params_tiltrotor.tilt_mc) { - _tilt_control = _params_tiltrotor.tilt_fw - fabsf(_params_tiltrotor.tilt_fw - _params_tiltrotor.tilt_mc)*progress; + _tilt_control = _params_tiltrotor.tilt_fw - fabsf(_params_tiltrotor.tilt_fw - _params_tiltrotor.tilt_mc) * progress; } _roll_weight_mc = progress; @@ -263,38 +267,26 @@ void Tiltrotor::update_external_state() } /** -* Prepare message to acutators with data from mc attitude controller. +* Prepare message to acutators with data from the attitude controllers. */ -void Tiltrotor::fill_mc_att_control_output() +void Tiltrotor::fill_att_control_output() { - _actuators_out_0->control[0] = _actuators_mc_in->control[0]; - _actuators_out_0->control[1] = _actuators_mc_in->control[1]; - _actuators_out_0->control[2] = _actuators_mc_in->control[2]; - _actuators_out_0->control[3] = _actuators_mc_in->control[3]; + _actuators_out_0->control[0] = _actuators_mc_in->control[0] * _roll_weight_mc; // roll + _actuators_out_0->control[1] = _actuators_mc_in->control[1] * _roll_weight_mc; // pitch + _actuators_out_0->control[2] = _actuators_mc_in->control[2] * _roll_weight_mc; // yaw + + if (_vtol_schedule.flight_mode == FW_MODE) { + _actuators_out_1->control[3] = _actuators_fw_in->control[3]; // fw throttle + } else { + _actuators_out_0->control[3] = _actuators_mc_in->control[3]; // mc throttle + } _actuators_out_1->control[0] = -_actuators_fw_in->control[0] * (1.0f - _roll_weight_mc); //roll elevon - _actuators_out_1->control[1] = (_actuators_fw_in->control[1] + _params->fw_pitch_trim)* (1.0f -_roll_weight_mc); //pitch elevon - + _actuators_out_1->control[1] = (_actuators_fw_in->control[1] + _params->fw_pitch_trim)* (1.0f -_roll_weight_mc); //pitch elevon _actuators_out_1->control[4] = _tilt_control; // for tilt-rotor control -} -/** -* Prepare message to acutators with data from fw attitude controller. -*/ -void Tiltrotor::fill_fw_att_control_output() -{ - /*For the first test in fw mode, only use engines for thrust!!!*/ - _actuators_out_0->control[0] = _actuators_mc_in->control[0] * _roll_weight_mc; - _actuators_out_0->control[1] = _actuators_mc_in->control[1] * _roll_weight_mc; - _actuators_out_0->control[2] = _actuators_mc_in->control[2] * _roll_weight_mc; - _actuators_out_0->control[3] = _actuators_fw_in->control[3]; - /*controls for the elevons */ - _actuators_out_1->control[0] = -_actuators_fw_in->control[0]; // roll elevon - _actuators_out_1->control[1] = _actuators_fw_in->control[1] + _params->fw_pitch_trim; // pitch elevon // unused now but still logged - _actuators_out_1->control[2] = _actuators_fw_in->control[2]; // yaw - _actuators_out_1->control[3] = _actuators_fw_in->control[3]; // throttle - _actuators_out_1->control[4] = _tilt_control; + _actuators_out_1->control[2] = _actuators_fw_in->control[2]; // fw yaw } /** diff --git a/src/modules/vtol_att_control/tiltrotor.h b/src/modules/vtol_att_control/tiltrotor.h index 3ef1362d00..07f3562027 100644 --- a/src/modules/vtol_att_control/tiltrotor.h +++ b/src/modules/vtol_att_control/tiltrotor.h @@ -99,8 +99,7 @@ private: float _tilt_control; float _roll_weight_mc; - void fill_mc_att_control_output(); - void fill_fw_att_control_output(); + void fill_att_control_output(); void set_max_mc(); void set_max_fw(unsigned pwm_value); diff --git a/src/modules/vtol_att_control/tiltrotor_params.c b/src/modules/vtol_att_control/tiltrotor_params.c index 7d233f6f50..d4e925f072 100644 --- a/src/modules/vtol_att_control/tiltrotor_params.c +++ b/src/modules/vtol_att_control/tiltrotor_params.c @@ -39,28 +39,6 @@ */ #include - -/** - * Duration of a front transition - * - * Time in seconds used for a transition - * - * @min 0.0 - * @max 5 - * @group VTOL Attitude Control - */ -PARAM_DEFINE_FLOAT(VT_F_TRANS_DUR,3.0f); - -/** - * Duration of a back transition - * - * Time in seconds used for a back transition - * - * @min 0.0 - * @max 5 - * @group VTOL Attitude Control - */ -PARAM_DEFINE_FLOAT(VT_B_TRANS_DUR,2.0f); /** * Position of tilt servo in mc mode @@ -71,7 +49,7 @@ PARAM_DEFINE_FLOAT(VT_B_TRANS_DUR,2.0f); * @max 1 * @group VTOL Attitude Control */ -PARAM_DEFINE_FLOAT(VT_TILT_MC,0.0f); +PARAM_DEFINE_FLOAT(VT_TILT_MC, 0.0f); /** * Position of tilt servo in transition mode @@ -82,7 +60,7 @@ PARAM_DEFINE_FLOAT(VT_TILT_MC,0.0f); * @max 1 * @group VTOL Attitude Control */ -PARAM_DEFINE_FLOAT(VT_TILT_TRANS,0.3f); +PARAM_DEFINE_FLOAT(VT_TILT_TRANS, 0.3f); /** * Position of tilt servo in fw mode @@ -93,15 +71,4 @@ PARAM_DEFINE_FLOAT(VT_TILT_TRANS,0.3f); * @max 1 * @group VTOL Attitude Control */ -PARAM_DEFINE_FLOAT(VT_TILT_FW,1.0f); - -/** - * Transition airspeed - * - * Airspeed at which we can switch to fw mode - * - * @min 0.0 - * @max 20 - * @group VTOL Attitude Control - */ -PARAM_DEFINE_FLOAT(VT_ARSP_TRANS,10.0f); +PARAM_DEFINE_FLOAT(VT_TILT_FW, 1.0f); diff --git a/src/modules/vtol_att_control/vtol_att_control_main.cpp b/src/modules/vtol_att_control/vtol_att_control_main.cpp index b70cd19dd8..0d462423b6 100644 --- a/src/modules/vtol_att_control/vtol_att_control_main.cpp +++ b/src/modules/vtol_att_control/vtol_att_control_main.cpp @@ -122,6 +122,9 @@ VtolAttitudeControl::VtolAttitudeControl() : } else if (_params.vtol_type == 1) { _tiltrotor = new Tiltrotor(this); _vtol_type = _tiltrotor; + } else if (_params.vtol_type == 2) { + _standard = new Standard(this); + _vtol_type = _standard; } else { _task_should_exit = true; } @@ -530,6 +533,9 @@ void VtolAttitudeControl::task_main() // update transition state if got any new data if (got_new_data) { _vtol_type->update_transition_state(); + + _vtol_type->process_mc_data(); + fill_mc_att_rates_sp(); } } else if (_vtol_type->get_mode() == EXTERNAL) { diff --git a/src/modules/vtol_att_control/vtol_att_control_main.h b/src/modules/vtol_att_control/vtol_att_control_main.h index 43e8969929..bf9a69d5c1 100644 --- a/src/modules/vtol_att_control/vtol_att_control_main.h +++ b/src/modules/vtol_att_control/vtol_att_control_main.h @@ -84,6 +84,7 @@ #include "tiltrotor.h" #include "tailsitter.h" +#include "standard.h" extern "C" __EXPORT int vtol_att_control_main(int argc, char *argv[]); @@ -188,6 +189,7 @@ private: VtolType * _vtol_type; // base class for different vtol types Tiltrotor * _tiltrotor; // tailsitter vtol type Tailsitter * _tailsitter; // tiltrotor vtol type + Standard * _standard; // standard vtol type //*****************Member functions*********************************************************************** diff --git a/src/modules/vtol_att_control/vtol_att_control_params.c b/src/modules/vtol_att_control/vtol_att_control_params.c index 33c095036c..56779ca8f9 100644 --- a/src/modules/vtol_att_control/vtol_att_control_params.c +++ b/src/modules/vtol_att_control/vtol_att_control_params.c @@ -143,10 +143,10 @@ PARAM_DEFINE_FLOAT(VT_PROP_EFF, 0.0f); PARAM_DEFINE_FLOAT(VT_ARSP_LP_GAIN, 0.3f); /** - * VTOL Type (Tailsitter=0, Tiltrotor=1) + * VTOL Type (Tailsitter=0, Tiltrotor=1, Standard=2) * * @min 0 - * @max 1 + * @max 2 * @group VTOL Attitude Control */ PARAM_DEFINE_INT32(VT_TYPE, 0); @@ -161,3 +161,47 @@ PARAM_DEFINE_INT32(VT_TYPE, 0); * @group VTOL Attitude Control */ PARAM_DEFINE_INT32(VT_ELEV_MC_LOCK, 0); + +/** + * Duration of a front transition + * + * Time in seconds used for a transition + * + * @min 0.0 + * @max 5 + * @group VTOL Attitude Control + */ +PARAM_DEFINE_FLOAT(VT_F_TRANS_DUR, 3.0f); + +/** + * Duration of a back transition + * + * Time in seconds used for a back transition + * + * @min 0.0 + * @max 5 + * @group VTOL Attitude Control + */ +PARAM_DEFINE_FLOAT(VT_B_TRANS_DUR, 2.0f); + +/** + * Transition blending airspeed + * + * Airspeed at which we can start blending both fw and mc controls. Set to 0 to disable. + * + * @min 0.0 + * @max 20.0 + * @group VTOL Attitude Control + */ +PARAM_DEFINE_FLOAT(VT_ARSP_BLEND, 8.0f); + +/** + * Transition airspeed + * + * Airspeed at which we can switch to fw mode + * + * @min 1.0 + * @max 20 + * @group VTOL Attitude Control + */ +PARAM_DEFINE_FLOAT(VT_ARSP_TRANS, 10.0f); diff --git a/src/modules/vtol_att_control/vtol_type.h b/src/modules/vtol_att_control/vtol_type.h index bbe6a8642e..a7fdbdde1a 100644 --- a/src/modules/vtol_att_control/vtol_type.h +++ b/src/modules/vtol_att_control/vtol_type.h @@ -38,8 +38,8 @@ * */ -#ifndef VTOL_YYPE_H -#define VTOL_YYPE_H +#ifndef VTOL_TYPE_H +#define VTOL_TYPE_H struct Params { int idle_pwm_mc; // pwm value for idle in mc mode From 9ef34b5d1cb2dbf6f5f61ed98031020274b3af42 Mon Sep 17 00:00:00 2001 From: Simon Wilks Date: Sat, 8 Aug 2015 16:16:59 +0200 Subject: [PATCH 161/174] Add standard VTOL airframe. --- .../init.d/13005_vtol_AAERT_quad | 50 +++ .../px4fmu_common/init.d/13005_vtol_AERT_quad | 50 +++ ROMFS/px4fmu_common/mixers/vtol_AAERT.aux.mix | 32 ++ ROMFS/px4fmu_common/mixers/vtol_AERT.aux.mix | 30 ++ .../px4fmu_common/mixers/vtol_quad_x.main.mix | 4 + src/modules/vtol_att_control/standard.cpp | 296 ++++++++++++++++++ src/modules/vtol_att_control/standard.h | 107 +++++++ .../vtol_att_control/standard_params.c | 51 +++ 8 files changed, 620 insertions(+) create mode 100644 ROMFS/px4fmu_common/init.d/13005_vtol_AAERT_quad create mode 100644 ROMFS/px4fmu_common/init.d/13005_vtol_AERT_quad create mode 100644 ROMFS/px4fmu_common/mixers/vtol_AAERT.aux.mix create mode 100644 ROMFS/px4fmu_common/mixers/vtol_AERT.aux.mix create mode 100644 ROMFS/px4fmu_common/mixers/vtol_quad_x.main.mix create mode 100644 src/modules/vtol_att_control/standard.cpp create mode 100644 src/modules/vtol_att_control/standard.h create mode 100644 src/modules/vtol_att_control/standard_params.c diff --git a/ROMFS/px4fmu_common/init.d/13005_vtol_AAERT_quad b/ROMFS/px4fmu_common/init.d/13005_vtol_AAERT_quad new file mode 100644 index 0000000000..4b8191f557 --- /dev/null +++ b/ROMFS/px4fmu_common/init.d/13005_vtol_AAERT_quad @@ -0,0 +1,50 @@ +#!nsh +# +# @name Generic AAERT tailplane airframe with Quad VTOL. +# +# @type Standard VTOL +# +# @maintainer Simon Wilks +# + +sh /etc/init.d/rc.vtol_defaults + +if [ $AUTOCNF == yes ] +then + param set VT_TYPE 2 + param set VT_MOT_COUNT 4 + param set VT_TRANS_THR 0.75 + + param set MC_ROLL_P 7.0 + param set MC_ROLLRATE_P 0.15 + param set MC_ROLLRATE_I 0.002 + param set MC_ROLLRATE_D 0.003 + param set MC_ROLLRATE_FF 0.0 + param set MC_PITCH_P 7.0 + param set MC_PITCHRATE_P 0.12 + param set MC_PITCHRATE_I 0.002 + param set MC_PITCHRATE_D 0.003 + param set MC_PITCHRATE_FF 0.0 + param set MC_YAW_P 2.8 + param set MC_YAW_FF 0.5 + param set MC_YAWRATE_P 0.22 + param set MC_YAWRATE_I 0.02 + param set MC_YAWRATE_D 0.0 + param set MC_YAWRATE_FF 0.0 +fi + +set MIXER vtol_quad_x +set PWM_OUT 12345678 + +set MIXER_AUX vtol_AAERT +set PWM_AUX_RATE 50 +set PWM_AUX_OUT 1234 +set PWM_AUX_DISARMED 1000 +set PWM_AUX_MIN 1000 +set PWM_AUX_MAX 2000 + +set MAV_TYPE 22 + +param set VT_MOT_COUNT 4 +param set VT_IDLE_PWM_MC 1080 +param set VT_TYPE 2 diff --git a/ROMFS/px4fmu_common/init.d/13005_vtol_AERT_quad b/ROMFS/px4fmu_common/init.d/13005_vtol_AERT_quad new file mode 100644 index 0000000000..a3e183a84a --- /dev/null +++ b/ROMFS/px4fmu_common/init.d/13005_vtol_AERT_quad @@ -0,0 +1,50 @@ +#!nsh +# +# @name Generic AERT with Quad VTOL. +# +# @type Standard VTOL +# +# @maintainer Simon Wilks +# + +sh /etc/init.d/rc.vtol_defaults + +if [ $AUTOCNF == yes ] +then + param set VT_TYPE 2 + param set VT_MOT_COUNT 4 + param set VT_TRANS_THR 0.75 + + param set MC_ROLL_P 7.0 + param set MC_ROLLRATE_P 0.15 + param set MC_ROLLRATE_I 0.002 + param set MC_ROLLRATE_D 0.003 + param set MC_ROLLRATE_FF 0.0 + param set MC_PITCH_P 7.0 + param set MC_PITCHRATE_P 0.12 + param set MC_PITCHRATE_I 0.002 + param set MC_PITCHRATE_D 0.003 + param set MC_PITCHRATE_FF 0.0 + param set MC_YAW_P 2.8 + param set MC_YAW_FF 0.5 + param set MC_YAWRATE_P 0.22 + param set MC_YAWRATE_I 0.02 + param set MC_YAWRATE_D 0.0 + param set MC_YAWRATE_FF 0.0 +fi + +set MIXER vtol_quad_x +set PWM_OUT 12345678 + +set MIXER_AUX vtol_AERT +set PWM_AUX_RATE 50 +set PWM_AUX_OUT 1234 +set PWM_AUX_DISARMED 1000 +set PWM_AUX_MIN 1000 +set PWM_AUX_MAX 2000 + +set MAV_TYPE 22 + +param set VT_MOT_COUNT 4 +param set VT_IDLE_PWM_MC 1080 +param set VT_TYPE 2 diff --git a/ROMFS/px4fmu_common/mixers/vtol_AAERT.aux.mix b/ROMFS/px4fmu_common/mixers/vtol_AAERT.aux.mix new file mode 100644 index 0000000000..f3e9c42354 --- /dev/null +++ b/ROMFS/px4fmu_common/mixers/vtol_AAERT.aux.mix @@ -0,0 +1,32 @@ +Mixer for an AAERT VTOL +======================= + +Aileron 1 mixer +--------------- +M: 1 +O: 10000 10000 0 -10000 10000 +S: 1 0 -7500 -7500 0 -10000 10000 + +Aileron 2 mixer +--------------- +M: 1 +O: 10000 10000 0 -10000 10000 +S: 1 0 -7500 -7500 0 -10000 10000 + +Elevator mixer +-------------- +M: 1 +O: 10000 10000 0 -10000 10000 +S: 1 1 10000 10000 0 -10000 10000 + +Rudder mixer +------------ +M: 1 +O: 10000 10000 0 -10000 10000 +S: 1 2 -10000 -10000 0 -10000 10000 + +Throttle mixer +-------------- +M: 1 +O: 10000 10000 0 -10000 10000 +S: 1 3 0 20000 -10000 -10000 10000 diff --git a/ROMFS/px4fmu_common/mixers/vtol_AERT.aux.mix b/ROMFS/px4fmu_common/mixers/vtol_AERT.aux.mix new file mode 100644 index 0000000000..260e60840a --- /dev/null +++ b/ROMFS/px4fmu_common/mixers/vtol_AERT.aux.mix @@ -0,0 +1,30 @@ +Mixer for a horizontal format with X-Quad and tractor AERT plane configuration +============================================================================== + +Motor speed mixer +----------------- +M: 1 +O: 10000 10000 0 -10000 10000 +S: 1 3 0 20000 -10000 -10000 10000 + +Aileron mixers +-------------- +M: 1 +O: 10000 10000 0 -10000 10000 +S: 1 0 -7500 -7500 0 -10000 10000 + +M: 1 +O: 10000 10000 0 -10000 10000 +S: 1 0 -7500 -7500 0 -10000 10000 + +Elevator mixer +-------------- +M: 1 +O: 10000 10000 0 -10000 10000 +S: 1 1 10000 10000 0 -10000 10000 + +Rudder mixer +------------ +M: 1 +O: 10000 10000 0 -10000 10000 +S: 1 2 -10000 -10000 0 -10000 10000 diff --git a/ROMFS/px4fmu_common/mixers/vtol_quad_x.main.mix b/ROMFS/px4fmu_common/mixers/vtol_quad_x.main.mix new file mode 100644 index 0000000000..92bfce6c8c --- /dev/null +++ b/ROMFS/px4fmu_common/mixers/vtol_quad_x.main.mix @@ -0,0 +1,4 @@ +# VTOL quad X mixer for PX4FMU +#============================= + +R: 4x 10000 10000 10000 0 diff --git a/src/modules/vtol_att_control/standard.cpp b/src/modules/vtol_att_control/standard.cpp new file mode 100644 index 0000000000..c38a935ff7 --- /dev/null +++ b/src/modules/vtol_att_control/standard.cpp @@ -0,0 +1,296 @@ +/**************************************************************************** + * + * Copyright (c) 2015 PX4 Development Team. All rights reserved. + * + * 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 standard.cpp + * + * @author Simon Wilks + * @author Roman Bapst + * +*/ + +#include "standard.h" +#include "vtol_att_control_main.h" + +Standard::Standard(VtolAttitudeControl *attc) : + VtolType(attc), + _flag_enable_mc_motors(true), + _pusher_throttle(0.0f), + _mc_att_ctl_weight(1.0f), + _airspeed_trans_blend_margin(0.0f) +{ + _vtol_schedule.flight_mode = MC_MODE; + _vtol_schedule.transition_start = 0; + + _params_handles_standard.front_trans_dur = param_find("VT_F_TRANS_DUR"); + _params_handles_standard.back_trans_dur = param_find("VT_B_TRANS_DUR"); + _params_handles_standard.pusher_trans = param_find("VT_TRANS_THR"); + _params_handles_standard.airspeed_blend = param_find("VT_ARSP_BLEND"); + _params_handles_standard.airspeed_trans = param_find("VT_ARSP_TRANS"); + } + +Standard::~Standard() +{ +} + +int +Standard::parameters_update() +{ + float v; + + /* duration of a forwards transition to fw mode */ + param_get(_params_handles_standard.front_trans_dur, &v); + _params_standard.front_trans_dur = math::constrain(v, 0.0f, 5.0f); + + /* duration of a back transition to mc mode */ + param_get(_params_handles_standard.back_trans_dur, &v); + _params_standard.back_trans_dur = math::constrain(v, 0.0f, 5.0f); + + /* target throttle value for pusher motor during the transition to fw mode */ + param_get(_params_handles_standard.pusher_trans, &v); + _params_standard.pusher_trans = math::constrain(v, 0.0f, 5.0f); + + /* airspeed at which it we should switch to fw mode */ + param_get(_params_handles_standard.airspeed_trans, &v); + _params_standard.airspeed_trans = math::constrain(v, 1.0f, 20.0f); + + /* airspeed at which we start blending mc/fw controls */ + param_get(_params_handles_standard.airspeed_blend, &v); + _params_standard.airspeed_blend = math::constrain(v, 0.0f, 20.0f); + + _airspeed_trans_blend_margin = _params_standard.airspeed_trans - _params_standard.airspeed_blend; + + return OK; +} + +void Standard::update_vtol_state() +{ + parameters_update(); + + /* After flipping the switch the vehicle will start the pusher (or tractor) motor, picking up + * forward speed. After the vehicle has picked up enough speed the rotors shutdown. + * For the back transition the pusher motor is immediately stopped and rotors reactivated. + */ + + if (_manual_control_sp->aux1 < 0.0f) { + // the transition to fw mode switch is off + if (_vtol_schedule.flight_mode == MC_MODE) { + // in mc mode + _vtol_schedule.flight_mode = MC_MODE; + _mc_att_ctl_weight = 1.0f; + + } else if (_vtol_schedule.flight_mode == FW_MODE) { + // transition to mc mode + _vtol_schedule.flight_mode = TRANSITION_TO_MC; + _flag_enable_mc_motors = true; + _vtol_schedule.transition_start = hrt_absolute_time(); + + } else if (_vtol_schedule.flight_mode == TRANSITION_TO_FW) { + // failsafe back to mc mode + _vtol_schedule.flight_mode = MC_MODE; + _mc_att_ctl_weight = 1.0f; + + } else if (_vtol_schedule.flight_mode == TRANSITION_TO_MC) { + // keep transitioning to mc mode + _vtol_schedule.flight_mode = MC_MODE; + } + + // the pusher motor should never be powered when in or transitioning to mc mode + _pusher_throttle = 0.0f; + + } else { + // the transition to fw mode switch is on + if (_vtol_schedule.flight_mode == MC_MODE) { + // start transition to fw mode + _vtol_schedule.flight_mode = TRANSITION_TO_FW; + _vtol_schedule.transition_start = hrt_absolute_time(); + + } else if (_vtol_schedule.flight_mode == FW_MODE) { + // in fw mode + _vtol_schedule.flight_mode = FW_MODE; + _mc_att_ctl_weight = 0.0f; + + } else if (_vtol_schedule.flight_mode == TRANSITION_TO_FW) { + // continue the transition to fw mode while monitoring airspeed for a final switch to fw mode + if (_airspeed->true_airspeed_m_s >= _params_standard.airspeed_trans) { + _vtol_schedule.flight_mode = FW_MODE; + // we can turn off the multirotor motors now + _flag_enable_mc_motors = false; + // don't set pusher throttle here as it's being ramped up elsewhere + } + + } else if (_vtol_schedule.flight_mode == TRANSITION_TO_MC) { + // transitioning to mc mode & transition switch on - failsafe back into fw mode + _vtol_schedule.flight_mode = FW_MODE; + } + } + + // map specific control phases to simple control modes + switch(_vtol_schedule.flight_mode) { + case MC_MODE: + _vtol_mode = ROTARY_WING; + break; + case FW_MODE: + _vtol_mode = FIXED_WING; + break; + case TRANSITION_TO_FW: + case TRANSITION_TO_MC: + _vtol_mode = TRANSITION; + break; + } +} + +void Standard::update_transition_state() +{ + if (_vtol_schedule.flight_mode == TRANSITION_TO_FW) { + if (_params_standard.front_trans_dur <= 0.0f) { + // just set the final target throttle value + _pusher_throttle = _params_standard.pusher_trans; + } else if (_pusher_throttle <= _params_standard.pusher_trans) { + // ramp up throttle to the target throttle value + _pusher_throttle = _params_standard.pusher_trans * + (float)hrt_elapsed_time(&_vtol_schedule.transition_start) / (_params_standard.front_trans_dur * 1000000.0f); + } + + // do blending of mc and fw controls if a blending airspeed has been provided + if (_airspeed_trans_blend_margin > 0.0f && _airspeed->true_airspeed_m_s >= _params_standard.airspeed_blend) { + _mc_att_ctl_weight = 1.0f - fabsf(_airspeed->true_airspeed_m_s - _params_standard.airspeed_blend) / _airspeed_trans_blend_margin; + } else { + // at low speeds give full weight to mc + _mc_att_ctl_weight = 1.0f; + } + + } else if (_vtol_schedule.flight_mode == TRANSITION_TO_MC) { + // continually increase mc attitude control as we transition back to mc mode + if (_params_standard.back_trans_dur > 0.0f) { + _mc_att_ctl_weight = (float)hrt_elapsed_time(&_vtol_schedule.transition_start) / (_params_standard.back_trans_dur * 1000000.0f); + } else { + _mc_att_ctl_weight = 1.0f; + } + + // in fw mode we need the multirotor motors to stop spinning, in backtransition mode we let them spin up again + if (_flag_enable_mc_motors) { + set_max_mc(2000); + set_idle_mc(); + _flag_enable_mc_motors = false; + } + } + + _mc_att_ctl_weight = math::constrain(_mc_att_ctl_weight, 0.0f, 1.0f); +} + +void Standard::update_mc_state() +{ + // do nothing +} + +void Standard::process_mc_data() +{ + fill_att_control_output(); +} + +void Standard::process_fw_data() +{ + fill_att_control_output(); +} + + void Standard::update_fw_state() +{ + // in fw mode we need the multirotor motors to stop spinning, in backtransition mode we let them spin up again + if (!_flag_enable_mc_motors) { + set_max_mc(950); + set_idle_fw(); // force them to stop, not just idle + _flag_enable_mc_motors = true; + } + } + +void Standard::update_external_state() +{ +} + +/** + * Prepare message to acutators with data from mc and fw attitude controllers. An mc attitude weighting will determine + * what proportion of control should be applied to each of the control groups (mc and fw). + */ +void Standard::fill_att_control_output() +{ + /* multirotor controls */ + _actuators_out_0->control[0] = _actuators_mc_in->control[0] * _mc_att_ctl_weight; // roll + _actuators_out_0->control[1] = _actuators_mc_in->control[1] * _mc_att_ctl_weight; // pitch + _actuators_out_0->control[2] = _actuators_mc_in->control[2] * _mc_att_ctl_weight; // yaw + _actuators_out_0->control[3] = _actuators_mc_in->control[3]; // throttle + + /* fixed wing controls */ + const float fw_att_ctl_weight = 1.0f - _mc_att_ctl_weight; + _actuators_out_1->control[0] = -_actuators_fw_in->control[0] * fw_att_ctl_weight; //roll + _actuators_out_1->control[1] = (_actuators_fw_in->control[1] + _params->fw_pitch_trim) * fw_att_ctl_weight; //pitch + _actuators_out_1->control[2] = _actuators_fw_in->control[2] * fw_att_ctl_weight; // yaw + + // set the fixed wing throttle control + if (_vtol_schedule.flight_mode == FW_MODE) { + // take the throttle value commanded by the fw controller + _actuators_out_1->control[3] = _actuators_fw_in->control[3]; + } else { + // otherwise we may be ramping up the throttle during the transition to fw mode + _actuators_out_1->control[3] = _pusher_throttle; + } +} + +/** +* Disable all multirotor motors when in fw mode. +*/ +void +Standard::set_max_mc(unsigned pwm_value) +{ + int ret; + unsigned servo_count; + char *dev = PWM_OUTPUT0_DEVICE_PATH; + int fd = open(dev, 0); + + if (fd < 0) {err(1, "can't open %s", dev);} + + ret = ioctl(fd, PWM_SERVO_GET_COUNT, (unsigned long)&servo_count); + struct pwm_output_values pwm_values; + memset(&pwm_values, 0, sizeof(pwm_values)); + + for (int i = 0; i < _params->vtol_motor_count; i++) { + pwm_values.values[i] = pwm_value; + pwm_values.channel_count = _params->vtol_motor_count; + } + + ret = ioctl(fd, PWM_SERVO_SET_MAX_PWM, (long unsigned int)&pwm_values); + + if (ret != OK) {errx(ret, "failed setting max values");} + + close(fd); +} diff --git a/src/modules/vtol_att_control/standard.h b/src/modules/vtol_att_control/standard.h new file mode 100644 index 0000000000..e4e1d92d85 --- /dev/null +++ b/src/modules/vtol_att_control/standard.h @@ -0,0 +1,107 @@ +/**************************************************************************** + * + * Copyright (c) 2015 PX4 Development Team. All rights reserved. + * + * 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 standard.h + * VTOL with fixed multirotor motor configurations (such as quad) and a pusher + * (or puller aka tractor) motor for forward flight. + * + * @author Simon Wilks + * @author Roman Bapst + * + */ + +#ifndef STANDARD_H +#define STANDARD_H +#include "vtol_type.h" +#include +#include + +class Standard : public VtolType +{ + +public: + + Standard(VtolAttitudeControl * _att_controller); + ~Standard(); + + void update_vtol_state(); + void update_mc_state(); + void process_mc_data(); + void update_fw_state(); + void process_fw_data(); + void update_transition_state(); + void update_external_state(); + +private: + + struct { + float front_trans_dur; + float back_trans_dur; + float pusher_trans; + float airspeed_blend; + float airspeed_trans; + } _params_standard; + + struct { + param_t front_trans_dur; + param_t back_trans_dur; + param_t pusher_trans; + param_t airspeed_blend; + param_t airspeed_trans; + } _params_handles_standard; + + enum vtol_mode { + MC_MODE = 0, + TRANSITION_TO_FW, + TRANSITION_TO_MC, + FW_MODE + }; + + struct { + vtol_mode flight_mode; // indicates in which mode the vehicle is in + hrt_abstime transition_start; // at what time did we start a transition (front- or backtransition) + }_vtol_schedule; + + bool _flag_enable_mc_motors; + float _pusher_throttle; + float _mc_att_ctl_weight; // the amount of multicopter attitude control that should be applied in fixed wing mode while transitioning + float _airspeed_trans_blend_margin; + + void fill_att_control_output(); + void set_max_mc(unsigned pwm_value); + + int parameters_update(); + +}; +#endif diff --git a/src/modules/vtol_att_control/standard_params.c b/src/modules/vtol_att_control/standard_params.c new file mode 100644 index 0000000000..134dcd0b8a --- /dev/null +++ b/src/modules/vtol_att_control/standard_params.c @@ -0,0 +1,51 @@ +/**************************************************************************** + * + * Copyright (c) 2015 PX4 Development Team. All rights reserved. + * + * 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 standard_params.c + * Parameters for the standard VTOL controller. + * + * @author Simon Wilks + * @author Roman Bapst + */ + +#include + +/** + * Target throttle value for pusher/puller motor during the transition to fw mode + * + * @min 0.0 + * @max 1.0 + * @group VTOL Attitude Control + */ +PARAM_DEFINE_FLOAT(VT_TRANS_THR, 0.6f); From 6b6fe5d22977bb035833b88d6c962d7b1b20e0a9 Mon Sep 17 00:00:00 2001 From: Simon Wilks Date: Sun, 9 Aug 2015 11:36:13 +0200 Subject: [PATCH 162/174] Remove old config and mixer file that slipped into the port. --- .../px4fmu_common/init.d/13005_vtol_AERT_quad | 50 ------------------- ROMFS/px4fmu_common/mixers/vtol_AERT.aux.mix | 30 ----------- 2 files changed, 80 deletions(-) delete mode 100644 ROMFS/px4fmu_common/init.d/13005_vtol_AERT_quad delete mode 100644 ROMFS/px4fmu_common/mixers/vtol_AERT.aux.mix diff --git a/ROMFS/px4fmu_common/init.d/13005_vtol_AERT_quad b/ROMFS/px4fmu_common/init.d/13005_vtol_AERT_quad deleted file mode 100644 index a3e183a84a..0000000000 --- a/ROMFS/px4fmu_common/init.d/13005_vtol_AERT_quad +++ /dev/null @@ -1,50 +0,0 @@ -#!nsh -# -# @name Generic AERT with Quad VTOL. -# -# @type Standard VTOL -# -# @maintainer Simon Wilks -# - -sh /etc/init.d/rc.vtol_defaults - -if [ $AUTOCNF == yes ] -then - param set VT_TYPE 2 - param set VT_MOT_COUNT 4 - param set VT_TRANS_THR 0.75 - - param set MC_ROLL_P 7.0 - param set MC_ROLLRATE_P 0.15 - param set MC_ROLLRATE_I 0.002 - param set MC_ROLLRATE_D 0.003 - param set MC_ROLLRATE_FF 0.0 - param set MC_PITCH_P 7.0 - param set MC_PITCHRATE_P 0.12 - param set MC_PITCHRATE_I 0.002 - param set MC_PITCHRATE_D 0.003 - param set MC_PITCHRATE_FF 0.0 - param set MC_YAW_P 2.8 - param set MC_YAW_FF 0.5 - param set MC_YAWRATE_P 0.22 - param set MC_YAWRATE_I 0.02 - param set MC_YAWRATE_D 0.0 - param set MC_YAWRATE_FF 0.0 -fi - -set MIXER vtol_quad_x -set PWM_OUT 12345678 - -set MIXER_AUX vtol_AERT -set PWM_AUX_RATE 50 -set PWM_AUX_OUT 1234 -set PWM_AUX_DISARMED 1000 -set PWM_AUX_MIN 1000 -set PWM_AUX_MAX 2000 - -set MAV_TYPE 22 - -param set VT_MOT_COUNT 4 -param set VT_IDLE_PWM_MC 1080 -param set VT_TYPE 2 diff --git a/ROMFS/px4fmu_common/mixers/vtol_AERT.aux.mix b/ROMFS/px4fmu_common/mixers/vtol_AERT.aux.mix deleted file mode 100644 index 260e60840a..0000000000 --- a/ROMFS/px4fmu_common/mixers/vtol_AERT.aux.mix +++ /dev/null @@ -1,30 +0,0 @@ -Mixer for a horizontal format with X-Quad and tractor AERT plane configuration -============================================================================== - -Motor speed mixer ------------------ -M: 1 -O: 10000 10000 0 -10000 10000 -S: 1 3 0 20000 -10000 -10000 10000 - -Aileron mixers --------------- -M: 1 -O: 10000 10000 0 -10000 10000 -S: 1 0 -7500 -7500 0 -10000 10000 - -M: 1 -O: 10000 10000 0 -10000 10000 -S: 1 0 -7500 -7500 0 -10000 10000 - -Elevator mixer --------------- -M: 1 -O: 10000 10000 0 -10000 10000 -S: 1 1 10000 10000 0 -10000 10000 - -Rudder mixer ------------- -M: 1 -O: 10000 10000 0 -10000 10000 -S: 1 2 -10000 -10000 0 -10000 10000 From ff360aa75a5383a307397915eff2531566c5da2d Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 10 Aug 2015 16:34:47 +0200 Subject: [PATCH 163/174] NuttX configs: Add hotfix for RX DMA buffer sizes --- nuttx-configs/aerocore/nsh/defconfig | 2 ++ nuttx-configs/px4-stm32f4discovery/nsh/defconfig | 2 ++ nuttx-configs/px4fmu-v2/nsh/defconfig | 2 ++ 3 files changed, 6 insertions(+) diff --git a/nuttx-configs/aerocore/nsh/defconfig b/nuttx-configs/aerocore/nsh/defconfig index e314bf1d82..655dd1406e 100644 --- a/nuttx-configs/aerocore/nsh/defconfig +++ b/nuttx-configs/aerocore/nsh/defconfig @@ -268,6 +268,8 @@ CONFIG_STM32_USART=y # # U[S]ART Configuration # +# Hot fix for lost data +CONFIG_STM32_RXDMA_BUFFER_SIZE_OVERRIDE=256 # CONFIG_USART1_RS485 is not set CONFIG_USART1_RXDMA=y # CONFIG_USART2_RS485 is not set diff --git a/nuttx-configs/px4-stm32f4discovery/nsh/defconfig b/nuttx-configs/px4-stm32f4discovery/nsh/defconfig index 03092256e9..7be5399629 100644 --- a/nuttx-configs/px4-stm32f4discovery/nsh/defconfig +++ b/nuttx-configs/px4-stm32f4discovery/nsh/defconfig @@ -263,6 +263,8 @@ CONFIG_STM32_USART=y # # U[S]ART Configuration # +# Hot fix for lost data +CONFIG_STM32_RXDMA_BUFFER_SIZE_OVERRIDE=256 # CONFIG_USART2_RS485 is not set CONFIG_USART2_RXDMA=y # CONFIG_USART6_RS485 is not set diff --git a/nuttx-configs/px4fmu-v2/nsh/defconfig b/nuttx-configs/px4fmu-v2/nsh/defconfig index ef9c673785..e828e42be0 100644 --- a/nuttx-configs/px4fmu-v2/nsh/defconfig +++ b/nuttx-configs/px4fmu-v2/nsh/defconfig @@ -294,6 +294,8 @@ CONFIG_STM32_USART=y # # U[S]ART Configuration # +# Hot fix for lost data +CONFIG_STM32_RXDMA_BUFFER_SIZE_OVERRIDE=256 # CONFIG_USART1_RS485 is not set CONFIG_USART1_RXDMA=y # CONFIG_USART2_RS485 is not set From 138daf3b36a99c19cd90fea2ef45e3319b76152f Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 10 Aug 2015 16:35:10 +0200 Subject: [PATCH 164/174] FMUv1: Use small buffer for RX DMA hotfix --- nuttx-configs/px4fmu-v1/nsh/defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nuttx-configs/px4fmu-v1/nsh/defconfig b/nuttx-configs/px4fmu-v1/nsh/defconfig index 2c9a21f212..874615d3b2 100644 --- a/nuttx-configs/px4fmu-v1/nsh/defconfig +++ b/nuttx-configs/px4fmu-v1/nsh/defconfig @@ -260,6 +260,8 @@ CONFIG_STM32_USART=y # # U[S]ART Configuration # +# Hot fix for lost data +CONFIG_STM32_RXDMA_BUFFER_SIZE_OVERRIDE=64 # CONFIG_USART1_RS485 is not set # CONFIG_USART1_RXDMA is not set # CONFIG_USART2_RS485 is not set From 05d752ae3426649252531c216ed5a4572c245145 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 10 Aug 2015 17:07:11 +0200 Subject: [PATCH 165/174] MAVLink: Limit use to 3 instances, which is what is realistically being used. --- src/modules/mavlink/mavlink_main.cpp | 6 ++++++ src/modules/mavlink/module.mk | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index 1e0b3ddb3e..f2dcd33d79 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -1789,6 +1789,12 @@ Mavlink::start(int argc, char *argv[]) // before returning to the shell int ic = Mavlink::instance_count(); + if (ic == MAVLINK_COMM_NUM_BUFFERS) { + warnx("Maximum MAVLink instance count of %d reached.", + (int)MAVLINK_COMM_NUM_BUFFERS); + return 1; + } + // Instantiate thread char buf[24]; sprintf(buf, "mavlink_if%d", ic); diff --git a/src/modules/mavlink/module.mk b/src/modules/mavlink/module.mk index e82b8bd935..509fd9e495 100644 --- a/src/modules/mavlink/module.mk +++ b/src/modules/mavlink/module.mk @@ -53,6 +53,6 @@ MAXOPTIMIZATION = -Os MODULE_STACKSIZE = 1200 -EXTRACXXFLAGS = -Weffc++ -Wno-attributes -Wno-packed +EXTRACXXFLAGS = -Weffc++ -Wno-attributes -Wno-packed -DMAVLINK_COMM_NUM_BUFFERS=3 -EXTRACFLAGS = -Wno-packed +EXTRACFLAGS = -Wno-packed -DMAVLINK_COMM_NUM_BUFFERS=3 From cab6d8b77090eca7484c913da81a5b64478304f0 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 10 Aug 2015 17:07:30 +0200 Subject: [PATCH 166/174] System lib: Remove unused variable from CPU load tracking --- src/modules/systemlib/cpuload.c | 4 ---- src/modules/systemlib/cpuload.h | 1 - 2 files changed, 5 deletions(-) diff --git a/src/modules/systemlib/cpuload.c b/src/modules/systemlib/cpuload.c index b41896abd9..ffbeb608b5 100644 --- a/src/modules/systemlib/cpuload.c +++ b/src/modules/systemlib/cpuload.c @@ -78,8 +78,6 @@ void cpuload_initialize_once() system_load.tasks[i].valid = false; } - uint64_t now = hrt_absolute_time(); - int static_tasks_count = 2; // there are at least 2 threads that should be initialized statically - "idle" and "init" #ifdef CONFIG_PAGING @@ -94,7 +92,6 @@ void cpuload_initialize_once() // perform static initialization of "system" threads for (system_load.total_count = 0; system_load.total_count < static_tasks_count; system_load.total_count++) { - system_load.tasks[system_load.total_count].start_time = now; system_load.tasks[system_load.total_count].total_runtime = 0; system_load.tasks[system_load.total_count].curr_start_time = 0; system_load.tasks[system_load.total_count].tcb = sched_gettcb( @@ -111,7 +108,6 @@ void sched_note_start(FAR struct tcb_s *tcb) for (i = 1; i < CONFIG_MAX_TASKS; i++) { if (!system_load.tasks[i].valid) { /* slot is available */ - system_load.tasks[i].start_time = hrt_absolute_time(); system_load.tasks[i].total_runtime = 0; system_load.tasks[i].curr_start_time = 0; system_load.tasks[i].tcb = tcb; diff --git a/src/modules/systemlib/cpuload.h b/src/modules/systemlib/cpuload.h index 16d132fdb8..adc60671ec 100644 --- a/src/modules/systemlib/cpuload.h +++ b/src/modules/systemlib/cpuload.h @@ -42,7 +42,6 @@ __BEGIN_DECLS struct system_load_taskinfo_s { uint64_t total_runtime; ///< Runtime since start (start_time - total_runtime)/(start_time - current_time) = load uint64_t curr_start_time; ///< Start time of the current scheduling slot - uint64_t start_time; ///< FIRST start time of task FAR struct tcb_s *tcb; ///< bool valid; ///< Task is currently active / valid }; From f7ef77371e8d014ffa09e6f5b4c985553eef92ad Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 10 Aug 2015 17:13:20 +0200 Subject: [PATCH 167/174] Fix startup order of FLOW sensor --- ROMFS/px4fmu_common/init.d/rc.sensors | 5 ----- ROMFS/px4fmu_common/init.d/rcS | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/rc.sensors b/ROMFS/px4fmu_common/init.d/rc.sensors index e5d527dd71..718a5e8212 100644 --- a/ROMFS/px4fmu_common/init.d/rc.sensors +++ b/ROMFS/px4fmu_common/init.d/rc.sensors @@ -110,11 +110,6 @@ else fi fi -# Check for flow sensor -if px4flow start & -then -fi - if ll40ls start then fi diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index dfa270b048..1c9fd9445b 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -708,6 +708,11 @@ fi # Boot is complete, inform MAVLink app(s) that the system is now fully up and running mavlink boot_complete +# Check for flow sensor - as it is a background task, launch it last +if px4flow start & +then +fi + if [ $EXIT_ON_END == yes ] then echo "Exit from nsh" From 7052ddf3db01a95bb85b5689974baa05f9e797b5 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 10 Aug 2015 17:14:36 +0200 Subject: [PATCH 168/174] Q Att estimator: Remove excessive stack use --- src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp b/src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp index a1c56aa1f8..53c81b64cd 100644 --- a/src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp +++ b/src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp @@ -205,7 +205,7 @@ int AttitudeEstimatorQ::start() { _control_task = task_spawn_cmd("attitude_estimator_q", SCHED_DEFAULT, SCHED_PRIORITY_MAX - 5, - 2500, + 2000, (main_t)&AttitudeEstimatorQ::task_main_trampoline, nullptr); From 825880ab5505d5a36e5772c3291ab916347269d4 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 10 Aug 2015 22:26:09 +0200 Subject: [PATCH 169/174] Only start PX4FLOW driver on FMUv2 --- ROMFS/px4fmu_common/init.d/rcS | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index 1c9fd9445b..ff873adac0 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -705,12 +705,17 @@ then # End of autostart fi +# There is no further script processing, so we can free some RAM +# XXX potentially unset all script variables. +unset TUNE_ERR + # Boot is complete, inform MAVLink app(s) that the system is now fully up and running mavlink boot_complete -# Check for flow sensor - as it is a background task, launch it last -if px4flow start & +if ver hwcmp PX4FMU_V2 then + # Check for flow sensor - as it is a background task, launch it last + px4flow start & fi if [ $EXIT_ON_END == yes ] @@ -719,7 +724,3 @@ then exit fi unset EXIT_ON_END - -# There is no further processing, so we can free some RAM -# XXX potentially unset all script variables. -unset TUNE_ERR From 134c1d991a6a003f5079d84b8a623f6f703cc2e1 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 11 Aug 2015 09:24:13 +0200 Subject: [PATCH 170/174] Commander: Time out if not starting successfully --- src/modules/commander/commander.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp index 57e175ed19..a01b33087f 100644 --- a/src/modules/commander/commander.cpp +++ b/src/modules/commander/commander.cpp @@ -275,7 +275,7 @@ int commander_main(int argc, char *argv[]) if (!strcmp(argv[1], "start")) { if (thread_running) { - warnx("commander already running"); + warnx("already running"); /* this is not an error */ exit(0); } @@ -288,11 +288,18 @@ int commander_main(int argc, char *argv[]) commander_thread_main, (argv) ? (char * const *)&argv[2] : (char * const *)NULL); - while (!thread_running) { - usleep(200); + unsigned constexpr max_wait_us = 1000000; + unsigned constexpr max_wait_steps = 2000; + + unsigned i; + for (i = 0; i < max_wait_steps; i++) { + usleep(max_wait_us / max_wait_steps); + if (thread_running) { + break; + } } - exit(0); + exit(!(i < max_wait_steps)); } if (!strcmp(argv[1], "stop")) { From c8ca147b4d06edaec12ecd3140c24a7ddfa2a739 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 11 Aug 2015 09:24:21 +0200 Subject: [PATCH 171/174] sdlog2: Waiting for full boot --- src/modules/sdlog2/sdlog2.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/modules/sdlog2/sdlog2.c b/src/modules/sdlog2/sdlog2.c index bedd854af6..71ac96350a 100644 --- a/src/modules/sdlog2/sdlog2.c +++ b/src/modules/sdlog2/sdlog2.c @@ -344,7 +344,20 @@ int sdlog2_main(int argc, char *argv[]) 3000, sdlog2_thread_main, (char * const *)argv); - exit(0); + + /* wait for the task to launch */ + unsigned const max_wait_us = 1000000; + unsigned const max_wait_steps = 2000; + + unsigned i; + for (i = 0; i < max_wait_steps; i++) { + usleep(max_wait_us / max_wait_steps); + if (thread_running) { + break; + } + } + + exit(!(i < max_wait_steps)); } if (!strcmp(argv[1], "stop")) { @@ -1228,8 +1241,6 @@ int sdlog2_thread_main(int argc, char *argv[]) /* close stdout */ close(1); - thread_running = true; - /* initialize thread synchronization */ pthread_mutex_init(&logbuffer_mutex, NULL); pthread_cond_init(&logbuffer_cond, NULL); @@ -1263,6 +1274,9 @@ int sdlog2_thread_main(int argc, char *argv[]) sdlog2_start_log(); } + /* running, report */ + thread_running = true; + while (!main_thread_should_exit) { usleep(sleep_delay); From 72c3f4b815da5ae2a3554d79a866a0336b4a5d43 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 11 Aug 2015 09:24:56 +0200 Subject: [PATCH 172/174] Flow: Shrink boot handler size --- src/drivers/px4flow/module.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/drivers/px4flow/module.mk b/src/drivers/px4flow/module.mk index ecd3e804a1..8d6964d103 100644 --- a/src/drivers/px4flow/module.mk +++ b/src/drivers/px4flow/module.mk @@ -41,4 +41,6 @@ SRCS = px4flow.cpp MAXOPTIMIZATION = -Os +MODULE_STACKSIZE = 1200 + EXTRACXXFLAGS = -Wno-attributes From f57d09aca0f9bccf48ecbada421db14edff05dd1 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 11 Aug 2015 09:45:49 +0200 Subject: [PATCH 173/174] FMUv1: Do not load AUX outputs --- ROMFS/px4fmu_common/init.d/rc.interface | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ROMFS/px4fmu_common/init.d/rc.interface b/ROMFS/px4fmu_common/init.d/rc.interface index f3761200a1..e305713377 100644 --- a/ROMFS/px4fmu_common/init.d/rc.interface +++ b/ROMFS/px4fmu_common/init.d/rc.interface @@ -97,6 +97,12 @@ then fi fi +# This is a FMUv2+ thing +if ver hwcmp PX4FMU_V1 +then + set MIXER_AUX none +fi + if [ $MIXER_AUX != none ] then # From fc4754f8e597dfeaae6780c0b164edf928916968 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 11 Aug 2015 10:43:54 +0200 Subject: [PATCH 174/174] Updated MAVLink submodule --- mavlink/include/mavlink/v1.0 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mavlink/include/mavlink/v1.0 b/mavlink/include/mavlink/v1.0 index 645a0e1b1e..d23a551e10 160000 --- a/mavlink/include/mavlink/v1.0 +++ b/mavlink/include/mavlink/v1.0 @@ -1 +1 @@ -Subproject commit 645a0e1b1eb09efeeaa14cc18d2474628a31ab53 +Subproject commit d23a551e108d92c7a49a66d162cb9d542bbe6be1