syntax = "proto3";

package cmvr.api;

import "cmvr/api/common.proto";

enum ArmFrameType {
  ARM_FRAME_BASE = 0;
  ARM_FRAME_TOOL = 1;
  ARM_FRAME_WORLD = 2;
  ARM_FRAME_USER = 3;
}

message JointPositionCommand {
  repeated double position = 1;
}

message JointVelocityCommand {
  repeated double velocity = 1;
}

message MotionOptions {
  double velocity = 1;
  double acceleration = 2;
  double blend_radius = 3;
  double jerk = 4;
  repeated double joint_velocity_limits = 5;
  bool asynchronous = 6;
}

message CartesianPose {
  double x = 1;
  double y = 2;
  double z = 3;
  double rx = 4;
  double ry = 5;
  double rz = 6;
}

message CartesianVelocity {
  double vx = 1;
  double vy = 2;
  double vz = 3;
  double wx = 4;
  double wy = 5;
  double wz = 6;
}

message TransformMatrix4x4 {
  double m00 = 1; double m01 = 2; double m02 = 3; double m03 = 4;
  double m10 = 5; double m11 = 6; double m12 = 7; double m13 = 8;
  double m20 = 9; double m21 = 10; double m22 = 11; double m23 = 12;
  double m30 = 13; double m31 = 14; double m32 = 15; double m33 = 16;
}

message MoveJ {
  message Request {
    CommandHeader.Request header = 1;
    JointPositionCommand target = 2;
    MotionOptions options = 3;
  }

  message Response {
    CommandHeader.Feedback header = 1;
  }
}

message MoveL {
  message Request {
    CommandHeader.Request header = 1;
    CartesianPose target = 2;
    MotionOptions options = 3;
    ArmFrameType frame = 4;
  }

  message Response {
    CommandHeader.Feedback header = 1;
  }
}

message SpeedJ {
  message Request {
    CommandHeader.Request header = 1;
    JointVelocityCommand velocity = 2;
    double acceleration = 3;
    double duration = 4;
  }

  message Response {
    CommandHeader.Feedback header = 1;
  }
}

message SpeedL {
  message Request {
    CommandHeader.Request header = 1;
    CartesianVelocity velocity = 2;
    double acceleration = 3;
    double duration = 4;
    ArmFrameType frame = 5;
  }

  message Response {
    CommandHeader.Feedback header = 1;
  }
}

message ServoJ {
  message Request {
    CommandHeader.Request header = 1;
    JointPositionCommand target = 2;
  }

  message Response {
    CommandHeader.Feedback header = 1;
  }
}

message JointState {
  repeated string name = 1;
  repeated double position = 2;
  repeated double velocity = 3;
  repeated double effort = 4;
  double timestamp = 5;
}

message JointRequest {
  CommandHeader.Request header = 1;
}

message JointResponse {
  CommandHeader.Feedback header = 1;
  JointState state = 2;
}

message GetPose {
  message Request {
    CommandHeader.Request header = 1;
    string base_link = 2;
    string ee_link = 3;
  }

  message Response {
    CommandHeader.Feedback header = 1;
    CartesianPose pose = 2;
  }
}

message CalibrateZeroQ {
  message Request {
    CommandHeader.Request header = 1;
    string joint_name = 2;
  }

  message Response {
    CommandHeader.Feedback header = 1;
  }
}

message GetPoseMatrix {
  message Request {
    CommandHeader.Request header = 1;
    string base_link = 2;
    string ee_link = 3;
  }

  message Response {
    CommandHeader.Feedback header = 1;
    TransformMatrix4x4 matrix = 2;
  }
}

message ComputeForwardKinematics {
  message Request {
    CommandHeader.Request header = 1;
    string base_link = 2;
    string ee_link = 3;
    JointPositionCommand joints = 4;
  }

  message Response {
    CommandHeader.Feedback header = 1;
    TransformMatrix4x4 matrix = 2;
  }
}
