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.proto;
006
007import edu.wpi.first.math.kinematics.MecanumDriveWheelPositions;
008import edu.wpi.first.math.proto.Kinematics.ProtobufMecanumDriveWheelPositions;
009import edu.wpi.first.util.protobuf.Protobuf;
010import us.hebi.quickbuf.Descriptors.Descriptor;
011
012public class MecanumDriveWheelPositionsProto
013    implements Protobuf<MecanumDriveWheelPositions, ProtobufMecanumDriveWheelPositions> {
014  @Override
015  public Class<MecanumDriveWheelPositions> getTypeClass() {
016    return MecanumDriveWheelPositions.class;
017  }
018
019  @Override
020  public Descriptor getDescriptor() {
021    return ProtobufMecanumDriveWheelPositions.getDescriptor();
022  }
023
024  @Override
025  public ProtobufMecanumDriveWheelPositions createMessage() {
026    return ProtobufMecanumDriveWheelPositions.newInstance();
027  }
028
029  @Override
030  public MecanumDriveWheelPositions unpack(ProtobufMecanumDriveWheelPositions msg) {
031    return new MecanumDriveWheelPositions(
032        msg.getFrontLeft(), msg.getFrontRight(), msg.getRearLeft(), msg.getRearRight());
033  }
034
035  @Override
036  public void pack(ProtobufMecanumDriveWheelPositions msg, MecanumDriveWheelPositions value) {
037    msg.setFrontLeft(value.frontLeftMeters);
038    msg.setFrontRight(value.frontRightMeters);
039    msg.setRearLeft(value.rearLeftMeters);
040    msg.setRearRight(value.rearRightMeters);
041  }
042}