RobotCore
1.0
WPILib port to raspberry Pi
Toggle main menu visibility
Loading...
Searching...
No Matches
VectorStruct.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
5
package
org.wpilib.math.linalg.struct;
6
7
import
java.nio.ByteBuffer;
8
import
org.ejml.simple.SimpleMatrix;
9
import
org.wpilib.math.linalg.Vector;
10
import
org.wpilib.math.util.Nat;
11
import
org.wpilib.math.util.Num;
12
import
org.wpilib.util.struct.Struct;
13
14
public
final
class
VectorStruct
<R
extends
Num
> implements
Struct
<Vector<R>> {
15
private
final
int
m_rows;
16
22
public
VectorStruct
(
Nat<R>
rows) {
23
m_rows = rows.
getNum
();
24
}
25
26
@Override
27
public
Class<Vector<R>>
getTypeClass
() {
28
@SuppressWarnings(
"unchecked"
)
29
var clazz = (Class<Vector<R>>) (Class<?>)
Vector
.class;
30
return
clazz;
31
}
32
33
@Override
34
public
String
getTypeName
() {
35
return
"Vector__"
+ m_rows;
36
}
37
38
@Override
39
public
int
getSize
() {
40
return
DOUBLE_SIZE
* m_rows;
41
}
42
43
@Override
44
public
String
getSchema
() {
45
return
"double data["
+ m_rows +
"]"
;
46
}
47
48
@Override
49
public
Vector<R>
unpack
(ByteBuffer bb) {
50
var storage =
new
SimpleMatrix(
Struct
.
unpackDoubleArray
(bb, m_rows));
51
return
new
Vector<R>
(storage);
52
}
53
54
@Override
55
public
void
pack(ByteBuffer bb,
Vector<R>
value) {
56
Struct
.
packArray
(bb, value.
getData
());
57
}
58
}
org.wpilib.math.linalg.Matrix.getData
double[] getData()
Definition
Matrix.java:602
org.wpilib.math.linalg.Vector
Definition
Vector.java:28
org.wpilib.math.linalg.Vector.Vector
Vector(Nat< R > rows)
Definition
Vector.java:34
org.wpilib.math.linalg.struct.VectorStruct.getSchema
String getSchema()
Definition
VectorStruct.java:44
org.wpilib.math.linalg.struct.VectorStruct.getTypeName
String getTypeName()
Definition
VectorStruct.java:34
org.wpilib.math.linalg.struct.VectorStruct.VectorStruct
VectorStruct(Nat< R > rows)
Definition
VectorStruct.java:22
org.wpilib.math.linalg.struct.VectorStruct.getSize
int getSize()
Definition
VectorStruct.java:39
org.wpilib.math.linalg.struct.VectorStruct.getTypeClass
Class< Vector< R > > getTypeClass()
Definition
VectorStruct.java:27
org.wpilib.math.linalg.struct.VectorStruct.unpack
Vector< R > unpack(ByteBuffer bb)
Definition
VectorStruct.java:49
org.wpilib.math.util.Num
Definition
Num.java:8
org.wpilib.math.util.Nat
Definition
Nat.java:41
org.wpilib.math.util.Nat.getNum
int getNum()
org.wpilib.util.struct.Struct
Definition
Struct.java:22
org.wpilib.util.struct.Struct.DOUBLE_SIZE
int DOUBLE_SIZE
Definition
Struct.java:42
org.wpilib.util.struct.Struct.packArray
static< T > void packArray(ByteBuffer bb, T[] arr, Struct< T > struct)
Definition
Struct.java:175
org.wpilib.util.struct.Struct.unpackDoubleArray
static double[] unpackDoubleArray(ByteBuffer bb, int size)
Definition
Struct.java:157
org
wpilib
math
linalg
struct
VectorStruct.java
Generated by
1.18.0