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