// 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 = "TrajectoryProto";
import "bosdyn/api/geometry.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";

// Parameters for how positional trajectories will be interpolated on robot.
enum PositionalInterpolation {
    POS_INTERP_UNKNOWN = 0; // Unknown interpolation, do not use.
    POS_INTERP_LINEAR = 1;  // Linear interpolation for positional data.
    POS_INTERP_CUBIC = 2;   // Cubic interpolation for positional data.
}

// Parameters for how angular trajectories will be interpolated on robot.
enum AngularInterpolation {
    ANG_INTERP_UNKNOWN = 0;     // Unknown interpolation, do not use.
    ANG_INTERP_LINEAR = 1;      // Linear interpolation for angular data.
    ANG_INTERP_CUBIC_EULER = 2; // Cubic interpolation (using Euler method) for angular data.
}

// A 2D pose trajectory, which specified multiple points and the desired times the robot should
// reach these points.
message SE2Trajectory {
    // The points in trajectory
    repeated SE2TrajectoryPoint points = 1;

    // All trajectories specify times relative to this reference time. The reference time should be
    // in robot clock. If this field is not included, this time will be the receive time of the
    // command.
    google.protobuf.Timestamp reference_time = 3;

    // Parameters for how trajectories will be interpolated on robot.
    PositionalInterpolation interpolation = 4;

    // Reserved for deprecated fields.
    reserved 2;
}

// A SE2 pose that can be used as a point within a trajectory.
message SE2TrajectoryPoint {
    // Required pose the robot will try and achieve.
    SE2Pose pose = 1;

    // The duration to reach the point relative to the trajectory reference time.
    google.protobuf.Duration time_since_reference = 3;
}

// A 3D pose trajectory, which specified multiple poses (and velocities for each pose)
// and the desired times the robot should reach these points.
message SE3Trajectory {
    // The points in trajectory
    repeated SE3TrajectoryPoint points = 1;

    // All trajectories specify times relative to this reference time. The reference time should be
    // in robot clock. If this field is not included, this time will be the receive time of the
    // command.
    google.protobuf.Timestamp reference_time = 3;

    // Parameters for how trajectories will be interpolated on robot.
    PositionalInterpolation pos_interpolation = 4;
    AngularInterpolation ang_interpolation = 5;

    // Reserved for deprecated fields.
    reserved 2;
}

// A SE3 pose and velocity that can be used as a point within a trajectory.
message SE3TrajectoryPoint {
    // Required pose the robot will try and achieve.
    SE3Pose pose = 1;

    // Optional velocity (linear and angular) the robot will try and achieve.
    SE3Velocity velocity = 2;

    // The duration to reach the point relative to the trajectory reference time.
    google.protobuf.Duration time_since_reference = 3;
}

// A 3D point trajectory, described by 3D points, a starting and ending velocity, and
// a reference time.
message Vec3Trajectory {
    // The points in trajectory.
    repeated Vec3TrajectoryPoint points = 1;

    // All trajectories specify times relative to this reference time. The reference time should be
    // in robot clock. If this field is not included, this time will be the receive time of the
    // command.
    google.protobuf.Timestamp reference_time = 3;

    // Parameters for how trajectories will be interpolated on robot.
    PositionalInterpolation pos_interpolation = 4;

    // Velocity at the starting point of the trajectory.
    Vec3 starting_velocity = 5;

    // Velocity at the ending point of the trajectory.
    Vec3 ending_velocity = 6;

    // Reserved for deprecated fields.
    reserved 2;
}

// A 3D point (and linear velocity) that can be used as a point within a trajectory.
message Vec3TrajectoryPoint {
    // The point 3D position.
    Vec3 point = 1;

    // These are all optional.  If nothing is specified, good defaults will be chosen
    // server-side.
    double linear_speed = 4;

    // The duration to reach the point relative to the trajectory reference time.
    google.protobuf.Duration time_since_reference = 3;

}

// A time-based trajectories of wrenches.
message WrenchTrajectory {
    // The wrenches in the trajectory
    repeated WrenchTrajectoryPoint points = 1;

    // All trajectories specify times relative to this reference time. The reference time should be
    // in robot clock. If this field is not included, this time will be the receive time of the
    // command.
    google.protobuf.Timestamp reference_time = 2;
}

message WrenchTrajectoryPoint {
    // The wrench to apply at this point in time.
    Wrench wrench = 1;

    // The duration to reach the point relative to the trajectory reference time.
    google.protobuf.Duration time_since_reference = 2;
}


// A Point trajectory.
message ScalarTrajectory {
    // The points in trajectory
    repeated ScalarTrajectoryPoint points = 1;

    // All trajectories specify times relative to this reference time. The reference time should be
    // in robot clock. If this field is not included, this time will be the receive time of the
    // command.
    google.protobuf.Timestamp reference_time = 2;

    // Parameters for how trajectories will be interpolated on robot.
    // (Note: ignored for ClawGripperCommand.Request, which will automatically
    // select between cubic interpolation or a minimum time trajectory)
    PositionalInterpolation interpolation = 3;
}

message ScalarTrajectoryPoint {
    // Required position at the trajectory point's reference time.
    double point = 1;

    // Optional speed at the trajectory point's reference time.
    google.protobuf.DoubleValue velocity = 2;

    // The duration to reach the point relative to the trajectory reference time.
    google.protobuf.Duration time_since_reference = 3;
}
