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.geometry.proto;
006
007import edu.wpi.first.math.geometry.Twist2d;
008import edu.wpi.first.math.proto.Geometry2D.ProtobufTwist2d;
009import edu.wpi.first.util.protobuf.Protobuf;
010import us.hebi.quickbuf.Descriptors.Descriptor;
011
012public class Twist2dProto implements Protobuf<Twist2d, ProtobufTwist2d> {
013  @Override
014  public Class<Twist2d> getTypeClass() {
015    return Twist2d.class;
016  }
017
018  @Override
019  public Descriptor getDescriptor() {
020    return ProtobufTwist2d.getDescriptor();
021  }
022
023  @Override
024  public ProtobufTwist2d createMessage() {
025    return ProtobufTwist2d.newInstance();
026  }
027
028  @Override
029  public Twist2d unpack(ProtobufTwist2d msg) {
030    return new Twist2d(msg.getDx(), msg.getDy(), msg.getDtheta());
031  }
032
033  @Override
034  public void pack(ProtobufTwist2d msg, Twist2d value) {
035    msg.setDx(value.dx);
036    msg.setDy(value.dy);
037    msg.setDtheta(value.dtheta);
038  }
039}