001// Copyright (c) Choreo contributors
002
003package choreo.trajectory;
004
005import java.util.List;
006
007/** A representation of a project file aka a .chor. */
008public class ProjectFile {
009  /** A representation of an expression. An equation and its value. */
010  public static class Expression {
011    /** The equation. */
012    public final String exp;
013
014    /** The value. */
015    public final double val;
016
017    Expression(String exp, double val) {
018      this.exp = exp;
019      this.val = val;
020    }
021  }
022
023  /** An xy pair of expressions. */
024  public static class XYExpression {
025    /** The x expression. */
026    public final Expression x;
027
028    /** The y expression. */
029    public final Expression y;
030
031    XYExpression(Expression x, Expression y) {
032      this.x = x;
033      this.y = y;
034    }
035  }
036
037  /**
038   * A collection of expressions representing the distance of the bumpers from the center of the
039   * robot.
040   */
041  public static class Bumpers {
042    /** The front bumper expression. */
043    public final Expression front;
044
045    /** The back bumper expression. */
046    public final Expression back;
047
048    /** The side bumper expression. */
049    public final Expression side;
050
051    Bumpers(Expression front, Expression back, Expression side) {
052      this.front = front;
053      this.back = back;
054      this.side = side;
055    }
056  }
057
058  /** The user configuration of the project. */
059  public static class Config {
060    /** The position of the front left module */
061    public final XYExpression frontLeft;
062
063    /** The position of the back left module */
064    public final XYExpression backLeft;
065
066    /** The mass of the robot. (kg) */
067    public final Expression mass;
068
069    /** The inertia of the robot. (kg-m²) */
070    public final Expression inertia;
071
072    /** The gearing of the robot. */
073    public final Expression gearing;
074
075    /** The radius of the wheel. (m) */
076    public final Expression wheelRadius;
077
078    /** The maximum velocity of the robot. (m/s) */
079    public final Expression vmax;
080
081    /** The maximum torque of the robot. (N-m) */
082    public final Expression tmax;
083
084    /** The Coefficient of Friction (CoF) of the wheels. */
085    public final Expression cof;
086
087    /** The bumpers of the robot. */
088    public final Bumpers bumper;
089
090    /** The width between the wheels of the robot. (m) */
091    public final Expression differentialTrackWidth;
092
093    Config(
094        XYExpression frontLeft,
095        XYExpression backLeft,
096        Expression mass,
097        Expression inertia,
098        Expression gearing,
099        Expression wheelRadius,
100        Expression vmax,
101        Expression tmax,
102        Expression cof,
103        Bumpers bumper,
104        Expression differentialTrackWidth) {
105      this.frontLeft = frontLeft;
106      this.backLeft = backLeft;
107      this.mass = mass;
108      this.inertia = inertia;
109      this.gearing = gearing;
110      this.wheelRadius = wheelRadius;
111      this.vmax = vmax;
112      this.tmax = tmax;
113      this.cof = cof;
114      this.bumper = bumper;
115      this.differentialTrackWidth = differentialTrackWidth;
116    }
117  }
118
119  /** The name of the project. */
120  public final String name;
121
122  /** The version of the project. */
123  public final String version;
124
125  /** The sample type for the project */
126  public final String type;
127
128  /** The configuration of the project. */
129  public final Config config;
130
131  /** The generation features of the project. */
132  public final List<String> generationFeatures;
133
134  ProjectFile(
135      String name, String version, String type, Config config, List<String> generationFeatures) {
136    this.name = name;
137    this.version = version;
138    this.type = type;
139    this.config = config;
140    this.generationFeatures = generationFeatures;
141  }
142}