// Copyright (c) 2022 Boston Dynamics, Inc.  All rights reserved.
//
// Downloading, reproducing, distributing or otherwise using the SDK Software
// is subject to the terms and conditions of the Boston Dynamics Software
// Development Kit License (20191101-BDSDK-SL).

syntax = "proto3";

package bosdyn.api;

option java_outer_classname = "PowerProto";

import "bosdyn/api/header.proto";
import "bosdyn/api/lease.proto";
import "bosdyn/api/license.proto";
import "bosdyn/api/robot_state.proto";

// Feedback on the current state of a power command on the robot.
enum PowerCommandStatus {
    // Status is not specified.
    STATUS_UNKNOWN = 0;

    // Power command is executing.
    STATUS_IN_PROGRESS = 1;

    // Power command succeeded.
    STATUS_SUCCESS = 2;

    // ERROR: Robot cannot be powered on while on wall power.
    STATUS_SHORE_POWER_CONNECTED = 3;

    // ERROR: Battery not inserted into robot.
    STATUS_BATTERY_MISSING = 4;

    // ERROR: Power command cant be overwritten.
    STATUS_COMMAND_IN_PROGRESS = 5;

    // ERROR: Cannot power on while estopped. A robot may have multiple estops.
    // Inspect EStopState for additional info.
    STATUS_ESTOPPED = 6;

    // ERROR: Cannot power due to a fault. Inspect FaultState for more info.
    STATUS_FAULTED = 7;

    // ERROR: Internal error occurred, may be clear-able by issuing a power off command.
    STATUS_INTERNAL_ERROR = 8;

    // ERROR: License check failed. Check license_status field for details.
    STATUS_LICENSE_ERROR = 9;

    // ERROR: The Spot hardware is not compatible with the request request.
    INCOMPATIBLE_HARDWARE_ERROR = 10;

    // ERROR: Robot has overridden the power command and disabled motor power. In the case
    // of a commanded power OFF, robot will report SUCCESS if power is disabled.
    STATUS_OVERRIDDEN = 11;
}

// The PowerCommand request which specifies a change in the robot's motor power.
message PowerCommandRequest {
    // Common request header.
    RequestHeader header = 1;

    // The Lease to show ownership of the robot.
    Lease lease = 2;

    // Commands for the robot to execute.
    // Note that not all Spot robots are compatible with all these commands. Check your robot's
    // HardwareConfiguration in bosdyn.api.robot_state.
    enum Request {
        option allow_alias = true;
        REQUEST_UNKNOWN = 0;                  // Invalid request; do not use.
        REQUEST_OFF = 1 [deprecated = true];  // Cut power to motors immediately.
        REQUEST_ON = 2 [deprecated = true];   // Turn on power to the robot motors.
        REQUEST_OFF_MOTORS = 1;               // Cut power to motors immediately.
        REQUEST_ON_MOTORS = 2;                // Turn on power to the robot motors.
        REQUEST_OFF_ROBOT = 3;                // Turn off the robot. Same as physical switch.
        REQUEST_CYCLE_ROBOT = 4;              // Power cycle the robot. Same as physical switch.
        REQUEST_OFF_PAYLOAD_PORTS = 5;        // Cut power to the payload ports.
        REQUEST_ON_PAYLOAD_PORTS = 6;         // Turn on power to the payload ports.
        REQUEST_OFF_WIFI_RADIO = 7;           // Cut power to the hardware Wi-Fi radio.
        REQUEST_ON_WIFI_RADIO = 8;            // Power on the hardware Wi-Fi radio.

    }
    Request request = 3;
}

// The PowerCommand response message which contains a unique identifier that can be used to
// get feedback on the progress of a power command from the power service.
message PowerCommandResponse {
    // Common response header.
    ResponseHeader header = 1;

    // Details about how the lease was used.
    LeaseUseResult lease_use_result = 2;

    // Current feedback of specified command.
    PowerCommandStatus status = 3;

    // Unique identifier for the command, If empty, was not accepted.
    uint32 power_command_id = 4;

    // License check status
    LicenseInfo.Status license_status = 5;

    // Optional list of active faults blocking success of the PowerCommandRequest
    repeated SystemFault blocking_faults = 6;
}

// The PowerCommandFeedback request message, which can get the feedback for a specific
// power command id number.
message PowerCommandFeedbackRequest {
    // Common request header.
    RequestHeader header = 1;

    // Unique identifier for the command of which feedback is desired.
    uint32 power_command_id = 2;
}

// The PowerCommandFeedback response message, which contains the progress of the power command.
message PowerCommandFeedbackResponse {
    // Common response header.
    ResponseHeader header = 1;

    // Current status of specified command.
    PowerCommandStatus status = 2;

    // Optional list of active faults blocking success of the PowerCommandRequest
    repeated SystemFault blocking_faults = 3;
}
