2. Adım : Hesaplanan Sabitlerin Girilmesi

Not

In C++, it is important that the feedforward constants be entered as the correct unit type. For more information on C++ units, see C ++ Ünite Kitaplığı.

Artık elimizde sistem sabitleri olduğuna göre sıra bu sabitleri kodumza yerleştirmeye geldi. Bunun için önerilen konum standart komut temelli proje yapısının Constants dosyasıdır.

RamseteCommand Örnek Projesi’nde (Java, C++) sabitler dosyası ile ilgili kısımlar aşağıda görüntülenebilmektedir.

İleri Besleme Kazançları

Son olarak tespit aracından edindiğimiz ileri besleme ve geri bildirim kazançlarını girmeliyiz.

Not

Feedforward and feedback gains do not, in general, transfer across robots. Do not use the gains from this tutorial for your own robot.

39    // These are example values only - DO NOT USE THESE FOR YOUR OWN ROBOT!
40    // These characterization values MUST be determined either experimentally or theoretically
41    // for *your* robot's drive.
42    // The Robot Characterization Toolsuite provides a convenient tool for obtaining these
43    // values for your robot.
44    public static final double ksVolts = 0.22;
45    public static final double kvVoltSecondsPerMeter = 1.98;
46    public static final double kaVoltSecondsSquaredPerMeter = 0.2;
47
48    // Example value only - as above, this must be tuned for your drive!
49    public static final double kPDriveVel = 8.5;
47// These are example values only - DO NOT USE THESE FOR YOUR OWN ROBOT!
48// These characterization values MUST be determined either experimentally or
49// theoretically for *your* robot's drive. The Robot Characterization
50// Toolsuite provides a convenient tool for obtaining these values for your
51// robot.
52inline constexpr auto ks = 0.22_V;
53inline constexpr auto kv = 1.98 * 1_V * 1_s / 1_m;
54inline constexpr auto ka = 0.2 * 1_V * 1_s * 1_s / 1_m;
55
56// Example value only - as above, this must be tuned for your drive!
57inline constexpr double kPDriveVel = 8.5;

DifferentialDriveKinematics

Additionally, we must create an instance of the DifferentialDriveKinematics class, which allows us to use the trackwidth (i.e. horizontal distance between the wheels) of the robot to convert from chassis speeds to wheel speeds. As elsewhere, we keep our units in meters.

29    public static final double kTrackwidthMeters = 0.69;
30    public static final DifferentialDriveKinematics kDriveKinematics =
31        new DifferentialDriveKinematics(kTrackwidthMeters);
38inline constexpr auto kTrackwidth = 0.69_m;
39extern const frc::DifferentialDriveKinematics kDriveKinematics;

Max Trajectory Velocity/Acceleration

We must also decide on a nominal max acceleration and max velocity for the robot during path-following. The maximum velocity value should be set somewhat below the nominal free-speed of the robot. Due to the later use of the DifferentialDriveVoltageConstraint, the maximum acceleration value is not extremely crucial.

Uyarı

Maksimum hız ve ivme, burada tanımlandığı üzere, sadece yörünge oluşumu sırasında uygulanmaktadır. Hız ve ivme, DriveSubsystem’e değerler vererek robotun büyük oranda belirlenen hız ve ivmeleri aşmasına sebep olabilecek, RamseteCommand’in kendisini sınırlamamaktadır.

57    public static final double kMaxSpeedMetersPerSecond = 3;
58    public static final double kMaxAccelerationMetersPerSecondSquared = 1;
61inline constexpr auto kMaxSpeed = 3_mps;
62inline constexpr auto kMaxAcceleration = 1_mps_sq;

Ramsete Parameters

Son olarak RAMSETE kontrolörü için bir çift parametre eklemeliyiz. Aşağıda gösterilen b ve zeta değerleri, mesafelerin metre cinsinden doğru bir şekilde ölçülmesi şartıyla, çoğu robot için uygundur.

Larger values of b make convergence more aggressive like a proportional term whereas larger values of zeta provide more damping in the response. These controller gains only dictate how the controller will output adjusted velocities. It does NOT affect the actual velocity tracking of the robot. This means that these controller gains are generally robot-agnostic.

Not

Gains of 2.0 and 0.7 for b and zeta have been tested repeatedly to produce desirable results when all units were in meters. As such, a zero-argument constructor for RamseteController exists with gains defaulted to these values.

60    // Reasonable baseline values for a RAMSETE follower in units of meters and seconds
61    public static final double kRamseteB = 2;
62    public static final double kRamseteZeta = 0.7;
64// Reasonable baseline values for a RAMSETE follower in units of meters and
65// seconds
66inline constexpr auto kRamseteB = 2.0 * 1_rad * 1_rad / (1_m * 1_m);
67inline constexpr auto kRamseteZeta = 0.7 / 1_rad;