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

Arm authorization #7377

Merged
merged 4 commits into from
Aug 28, 2017
Merged

Arm authorization #7377

merged 4 commits into from
Aug 28, 2017

Conversation

zehortigoza
Copy link
Contributor

@zehortigoza zehortigoza commented Jun 7, 2017

Allow PX4 to request flight authorization before arm.

Government entities like NASA are working in systems to managed the aero space for drones(https://utm.arc.nasa.gov/) but this also can have another uses by private companies.

Here we have a prof of concept application that authorizes mission based on the altitude of the waypoints of mission loaded. mavlink-router/mavlink-router#94

@TSC21
Copy link
Member

TSC21 commented Jun 7, 2017

@zehortigoza this is very promising. But, if one is not using an external system to send the authorization, can one just send the authorization through a RC channel for example?

@zehortigoza
Copy link
Contributor Author

@zehortigoza this is very promising. But, if one is not using an external system to send the authorization, can one just send the authorization through a RC channel for example?

Authorization through RC is something that we can do but I don't see any point in doing as it can not get mission data and process it.

@TSC21
Copy link
Member

TSC21 commented Jun 7, 2017

Authorization through RC is something that we can do but I don't see any point in doing as it can not get mission data and process it.

I understand, but is this supposed to be a mandatory verification or just optional? 'cause not everyone plans to use companion computers or GCS links. If you consider it mandatory, you should add an option like the above.

@zehortigoza
Copy link
Contributor Author

I understand, but is this supposed to be a mandatory verification or just optional? 'cause not everyone plans to use companion computers or GCS links. If you consider it mandatory, you should add an option like the above.

PX4 already had a parameter to only arm if there is a mission, I added(actually using the same byte, just using bitmask now) a new one to arm only if it got a mission authorization.

@lfelipe lfelipe requested a review from sanderux June 8, 2017 15:24
@lfelipe
Copy link
Contributor

lfelipe commented Jun 8, 2017

@sanderux pinged you for review as it seems from the last dev meeting that you are interested in something close to this (getting an external entity to validate flight based on weather conditions)

#include <uORB/topics/vehicle_command.h>
#include <uORB/topics/vehicle_command_ack.h>

#define MISSION_AUTH_SYSTEM_ID 10
Copy link
Member

Choose a reason for hiding this comment

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

Why is this hard?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I will make this a parameter.

#define MISSION_APPROVED_TIMEOUT_USEC (1000000 * 60)
#define MISSION_AUTH_CHECK_DEFAULT_TIMEOUT_USEC (1000000 * 60)
#define MISSION_AUTH_CMD_ACK_TIMEOUT_USEC (50000)

Copy link
Member

Choose a reason for hiding this comment

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

These should also be configurable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I will make this a parameter.

*
****************************************************************************/
#include "mission_auth.h"

Copy link
Member

Choose a reason for hiding this comment

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

Are we only requesting auth for missions? i think it should be flight approval (auth for arm)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will rename it to make more generic.

state = MISSION_AUTH_WAITING_AUTH;

mavlink_log_critical(mavlink_log_pub, "Requesting mission authorization...");

Copy link
Member

Choose a reason for hiding this comment

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

Please avoid needless user feedback, at minimum this should be an info message

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 don't think that this is needless, user should know why the first request did not armed the vehicle.

Copy link
Member

Choose a reason for hiding this comment

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

The message here only informs that the vehicle is requesting. If the response comes within a ms this message is a bit much

MISSION_APPROVED_TIMEOUT_USEC / 1000000);
state = MISSION_AUTH_MISSION_APPROVED;
auth_timeout = now + MISSION_APPROVED_TIMEOUT_USEC;
break;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think flight approval should require 2 arm commands, in a real life use case flight approval could be requested from the onboard computer (like checking weather conditions) that would only take a few ms. The vehicle should arm directly after receiving approval.

If there are use cases where flight approval is either manual or massively delayed you could make this configurable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was our first approach but getting final approval for the mission through 3G/4G was taking 10~20 seconds when the signal was good.
Having 2 arms commands makes it more safe as you know that the second arm command will actually arm the drone immediately.

Copy link
Member

Choose a reason for hiding this comment

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

I have a suggestion here. From a user perspective, 2 arm commands are completely un-intuitive. I would suggest that you request authorization on pre-arm (safety switch pressed and system de-saftied).

Then wait for arming from the operator. If the auth has succeeded by then, directly arm - otherwise refuse arming citing no authorization yet. How does that sound?

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this should be configurable too

Copy link
Member

Choose a reason for hiding this comment

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

Safetyswitch is not always used, i would propose to make this configurable

default:
mavlink_log_critical(mavlink_log_pub, "Mission denied");
state = MISSION_AUTH_IDLE;
break;
Copy link
Member

Choose a reason for hiding this comment

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

There should be a reason included in the message. Perhaps a set of pre-defined messages including an option to send nothing (in our case the onboard computer sends the reason directly to the GCS)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, so should I move to a new MAVlink message instead of keep using COMMAND_LONG/COMMAND_ACK? Any other suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

If the ACK includes a status code we could compile a list of reasons

orb_publish(ORB_ID(vehicle_command_ack), _command_ack_pub, &command_ack);
}
}

Copy link
Member

Choose a reason for hiding this comment

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

For feedback and log purposes i think we should also register who approved the flight

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good

@LorenzMeier
Copy link
Member

@zehortigoza Commander is scheduled for a rewrite - do you feel this is something you're ready to embark on?

@zehortigoza
Copy link
Contributor Author

New version with the fixes requested.

@zehortigoza zehortigoza changed the title RFC: Mission authorization RFC: Arm authorization Jun 27, 2017
@LorenzMeier
Copy link
Member

LorenzMeier commented Jul 9, 2017

@zehortigoza Sorry for only getting back to this now - the 1.6 release consumed my attention. Could you please rebase this on master and join the dev call on Wednesday to discuss the concept?

Link: http://discuss.px4.io/t/weekly-dev-call-of-july-12-2017/3833

@zehortigoza
Copy link
Contributor Author

@zehortigoza Sorry for only getting back to this now - the 1.6 release consumed my attention. Could you please rebase this on master and join the dev call on Wednesday to discuss the concept?

Link: http://discuss.px4.io/t/weekly-dev-call-of-july-12-2017/3833

sure

@mrpollo
Copy link
Contributor

mrpollo commented Jul 18, 2017

@zehortigoza can you attend the dev call this Wednesday 8 am PST? we would like to discuss this with you

@zehortigoza
Copy link
Contributor Author

@mrpollo Sure I will be there.

@zehortigoza
Copy link
Contributor Author

Updated it again, the first commits were send as separated PR #7613

@zehortigoza zehortigoza changed the title RFC: Arm authorization Arm authorization Aug 8, 2017
@@ -614,3 +614,21 @@ PARAM_DEFINE_INT32(COM_ARM_MIS_REQ, 0);
* @group Mission
*/
PARAM_DEFINE_INT32(COM_POSCTL_NAVL, 0);

/**
* Arm authorization parameters, this uint32_t will be spited between starting from the LSB:
Copy link
Member

Choose a reason for hiding this comment

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

typo: spited -> splitted.

@@ -610,6 +620,34 @@ MavlinkReceiver::handle_message_command_ack(mavlink_message_t *msg)
}

void
MavlinkReceiver::handle_message_command_ack2(mavlink_message_t *msg)
Copy link
Member

Choose a reason for hiding this comment

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

Could you please send a PR against the MAVLink devguide detailing the proposal?
https://github.com/mavlink/mavlink-devguide

Please also try to find a better name for ACK2 - it should have a notion of how ACK and the new ACK messages are different (like GPS and GPS_INT or ATTITUDE and ATTITUDE_QUAT).

Thanks!

Copy link
Member

@LorenzMeier LorenzMeier left a comment

Choose a reason for hiding this comment

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

Generally in good shape - if you add the documentation to upstream MAVLink so anyone else can also implement it and the spec is agreed-on we could move this forward.

@zehortigoza
Copy link
Contributor Author

New version now that the mavlink side was merged.

The commits handling the new fields in command_ack were also sent in another PR: #7821

Could you please send a PR against the MAVLink devguide detailing the proposal?
https://github.com/mavlink/mavlink-devguide

I will write that until tuesday.

@LorenzMeier
Copy link
Member

other PR is in

… new requirement

Instead of having several bools to each requirement to arm, lets group then
in a byte and use bitmask.
This also add a new arm requirement "arm authorization" that
will be implemented in another patch.
If 2 or more vehicle_command are queued a call to update() will
return the oldest vehicle_command and set the _cmd_time to the
timestamp of the last vehicle_command queued losing it.
Using update_if_changed() fix this causing all item being consumed
one at each call of send().
If the second bit of COM_ARM_MIS_EXT_REQ is set the vehicle
will only arm after receive an authorization.

The authorization flow:
vehicle/external -> command: arm authorization request -> arm authorizer
vehicle <- command ack with result in progress <- arm authorizer
vehicle <- any data request <- arm authorizer
vehicle -> data response -> arm authorizer
vehicle <- command ack authorizing or denying <- arm authorizer

Right now there is 2 ways to start the arm authorization request,
that can be configured by COM_ARM_AUTH parameter.
- One arm: When pilot request the vehicle to arm, it will request
authorization blocking the arm process up to the timeout defined in
COM_ARM_AUTH parameter.
- Two arms request: The first arm request will request the
authorization and will deny the first arm request, if authorizer
approved the request, pilot can arm again within the authorized
time and arm without any block.

The arm authorizer can be running anywhere(compute board or PX4
itself) and it is responsible to request the mission list or any
other information to vehicle before send a final response, it
should send to vehicle a COMMAND_ACK with
result = MAV_RESULT_IN_PROGRESS as soon as it receive the arm
authorization request and the final result
as after it got all the data that it needs authorize or deny the
request.
@zehortigoza
Copy link
Contributor Author

Rebased again and documentation PR sent mavlink/mavlink-devguide#16

@LorenzMeier
Copy link
Member

Jenkins test this please.

@LorenzMeier LorenzMeier merged commit 3fd7e3f into PX4:master Aug 28, 2017
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.

7 participants