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

Documentation offboard is_active method is confusing #1549

Open
Bardo91 opened this issue Sep 15, 2021 · 2 comments
Open

Documentation offboard is_active method is confusing #1549

Bardo91 opened this issue Sep 15, 2021 · 2 comments
Labels

Comments

@Bardo91
Copy link

Bardo91 commented Sep 15, 2021

According to the documentation in https://mavsdk.mavlink.io/v0.37.0/en/api_reference/classmavsdk_1_1_offboard.html#classmavsdk_1_1_offboard_1aa5e0f3c02a03f2667f82d5e162221ff5 , it is said that is_active() method returns true if offboard control is active.

True means that the vehicle is in offboard mode and we are actively sending setpoints.

Additionally, in section Monitoring Offboard Mode in https://mavsdk.mavlink.io/v0.37.0/en/guide/offboard.html . It is said

The vehicle may change out of offboard mode outside the control of your application (for example if a GCS were to put the vehicle into Hold mode). In this case, the SDK will automatically stop sending setpoints and Offboard::is_active() will change from true to false.

From these texts, I understood that if I continuously this method and the flight_mode() from telemetry, is_active should be returning 1 if flight_mode is offboard, and 0 otherwise.

However, I am doing a simple test and I am getting is_active() == 1 with the UAV in Altctl. This is the code.

    int counter = 0;
    while(run){
        std::cout <<    autopilot->mavOffboard_->is_active()  << ", " << 
                        autopilot->mavTelemetry_->flight_mode() << std::endl;

        mavsdk::Offboard::Attitude cmdRpyt{};
        cmdRpyt.roll_deg = 0;
        cmdRpyt.pitch_deg = 0;
        cmdRpyt.thrust_value = 0.2*sin(counter*0.02)+0.3;
        cmdRpyt.yaw_deg = 0;

        auto result = autopilot->mavOffboard_->set_attitude(cmdRpyt);

        auto values = autopilot->rpy();
        counter++;
        rate.wait();
    }

image

In the image, I show that is_active values 1 in Altctl, and if I pull manually the switch to toggle to offboard control, it switches the mode and the value is still 1. The engines in Altctl mode spin at a constant speed, and when I toggle to offboard I hear them swinging as expected from the code.

If I commented out the "set_attitude" command, then is when I see is_active() == 0, and obviously, the autopilot do not let me switch to offboard mode, as there aren't any control command being received.
image

Did someone noticed it too?

If so, the documentation should say that is_active returns true when the offboard is receiving setpoint, but does not imply that the offboard mode itself is active.

@julianoes julianoes added the bug label Sep 15, 2021
@julianoes
Copy link
Collaborator

However, I am doing a simple test and I am getting is_active() == 1 with the UAV in Altctl.

That sounds like a bug. Thanks for reporting.

@julianoes
Copy link
Collaborator

Hm, so reading the code, it should switch to is_active() == 0 after 3 seconds.

if (!offboard_mode_active && _mode != Mode::NotActive &&
_time.elapsed_since_s(_last_started) > 3.0) {
// It seems that we are no longer in offboard mode but still trying to send
// setpoints. Let's stop for now.
stop_sending_setpoints();

Could it be that you're missing that you actively need to do offboard.start()?

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

No branches or pull requests

2 participants