# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: control.proto
# plugin: python-betterproto2
# This file has been @generated

__all__ = (
    "AddTargetFromAnchorCam",
    "CombinedMove",
    "Command",
    "CommonCommand",
    "ControlBatchUpdate",
    "ControlItem",
    "DeleteTarget",
    "EpControl",
    "GantryGoalPos",
    "JogSpool",
    "ScaleRoom",
)

from dataclasses import dataclass

import betterproto2

from ...message_pool import default_message_pool

_COMPILER_VERSION = "0.9.0"
betterproto2.check_compiler_version(_COMPILER_VERSION)


class Command(betterproto2.Enum):
    TIGHTEN_LINES = 0
    """
    Reel every line until tight (by switch)
    """

    HALF_CAL = 1
    """
    Perform fast calibration (takes about 2 seconds)
    """

    FULL_CAL = 2
    """
    Perform full calibration sequence. (requires setup of cards on the floor)
    """

    ZERO_WINCH = 3
    """
    Zero the winch line in the gripper by reeling it in until it hits the limit switch
    """

    STOP_ALL = 4
    """
    Stop all spool motion (while respecting deceleration limits)
    """

    ENABLE_LEROBOT = 5
    """
    Begin accepting connections from lerobot teleoperation or data collection tools
    """

    PICK_AND_DROP = 9
    """
    Begin performing automated pick and drop of targets in queue
    """

    PARK = 10
    """
    Drop everything and auto park on the saddle
    """

    UNPARK = 11
    """
    Unpark from the saddle and move clear of it.
    """

    GRASP = 12
    """
    Execute an automated grasp at the current position.
    """

    SUBMIT_TARGETS_TO_DATASET = 13
    """
    Take the current set of targets as complete and correct and add entries to dataset
    """

    HORIZONTAL_CHECK = 6
    """
    =====  Commands intended only for diagnostics =====

    A horizontal move paralell to the floor that measures the quality of calibration
    """

    COLLECT_GRIPPER_IMAGES = 7
    """
    Begin saving images of the gripper camera at regular intervals in a local directory
    """

    SHUTDOWN = 8
    """
    Shuts down the observer process. robot components remain on.
    """

    @classmethod
    def betterproto_value_to_renamed_proto_names(cls) -> dict[int, str]:
        return {
            0: "COMMAND_TIGHTEN_LINES",
            1: "COMMAND_HALF_CAL",
            2: "COMMAND_FULL_CAL",
            3: "COMMAND_ZERO_WINCH",
            4: "COMMAND_STOP_ALL",
            5: "COMMAND_ENABLE_LEROBOT",
            9: "COMMAND_PICK_AND_DROP",
            10: "COMMAND_PARK",
            11: "COMMAND_UNPARK",
            12: "COMMAND_GRASP",
            13: "COMMAND_SUBMIT_TARGETS_TO_DATASET",
            6: "COMMAND_HORIZONTAL_CHECK",
            7: "COMMAND_COLLECT_GRIPPER_IMAGES",
            8: "COMMAND_SHUTDOWN",
        }

    @classmethod
    def betterproto_renamed_proto_names_to_value(cls) -> dict[str, int]:
        return {
            "COMMAND_TIGHTEN_LINES": 0,
            "COMMAND_HALF_CAL": 1,
            "COMMAND_FULL_CAL": 2,
            "COMMAND_ZERO_WINCH": 3,
            "COMMAND_STOP_ALL": 4,
            "COMMAND_ENABLE_LEROBOT": 5,
            "COMMAND_PICK_AND_DROP": 9,
            "COMMAND_PARK": 10,
            "COMMAND_UNPARK": 11,
            "COMMAND_GRASP": 12,
            "COMMAND_SUBMIT_TARGETS_TO_DATASET": 13,
            "COMMAND_HORIZONTAL_CHECK": 6,
            "COMMAND_COLLECT_GRIPPER_IMAGES": 7,
            "COMMAND_SHUTDOWN": 8,
        }


@dataclass(eq=False, repr=False)
class AddTargetFromAnchorCam(betterproto2.Message):
    """
    Add a new target by projecting the provided point from the given camera
    and adds the current image and point to a dataset
    """

    anchor_num: "int" = betterproto2.field(1, betterproto2.TYPE_UINT32)

    img_norm_x: "float" = betterproto2.field(2, betterproto2.TYPE_FLOAT)

    img_norm_y: "float" = betterproto2.field(3, betterproto2.TYPE_FLOAT)

    target_id: "str | None" = betterproto2.field(
        4, betterproto2.TYPE_STRING, optional=True
    )
    """
    If an id is set, this is interpreted as a move command, to set a new position for the given item.
    """


default_message_pool.register_message(
    "nf.control", "AddTargetFromAnchorCam", AddTargetFromAnchorCam
)


@dataclass(eq=False, repr=False)
class CombinedMove(betterproto2.Message):
    """
    A movement command typically sent from a gamepad or policy
    """

    direction: "_common__.Vec3 | None" = betterproto2.field(
        1, betterproto2.TYPE_MESSAGE, optional=True
    )
    """
    Direction in which to move gantry
    When unset, gantry continues moving according to it's last command
    when unset, speed is ignored
    """

    speed: "float | None" = betterproto2.field(
        2, betterproto2.TYPE_FLOAT, optional=True
    )
    """
    Speed to move gantry
    if speed is set, direction is normalized to a unit vector and multiplied by speed.
    if speed is unset, direction is assumed to be a velocity vector

    meters per second
    """

    finger: "float | None" = betterproto2.field(
        3, betterproto2.TYPE_FLOAT, optional=True
    )
    """
    Set the finger servo angle
    Range [-90,90]
    When unset, finger command will not be issued, finger continues tracking previously commanded angle.
    """

    winch: "float | None" = betterproto2.field(
        4, betterproto2.TYPE_FLOAT, optional=True
    )
    """
    Set the winch line speed
    Line lengthening speed in meters per second
    when unset, winch spool continues at previously commanded speed.
    not used in arp
    """

    wrist: "float | None" = betterproto2.field(
        5, betterproto2.TYPE_FLOAT, optional=True
    )
    """
    Set the wrist angle in degrees
    when unset, wrist command will not be issued, wrist continues holding previously commanded angle
    Not used in pilot
    """


default_message_pool.register_message("nf.control", "CombinedMove", CombinedMove)


@dataclass(eq=False, repr=False)
class CommonCommand(betterproto2.Message):
    """
    Start one of several common tasks which take no arguments.
    """

    name: "Command" = betterproto2.field(
        1, betterproto2.TYPE_ENUM, default_factory=lambda: Command(0)
    )


default_message_pool.register_message("nf.control", "CommonCommand", CommonCommand)


@dataclass(eq=False, repr=False)
class ControlBatchUpdate(betterproto2.Message):
    """
    the frame sent over the wire
    """

    robot_id: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)

    updates: "list[ControlItem]" = betterproto2.field(
        2, betterproto2.TYPE_MESSAGE, repeated=True
    )


default_message_pool.register_message(
    "nf.control", "ControlBatchUpdate", ControlBatchUpdate
)


@dataclass(eq=False, repr=False)
class ControlItem(betterproto2.Message):
    """
    A single kind of update that a UI, ursina or web, is providing to Observer
    Typically to control the robot

    Oneofs:
        - payload:
    """

    command: "CommonCommand | None" = betterproto2.field(
        1, betterproto2.TYPE_MESSAGE, optional=True, group="payload"
    )

    jog_spool: "JogSpool | None" = betterproto2.field(
        2, betterproto2.TYPE_MESSAGE, optional=True, group="payload"
    )

    move: "CombinedMove | None" = betterproto2.field(
        3, betterproto2.TYPE_MESSAGE, optional=True, group="payload"
    )

    gantry_goal_pos: "GantryGoalPos | None" = betterproto2.field(
        4, betterproto2.TYPE_MESSAGE, optional=True, group="payload"
    )

    episode_control: "EpControl | None" = betterproto2.field(
        5, betterproto2.TYPE_MESSAGE, optional=True, group="payload"
    )

    scale_room: "ScaleRoom | None" = betterproto2.field(
        6, betterproto2.TYPE_MESSAGE, optional=True, group="payload"
    )

    add_cam_target: "AddTargetFromAnchorCam | None" = betterproto2.field(
        7, betterproto2.TYPE_MESSAGE, optional=True, group="payload"
    )

    delete_target: "DeleteTarget | None" = betterproto2.field(
        8, betterproto2.TYPE_MESSAGE, optional=True, group="payload"
    )


default_message_pool.register_message("nf.control", "ControlItem", ControlItem)


@dataclass(eq=False, repr=False)
class DeleteTarget(betterproto2.Message):
    target_id: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)


default_message_pool.register_message("nf.control", "DeleteTarget", DeleteTarget)


@dataclass(eq=False, repr=False)
class EpControl(betterproto2.Message):
    """
    Adds the named episode control events to a set
    When lerobot is connected, this is how a teleoperator can start or stop an episode during recording
    """

    events: "list[str]" = betterproto2.field(1, betterproto2.TYPE_STRING, repeated=True)


default_message_pool.register_message("nf.control", "EpControl", EpControl)


@dataclass(eq=False, repr=False)
class GantryGoalPos(betterproto2.Message):
    """
    Set the given goal position for the gantry, it will begin moving there.
    """

    pos: "_common__.Vec3 | None" = betterproto2.field(
        1, betterproto2.TYPE_MESSAGE, optional=True
    )


default_message_pool.register_message("nf.control", "GantryGoalPos", GantryGoalPos)


@dataclass(eq=False, repr=False)
class JogSpool(betterproto2.Message):
    """
    Used for direct control of a single spool during installation or maintenence
    not for typical robot movement

    Oneofs:
        - var:
    """

    is_gripper: "bool" = betterproto2.field(1, betterproto2.TYPE_BOOL)

    anchor_num: "int" = betterproto2.field(2, betterproto2.TYPE_UINT32)
    """
    only set for anchors
    """

    speed: "float | None" = betterproto2.field(
        3, betterproto2.TYPE_FLOAT, optional=True, group="var"
    )
    """
    lengthen the line by this many meters per second until told to stop
    """

    offset: "float | None" = betterproto2.field(
        4, betterproto2.TYPE_FLOAT, optional=True, group="var"
    )
    """
    change the length of unspooled line by this many meters at a fixed and safe speed.
    """


default_message_pool.register_message("nf.control", "JogSpool", JogSpool)


@dataclass(eq=False, repr=False)
class ScaleRoom(betterproto2.Message):
    """
    message used to tweak calibration by scaling all the anchor positions towards or away from the origin
    """

    scale: "float" = betterproto2.field(1, betterproto2.TYPE_FLOAT)

    tiltcams: "float" = betterproto2.field(2, betterproto2.TYPE_FLOAT)


default_message_pool.register_message("nf.control", "ScaleRoom", ScaleRoom)


from .. import common as _common__
