syntax = "proto3";

package krec.proto;

message KRecHeader {
    string uuid = 1;
    string task = 2;
    string robot_platform = 3;
    string robot_serial = 4;
    uint64 start_timestamp = 5;
    uint64 end_timestamp = 6;
    repeated ActuatorConfig actuator_configs = 7;
}

message KRecFrame {
    uint64 real_timestamp = 1;
    uint64 video_timestamp = 2;
    uint64 video_frame_number = 3;
    uint64 inference_step = 4;
    repeated ActuatorState actuator_states = 5;
    repeated ActuatorCommand actuator_commands = 6;
    optional IMUValues imu_values = 7;
}

message ActuatorConfig {
    uint32 actuator_id = 1;
    optional double kp = 2;
    optional double kd = 3;
    optional double ki = 4;
    optional double max_torque = 5;  // Nm
    optional string name = 6;
}

message ActuatorState {
    uint32 actuator_id = 1;          // Actuator ID
    bool online = 2;                 // Online status
    optional double position = 3;    // Position in degrees
    optional double velocity = 4;    // Velocity in degrees/second
    optional double torque = 5;      // Torque in Nm
    optional double temperature = 6; // Temperature in Celsius
    optional float voltage = 7;      // Voltage in volts
    optional float current = 8;      // Current in amperes
}

message ActuatorCommand {
    uint32 actuator_id = 1;
    float position = 2;
    float velocity = 3;
    float torque = 4;
}

message IMUValues {
    optional Vec3 accel = 1; // Acceleration
    optional Vec3 gyro = 2;  // Gyroscope
    optional Vec3 mag = 3;   // Magnetometer
    optional IMUQuaternion quaternion = 4;
}

message Vec3 {
    double x = 1;
    double y = 2;
    double z = 3;
}

message IMUQuaternion {
    double x = 1;
    double y = 2;
    double z = 3;
    double w = 4;
}