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