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 callbacks that provide a result (for server commands) #245

Open
bazfp opened this issue Aug 9, 2021 · 4 comments
Open

Add callbacks that provide a result (for server commands) #245

bazfp opened this issue Aug 9, 2021 · 4 comments

Comments

@bazfp
Copy link

bazfp commented Aug 9, 2021

While defining the proto API for MAVSDK autopilot server plugins I ran into an issue where I needed to provide logic to allow or disallow a certain action in a timely manner. for example with an arming request MAV_CMD_COMPONENT_ARM_DISARM

As this request is a mavlink command, it requires an ack to be successful, failed or unsupported almost immediately. The only way for me to fulfil this at current was to store the state of is_armable in the plugin and provide proto to change that state. This state is checked when a command is observed and the ack is sent immediately. It works, but not an ideal solution.

https://github.com/mavlink/MAVSDK/blob/main/src/plugins/action_server/action_server_impl.cpp#L57

I would like to be able to do something like the following:

action_server.subscribe_arm_request([](action_server::ArmRequest arm_request)
{
  return some_check_to_see_if_can_arm(arm_request); // True if allow // False if not
});

In the plugin, this callback result could then be used to ack the command correctly.

The return value should probably map to command ack states really - instead of just a boolean.

@dlech
Copy link
Contributor

dlech commented Nov 10, 2021

This sort of callback would be useful for a camera server as well.

@dlech
Copy link
Contributor

dlech commented Nov 11, 2021

Looking at what is possible with gRPC, it looks like the closest thing is a bidirectional stream.

@dlech
Copy link
Contributor

dlech commented Nov 11, 2021

It looks like the TrackingServer is implemented in a way where the ack is deferred.

@julianoes
Copy link
Collaborator

@JonasVautherin what's your take on this? For now, we just use several workarounds, either state like is_armable or explicit responses that need to be made when requests come in.

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

No branches or pull requests

3 participants