Skip to content

Commit afc28d2

Browse files
committed
Add human friendly pahr
1 parent a737ad3 commit afc28d2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/cli/cli.cpp

Lines changed: 13 additions & 1 deletion
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
}
@@ -175,7 +186,8 @@ static const struct cli_print_s cli_print_options[] = {
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)