2015-05-29 23:12:49 -03:00
|
|
|
#include "Copter.h"
|
|
|
|
|
2011-07-17 07:34:05 -03:00
|
|
|
#if CLI_ENABLED == ENABLED
|
|
|
|
|
2015-11-03 09:46:40 -04:00
|
|
|
#define PWM_CALIB_MIN 1000
|
|
|
|
#define PWM_CALIB_MAX 2000
|
|
|
|
#define PWM_HIGHEST_MAX 2200
|
|
|
|
#define PWM_LOWEST_MAX 1200
|
|
|
|
#define PWM_HIGHEST_MIN 1800
|
|
|
|
#define PWM_LOWEST_MIN 800
|
2014-07-07 14:11:53 -03:00
|
|
|
|
2011-02-19 17:04:05 -04:00
|
|
|
// Command/function table for the setup menu
|
2015-10-25 14:03:46 -03:00
|
|
|
static const struct Menu::command setup_menu_commands[] = {
|
2015-05-29 23:12:49 -03:00
|
|
|
{"reset", MENU_FUNC(setup_factory)},
|
|
|
|
{"show", MENU_FUNC(setup_show)},
|
|
|
|
{"set", MENU_FUNC(setup_set)},
|
|
|
|
{"esc_calib", MENU_FUNC(esc_calib)},
|
2010-12-19 12:40:33 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// Create the setup menu object.
|
|
|
|
MENU(setup_menu, "setup", setup_menu_commands);
|
|
|
|
|
|
|
|
// Called from the top-level menu to run the setup menu.
|
2015-05-29 23:12:49 -03:00
|
|
|
int8_t Copter::setup_mode(uint8_t argc, const Menu::arg *argv)
|
2010-12-19 12:40:33 -04:00
|
|
|
{
|
2012-08-21 23:19:50 -03:00
|
|
|
// Give the user some guidance
|
2015-10-25 17:10:41 -03:00
|
|
|
cliSerial->printf("Setup Mode\n\n\n");
|
2012-08-21 23:19:50 -03:00
|
|
|
|
|
|
|
// Run the setup menu. When the menu exits, we will return to the main menu.
|
|
|
|
setup_menu.run();
|
2011-07-17 07:30:21 -03:00
|
|
|
return 0;
|
2010-12-19 12:40:33 -04:00
|
|
|
}
|
|
|
|
|
2013-05-31 02:56:08 -03:00
|
|
|
// Initialise the EEPROM to 'factory' settings (mostly defined in APM_Config.h or via defaults).
|
|
|
|
// Called by the setup menu 'factoryreset' command.
|
2015-05-29 23:12:49 -03:00
|
|
|
int8_t Copter::setup_factory(uint8_t argc, const Menu::arg *argv)
|
2013-05-31 02:56:08 -03:00
|
|
|
{
|
|
|
|
int16_t c;
|
|
|
|
|
2015-10-25 17:10:41 -03:00
|
|
|
cliSerial->printf("\n'Y' = factory reset, any other key to abort:\n");
|
2013-05-31 02:56:08 -03:00
|
|
|
|
|
|
|
do {
|
|
|
|
c = cliSerial->read();
|
|
|
|
} while (-1 == c);
|
|
|
|
|
|
|
|
if (('y' != c) && ('Y' != c))
|
|
|
|
return(-1);
|
|
|
|
|
|
|
|
AP_Param::erase_all();
|
2015-10-25 17:10:41 -03:00
|
|
|
cliSerial->printf("\nReboot board");
|
2013-05-31 02:56:08 -03:00
|
|
|
|
|
|
|
delay(1000);
|
|
|
|
|
|
|
|
for (;; ) {
|
|
|
|
}
|
|
|
|
// note, cannot actually return here
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2014-08-29 18:00:29 -03:00
|
|
|
//Set a parameter to a specified value. It will cast the value to the current type of the
|
|
|
|
//parameter and make sure it fits in case of INT8 and INT16
|
2015-05-29 23:12:49 -03:00
|
|
|
int8_t Copter::setup_set(uint8_t argc, const Menu::arg *argv)
|
2014-08-29 18:00:29 -03:00
|
|
|
{
|
|
|
|
int8_t value_int8;
|
|
|
|
int16_t value_int16;
|
|
|
|
|
|
|
|
AP_Param *param;
|
|
|
|
enum ap_var_type p_type;
|
|
|
|
|
|
|
|
if(argc!=3)
|
|
|
|
{
|
2016-11-25 18:23:06 -04:00
|
|
|
cliSerial->println("Invalid command. Usage: set <name> <value>");
|
2014-08-29 18:00:29 -03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
param = AP_Param::find(argv[1].str, &p_type);
|
|
|
|
if(!param)
|
|
|
|
{
|
2015-10-25 17:10:41 -03:00
|
|
|
cliSerial->printf("Param not found: %s\n", argv[1].str);
|
2014-08-29 18:00:29 -03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-10-05 17:47:54 -03:00
|
|
|
const char *strType = "Value out of range for type";
|
2014-08-29 18:00:29 -03:00
|
|
|
switch(p_type)
|
|
|
|
{
|
|
|
|
case AP_PARAM_INT8:
|
|
|
|
value_int8 = (int8_t)(argv[2].i);
|
|
|
|
if(argv[2].i!=value_int8)
|
|
|
|
{
|
2016-10-05 17:47:54 -03:00
|
|
|
cliSerial->printf("%s INT8\n", strType);
|
2014-08-29 18:00:29 -03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
((AP_Int8*)param)->set_and_save(value_int8);
|
|
|
|
break;
|
|
|
|
case AP_PARAM_INT16:
|
|
|
|
value_int16 = (int16_t)(argv[2].i);
|
|
|
|
if(argv[2].i!=value_int16)
|
|
|
|
{
|
2016-10-05 17:47:54 -03:00
|
|
|
cliSerial->printf("%s INT16\n", strType);
|
2014-08-29 18:00:29 -03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
((AP_Int16*)param)->set_and_save(value_int16);
|
|
|
|
break;
|
|
|
|
|
|
|
|
//int32 and float don't need bounds checking, just use the value provoded by Menu::arg
|
|
|
|
case AP_PARAM_INT32:
|
|
|
|
((AP_Int32*)param)->set_and_save(argv[2].i);
|
|
|
|
break;
|
|
|
|
case AP_PARAM_FLOAT:
|
|
|
|
((AP_Float*)param)->set_and_save(argv[2].f);
|
|
|
|
break;
|
|
|
|
default:
|
2015-10-25 17:10:41 -03:00
|
|
|
cliSerial->printf("Cannot set parameter of type %d.\n", p_type);
|
2014-08-29 18:00:29 -03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-05-31 02:56:08 -03:00
|
|
|
// Print the current configuration.
|
|
|
|
// Called by the setup menu 'show' command.
|
2015-05-29 23:12:49 -03:00
|
|
|
int8_t Copter::setup_show(uint8_t argc, const Menu::arg *argv)
|
2013-05-31 02:56:08 -03:00
|
|
|
{
|
|
|
|
AP_Param *param;
|
|
|
|
ap_var_type type;
|
|
|
|
|
|
|
|
//If a parameter name is given as an argument to show, print only that parameter
|
|
|
|
if(argc>=2)
|
|
|
|
{
|
|
|
|
|
|
|
|
param=AP_Param::find(argv[1].str, &type);
|
|
|
|
|
|
|
|
if(!param)
|
|
|
|
{
|
2015-10-26 09:57:26 -03:00
|
|
|
cliSerial->printf("Parameter not found: '%s'\n", argv[1].str);
|
2013-05-31 02:56:08 -03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
AP_Param::show(param, argv[1].str, type, cliSerial);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// clear the area
|
|
|
|
print_blanks(8);
|
|
|
|
|
|
|
|
report_version();
|
|
|
|
report_radio();
|
|
|
|
report_frame();
|
|
|
|
report_batt_monitor();
|
|
|
|
report_flight_modes();
|
|
|
|
report_ins();
|
|
|
|
report_compass();
|
|
|
|
report_optflow();
|
|
|
|
|
|
|
|
AP_Param::show_all(cliSerial);
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2015-05-29 23:12:49 -03:00
|
|
|
int8_t Copter::esc_calib(uint8_t argc,const Menu::arg *argv)
|
2014-07-07 14:11:53 -03:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
char c;
|
|
|
|
unsigned max_channels = 0;
|
|
|
|
uint32_t set_mask = 0;
|
|
|
|
|
|
|
|
uint16_t pwm_high = PWM_CALIB_MAX;
|
|
|
|
uint16_t pwm_low = PWM_CALIB_MIN;
|
|
|
|
|
|
|
|
|
|
|
|
if (argc < 2) {
|
2015-10-25 17:10:41 -03:00
|
|
|
cliSerial->printf("Pls provide Channel Mask\n"
|
2015-10-24 18:45:41 -03:00
|
|
|
"\tusage: esc_calib 1010 - enables calibration for 2nd and 4th Motor\n");
|
2014-07-07 14:11:53 -03:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-28 13:40:07 -03:00
|
|
|
set_mask = strtol (argv[1].str, nullptr, 2);
|
2014-07-07 14:11:53 -03:00
|
|
|
if (set_mask == 0)
|
2016-11-25 18:23:06 -04:00
|
|
|
cliSerial->print("no channels chosen");
|
2015-10-25 17:10:41 -03:00
|
|
|
//cliSerial->printf("\n%d\n",set_mask);
|
2014-07-07 14:11:53 -03:00
|
|
|
set_mask<<=1;
|
|
|
|
/* wait 50 ms */
|
|
|
|
hal.scheduler->delay(50);
|
|
|
|
|
|
|
|
|
2015-10-25 17:10:41 -03:00
|
|
|
cliSerial->printf("\nATTENTION, please remove or fix propellers before starting calibration!\n"
|
2014-07-07 14:11:53 -03:00
|
|
|
"\n"
|
|
|
|
"Make sure\n"
|
|
|
|
"\t - that the ESCs are not powered\n"
|
|
|
|
"\t - that safety is off\n"
|
|
|
|
"\t - that the controllers are stopped\n"
|
|
|
|
"\n"
|
2015-10-24 18:45:41 -03:00
|
|
|
"Do you want to start calibration now: y or n?\n");
|
2014-07-07 14:11:53 -03:00
|
|
|
|
|
|
|
/* wait for user input */
|
2016-10-05 17:47:54 -03:00
|
|
|
const char *strEscCalib = "ESC calibration";
|
2014-07-07 14:11:53 -03:00
|
|
|
while (1) {
|
|
|
|
c= cliSerial->read();
|
|
|
|
if (c == 'y' || c == 'Y') {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
} else if (c == 0x03 || c == 0x63 || c == 'q') {
|
2016-10-05 17:47:54 -03:00
|
|
|
cliSerial->printf("%s exited\n", strEscCalib);
|
2014-07-07 14:11:53 -03:00
|
|
|
return(0);
|
|
|
|
|
|
|
|
} else if (c == 'n' || c == 'N') {
|
2016-10-05 17:47:54 -03:00
|
|
|
cliSerial->printf("%s aborted\n", strEscCalib);
|
2014-07-07 14:11:53 -03:00
|
|
|
return(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* rate limit to ~ 20 Hz */
|
|
|
|
hal.scheduler->delay(50);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* get number of channels available on the device */
|
|
|
|
max_channels = AP_MOTORS_MAX_NUM_MOTORS;
|
|
|
|
|
|
|
|
/* tell IO/FMU that the system is armed (it will output values if safety is off) */
|
|
|
|
motors.armed(true);
|
|
|
|
|
|
|
|
|
2016-11-25 18:23:06 -04:00
|
|
|
cliSerial->println("Outputs armed");
|
2014-07-07 14:11:53 -03:00
|
|
|
|
|
|
|
|
|
|
|
/* wait for user confirmation */
|
2015-10-25 17:10:41 -03:00
|
|
|
cliSerial->printf("\nHigh PWM set: %d\n"
|
2014-07-07 14:11:53 -03:00
|
|
|
"\n"
|
|
|
|
"Connect battery now and hit c+ENTER after the ESCs confirm the first calibration step\n"
|
2015-10-24 18:45:41 -03:00
|
|
|
"\n", pwm_high);
|
2014-07-07 14:11:53 -03:00
|
|
|
|
|
|
|
while (1) {
|
|
|
|
/* set max PWM */
|
|
|
|
for (unsigned i = 0; i < max_channels; i++) {
|
|
|
|
|
|
|
|
if (set_mask & 1<<i) {
|
|
|
|
motors.output_test(i, pwm_high);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
c = cliSerial->read();
|
|
|
|
|
|
|
|
if (c == 'c') {
|
|
|
|
break;
|
|
|
|
|
2016-08-11 17:54:49 -03:00
|
|
|
} else if (c == 0x03 || c == 'q') {
|
2016-10-05 17:47:54 -03:00
|
|
|
cliSerial->printf("%s exited\n", strEscCalib);
|
2014-07-07 14:11:53 -03:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* rate limit to ~ 20 Hz */
|
|
|
|
hal.scheduler->delay(50);
|
|
|
|
}
|
|
|
|
|
2015-10-25 17:10:41 -03:00
|
|
|
cliSerial->printf("Low PWM set: %d\n"
|
2014-07-07 14:11:53 -03:00
|
|
|
"\n"
|
|
|
|
"Hit c+Enter when finished\n"
|
2015-10-24 18:45:41 -03:00
|
|
|
"\n", pwm_low);
|
2014-07-07 14:11:53 -03:00
|
|
|
|
|
|
|
while (1) {
|
|
|
|
|
|
|
|
/* set disarmed PWM */
|
|
|
|
for (unsigned i = 0; i < max_channels; i++) {
|
|
|
|
if (set_mask & 1<<i) {
|
|
|
|
motors.output_test(i, pwm_low);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
c = cliSerial->read();
|
|
|
|
|
|
|
|
if (c == 'c') {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2016-08-11 17:54:49 -03:00
|
|
|
} else if (c == 0x03 || c == 'q') {
|
2016-10-05 17:47:54 -03:00
|
|
|
cliSerial->printf("%s exited\n", strEscCalib);
|
2014-07-07 14:11:53 -03:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* rate limit to ~ 20 Hz */
|
|
|
|
hal.scheduler->delay(50);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* disarm */
|
|
|
|
motors.armed(false);
|
|
|
|
|
2016-11-25 18:23:06 -04:00
|
|
|
cliSerial->println("Outputs disarmed");
|
2014-07-07 14:11:53 -03:00
|
|
|
|
2016-10-05 17:47:54 -03:00
|
|
|
cliSerial->printf("%s finished\n", strEscCalib);
|
2014-07-07 14:11:53 -03:00
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-20 03:11:21 -04:00
|
|
|
/***************************************************************************/
|
2011-02-24 01:56:59 -04:00
|
|
|
// CLI reports
|
2011-01-20 03:11:21 -04:00
|
|
|
/***************************************************************************/
|
2011-05-09 12:46:56 -03:00
|
|
|
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::report_batt_monitor()
|
2011-05-09 12:46:56 -03:00
|
|
|
{
|
2015-10-25 17:10:41 -03:00
|
|
|
cliSerial->printf("\nBatt Mon:\n");
|
2012-08-21 23:19:50 -03:00
|
|
|
print_divider();
|
2014-12-03 01:33:06 -04:00
|
|
|
if (battery.num_instances() == 0) {
|
|
|
|
print_enabled(false);
|
|
|
|
} else if (!battery.has_current()) {
|
2016-11-25 18:23:06 -04:00
|
|
|
cliSerial->print("volts");
|
2014-12-03 01:33:06 -04:00
|
|
|
} else {
|
2016-11-25 18:23:06 -04:00
|
|
|
cliSerial->print("volts and cur");
|
2014-12-03 01:33:06 -04:00
|
|
|
}
|
2012-08-21 23:19:50 -03:00
|
|
|
print_blanks(2);
|
2011-01-20 03:11:21 -04:00
|
|
|
}
|
|
|
|
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::report_frame()
|
2011-01-20 03:11:21 -04:00
|
|
|
{
|
2016-11-25 18:23:06 -04:00
|
|
|
cliSerial->println("Frame");
|
2012-08-21 23:19:50 -03:00
|
|
|
print_divider();
|
2016-12-12 06:22:56 -04:00
|
|
|
cliSerial->println(get_frame_string());
|
2012-08-21 23:19:50 -03:00
|
|
|
|
|
|
|
print_blanks(2);
|
2011-01-20 03:11:21 -04:00
|
|
|
}
|
|
|
|
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::report_radio()
|
2011-01-20 03:11:21 -04:00
|
|
|
{
|
2016-11-25 18:23:06 -04:00
|
|
|
cliSerial->println("Radio");
|
2012-08-21 23:19:50 -03:00
|
|
|
print_divider();
|
|
|
|
// radio
|
|
|
|
print_radio_values();
|
|
|
|
print_blanks(2);
|
2011-01-20 03:11:21 -04:00
|
|
|
}
|
|
|
|
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::report_ins()
|
2011-01-20 03:11:21 -04:00
|
|
|
{
|
2016-11-25 18:23:06 -04:00
|
|
|
cliSerial->println("INS");
|
2012-08-21 23:19:50 -03:00
|
|
|
print_divider();
|
2011-01-20 03:11:21 -04:00
|
|
|
|
2012-08-21 23:19:50 -03:00
|
|
|
print_gyro_offsets();
|
2012-11-05 00:32:38 -04:00
|
|
|
print_accel_offsets_and_scaling();
|
2012-08-21 23:19:50 -03:00
|
|
|
print_blanks(2);
|
2011-01-20 03:11:21 -04:00
|
|
|
}
|
|
|
|
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::report_flight_modes()
|
2011-01-20 03:11:21 -04:00
|
|
|
{
|
2016-11-25 18:23:06 -04:00
|
|
|
cliSerial->println("Flight modes");
|
2012-08-21 23:19:50 -03:00
|
|
|
print_divider();
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2012-08-21 23:19:50 -03:00
|
|
|
for(int16_t i = 0; i < 6; i++ ) {
|
2016-01-25 17:26:20 -04:00
|
|
|
print_switch(i, (control_mode_t)flight_modes[i].get(), BIT_IS_SET(g.simple_modes, i));
|
2012-08-21 23:19:50 -03:00
|
|
|
}
|
|
|
|
print_blanks(2);
|
2011-01-20 03:11:21 -04:00
|
|
|
}
|
|
|
|
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::report_optflow()
|
2011-07-21 20:14:53 -03:00
|
|
|
{
|
2012-11-18 12:16:07 -04:00
|
|
|
#if OPTFLOW == ENABLED
|
2016-11-25 18:23:06 -04:00
|
|
|
cliSerial->println("OptFlow");
|
2012-08-21 23:19:50 -03:00
|
|
|
print_divider();
|
2011-07-21 20:14:53 -03:00
|
|
|
|
2014-07-11 23:34:55 -03:00
|
|
|
print_enabled(optflow.enabled());
|
2011-07-21 20:14:53 -03:00
|
|
|
|
2012-08-21 23:19:50 -03:00
|
|
|
print_blanks(2);
|
2012-11-18 12:16:07 -04:00
|
|
|
#endif // OPTFLOW == ENABLED
|
2011-07-21 20:14:53 -03:00
|
|
|
}
|
2011-12-23 18:41:18 -04:00
|
|
|
|
2011-01-20 03:11:21 -04:00
|
|
|
/***************************************************************************/
|
|
|
|
// CLI utilities
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::print_radio_values()
|
2011-01-20 03:11:21 -04:00
|
|
|
{
|
ArduCopter: Fix up after refactoring RC_Channel class
Further to refactor of RC_Channel class which included
adding get_xx set_xx methods, change reads and writes to the public members
to calls to get and set functionsss
old public member(int16_t) get function -> int16_t set function (int16_t)
(expression where c is an object of type RC_Channel)
c.radio_in c.get_radio_in() c.set_radio_in(v)
c.control_in c.get_control_in() c.set_control_in(v)
c.servo_out c.get_servo_out() c.set_servo_out(v)
c.pwm_out c.get_pwm_out() // use existing
c.radio_out c.get_radio_out() c.set_radio_out(v)
c.radio_max c.get_radio_max() c.set_radio_max(v)
c.radio_min c.get_radio_min() c.set_radio_min(v)
c.radio_trim c.get_radio_trim() c.set_radio_trim(v);
c.min_max_configured() // return true if min and max are configured
Because data members of RC_Channels are now private and so cannot be written directly
some overloads are provided in the Plane classes to provide the old functionality
new overload Plane::stick_mix_channel(RC_Channel *channel)
which forwards to the previously existing
void stick_mix_channel(RC_Channel *channel, int16_t &servo_out);
new overload Plane::channel_output_mixer(Rc_Channel* , RC_Channel*)const
which forwards to
(uint8_t mixing_type, int16_t & chan1, int16_t & chan2)const;
Rename functions
RC_Channel_aux::set_radio_trim(Aux_servo_function_t function)
to RC_Channel_aux::set_trim_to_radio_in_for(Aux_servo_function_t function)
RC_Channel_aux::set_servo_out(Aux_servo_function_t function, int16_t value)
to RC_Channel_aux::set_servo_out_for(Aux_servo_function_t function, int16_t value)
Rationale:
RC_Channel is a complicated class, which combines
several functionalities dealing with stick inputs
in pwm and logical units, logical and actual actuator
outputs, unit conversion etc, etc
The intent of this PR is to clarify existing use of
the class. At the basic level it should now be possible
to grep all places where private variable is set by
searching for the set_xx function.
(The wider purpose is to provide a more generic and
logically simpler method of output mixing. This is a small step)
2016-05-08 05:46:59 -03:00
|
|
|
cliSerial->printf("CH1: %d | %d\n", (int)channel_roll->get_radio_min(), (int)channel_roll->get_radio_max());
|
|
|
|
cliSerial->printf("CH2: %d | %d\n", (int)channel_pitch->get_radio_min(), (int)channel_pitch->get_radio_max());
|
|
|
|
cliSerial->printf("CH3: %d | %d\n", (int)channel_throttle->get_radio_min(), (int)channel_throttle->get_radio_max());
|
|
|
|
cliSerial->printf("CH4: %d | %d\n", (int)channel_yaw->get_radio_min(), (int)channel_yaw->get_radio_max());
|
|
|
|
cliSerial->printf("CH5: %d | %d\n", (int)g.rc_5.get_radio_min(), (int)g.rc_5.get_radio_max());
|
|
|
|
cliSerial->printf("CH6: %d | %d\n", (int)g.rc_6.get_radio_min(), (int)g.rc_6.get_radio_max());
|
|
|
|
cliSerial->printf("CH7: %d | %d\n", (int)g.rc_7.get_radio_min(), (int)g.rc_7.get_radio_max());
|
|
|
|
cliSerial->printf("CH8: %d | %d\n", (int)g.rc_8.get_radio_min(), (int)g.rc_8.get_radio_max());
|
2010-12-19 12:40:33 -04:00
|
|
|
}
|
|
|
|
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::print_switch(uint8_t p, uint8_t m, bool b)
|
2010-12-19 12:40:33 -04:00
|
|
|
{
|
2015-10-25 17:10:41 -03:00
|
|
|
cliSerial->printf("Pos %d:\t",p);
|
2013-04-20 02:18:22 -03:00
|
|
|
print_flight_mode(cliSerial, m);
|
2015-10-25 17:10:41 -03:00
|
|
|
cliSerial->printf(",\t\tSimple: ");
|
2012-08-21 23:19:50 -03:00
|
|
|
if(b)
|
2016-11-25 18:23:06 -04:00
|
|
|
cliSerial->println("ON");
|
2012-08-21 23:19:50 -03:00
|
|
|
else
|
2016-11-25 18:23:06 -04:00
|
|
|
cliSerial->println("OFF");
|
2010-12-19 12:40:33 -04:00
|
|
|
}
|
|
|
|
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::print_accel_offsets_and_scaling(void)
|
2011-02-18 23:59:58 -04:00
|
|
|
{
|
2013-08-13 12:23:10 -03:00
|
|
|
const Vector3f &accel_offsets = ins.get_accel_offsets();
|
|
|
|
const Vector3f &accel_scale = ins.get_accel_scale();
|
2015-10-25 17:10:41 -03:00
|
|
|
cliSerial->printf("A_off: %4.2f, %4.2f, %4.2f\nA_scale: %4.2f, %4.2f, %4.2f\n",
|
2015-05-03 03:03:28 -03:00
|
|
|
(double)accel_offsets.x, // Pitch
|
|
|
|
(double)accel_offsets.y, // Roll
|
|
|
|
(double)accel_offsets.z, // YAW
|
|
|
|
(double)accel_scale.x, // Pitch
|
|
|
|
(double)accel_scale.y, // Roll
|
|
|
|
(double)accel_scale.z); // YAW
|
2011-02-18 23:59:58 -04:00
|
|
|
}
|
|
|
|
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::print_gyro_offsets(void)
|
2011-02-18 23:59:58 -04:00
|
|
|
{
|
2013-08-13 12:23:10 -03:00
|
|
|
const Vector3f &gyro_offsets = ins.get_gyro_offsets();
|
2015-10-25 17:10:41 -03:00
|
|
|
cliSerial->printf("G_off: %4.2f, %4.2f, %4.2f\n",
|
2015-05-03 03:03:28 -03:00
|
|
|
(double)gyro_offsets.x,
|
|
|
|
(double)gyro_offsets.y,
|
|
|
|
(double)gyro_offsets.z);
|
2011-02-18 23:59:58 -04:00
|
|
|
}
|
|
|
|
|
2011-07-17 07:34:05 -03:00
|
|
|
#endif // CLI_ENABLED
|
|
|
|
|
2014-03-04 23:01:45 -04:00
|
|
|
// report_compass - displays compass information. Also called by compassmot.pde
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::report_compass()
|
2014-03-04 23:01:45 -04:00
|
|
|
{
|
2016-11-25 18:23:06 -04:00
|
|
|
cliSerial->println("Compass");
|
2014-03-04 23:01:45 -04:00
|
|
|
print_divider();
|
|
|
|
|
|
|
|
print_enabled(g.compass_enabled);
|
|
|
|
|
|
|
|
// mag declination
|
2015-10-25 17:10:41 -03:00
|
|
|
cliSerial->printf("Mag Dec: %4.4f\n",
|
2015-05-03 03:03:28 -03:00
|
|
|
(double)degrees(compass.get_declination()));
|
2014-03-04 23:01:45 -04:00
|
|
|
|
|
|
|
// mag offsets
|
2014-07-22 04:32:37 -03:00
|
|
|
Vector3f offsets;
|
|
|
|
for (uint8_t i=0; i<compass.get_count(); i++) {
|
2015-09-28 16:57:03 -03:00
|
|
|
offsets = compass.get_offsets(i);
|
2014-07-22 04:32:37 -03:00
|
|
|
// mag offsets
|
2015-10-25 17:10:41 -03:00
|
|
|
cliSerial->printf("Mag%d off: %4.4f, %4.4f, %4.4f\n",
|
2014-07-22 04:32:37 -03:00
|
|
|
(int)i,
|
2015-05-03 03:03:28 -03:00
|
|
|
(double)offsets.x,
|
|
|
|
(double)offsets.y,
|
|
|
|
(double)offsets.z);
|
2014-07-22 04:32:37 -03:00
|
|
|
}
|
2014-03-04 23:01:45 -04:00
|
|
|
|
|
|
|
// motor compensation
|
2015-10-25 16:22:31 -03:00
|
|
|
cliSerial->print("Motor Comp: ");
|
2014-11-15 22:01:41 -04:00
|
|
|
if( compass.get_motor_compensation_type() == AP_COMPASS_MOT_COMP_DISABLED ) {
|
2016-11-25 18:23:06 -04:00
|
|
|
cliSerial->println("Off");
|
2014-03-04 23:01:45 -04:00
|
|
|
}else{
|
2014-11-15 22:01:41 -04:00
|
|
|
if( compass.get_motor_compensation_type() == AP_COMPASS_MOT_COMP_THROTTLE ) {
|
2015-10-25 16:22:31 -03:00
|
|
|
cliSerial->print("Throttle");
|
2014-03-04 23:01:45 -04:00
|
|
|
}
|
2014-11-15 22:01:41 -04:00
|
|
|
if( compass.get_motor_compensation_type() == AP_COMPASS_MOT_COMP_CURRENT ) {
|
2015-10-25 16:22:31 -03:00
|
|
|
cliSerial->print("Current");
|
2014-03-04 23:01:45 -04:00
|
|
|
}
|
2014-07-22 04:32:37 -03:00
|
|
|
Vector3f motor_compensation;
|
|
|
|
for (uint8_t i=0; i<compass.get_count(); i++) {
|
|
|
|
motor_compensation = compass.get_motor_compensation(i);
|
2015-10-25 17:10:41 -03:00
|
|
|
cliSerial->printf("\nComMot%d: %4.2f, %4.2f, %4.2f\n",
|
2014-07-22 04:32:37 -03:00
|
|
|
(int)i,
|
2015-05-03 03:03:28 -03:00
|
|
|
(double)motor_compensation.x,
|
|
|
|
(double)motor_compensation.y,
|
|
|
|
(double)motor_compensation.z);
|
2014-07-22 04:32:37 -03:00
|
|
|
}
|
2014-03-04 23:01:45 -04:00
|
|
|
}
|
|
|
|
print_blanks(1);
|
|
|
|
}
|
|
|
|
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::print_blanks(int16_t num)
|
2011-07-17 07:34:05 -03:00
|
|
|
{
|
2012-08-21 23:19:50 -03:00
|
|
|
while(num > 0) {
|
|
|
|
num--;
|
2012-11-21 02:08:03 -04:00
|
|
|
cliSerial->println("");
|
2012-08-21 23:19:50 -03:00
|
|
|
}
|
2011-07-17 07:34:05 -03:00
|
|
|
}
|
|
|
|
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::print_divider(void)
|
2011-07-17 07:34:05 -03:00
|
|
|
{
|
2012-08-21 23:19:50 -03:00
|
|
|
for (int i = 0; i < 40; i++) {
|
2015-10-25 16:22:31 -03:00
|
|
|
cliSerial->print("-");
|
2012-08-21 23:19:50 -03:00
|
|
|
}
|
2012-11-21 02:08:03 -04:00
|
|
|
cliSerial->println();
|
2011-07-17 07:34:05 -03:00
|
|
|
}
|
|
|
|
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::print_enabled(bool b)
|
2011-07-17 07:34:05 -03:00
|
|
|
{
|
2012-08-21 23:19:50 -03:00
|
|
|
if(b)
|
2015-10-25 16:22:31 -03:00
|
|
|
cliSerial->print("en");
|
2012-08-21 23:19:50 -03:00
|
|
|
else
|
2015-10-25 16:22:31 -03:00
|
|
|
cliSerial->print("dis");
|
2016-11-25 18:23:06 -04:00
|
|
|
cliSerial->println("abled");
|
2011-07-17 07:34:05 -03:00
|
|
|
}
|
|
|
|
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::report_version()
|
2011-07-17 07:34:05 -03:00
|
|
|
{
|
2016-08-08 00:15:14 -03:00
|
|
|
cliSerial->printf("FW Ver: %d\n",(int)(g.k_format_version));
|
2012-08-21 23:19:50 -03:00
|
|
|
print_divider();
|
|
|
|
print_blanks(2);
|
2011-07-17 07:34:05 -03:00
|
|
|
}
|