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.Pose3d;
008import edu.wpi.first.math.geometry.Rotation3d;
009import edu.wpi.first.math.geometry.Translation3d;
010import edu.wpi.first.math.proto.Geometry3D.ProtobufPose3d;
011import edu.wpi.first.util.protobuf.Protobuf;
012import us.hebi.quickbuf.Descriptors.Descriptor;
013
014public class Pose3dProto implements Protobuf<Pose3d, ProtobufPose3d> {
015  @Override
016  public Class<Pose3d> getTypeClass() {
017    return Pose3d.class;
018  }
019
020  @Override
021  public Descriptor getDescriptor() {
022    return ProtobufPose3d.getDescriptor();
023  }
024
025  @Override
026  public ProtobufPose3d createMessage() {
027    return ProtobufPose3d.newInstance();
028  }
029
030  @Override
031  public Pose3d unpack(ProtobufPose3d msg) {
032    return new Pose3d(
033        Translation3d.proto.unpack(msg.getTranslation()),
034        Rotation3d.proto.unpack(msg.getRotation()));
035  }
036
037  @Override
038  public void pack(ProtobufPose3d msg, Pose3d value) {
039    Translation3d.proto.pack(msg.getMutableTranslation(), value.getTranslation());
040    Rotation3d.proto.pack(msg.getMutableRotation(), value.getRotation());
041  }
042
043  @Override
044  public boolean isImmutable() {
045    return true;
046  }
047}