Package org.littletonrobotics.junction
Class LogTable
java.lang.Object
org.littletonrobotics.junction.LogTable
A table of logged data in allowable types. Can reference another higher level table.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents all possible data types that can be logged.static classRepresents a value stored in a LogTable, including type and value. -
Constructor Summary
ConstructorsConstructorDescriptionLogTable(long timestamp) Creates a new LogTable, to serve as the root table. -
Method Summary
Modifier and TypeMethodDescriptionstatic LogTableCreates a new LogTable, copying data from the given source.Reads a generic value from the table.booleanReads a Boolean value from the table.boolean[]Reads a BooleanArray value from the table.boolean[][]Reads a 2D BooleanArray value from the table.byte[]Reads a Raw value from the table.byte[][]Reads a 2D Raw value from the table.doubleReads a Double value from the table.double[]Reads a DoubleArray value from the table.double[][]Reads a 2D DoubleArray value from the table.floatReads a Float value from the table.float[]Reads a FloatArray value from the table.float[][]Reads a 2D FloatArray value from the table.intReads an Integer value from the table.int[]Reads an IntegerArray value from the table.int[][]Reads a 2D IntegerArray value from the table.longReads an Integer value from the table.long[]Reads an IntegerArray value from the table.long[][]Reads a 2D IntegerArray value from the table.<E extends Enum<E>>
EReads an enum value from the table.<E extends Enum<E>>
E[]Reads an enum array value from the table.<E extends Enum<E>>
E[][]Reads a 2D enum array value from the table.<T,MessageType extends us.hebi.quickbuf.ProtoMessage<?>>
TReads a protobuf value from the table.<T> TReads a struct value from the table.<T> T[]Reads a struct array value from the table.<T> T[][]Reads a 2D struct array value from the table.Reads a Color value from the table.Reads a String value from the table.String[]Reads a StringArray value from the table.String[][]Reads a 2D StringArray value from the table.Reads a Measure value from the table.<R extends Record>
RReads a serialized record value from the table.<R extends Record>
R[]Reads a serialized record array value from the table.<R extends Record>
R[][]Reads a serialized 2D record array value from the table.<T extends LoggableInputs>
TReads a LoggableInput subtable from the table.<T extends StructSerializable>
T[]Reads a serialized (struct) array value from the table.<T extends StructSerializable>
T[][]Reads a serialized 2D (struct) array value from the table.getAll(boolean subtableOnly) Returns a set of all values from the table.getSubtable(String tableName) Creates a new LogTable for referencing a single subtable.longReturns the timestamp of the table.voidWrites a new Boolean value to the table.voidWrites a new BooleanArray value to the table.voidWrites a new 2D BooleanArray value to the table.voidWrites a new Raw value to the table.voidWrites a new 2D Raw value to the table.voidWrites a new Double value to the table.voidWrites a new DoubleArray value to the table.voidWrites a new 2D DoubleArray value to the table.voidWrites a new Double value to the table with units.voidWrites a new Float value to the table.voidWrites a new FloatArray value to the table.voidWrites a new 2D FloatArray value to the table.voidWrites a new Float value to the table with units.voidWrites a new Integer value to the table.voidWrites a new IntegerArray value to the table.voidWrites a new 2D IntegerArray value to the table.voidWrites a new Integer value to the table.voidWrites a new IntegerArray value to the table.voidWrites a new 2D IntegerArray value to the table.<E extends Enum<E>>
voidWrites a new enum value to the table.<E extends Enum<E>>
voidWrites a new enum array value to the table.<E extends Enum<E>>
voidWrites a new 2D enum array value to the table.<U extends Unit>
voidWrites a new Measure value to the table.<T,MessageType extends us.hebi.quickbuf.ProtoMessage<?>>
voidWrites a new protobuf value to the table.<T> voidWrites a new struct value to the table.<T> voidWrites a new struct array value to the table.<T> voidWrites a new 2D struct array value to the table.voidWrites a new Color value to the table.voidWrites a new String value to the table.voidWrites a new StringArray value to the table.voidWrites a new 2D StringArray value to the table.voidput(String key, LogTable.LogValue value) Writes a new generic value to the table.<R extends Record>
voidWrites a new auto serialized record value to the table.<R extends Record>
voidWrites a new auto serialized record array value to the table.<R extends Record>
voidWrites a new auto serialized 2D record array value to the table.<T extends LoggableInputs>
voidWrites a new LoggableInput subtable to the table.<T extends StructSerializable>
voidWrites a new auto serialized array value to the table.<T extends StructSerializable>
voidWrites a new auto serialized 2D array value to the table.voidsetTimestamp(long timestamp) Updates the timestamp of the table.toString()Returns a string representation of the table.
-
Constructor Details
-
LogTable
public LogTable(long timestamp) Creates a new LogTable, to serve as the root table.- Parameters:
timestamp- The timestamp for the table.
-
-
Method Details
-
clone
Creates a new LogTable, copying data from the given source. The original table can be safely modified without affecting the copy.- Parameters:
source- The source table.- Returns:
- The new table.
-
setTimestamp
public void setTimestamp(long timestamp) Updates the timestamp of the table.- Parameters:
timestamp- The new timestamp.
-
getTimestamp
public long getTimestamp()Returns the timestamp of the table.- Returns:
- The timestamp.
-
getSubtable
Creates a new LogTable for referencing a single subtable. Modifications to the subtable will be reflected in the original object.- Parameters:
tableName- The name of the subtable. Do not include a trailing slash.- Returns:
- The subtable object.
-
getAll
Returns a set of all values from the table. If reading a single subtable, the data will be a copy. Otherwise, it will be a reference.- Parameters:
subtableOnly- If true, include only values in the subtable (no prefix). If false, include all values.- Returns:
- Map of the requested data.
-
put
Writes a new generic value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new Raw value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new 2D Raw value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new Boolean value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new BooleanArray value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new 2D BooleanArray value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new Integer value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new IntegerArray value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new 2D IntegerArray value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new Integer value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new IntegerArray value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new 2D IntegerArray value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new Float value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new Float value to the table with units. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.unit- The unit to save as metadata.
-
put
Writes a new FloatArray value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new 2D FloatArray value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new Double value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new Double value to the table with units. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.unit- The unit to save as metadata.
-
put
Writes a new DoubleArray value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new 2D DoubleArray value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new String value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new StringArray value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new 2D StringArray value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new enum value to the table. Skipped if the key already exists as a different type.- Type Parameters:
E- The enum type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new enum array value to the table. Skipped if the key already exists as a different type.- Type Parameters:
E- The enum type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new 2D enum array value to the table. Skipped if the key already exists as a different type.- Type Parameters:
E- The enum type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new Measure value to the table. Skipped if the key already exists as a different type.This overload always records the value in its base unit. Use the double overload with a unit string to record values with alternative units.
- Type Parameters:
U- The unit type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new Color value to the table. Skipped if the key already exists as a different type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new LoggableInput subtable to the table.- Type Parameters:
T- The input type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new struct value to the table. Skipped if the key already exists as a different type.- Type Parameters:
T- The struct type.- Parameters:
key- The field name.struct- The struct serialization object.value- The field value.
-
put
Writes a new struct array value to the table. Skipped if the key already exists as a different type.- Type Parameters:
T- The struct type.- Parameters:
key- The field name.struct- The struct serialization object.value- The field value.
-
put
Writes a new 2D struct array value to the table. Skipped if the key already exists as a different type.- Type Parameters:
T- The struct type.- Parameters:
key- The field name.struct- The struct serialization object.value- The field value.
-
put
public <T,MessageType extends us.hebi.quickbuf.ProtoMessage<?>> void put(String key, Protobuf<T, MessageType> proto, T value) Writes a new protobuf value to the table. Skipped if the key already exists as a different type.- Type Parameters:
T- The value type.MessageType- The protobuf message type.- Parameters:
key- The field name.proto- The protobuf serialization object.value- The field value.
-
put
Writes a new auto serialized value to the table. Skipped if the key already exists as a different type.- Type Parameters:
T- The object type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new auto serialized array value to the table. Skipped if the key already exists as a different type.- Type Parameters:
T- The object type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new auto serialized 2D array value to the table. Skipped if the key already exists as a different type.- Type Parameters:
T- The object type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new auto serialized record value to the table. Skipped if the key already exists as a different type.- Type Parameters:
R- The record type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new auto serialized record array value to the table. Skipped if the key already exists as a different type.- Type Parameters:
R- The record type.- Parameters:
key- The field name.value- The field value.
-
put
Writes a new auto serialized 2D record array value to the table. Skipped if the key already exists as a different type.- Type Parameters:
R- The record type.- Parameters:
key- The field name.value- The field value.
-
get
Reads a generic value from the table.- Parameters:
key- The field name.- Returns:
- The field value.
-
get
Reads a Raw value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a 2D Raw value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a Boolean value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a BooleanArray value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a 2D BooleanArray value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads an Integer value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads an IntegerArray value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a 2D IntegerArray value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads an Integer value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads an IntegerArray value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a 2D IntegerArray value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a Float value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a FloatArray value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a 2D FloatArray value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a Double value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a DoubleArray value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a 2D DoubleArray value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a String value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a StringArray value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a 2D StringArray value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads an enum value from the table.- Type Parameters:
E- The enum type.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads an enum array value from the table.- Type Parameters:
E- The enum type.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a 2D enum array value from the table.- Type Parameters:
E- The enum type.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a Measure value from the table.- Type Parameters:
U- The unit type.M- The measure type.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
public <U extends Unit,Base extends Measure<U>, M getM extends MutableMeasure<U, Base, M>> (String key, M value) Reads a MutableMeasure value from the table.Unlike other "get" methods, this method mutates the provided value instead of returning a new instance. The object returned from this method is the same instance as the provided value.
- Type Parameters:
U- The unit type.Base- The base unit typeM- The measure type.- Parameters:
key- The field name.value- The field value, to be mutated.- Returns:
- The field value.
-
get
Reads a Color value from the table.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a LoggableInput subtable from the table.- Type Parameters:
T- The input type.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a struct value from the table.- Type Parameters:
T- The struct type.- Parameters:
key- The field name.struct- The struct serialization object.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a struct array value from the table.- Type Parameters:
T- The struct type.- Parameters:
key- The field name.struct- The struct serialization object.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a 2D struct array value from the table.- Type Parameters:
T- The struct type.- Parameters:
key- The field name.struct- The struct serialization object.defaultValue- The default field value.- Returns:
- The field value.
-
get
public <T,MessageType extends us.hebi.quickbuf.ProtoMessage<?>> T get(String key, Protobuf<T, MessageType> proto, T defaultValue) Reads a protobuf value from the table.- Type Parameters:
T- The value type.MessageType- The protobuf message type.- Parameters:
key- The field name.proto- The protobuf serialization object.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a serialized (struct/protobuf) value from the table.- Type Parameters:
T- The object type.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a serialized (struct) array value from the table.- Type Parameters:
T- The object type.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a serialized 2D (struct) array value from the table.- Type Parameters:
T- The object type.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a serialized record value from the table.- Type Parameters:
R- The record type.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a serialized record array value from the table.- Type Parameters:
R- The record type.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
get
Reads a serialized 2D record array value from the table.- Type Parameters:
R- The record type.- Parameters:
key- The field name.defaultValue- The default field value.- Returns:
- The field value.
-
toString
Returns a string representation of the table.
-