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.MecanumDriveWheelAccelerations;
009import org.wpilib.util.struct.Struct;
010
011public class MecanumDriveWheelAccelerationsStruct
012    implements Struct<MecanumDriveWheelAccelerations> {
013  @Override
014  public Class<MecanumDriveWheelAccelerations> getTypeClass() {
015    return MecanumDriveWheelAccelerations.class;
016  }
017
018  @Override
019  public String getTypeName() {
020    return "MecanumDriveWheelAccelerations";
021  }
022
023  @Override
024  public int getSize() {
025    return kSizeDouble * 4;
026  }
027
028  @Override
029  public String getSchema() {
030    return "double front_left;double front_right;double rear_left;double rear_right";
031  }
032
033  @Override
034  public MecanumDriveWheelAccelerations unpack(ByteBuffer bb) {
035    double frontLeft = bb.getDouble();
036    double frontRight = bb.getDouble();
037    double rearLeft = bb.getDouble();
038    double rearRight = bb.getDouble();
039    return new MecanumDriveWheelAccelerations(frontLeft, frontRight, rearLeft, rearRight);
040  }
041
042  @Override
043  public void pack(ByteBuffer bb, MecanumDriveWheelAccelerations value) {
044    bb.putDouble(value.frontLeft);
045    bb.putDouble(value.frontRight);
046    bb.putDouble(value.rearLeft);
047    bb.putDouble(value.rearRight);
048  }
049}