Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions protobuf_definitions/control.proto
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ message PauseMissionCtrl {
message ClearMissionCtrl {
}

// Clears the mission rules.
message ClearMissionRulesCtrl {
}

// Run a single instruction right away, outside any mission.
//
// Instructions that do not move the drone (camera, tilt, lights, multibeam) run in any mission
Expand Down
4 changes: 3 additions & 1 deletion protobuf_definitions/message_formats.proto
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,9 @@ enum NotificationType {
NOTIFICATION_TYPE_DVL_PROTOCOL_UNSUPPORTED = 34; // DVL firmware speaks a protocol version Blunux does not support.
NOTIFICATION_TYPE_INSTRUCTION_STARTED = 35; // A mission instruction started; the value names it.
NOTIFICATION_TYPE_MISSION_PAUSED_BY_INSTRUCTION = 36; // Paused after an instruction with pause_on_completion.
NOTIFICATION_TYPE_MISSION_UPDATED = 37; // The loaded mission was changed; the value is its revision.
NOTIFICATION_TYPE_MISSION_UPDATED = 37; // The loaded mission was changed; the value says what changed.
NOTIFICATION_TYPE_MISSION_RULE_FIRED = 38; // A mission rule fired; the value is its name.
NOTIFICATION_TYPE_MISSION_RULE_RELEASED = 39; // A mission rule released; the value is its name.
}

// List of available notification levels.
Expand Down
44 changes: 44 additions & 0 deletions protobuf_definitions/mission_planning.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
syntax = "proto3";

package blueye.protocol;
import "google/protobuf/timestamp.proto";
import "message_formats.proto";
option csharp_namespace = "Blueye.Protocol.Protobuf";

Expand Down Expand Up @@ -101,6 +102,40 @@ message ControlModeCommand {
}

// A WaypointCommand will request the drone to drive to a point automatically.
// DetectionTrigger fires a rule on what the computer vision models see.
message DetectionTrigger {
repeated string class_names = 1; // Any of these class names; empty matches every class.
string model_name = 2; // Only detections from this model; empty matches every model.
Camera camera = 3; // Only detections from this camera; unspecified matches every camera.
float min_confidence = 4; // Detections below this confidence are ignored (0..1).
float min_area_fraction = 5; // Least bounding box area over image area a detection must have (0..1).
uint32 hold_ms = 6; // How long the trigger must match before the rule fires.
uint32 release_ms = 7; // How long the trigger must stay unmatched before the rule releases.
uint32 cooldown_ms = 8; // Time after a release before the rule can fire again.
}

// MissionRule runs instructions when its trigger fires and when it releases.
message MissionRule {
uint32 id = 1; // Rule id, defined by the client.
string name = 2; // Rule name, for the log and the app.
bool enabled = 3; // A disabled rule never fires.
oneof trigger {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consider making this a list of triggers that are AND evaluated, so we have a repeated list of oneof triggers.

DetectionTrigger detection_trigger = 4; // Fire on detections.
}
repeated Instruction enter_instructions = 5; // Run when the rule fires. Instructions that move the drone are refused.
repeated Instruction exit_instructions = 6; // Run when the rule releases.
}
Comment on lines +117 to +127

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@follesoe protocol-wise I think this is a good design. The trigger can then be extended to be a DepthTrigger, AltitudeTrigger, LocationTrigger, among other ideas. What do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good!


// MissionRuleStatus is the state of one rule.
message MissionRuleStatus {
uint32 id = 1; // Rule id.
MissionRuleState state = 2; // What the rule is doing.
uint32 episodes = 3; // Times the rule has fired since it was set.
google.protobuf.Timestamp last_fired = 4; // When the rule last fired; unset before the first time.
InstructionResultState last_result = 5; // Outcome of the last instruction the rule ran.
string last_reason = 6; // Reason of the last result, when there is one.
}

// InsertInstruction adds an instruction to the loaded mission.
message InsertInstruction {
Instruction instruction = 1; // The instruction to add. Its id must be new to the mission.
Expand Down Expand Up @@ -371,6 +406,15 @@ message MissionStatus {
}

// Outcome of an instruction started with RunInstructionCtrl.
// MissionRuleState is where a rule is in its episode.
enum MissionRuleState {
MISSION_RULE_STATE_UNSPECIFIED = 0; // Unspecified.
MISSION_RULE_STATE_IDLE = 1; // Waiting for the trigger.
MISSION_RULE_STATE_ACTIVE = 2; // The rule has fired and has not released yet.
MISSION_RULE_STATE_COOLDOWN = 3; // Released; waiting for the cooldown before it can fire again.
MISSION_RULE_STATE_DISABLED = 4; // The rule is disabled.
}

enum InstructionResultState {
INSTRUCTION_RESULT_STATE_UNSPECIFIED = 0; // Unspecified.
INSTRUCTION_RESULT_STATE_ACCEPTED = 1; // The instruction was accepted and has started.
Expand Down
20 changes: 20 additions & 0 deletions protobuf_definitions/req_rep.proto
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,26 @@ message SetInstructionUpdateRep {
uint32 revision = 3; // Revision of the mission after the change.
}

// Replaces the mission rules. Rules run independently of missions.
message SetMissionRulesReq {
repeated MissionRule rules = 1; // The rules to run; an empty list clears them.
}

// Response after setting the mission rules.
message SetMissionRulesRep {
bool accepted = 1; // True when the rules were set.
string reason = 2; // Why the rules were refused.
}

// Get the mission rules.
message GetMissionRulesReq {
}

// The mission rules.
message GetMissionRulesRep {
repeated MissionRule rules = 1; // The rules currently set.
}

// Set the heading mode used in dead reckoning.
message SetHeadingModeReq {
HeadingMode heading_mode = 1; // The heading mode to set.
Expand Down
5 changes: 5 additions & 0 deletions protobuf_definitions/telemetry.proto
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ message NotificationTel {
//
// Published when the instruction is accepted or rejected, and again when it completes, fails or
// is cancelled.
// State of the mission rules.
message MissionRulesTel {
repeated MissionRuleStatus rules = 1; // One entry per rule.
}

message InstructionResultTel {
InstructionResult result = 1; // Result of the instruction.
}
Expand Down
Loading