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.DifferentialDriveWheelVelocities; 009import org.wpilib.util.struct.Struct; 010 011public class DifferentialDriveWheelVelocitiesStruct 012 implements Struct<DifferentialDriveWheelVelocities> { 013 @Override 014 public Class<DifferentialDriveWheelVelocities> getTypeClass() { 015 return DifferentialDriveWheelVelocities.class; 016 } 017 018 @Override 019 public String getTypeName() { 020 return "DifferentialDriveWheelVelocities"; 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 DifferentialDriveWheelVelocities unpack(ByteBuffer bb) { 035 double left = bb.getDouble(); 036 double right = bb.getDouble(); 037 return new DifferentialDriveWheelVelocities(left, right); 038 } 039 040 @Override 041 public void pack(ByteBuffer bb, DifferentialDriveWheelVelocities value) { 042 bb.putDouble(value.left); 043 bb.putDouble(value.right); 044 } 045}