RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
Rotation2dStruct.java
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5package org.wpilib.math.geometry.struct;
6
7import java.nio.ByteBuffer;
8import org.wpilib.math.geometry.Rotation2d;
9import org.wpilib.util.struct.Struct;
10
11public final class Rotation2dStruct implements Struct<Rotation2d> {
12 @Override
13 public Class<Rotation2d> getTypeClass() {
14 return Rotation2d.class;
15 }
16
17 @Override
18 public String getTypeName() {
19 return "Rotation2d";
20 }
21
22 @Override
23 public int getSize() {
24 return DOUBLE_SIZE;
25 }
26
27 @Override
28 public String getSchema() {
29 return "double value";
30 }
31
32 @Override
33 public Rotation2d unpack(ByteBuffer bb) {
34 double value = bb.getDouble();
35 return new Rotation2d(value);
36 }
37
38 @Override
39 public void pack(ByteBuffer bb, Rotation2d value) {
40 bb.putDouble(value.getRadians());
41 }
42
43 @Override
44 public boolean isImmutable() {
45 return true;
46 }
47}