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.Ellipse2d; 008import edu.wpi.first.math.geometry.Pose2d; 009import edu.wpi.first.math.proto.Geometry2D.ProtobufEllipse2d; 010import edu.wpi.first.util.protobuf.Protobuf; 011import us.hebi.quickbuf.Descriptors.Descriptor; 012 013public class Ellipse2dProto implements Protobuf<Ellipse2d, ProtobufEllipse2d> { 014 @Override 015 public Class<Ellipse2d> getTypeClass() { 016 return Ellipse2d.class; 017 } 018 019 @Override 020 public Descriptor getDescriptor() { 021 return ProtobufEllipse2d.getDescriptor(); 022 } 023 024 @Override 025 public ProtobufEllipse2d createMessage() { 026 return ProtobufEllipse2d.newInstance(); 027 } 028 029 @Override 030 public Ellipse2d unpack(ProtobufEllipse2d msg) { 031 return new Ellipse2d( 032 Pose2d.proto.unpack(msg.getCenter()), msg.getXSemiAxis(), msg.getYSemiAxis()); 033 } 034 035 @Override 036 public void pack(ProtobufEllipse2d msg, Ellipse2d value) { 037 Pose2d.proto.pack(msg.getMutableCenter(), value.getCenter()); 038 msg.setXSemiAxis(value.getXSemiAxis()); 039 msg.setYSemiAxis(value.getYSemiAxis()); 040 } 041}