syntax = "proto3";

package cmvr.config;

import "cmvr/common/geometry.proto";
import "cmvr/config/touch_screen_common_config.proto";
import "cmvr/config/touch_screen_algorithm_config.proto";

message TouchScreenInitJointPoint {
  optional string joint_name = 1;
  optional double rad = 2;
}

message TouchScreenTaskDevicesConfig {
  reserved 1;
  reserved "robot_id";

  optional string arm_id = 4;
  optional string dexhand_id = 2;
  optional string camera_id = 3;
}

message TouchScreenTaskInitializationConfig {
  optional bool before_start = 1;
  optional bool after_finish = 2;
  repeated TouchScreenInitJointPoint joint_positions = 3;
  optional double velocity = 4;
  optional double acceleration = 5;
}

message TouchScreenTaskPerceptionConfig {
  TouchScreenApriltagConfig apriltag = 1;
}

message TouchScreenAlignmentTargetConfig {
  .cmvr.common.Vec3 position_in_camera = 1;
  .cmvr.common.Vec3 rotation_vector = 2;
  optional TouchScreenAlignMode mode = 3;
}

message TouchScreenTaskAlignmentConfig {
  reserved 1;
  reserved "kinematics";
  TouchScreenIbvsConfig ibvs = 2;
  TouchScreenAlignmentTargetConfig target = 3;
  .cmvr.common.Vec6 error_threshold = 4;
  optional int32 stable_frames = 5;
  optional double timeout_s = 6;
  optional bool pause_when_reached = 7;
}

message TouchScreenTouchSpeedLConfig {
  .cmvr.common.Vec6 twist_tool = 1;
  optional double acceleration = 2;
  optional double max_distance_m = 3;
}

message TouchScreenTouchMoveLConfig {
  .cmvr.common.Vec6 direction_tool = 1;
  optional double distance_m = 2;
  optional double velocity = 3;
  optional double acceleration = 4;
  optional double jerk = 5;
  repeated double joint_velocity_limits = 6;
}

message TouchScreenTactileTriggerConfig {
  optional TouchScreenFingerType finger = 1;
  optional TouchScreenTactileRegion region = 2;
  optional TouchScreenTactileCriterion criterion = 3;
  optional double force_threshold = 4;
}

message TouchScreenTaskTouchConfig {
  oneof motion {
    TouchScreenTouchSpeedLConfig speed_l = 1;
    TouchScreenTouchMoveLConfig move_l = 2;
  }

  TouchScreenTactileTriggerConfig tactile = 3;
  optional double dwell_time_s = 4;
}

message TouchScreenTaskRetractConfig {
  .cmvr.common.Vec6 twist_tool = 1;
  optional double acceleration = 2;
  optional double duration_s = 3;
}

message TouchScreenTaskConfig {
  TouchScreenTaskDevicesConfig devices = 1;
  TouchScreenTaskInitializationConfig initialization = 2;
  TouchScreenTaskPerceptionConfig perception = 3;
  TouchScreenTaskAlignmentConfig alignment = 4;
  TouchScreenTaskTouchConfig touch = 5;
  TouchScreenTaskRetractConfig retract = 6;
  optional string id = 7;
}

message TouchScreenTaskRootConfig {
  TouchScreenTaskConfig touch_screen_task = 1;
}
