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.Quaternion; 008import edu.wpi.first.math.geometry.Rotation3d; 009import edu.wpi.first.math.proto.Geometry3D.ProtobufRotation3d; 010import edu.wpi.first.util.protobuf.Protobuf; 011import us.hebi.quickbuf.Descriptors.Descriptor; 012 013public class Rotation3dProto implements Protobuf<Rotation3d, ProtobufRotation3d> { 014 @Override 015 public Class<Rotation3d> getTypeClass() { 016 return Rotation3d.class; 017 } 018 019 @Override 020 public Descriptor getDescriptor() { 021 return ProtobufRotation3d.getDescriptor(); 022 } 023 024 @Override 025 public Protobuf<?, ?>[] getNested() { 026 return new Protobuf<?, ?>[] {Quaternion.proto}; 027 } 028 029 @Override 030 public ProtobufRotation3d createMessage() { 031 return ProtobufRotation3d.newInstance(); 032 } 033 034 @Override 035 public Rotation3d unpack(ProtobufRotation3d msg) { 036 return new Rotation3d(Quaternion.proto.unpack(msg.getQ())); 037 } 038 039 @Override 040 public void pack(ProtobufRotation3d msg, Rotation3d value) { 041 Quaternion.proto.pack(msg.getMutableQ(), value.getQuaternion()); 042 } 043}