Pitch Roll and Yaw based Logs

I’m hoping someone can help here… I’m trying to log the values for PITCH, ROLL, and YAW, as well as their rate, at regular intervals. I’m reading through the dev documentation and though there is a section on logging, there doesn’t seem to be any documentation regarding the AP::ahrs variables.

From browsing the code, I think that AP::ahrs().pitch, AP::ahrs().roll, and AP::ahrs().yaw are the variables which probably store the current state of those parameters (after the EKF estimation), but how would I use them? I haven’t figured out logging yet, but I have tried to write those variables to mavlink from within the 1hz UserCode super slow loop using ::gcs_send_text_P, but I can’t even get the label text, let alone the variable.

Can someone help me to understand how these variables are accessed and what I’m doing wrong trying to output to any console?

I’m hoping someone can help here… I’m trying to log the values for PITCH,
ROLL, and YAW, as well as their rate, at regular intervals. I’m reading
through the dev documentation and though there is a section on logging,
there doesn’t seem to be any documentation regarding the AP::ahrs
variables.

These are available in the dataflash logs as ATT.Pitch ATT.Roll etc.

They’re available over mavlink in ATTITUDE.roll and friends.

From browsing the code, I think that AP::ahrs().pitch, AP::ahrs().roll,
and AP::ahrs().yaw are the variables which probably store the current
state of those parameters (after the EKF estimation), but how would I use
them? I haven’t figured out logging yet, but I have tried to write those
variables to mavlink from within the 1hz UserCode super slow loop using
::gcs_send_text_P, but I can’t even get the label text, let alone the
variable.

That method shouldn’t even exist any more :slight_smile: What version of the code
are you using, and where did you find that function name?

1 Like

That function name came off of a solution someone posted in a forum somewhere I can no longer find and was the only reference I could find to what I was trying to do.

Figuring out how to log these values was precursor to using them in my own custom functions, so already having them in the logs isn’t really what I was looking for. How would I access those variables from my functions in flight? The data I need is the same pit/rol data available over mavlink, but there must be a better way to access them than reading an output stream?

@icoblue,

From anywhere within the ardupilot code AP::ahrs().roll or AP::ahrs().roll_sensor should return the roll in radians or centidegress respectively. Similarly AP::ahrs().pitch and AP::ahrs().pitch_sensor should return the pitch.

Hope that helps.