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

Add Logic to Check Result of COMMAND_LONG #782

Merged

Conversation

ericjohnson97
Copy link
Contributor

@ericjohnson97 ericjohnson97 commented Feb 27, 2024

Notifies user when COMMAND_LONG fails.

2024-02-27.16-03-39.mp4

closes #628

@rafaellehmkuhl
Copy link
Member

Nice!
Could you add a video on how is the notification appearing for the user on those cases?

@ericjohnson97
Copy link
Contributor Author

Nice! Could you add a video on how is the notification appearing for the user on those cases?

np. updated!

@ericjohnson97
Copy link
Contributor Author

@rafaellehmkuhl It would probably be good to make the alert text wrap, but that should probably be a different PR

this._statusText.text = `Command: ${mav_command} failed with result: ${commandAck.result.type}`
this._statusText.severity = AlertLevel.Error
this.onStatusText.emit()
reject(new Error(`Command failed with result: ${commandAck.result.type}`))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should receive an argument on the sendCommandAck to allow such validation done automatically, or allow the code to deal with the result manually.
It would be nicer if the returned object is not commandAck but a wrapper that allows dealing with it in a better way, including raising error/warning messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should receive an argument on the sendCommandAck to allow such validation done automatically, or allow the code to deal with the result manually.

Are you thinking of having another method that calls sendCommandLong and does the ack listening after the sendCommandLong method returns?

It would be nicer if the returned object is not commandAck but a wrapper that allows dealing with it in a better way, including raising error/warning messages.

What methods do you think should go in the object? Are there any other objects that are similar that I can use for reference?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you thinking of having another method that calls sendCommandLong and does the ack listening after the sendCommandLong method returns?

I'm talking about having just an optional argument for the sendCommandLong, for now that should be enough.

What methods do you think should go in the object? Are there any other objects that are similar that I can use for reference?

A function on the commandAck should be enough, an alert() that emits an Swal.fire would be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know about the Swal.fire that seems better than as a text alert! I will add that and remove the current text alert I will also add the optional argument as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know what you think of the changes. I can tweak as needed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just putting my 2 cents (I didn't check the whole logic as patrick is already taking care of that):

I think it's important that the one invoking the command method is informed about the result of the promise (even for timeouts), and should also have the option to decide whether or not a Swal popup should be fired in case of failure or timeout. Different interfaces will have different approaches on that. Some will prefer the automatic handling, and others will need more control.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added another optional argument to suppress swals based on this

src/libs/vehicle/ardupilot/ardupilot.ts Outdated Show resolved Hide resolved
@ericjohnson97 ericjohnson97 force-pushed the feature/command_ack branch 2 times, most recently from 545f0a6 to 9937643 Compare February 28, 2024 01:41

this.write(command)
if (![MavResult.MAV_RESULT_ACCEPTED, MavResult.MAV_RESULT_IN_PROGRESS].includes(commandAck.result.type)) {
commandAck.alertMessage()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that alertMessage has its own check for ack type, this should be done before the if line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to get rid of this check but, if I don't, a swal will be emitted on all command ACKs including the accepted commands. I thought of only having alerts for failed ACKs, but I thought it would be useful in certain cases to call the alert on an accepted ACK.

@patrickelectric patrickelectric merged commit 213dac9 into bluerobotics:master Mar 1, 2024
7 checks passed
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 this pull request may close these issues.

Notify User When Command Long Fails Based on Command Ack Message
3 participants