Skip to content

Commit 17c1b62

Browse files
authored
human friendly pahr (#57)
1 parent 22b4441 commit 17c1b62

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/cli/cli.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ static void cli_print_imu_MagData() {
6666
Serial.printf("mx:%+.2f\tmy:%+.2f\tmz:%+.2f\t", ahr.mx, ahr.my, ahr.mz);
6767
}
6868

69+
static void cli_print_ahr_RollPitchYaw_verbose() {
70+
// from ahr.h:
71+
// roll in degrees: -180 to 180, roll right is +
72+
// pitch in degrees: -90 to 90, pitch up is +
73+
// yaw in degrees: -180 to 180, yaw right is positive
74+
const char* roll_str = (ahr.roll >= 0.0) ? "right" : "left"; // roll right is clockwise, is it?
75+
const char* pitch_str = (ahr.pitch >= 0.0) ? "up" : "down";
76+
const char* yaw_str = (ahr.yaw >= 0.0) ? "right" : "left";
77+
Serial.printf("roll:%+.1f (roll %s)\tpitch:%+.1f (pitch %s)\tyaw:%+.1f (yaw %s)\t", ahr.roll, roll_str, ahr.pitch, pitch_str, ahr.yaw, yaw_str);
78+
}
79+
6980
static void cli_print_ahr_RollPitchYaw() {
7081
Serial.printf("roll:%+.1f\tpitch:%+.1f\tyaw:%+.1f\t", ahr.roll, ahr.pitch, ahr.yaw);
7182
}
@@ -164,18 +175,19 @@ struct cli_print_s {
164175
void (*function)(void);
165176
};
166177

167-
#define CLI_PRINT_FLAG_COUNT 15
178+
#define CLI_PRINT_FLAG_COUNT 16
168179
bool cli_print_flag[CLI_PRINT_FLAG_COUNT] = {false};
169180

170-
static const struct cli_print_s cli_print_options[] = {
181+
static const struct cli_print_s cli_print_options[CLI_PRINT_FLAG_COUNT] = {
171182
{"po", "Overview", cli_print_overview},
172183
{"ppwm", "Radio pwm (expected: 1000 to 2000)", cli_print_rcl_RadioPWM},
173184
{"prcl", "Scaled radio (expected: -1 to 1)", cli_print_rcl_RadioScaled},
174185
{"pimu", "IMU loop timing (expected: miss% <= 1)", cli_print_imu_Rate},
175186
{"pgyr", "Filtered gyro (expected: -250 to 250, 0 at rest)", cli_print_imu_GyroData},
176187
{"pacc", "Filtered accelerometer (expected: -2 to 2; when level: x=0,y=0,z=1)", cli_print_imu_AccData},
177188
{"pmag", "Filtered magnetometer (expected: -300 to 300)", cli_print_imu_MagData},
178-
{"pahr", "AHRS roll, pitch, and yaw (expected: degrees, 0 when level)", cli_print_ahr_RollPitchYaw},
189+
{"pahr", "AHRS roll, pitch, and yaw in human friendly format (expected: degrees, 0 when level)", cli_print_ahr_RollPitchYaw_verbose},
190+
{"pah", "AHRS roll, pitch, and yaw in less verbose format (expected: degrees, 0 when level)", cli_print_ahr_RollPitchYaw},
179191
{"ppid", "PID output (expected: -1 to 1)", cli_print_control_PIDoutput},
180192
{"pout", "Motor/servo output (expected: 0 to 1)", cli_print_out_Command},
181193
{"pbat", "Battery voltage, current, Ah used and Wh used", cli_print_bat},

0 commit comments

Comments
 (0)