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 org.wpilib.math.kinematics.struct;
006
007import java.nio.ByteBuffer;
008import org.wpilib.math.kinematics.ChassisAccelerations;
009import org.wpilib.util.struct.Struct;
010
011public class ChassisAccelerationsStruct implements Struct<ChassisAccelerations> {
012  @Override
013  public Class<ChassisAccelerations> getTypeClass() {
014    return ChassisAccelerations.class;
015  }
016
017  @Override
018  public String getTypeName() {
019    return "ChassisAccelerations";
020  }
021
022  @Override
023  public int getSize() {
024    return kSizeDouble * 3;
025  }
026
027  @Override
028  public String getSchema() {
029    return "double ax;double ay;double alpha";
030  }
031
032  @Override
033  public ChassisAccelerations unpack(ByteBuffer bb) {
034    double ax = bb.getDouble();
035    double ay = bb.getDouble();
036    double alpha = bb.getDouble();
037    return new ChassisAccelerations(ax, ay, alpha);
038  }
039
040  @Override
041  public void pack(ByteBuffer bb, ChassisAccelerations value) {
042    bb.putDouble(value.ax);
043    bb.putDouble(value.ay);
044    bb.putDouble(value.alpha);
045  }
046}