001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.math.controller.struct;
006
007import edu.wpi.first.math.controller.DifferentialDriveFeedforward;
008import edu.wpi.first.util.struct.Struct;
009import java.nio.ByteBuffer;
010
011public final class DifferentialDriveFeedforwardStruct
012    implements Struct<DifferentialDriveFeedforward> {
013  @Override
014  public Class<DifferentialDriveFeedforward> getTypeClass() {
015    return DifferentialDriveFeedforward.class;
016  }
017
018  @Override
019  public String getTypeName() {
020    return "DifferentialDriveFeedforward";
021  }
022
023  @Override
024  public int getSize() {
025    return kSizeDouble * 4;
026  }
027
028  @Override
029  public String getSchema() {
030    return "double kVLinear;double kALinear;double kVAngular;double kAAngular";
031  }
032
033  @Override
034  public DifferentialDriveFeedforward unpack(ByteBuffer bb) {
035    double kVLinear = bb.getDouble();
036    double kALinear = bb.getDouble();
037    double kVAngular = bb.getDouble();
038    double kAAngular = bb.getDouble();
039    return new DifferentialDriveFeedforward(kVLinear, kALinear, kVAngular, kAAngular);
040  }
041
042  @Override
043  public void pack(ByteBuffer bb, DifferentialDriveFeedforward value) {
044    bb.putDouble(value.m_kVLinear);
045    bb.putDouble(value.m_kALinear);
046    bb.putDouble(value.m_kVAngular);
047    bb.putDouble(value.m_kAAngular);
048  }
049}