Hey guys,
I am trying to get the roll, pitch and yaw angle of my connected pixhawk using mavsdk.
I have written a short script that connects with the pixhawk over usb and then set the rate of attitude to 1Hz:
const Telemetry::Result set_rate_result_attitude = telemetry->set_rate_attitude(1.0); // Attitude
if (set_rate_result_attitude != Telemetry::Result::SUCCESS) {
BLUE_TEXT;
std::cout << ERROR_CONSOLE_TEXT
<< “Attitude->Setting rate failed:” << Telemetry::result_str(set_rate_result_attitude)
<< NORMAL_CONSOLE_TEXT << std::endl;
}
After that I set up a callback for the attitude:
// Set up callback to monitor Attitude
telemetry->attitude_euler_angle_async([](Telemetry::EulerAngle euler_angle) {
std::cout << "Angle Information" << std::endl
<< "\t Pitch: " << euler_angle.roll_deg << std::endl
<< "\t Roll: " << euler_angle.pitch_deg << std::endl
<< "\t Yaw: " << euler_angle.yaw_deg << std::endl;
});
However, everytime I run the code the console output is:
Attitude->Setting rate failed: Command denied
When I connect the pixhawk with QGroundControl or MissionPlanner and after that run my code (without powering off my pixhawk) I get the attitude values without any problems.
QGroundControl and MissionPlanner must somehow activate something what I am missing. What can that be? What am I missing? Where can I get more documentation about mavsdk? I have tried to read everything on mavsdk but I haven´t found any “preconditions” for attitude or the other properties.
Please help.