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

pymavlink set_mode ack, wrong constant being used #245

Closed
refeed opened this issue Apr 14, 2022 · 3 comments · Fixed by #247
Closed

pymavlink set_mode ack, wrong constant being used #245

refeed opened this issue Apr 14, 2022 · 3 comments · Fixed by #247

Comments

@refeed
Copy link
Contributor

refeed commented Apr 14, 2022

On https://www.ardusub.com/developers/pymavlink.html

There's a part that explains how to wait for the ack:

while True:
    # Wait for ACK command
    ack_msg = master.recv_match(type='COMMAND_ACK', blocking=True)
    ack_msg = ack_msg.to_dict()

    # Check if command in the same in `set_mode`
    if ack_msg['command'] != mavutil.mavlink.MAVLINK_MSG_ID_SET_MODE:
        continue

    # Print the ACK result !
    print(mavutil.mavlink.enums['MAV_RESULT'][ack_msg['result']].description)
    break

But this constant: MAVLINK_MSG_ID_SET_MODE seemingly should be MAV_CMD_DO_SET_MODE ? Because when I ran the snippet above, it just stuck in that if statement ( if ack_msg['command'] != mavutil.mavlink.MAVLINK_MSG_ID_SET_MODE:)

I was using Ardupilot SITL btw, not the Ardusub one, but shouldn't they use the same constant?

@ES-Alexander
Copy link
Contributor

But this constant: MAVLINK_MSG_ID_SET_MODE seemingly should be MAV_CMD_DO_SET_MODE ?

Yes, I believe that's correct. SET_MODE used to be a message but is now a command, and that example hasn't been updated to reflect that. There's a more up to date example here as part of a more complete program, although it requires Python >= 3.8.

refeed added a commit to refeed/ardusub-gitbook that referenced this issue May 1, 2022
@refeed
Copy link
Contributor Author

refeed commented May 1, 2022

I see, thanks for the explanation! In your example you used two constants

            # check if acknowledged MAV_CMD_DO_SET_MODE or SET_MODE (old)
            if ack_msg.command in (176, 11):

I just pushed a PR, should I update it to also put the two constants there?

@ES-Alexander
Copy link
Contributor

I just pushed a PR, should I update it to also put the two constants there?

I included both at the time for compatibility, and because I wasn’t sure whether the message was used by any of the send options. Looking again the acknowledgement is using the command protocol, which presumably wasn’t used when it was just a ‘message’, so receiving the message ID there is likely impossible anyway.

refeed added a commit to refeed/ardusub-gitbook that referenced this issue May 1, 2022
refeed added a commit to refeed/ardusub-gitbook that referenced this issue May 2, 2022
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

Successfully merging a pull request may close this issue.

2 participants