Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set_rate for AngularVelocityBody #2247

Closed
RizzwareEngineer opened this issue Mar 13, 2024 · 1 comment
Closed

set_rate for AngularVelocityBody #2247

RizzwareEngineer opened this issue Mar 13, 2024 · 1 comment

Comments

@RizzwareEngineer
Copy link

Searching through documentation, there are a number of Telemetry methods that do not list their respective synchronous version.

For example, I'd like to receive AngularVelocityBody telemetry at the same rate as position as exemplified below:

    const auto set_rate_position = telemetry.set_rate_position(1.0);
    if (set_rate_position != Telemetry::Result::Success) {
        std::cerr << "Setting rate for position failed: " << set_rate_position << '\n';
        return 1;
    }

    // Set up callback to monitor altitude while the vehicle is in flight
    telemetry.subscribe_position([](Telemetry::Position position) {
        std::cout << "Altitude: " << position.relative_altitude_m << " m\n";
    });

However, the documentation makes no mention of AngularVelocityBody's, let alone a handful of method's, set_rate equivalent.

I must be looking in the wrong direction, or did I misinterpret this documentation snippet?
All the methods have both synchronous and asynchronous versions, and users can set the rate at which the vehicle provides updates for each type of information. All the methods of a particular type (synchronous, asynchronous, and set_rate methods) are used in the same way.

@julianoes
Copy link
Collaborator

The docs are usually lying. The source is the truth. 😄

It's a bit tricky, because some of the topics rely on the same message. In this case AngularVelocityBody actually comes with the ATTITUDE message, so you can set the rate by using set_rate_attitude.

See here:

void TelemetryImpl::process_attitude(const mavlink_message_t& message)
{
mavlink_attitude_t attitude;
mavlink_msg_attitude_decode(&message, &attitude);
Telemetry::EulerAngle euler_angle;
euler_angle.roll_deg = to_deg_from_rad(attitude.roll);
euler_angle.pitch_deg = to_deg_from_rad(attitude.pitch);
euler_angle.yaw_deg = to_deg_from_rad(attitude.yaw);
euler_angle.timestamp_us = static_cast<uint64_t>(attitude.time_boot_ms) * 1000;
set_attitude_euler(euler_angle);
Telemetry::AngularVelocityBody angular_velocity_body;
angular_velocity_body.roll_rad_s = attitude.rollspeed;
angular_velocity_body.pitch_rad_s = attitude.pitchspeed;
angular_velocity_body.yaw_rad_s = attitude.yawspeed;
set_attitude_angular_velocity_body(angular_velocity_body);
_attitude_euler_angle_subscriptions.queue(
attitude_euler(), [this](const auto& func) { _system_impl->call_user_callback(func); });
_attitude_angular_velocity_body_subscriptions.queue(
attitude_angular_velocity_body(),
[this](const auto& func) { _system_impl->call_user_callback(func); });
}

I'm aware this is not optimal but I don't have a good solution. I guess the best would be to add some docstrings describing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants