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