// Copyright 2021:
//   JaiaRobotics LLC
// File authors:
//   Toby Schneider <toby@gobysoft.org>
//
//
// This file is part of the JaiaBot Project Binaries
// ("The Jaia Binaries").
//
// The Jaia Binaries are free software: you can redistribute them and/or modify
// them under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.x
//
// The Jaia Binaries are distributed in the hope that they will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with the Jaia Binaries.  If not, see <http://www.gnu.org/licenses/>.

syntax = "proto2";

import "goby/middleware/protobuf/app_config.proto";
import "goby/zeromq/protobuf/interprocess_config.proto";
import "jaiabot/messages/mission.proto";
import "jaiabot/messages/jaia_dccl.proto";
import "jaiabot/messages/imu.proto";
import "dccl/option_extensions.proto";

package jaiabot.config;

message Fusion
{
    option (dccl.msg) = {
        unit_system: "si"
    };

    // required parameters for ApplicationBase3 class
    optional goby.middleware.protobuf.AppConfig app = 1;
    // required parameters for connecting to 'gobyd'
    optional goby.zeromq.protobuf.InterProcessPortalConfig interprocess = 2;

    required int32 bot_id = 10;

    required jaiabot.protobuf.BotStatus.BotType bot_type = 11;

    optional int32 health_report_timeout_seconds = 12 [default = 20];

    optional int32 init_data_health_timeout_seconds = 15 [default = 20];

    optional int32 data_timeout_seconds = 20 [default = 20];

    optional int32 heading_timeout_seconds = 21 [default = 15];

    repeated jaiabot.protobuf.MissionState discard_location_states = 30;

    optional double imu_heading_course_max_diff = 31 [default = 45];

    // timeout in seconds
    optional int32 course_over_ground_timeout = 32 [default = 3]; 

    optional jaiabot.protobuf.IMUIssue.SolutionType imu_issue_solution = 33 [default = REPORT_IMU];

    optional bool is_sim = 34 [default = false];

    // How many times to verify data is indicating imu issue before declaring one
    optional int32 total_imu_issue_checks = 35 [default = 4];

    // When to start detecting imu issues again after detecting one
    optional int32 imu_detect_timeout = 36 [default = 20]; 

    // Rate in milliseconds
    optional int32 bot_status_period_ms = 37 [default = 1000]; 

    repeated jaiabot.protobuf.MissionState include_course_error_detection_states = 38;

    repeated jaiabot.protobuf.MissionState include_imu_detection_states = 39;

    // Battery configurations
    optional bool watch_battery_percentage = 40 [default = true];
    optional float battery_percentage_low_level = 41 [default = 50];
    optional float battery_percentage_very_low_level = 42 [default = 20];
    optional float battery_percentage_critically_low_level = 43 [default = 10];

    // The period to check for a imu issue in seconds
    optional int32 imu_detect_period = 44 [default = 1]; 

    // When the bots pitch is horizontal then we can start detecting imu issues again
    optional int32 imu_issue_detect_horizontal_pitch_checks = 45 [default = 3];
    
    // The min amount of time to determine the bot is horizontal
    optional double imu_issue_detect_horizontal_pitch_min_time = 46 
        [default = 1, (dccl.field).units = { base_dimensions: "T" }];

    // The angle at which we determine the bot to be horizontal
    optional double imu_detect_horizontal_pitch = 47 [default = 45];

    // The max diff between desired heading and current heading when
    // detecting an imu issue
    optional double imu_detect_desired_heading_vs_current_max_diff = 48 [default = 45];

    // Dive states to send node status based on published depth values
    repeated jaiabot.protobuf.MissionState diving_states = 49;

    required string bot_gpsd_device = 50;  // gpsd device for bot itself

}
