mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
[wpimath] Add protobuf/struct for trivial types (#5935)
This implements de/serialization for the types that aren't templated (SwerveDriveKinematics) in C++ or where there is no trivial way to go round-trip (Splines) for the messages.
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
|
||||
package edu.wpi.first.math.controller;
|
||||
|
||||
import edu.wpi.first.math.controller.proto.ArmFeedforwardProto;
|
||||
import edu.wpi.first.math.controller.struct.ArmFeedforwardStruct;
|
||||
|
||||
/**
|
||||
* A helper class that computes feedforward outputs for a simple arm (modeled as a motor acting
|
||||
* against the force of gravity on a beam suspended at an angle).
|
||||
@@ -14,6 +17,9 @@ public class ArmFeedforward {
|
||||
public final double kv;
|
||||
public final double ka;
|
||||
|
||||
public static final ArmFeedforwardProto proto = new ArmFeedforwardProto();
|
||||
public static final ArmFeedforwardStruct struct = new ArmFeedforwardStruct();
|
||||
|
||||
/**
|
||||
* Creates a new ArmFeedforward with the specified gains. Units of the gain values will dictate
|
||||
* units of the computed feedforward.
|
||||
|
||||
@@ -4,11 +4,19 @@
|
||||
|
||||
package edu.wpi.first.math.controller;
|
||||
|
||||
import edu.wpi.first.math.controller.proto.DifferentialDriveWheelVoltagesProto;
|
||||
import edu.wpi.first.math.controller.struct.DifferentialDriveWheelVoltagesStruct;
|
||||
|
||||
/** Motor voltages for a differential drive. */
|
||||
public class DifferentialDriveWheelVoltages {
|
||||
public double left;
|
||||
public double right;
|
||||
|
||||
public static final DifferentialDriveWheelVoltagesProto proto =
|
||||
new DifferentialDriveWheelVoltagesProto();
|
||||
public static final DifferentialDriveWheelVoltagesStruct struct =
|
||||
new DifferentialDriveWheelVoltagesStruct();
|
||||
|
||||
public DifferentialDriveWheelVoltages() {}
|
||||
|
||||
public DifferentialDriveWheelVoltages(double left, double right) {
|
||||
|
||||
@@ -6,6 +6,8 @@ package edu.wpi.first.math.controller;
|
||||
|
||||
import edu.wpi.first.math.MatBuilder;
|
||||
import edu.wpi.first.math.Nat;
|
||||
import edu.wpi.first.math.controller.proto.ElevatorFeedforwardProto;
|
||||
import edu.wpi.first.math.controller.struct.ElevatorFeedforwardStruct;
|
||||
import edu.wpi.first.math.system.plant.LinearSystemId;
|
||||
|
||||
/**
|
||||
@@ -18,6 +20,9 @@ public class ElevatorFeedforward {
|
||||
public final double kv;
|
||||
public final double ka;
|
||||
|
||||
public static final ElevatorFeedforwardProto proto = new ElevatorFeedforwardProto();
|
||||
public static final ElevatorFeedforwardStruct struct = new ElevatorFeedforwardStruct();
|
||||
|
||||
/**
|
||||
* Creates a new ElevatorFeedforward with the specified gains. Units of the gain values will
|
||||
* dictate units of the computed feedforward.
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.controller.proto;
|
||||
|
||||
import edu.wpi.first.math.controller.ArmFeedforward;
|
||||
import edu.wpi.first.math.proto.Controller.ProtobufArmFeedforward;
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
import us.hebi.quickbuf.Descriptors.Descriptor;
|
||||
|
||||
public class ArmFeedforwardProto implements Protobuf<ArmFeedforward, ProtobufArmFeedforward> {
|
||||
@Override
|
||||
public Class<ArmFeedforward> getTypeClass() {
|
||||
return ArmFeedforward.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Descriptor getDescriptor() {
|
||||
return ProtobufArmFeedforward.getDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtobufArmFeedforward createMessage() {
|
||||
return ProtobufArmFeedforward.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmFeedforward unpack(ProtobufArmFeedforward msg) {
|
||||
return new ArmFeedforward(msg.getKs(), msg.getKg(), msg.getKv(), msg.getKa());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ProtobufArmFeedforward msg, ArmFeedforward value) {
|
||||
msg.setKs(value.ks);
|
||||
msg.setKg(value.kg);
|
||||
msg.setKv(value.kv);
|
||||
msg.setKa(value.ka);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.controller.proto;
|
||||
|
||||
import edu.wpi.first.math.controller.DifferentialDriveWheelVoltages;
|
||||
import edu.wpi.first.math.proto.Controller.ProtobufDifferentialDriveWheelVoltages;
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
import us.hebi.quickbuf.Descriptors.Descriptor;
|
||||
|
||||
public class DifferentialDriveWheelVoltagesProto
|
||||
implements Protobuf<DifferentialDriveWheelVoltages, ProtobufDifferentialDriveWheelVoltages> {
|
||||
@Override
|
||||
public Class<DifferentialDriveWheelVoltages> getTypeClass() {
|
||||
return DifferentialDriveWheelVoltages.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Descriptor getDescriptor() {
|
||||
return ProtobufDifferentialDriveWheelVoltages.getDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtobufDifferentialDriveWheelVoltages createMessage() {
|
||||
return ProtobufDifferentialDriveWheelVoltages.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DifferentialDriveWheelVoltages unpack(ProtobufDifferentialDriveWheelVoltages msg) {
|
||||
return new DifferentialDriveWheelVoltages(msg.getLeft(), msg.getRight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(
|
||||
ProtobufDifferentialDriveWheelVoltages msg, DifferentialDriveWheelVoltages value) {
|
||||
msg.setLeft(value.left);
|
||||
msg.setRight(value.right);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.controller.proto;
|
||||
|
||||
import edu.wpi.first.math.controller.ElevatorFeedforward;
|
||||
import edu.wpi.first.math.proto.Controller.ProtobufElevatorFeedforward;
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
import us.hebi.quickbuf.Descriptors.Descriptor;
|
||||
|
||||
public class ElevatorFeedforwardProto
|
||||
implements Protobuf<ElevatorFeedforward, ProtobufElevatorFeedforward> {
|
||||
@Override
|
||||
public Class<ElevatorFeedforward> getTypeClass() {
|
||||
return ElevatorFeedforward.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Descriptor getDescriptor() {
|
||||
return ProtobufElevatorFeedforward.getDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtobufElevatorFeedforward createMessage() {
|
||||
return ProtobufElevatorFeedforward.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElevatorFeedforward unpack(ProtobufElevatorFeedforward msg) {
|
||||
return new ElevatorFeedforward(msg.getKs(), msg.getKg(), msg.getKv(), msg.getKa());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ProtobufElevatorFeedforward msg, ElevatorFeedforward value) {
|
||||
msg.setKs(value.ks);
|
||||
msg.setKg(value.kg);
|
||||
msg.setKv(value.kv);
|
||||
msg.setKa(value.ka);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.controller.struct;
|
||||
|
||||
import edu.wpi.first.math.controller.ArmFeedforward;
|
||||
import edu.wpi.first.util.struct.Struct;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class ArmFeedforwardStruct implements Struct<ArmFeedforward> {
|
||||
@Override
|
||||
public Class<ArmFeedforward> getTypeClass() {
|
||||
return ArmFeedforward.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeString() {
|
||||
return "struct:ArmFeedforward";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return kSizeDouble * 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchema() {
|
||||
return "double ks;double kg;double kv;double ka";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmFeedforward unpack(ByteBuffer bb) {
|
||||
double ks = bb.getDouble();
|
||||
double kg = bb.getDouble();
|
||||
double kv = bb.getDouble();
|
||||
double ka = bb.getDouble();
|
||||
return new ArmFeedforward(ks, kg, kv, ka);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ByteBuffer bb, ArmFeedforward value) {
|
||||
bb.putDouble(value.ks);
|
||||
bb.putDouble(value.kg);
|
||||
bb.putDouble(value.kv);
|
||||
bb.putDouble(value.ka);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.controller.struct;
|
||||
|
||||
import edu.wpi.first.math.controller.DifferentialDriveWheelVoltages;
|
||||
import edu.wpi.first.util.struct.Struct;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class DifferentialDriveWheelVoltagesStruct
|
||||
implements Struct<DifferentialDriveWheelVoltages> {
|
||||
@Override
|
||||
public Class<DifferentialDriveWheelVoltages> getTypeClass() {
|
||||
return DifferentialDriveWheelVoltages.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeString() {
|
||||
return "struct:DifferentialDriveWheelVoltages";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return kSizeDouble * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchema() {
|
||||
return "double left;double right";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DifferentialDriveWheelVoltages unpack(ByteBuffer bb) {
|
||||
double left = bb.getDouble();
|
||||
double right = bb.getDouble();
|
||||
return new DifferentialDriveWheelVoltages(left, right);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ByteBuffer bb, DifferentialDriveWheelVoltages value) {
|
||||
bb.putDouble(value.left);
|
||||
bb.putDouble(value.right);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.controller.struct;
|
||||
|
||||
import edu.wpi.first.math.controller.ElevatorFeedforward;
|
||||
import edu.wpi.first.util.struct.Struct;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class ElevatorFeedforwardStruct implements Struct<ElevatorFeedforward> {
|
||||
@Override
|
||||
public Class<ElevatorFeedforward> getTypeClass() {
|
||||
return ElevatorFeedforward.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeString() {
|
||||
return "struct:ElevatorFeedforward";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return kSizeDouble * 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchema() {
|
||||
return "double ks;double kg;double kv;double ka";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElevatorFeedforward unpack(ByteBuffer bb) {
|
||||
double ks = bb.getDouble();
|
||||
double kg = bb.getDouble();
|
||||
double kv = bb.getDouble();
|
||||
double ka = bb.getDouble();
|
||||
return new ElevatorFeedforward(ks, kg, kv, ka);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ByteBuffer bb, ElevatorFeedforward value) {
|
||||
bb.putDouble(value.ks);
|
||||
bb.putDouble(value.kg);
|
||||
bb.putDouble(value.kv);
|
||||
bb.putDouble(value.ka);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ import static edu.wpi.first.units.Units.Seconds;
|
||||
import edu.wpi.first.math.geometry.Pose2d;
|
||||
import edu.wpi.first.math.geometry.Rotation2d;
|
||||
import edu.wpi.first.math.geometry.Translation2d;
|
||||
import edu.wpi.first.math.kinematics.proto.ChassisSpeedsProto;
|
||||
import edu.wpi.first.math.kinematics.struct.ChassisSpeedsStruct;
|
||||
import edu.wpi.first.units.Angle;
|
||||
import edu.wpi.first.units.Distance;
|
||||
import edu.wpi.first.units.Measure;
|
||||
@@ -36,6 +38,9 @@ public class ChassisSpeeds {
|
||||
/** Represents the angular velocity of the robot frame. (CCW is +) */
|
||||
public double omegaRadiansPerSecond;
|
||||
|
||||
public static final ChassisSpeedsProto proto = new ChassisSpeedsProto();
|
||||
public static final ChassisSpeedsStruct struct = new ChassisSpeedsStruct();
|
||||
|
||||
/** Constructs a ChassisSpeeds with zeros for dx, dy, and theta. */
|
||||
public ChassisSpeeds() {}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import static edu.wpi.first.units.Units.Meters;
|
||||
import edu.wpi.first.math.MathSharedStore;
|
||||
import edu.wpi.first.math.MathUsageId;
|
||||
import edu.wpi.first.math.geometry.Twist2d;
|
||||
import edu.wpi.first.math.kinematics.proto.DifferentialDriveKinematicsProto;
|
||||
import edu.wpi.first.math.kinematics.struct.DifferentialDriveKinematicsStruct;
|
||||
import edu.wpi.first.units.Distance;
|
||||
import edu.wpi.first.units.Measure;
|
||||
|
||||
@@ -24,6 +26,11 @@ public class DifferentialDriveKinematics
|
||||
implements Kinematics<DifferentialDriveWheelSpeeds, DifferentialDriveWheelPositions> {
|
||||
public final double trackWidthMeters;
|
||||
|
||||
public static final DifferentialDriveKinematicsProto proto =
|
||||
new DifferentialDriveKinematicsProto();
|
||||
public static final DifferentialDriveKinematicsStruct struct =
|
||||
new DifferentialDriveKinematicsStruct();
|
||||
|
||||
/**
|
||||
* Constructs a differential drive kinematics object.
|
||||
*
|
||||
|
||||
@@ -6,6 +6,8 @@ package edu.wpi.first.math.kinematics;
|
||||
|
||||
import static edu.wpi.first.units.Units.MetersPerSecond;
|
||||
|
||||
import edu.wpi.first.math.kinematics.proto.DifferentialDriveWheelSpeedsProto;
|
||||
import edu.wpi.first.math.kinematics.struct.DifferentialDriveWheelSpeedsStruct;
|
||||
import edu.wpi.first.units.Distance;
|
||||
import edu.wpi.first.units.Measure;
|
||||
import edu.wpi.first.units.Velocity;
|
||||
@@ -18,6 +20,11 @@ public class DifferentialDriveWheelSpeeds {
|
||||
/** Speed of the right side of the robot. */
|
||||
public double rightMetersPerSecond;
|
||||
|
||||
public static final DifferentialDriveWheelSpeedsProto proto =
|
||||
new DifferentialDriveWheelSpeedsProto();
|
||||
public static final DifferentialDriveWheelSpeedsStruct struct =
|
||||
new DifferentialDriveWheelSpeedsStruct();
|
||||
|
||||
/** Constructs a DifferentialDriveWheelSpeeds with zeros for left and right speeds. */
|
||||
public DifferentialDriveWheelSpeeds() {}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import edu.wpi.first.math.MathSharedStore;
|
||||
import edu.wpi.first.math.MathUsageId;
|
||||
import edu.wpi.first.math.geometry.Translation2d;
|
||||
import edu.wpi.first.math.geometry.Twist2d;
|
||||
import edu.wpi.first.math.kinematics.proto.MecanumDriveKinematicsProto;
|
||||
import edu.wpi.first.math.kinematics.struct.MecanumDriveKinematicsStruct;
|
||||
import org.ejml.simple.SimpleMatrix;
|
||||
|
||||
/**
|
||||
@@ -42,6 +44,9 @@ public class MecanumDriveKinematics
|
||||
|
||||
private Translation2d m_prevCoR = new Translation2d();
|
||||
|
||||
public static final MecanumDriveKinematicsProto proto = new MecanumDriveKinematicsProto();
|
||||
public static final MecanumDriveKinematicsStruct struct = new MecanumDriveKinematicsStruct();
|
||||
|
||||
/**
|
||||
* Constructs a mecanum drive kinematics object.
|
||||
*
|
||||
@@ -207,4 +212,20 @@ public class MecanumDriveKinematics
|
||||
m_inverseKinematics.setRow(2, 0, 1, 1, rl.getX() - rl.getY());
|
||||
m_inverseKinematics.setRow(3, 0, 1, -1, -(rr.getX() + rr.getY()));
|
||||
}
|
||||
|
||||
public Translation2d getFrontLeft() {
|
||||
return m_frontLeftWheelMeters;
|
||||
}
|
||||
|
||||
public Translation2d getFrontRight() {
|
||||
return m_frontRightWheelMeters;
|
||||
}
|
||||
|
||||
public Translation2d getRearLeft() {
|
||||
return m_rearLeftWheelMeters;
|
||||
}
|
||||
|
||||
public Translation2d getRearRight() {
|
||||
return m_rearRightWheelMeters;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ package edu.wpi.first.math.kinematics;
|
||||
import static edu.wpi.first.units.Units.Meters;
|
||||
|
||||
import edu.wpi.first.math.MathUtil;
|
||||
import edu.wpi.first.math.kinematics.proto.MecanumDriveWheelPositionsProto;
|
||||
import edu.wpi.first.math.kinematics.struct.MecanumDriveWheelPositionsStruct;
|
||||
import edu.wpi.first.units.Distance;
|
||||
import edu.wpi.first.units.Measure;
|
||||
import java.util.Objects;
|
||||
@@ -24,6 +26,10 @@ public class MecanumDriveWheelPositions implements WheelPositions<MecanumDriveWh
|
||||
/** Distance measured by the rear right wheel. */
|
||||
public double rearRightMeters;
|
||||
|
||||
public static final MecanumDriveWheelPositionsStruct struct =
|
||||
new MecanumDriveWheelPositionsStruct();
|
||||
public static final MecanumDriveWheelPositionsProto proto = new MecanumDriveWheelPositionsProto();
|
||||
|
||||
/** Constructs a MecanumDriveWheelPositions with zeros for all member fields. */
|
||||
public MecanumDriveWheelPositions() {}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ package edu.wpi.first.math.kinematics;
|
||||
|
||||
import static edu.wpi.first.units.Units.MetersPerSecond;
|
||||
|
||||
import edu.wpi.first.math.kinematics.proto.MecanumDriveWheelSpeedsProto;
|
||||
import edu.wpi.first.math.kinematics.struct.MecanumDriveWheelSpeedsStruct;
|
||||
import edu.wpi.first.units.Distance;
|
||||
import edu.wpi.first.units.Measure;
|
||||
import edu.wpi.first.units.Velocity;
|
||||
@@ -24,6 +26,9 @@ public class MecanumDriveWheelSpeeds {
|
||||
/** Speed of the rear right wheel. */
|
||||
public double rearRightMetersPerSecond;
|
||||
|
||||
public static final MecanumDriveWheelSpeedsStruct struct = new MecanumDriveWheelSpeedsStruct();
|
||||
public static final MecanumDriveWheelSpeedsProto proto = new MecanumDriveWheelSpeedsProto();
|
||||
|
||||
/** Constructs a MecanumDriveWheelSpeeds with zeros for all member fields. */
|
||||
public MecanumDriveWheelSpeeds() {}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import static edu.wpi.first.units.Units.Meters;
|
||||
import edu.wpi.first.math.MathUtil;
|
||||
import edu.wpi.first.math.geometry.Rotation2d;
|
||||
import edu.wpi.first.math.interpolation.Interpolatable;
|
||||
import edu.wpi.first.math.kinematics.proto.SwerveModulePositionProto;
|
||||
import edu.wpi.first.math.kinematics.struct.SwerveModulePositionStruct;
|
||||
import edu.wpi.first.units.Distance;
|
||||
import edu.wpi.first.units.Measure;
|
||||
import java.util.Objects;
|
||||
@@ -22,6 +24,9 @@ public class SwerveModulePosition
|
||||
/** Angle of the module. */
|
||||
public Rotation2d angle = Rotation2d.fromDegrees(0);
|
||||
|
||||
public static final SwerveModulePositionStruct struct = new SwerveModulePositionStruct();
|
||||
public static final SwerveModulePositionProto proto = new SwerveModulePositionProto();
|
||||
|
||||
/** Constructs a SwerveModulePosition with zeros for distance and angle. */
|
||||
public SwerveModulePosition() {}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ package edu.wpi.first.math.kinematics;
|
||||
import static edu.wpi.first.units.Units.MetersPerSecond;
|
||||
|
||||
import edu.wpi.first.math.geometry.Rotation2d;
|
||||
import edu.wpi.first.math.kinematics.proto.SwerveModuleStateProto;
|
||||
import edu.wpi.first.math.kinematics.struct.SwerveModuleStateStruct;
|
||||
import edu.wpi.first.units.Distance;
|
||||
import edu.wpi.first.units.Measure;
|
||||
import edu.wpi.first.units.Velocity;
|
||||
@@ -20,6 +22,9 @@ public class SwerveModuleState implements Comparable<SwerveModuleState> {
|
||||
/** Angle of the module. */
|
||||
public Rotation2d angle = Rotation2d.fromDegrees(0);
|
||||
|
||||
public static final SwerveModuleStateStruct struct = new SwerveModuleStateStruct();
|
||||
public static final SwerveModuleStateProto proto = new SwerveModuleStateProto();
|
||||
|
||||
/** Constructs a SwerveModuleState with zeros for speed and angle. */
|
||||
public SwerveModuleState() {}
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.kinematics.proto;
|
||||
|
||||
import edu.wpi.first.math.kinematics.ChassisSpeeds;
|
||||
import edu.wpi.first.math.proto.Kinematics.ProtobufChassisSpeeds;
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
import us.hebi.quickbuf.Descriptors.Descriptor;
|
||||
|
||||
public class ChassisSpeedsProto implements Protobuf<ChassisSpeeds, ProtobufChassisSpeeds> {
|
||||
@Override
|
||||
public Class<ChassisSpeeds> getTypeClass() {
|
||||
return ChassisSpeeds.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Descriptor getDescriptor() {
|
||||
return ProtobufChassisSpeeds.getDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtobufChassisSpeeds createMessage() {
|
||||
return ProtobufChassisSpeeds.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChassisSpeeds unpack(ProtobufChassisSpeeds msg) {
|
||||
return new ChassisSpeeds(msg.getVx(), msg.getVy(), msg.getOmega());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ProtobufChassisSpeeds msg, ChassisSpeeds value) {
|
||||
msg.setVx(value.vxMetersPerSecond);
|
||||
msg.setVy(value.vyMetersPerSecond);
|
||||
msg.setOmega(value.omegaRadiansPerSecond);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.kinematics.proto;
|
||||
|
||||
import edu.wpi.first.math.kinematics.DifferentialDriveKinematics;
|
||||
import edu.wpi.first.math.proto.Kinematics.ProtobufDifferentialDriveKinematics;
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
import us.hebi.quickbuf.Descriptors.Descriptor;
|
||||
|
||||
public class DifferentialDriveKinematicsProto
|
||||
implements Protobuf<DifferentialDriveKinematics, ProtobufDifferentialDriveKinematics> {
|
||||
@Override
|
||||
public Class<DifferentialDriveKinematics> getTypeClass() {
|
||||
return DifferentialDriveKinematics.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Descriptor getDescriptor() {
|
||||
return ProtobufDifferentialDriveKinematics.getDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtobufDifferentialDriveKinematics createMessage() {
|
||||
return ProtobufDifferentialDriveKinematics.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DifferentialDriveKinematics unpack(ProtobufDifferentialDriveKinematics msg) {
|
||||
return new DifferentialDriveKinematics(msg.getTrackWidth());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ProtobufDifferentialDriveKinematics msg, DifferentialDriveKinematics value) {
|
||||
msg.setTrackWidth(value.trackWidthMeters);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.kinematics.proto;
|
||||
|
||||
import edu.wpi.first.math.kinematics.DifferentialDriveWheelSpeeds;
|
||||
import edu.wpi.first.math.proto.Kinematics.ProtobufDifferentialDriveWheelSpeeds;
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
import us.hebi.quickbuf.Descriptors.Descriptor;
|
||||
|
||||
public class DifferentialDriveWheelSpeedsProto
|
||||
implements Protobuf<DifferentialDriveWheelSpeeds, ProtobufDifferentialDriveWheelSpeeds> {
|
||||
@Override
|
||||
public Class<DifferentialDriveWheelSpeeds> getTypeClass() {
|
||||
return DifferentialDriveWheelSpeeds.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Descriptor getDescriptor() {
|
||||
return ProtobufDifferentialDriveWheelSpeeds.getDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtobufDifferentialDriveWheelSpeeds createMessage() {
|
||||
return ProtobufDifferentialDriveWheelSpeeds.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DifferentialDriveWheelSpeeds unpack(ProtobufDifferentialDriveWheelSpeeds msg) {
|
||||
return new DifferentialDriveWheelSpeeds(msg.getLeft(), msg.getRight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ProtobufDifferentialDriveWheelSpeeds msg, DifferentialDriveWheelSpeeds value) {
|
||||
msg.setLeft(value.leftMetersPerSecond);
|
||||
msg.setRight(value.rightMetersPerSecond);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.kinematics.proto;
|
||||
|
||||
import edu.wpi.first.math.geometry.Translation2d;
|
||||
import edu.wpi.first.math.kinematics.MecanumDriveKinematics;
|
||||
import edu.wpi.first.math.proto.Kinematics.ProtobufMecanumDriveKinematics;
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
import us.hebi.quickbuf.Descriptors.Descriptor;
|
||||
|
||||
public class MecanumDriveKinematicsProto
|
||||
implements Protobuf<MecanumDriveKinematics, ProtobufMecanumDriveKinematics> {
|
||||
@Override
|
||||
public Class<MecanumDriveKinematics> getTypeClass() {
|
||||
return MecanumDriveKinematics.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Descriptor getDescriptor() {
|
||||
return ProtobufMecanumDriveKinematics.getDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Protobuf<?, ?>[] getNested() {
|
||||
return new Protobuf<?, ?>[] {Translation2d.proto};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtobufMecanumDriveKinematics createMessage() {
|
||||
return ProtobufMecanumDriveKinematics.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MecanumDriveKinematics unpack(ProtobufMecanumDriveKinematics msg) {
|
||||
return new MecanumDriveKinematics(
|
||||
Translation2d.proto.unpack(msg.getFrontLeft()),
|
||||
Translation2d.proto.unpack(msg.getFrontRight()),
|
||||
Translation2d.proto.unpack(msg.getRearLeft()),
|
||||
Translation2d.proto.unpack(msg.getRearRight()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ProtobufMecanumDriveKinematics msg, MecanumDriveKinematics value) {
|
||||
Translation2d.proto.pack(msg.getMutableFrontLeft(), value.getFrontLeft());
|
||||
Translation2d.proto.pack(msg.getMutableFrontRight(), value.getFrontRight());
|
||||
Translation2d.proto.pack(msg.getMutableRearLeft(), value.getRearLeft());
|
||||
Translation2d.proto.pack(msg.getMutableRearRight(), value.getRearRight());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.kinematics.proto;
|
||||
|
||||
import edu.wpi.first.math.kinematics.MecanumDriveWheelPositions;
|
||||
import edu.wpi.first.math.proto.Kinematics.ProtobufMecanumDriveWheelPositions;
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
import us.hebi.quickbuf.Descriptors.Descriptor;
|
||||
|
||||
public class MecanumDriveWheelPositionsProto
|
||||
implements Protobuf<MecanumDriveWheelPositions, ProtobufMecanumDriveWheelPositions> {
|
||||
@Override
|
||||
public Class<MecanumDriveWheelPositions> getTypeClass() {
|
||||
return MecanumDriveWheelPositions.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Descriptor getDescriptor() {
|
||||
return ProtobufMecanumDriveWheelPositions.getDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtobufMecanumDriveWheelPositions createMessage() {
|
||||
return ProtobufMecanumDriveWheelPositions.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MecanumDriveWheelPositions unpack(ProtobufMecanumDriveWheelPositions msg) {
|
||||
return new MecanumDriveWheelPositions(
|
||||
msg.getFrontLeft(), msg.getFrontRight(), msg.getRearLeft(), msg.getRearRight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ProtobufMecanumDriveWheelPositions msg, MecanumDriveWheelPositions value) {
|
||||
msg.setFrontLeft(value.frontLeftMeters);
|
||||
msg.setFrontRight(value.frontRightMeters);
|
||||
msg.setRearLeft(value.rearLeftMeters);
|
||||
msg.setRearRight(value.rearRightMeters);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.kinematics.proto;
|
||||
|
||||
import edu.wpi.first.math.kinematics.MecanumDriveWheelSpeeds;
|
||||
import edu.wpi.first.math.proto.Kinematics.ProtobufMecanumDriveWheelSpeeds;
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
import us.hebi.quickbuf.Descriptors.Descriptor;
|
||||
|
||||
public class MecanumDriveWheelSpeedsProto
|
||||
implements Protobuf<MecanumDriveWheelSpeeds, ProtobufMecanumDriveWheelSpeeds> {
|
||||
@Override
|
||||
public Class<MecanumDriveWheelSpeeds> getTypeClass() {
|
||||
return MecanumDriveWheelSpeeds.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Descriptor getDescriptor() {
|
||||
return ProtobufMecanumDriveWheelSpeeds.getDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtobufMecanumDriveWheelSpeeds createMessage() {
|
||||
return ProtobufMecanumDriveWheelSpeeds.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MecanumDriveWheelSpeeds unpack(ProtobufMecanumDriveWheelSpeeds msg) {
|
||||
return new MecanumDriveWheelSpeeds(
|
||||
msg.getFrontLeft(), msg.getFrontRight(), msg.getRearLeft(), msg.getRearRight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ProtobufMecanumDriveWheelSpeeds msg, MecanumDriveWheelSpeeds value) {
|
||||
msg.setFrontLeft(value.frontLeftMetersPerSecond);
|
||||
msg.setFrontRight(value.frontRightMetersPerSecond);
|
||||
msg.setRearLeft(value.rearLeftMetersPerSecond);
|
||||
msg.setRearRight(value.rearRightMetersPerSecond);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.kinematics.proto;
|
||||
|
||||
import edu.wpi.first.math.geometry.Rotation2d;
|
||||
import edu.wpi.first.math.kinematics.SwerveModulePosition;
|
||||
import edu.wpi.first.math.proto.Kinematics.ProtobufSwerveModulePosition;
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
import us.hebi.quickbuf.Descriptors.Descriptor;
|
||||
|
||||
public class SwerveModulePositionProto
|
||||
implements Protobuf<SwerveModulePosition, ProtobufSwerveModulePosition> {
|
||||
@Override
|
||||
public Class<SwerveModulePosition> getTypeClass() {
|
||||
return SwerveModulePosition.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Descriptor getDescriptor() {
|
||||
return ProtobufSwerveModulePosition.getDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Protobuf<?, ?>[] getNested() {
|
||||
return new Protobuf<?, ?>[] {Rotation2d.proto};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtobufSwerveModulePosition createMessage() {
|
||||
return ProtobufSwerveModulePosition.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SwerveModulePosition unpack(ProtobufSwerveModulePosition msg) {
|
||||
return new SwerveModulePosition(msg.getDistance(), Rotation2d.proto.unpack(msg.getAngle()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ProtobufSwerveModulePosition msg, SwerveModulePosition value) {
|
||||
msg.setDistance(value.distanceMeters);
|
||||
Rotation2d.proto.pack(msg.getMutableAngle(), value.angle);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.kinematics.proto;
|
||||
|
||||
import edu.wpi.first.math.geometry.Rotation2d;
|
||||
import edu.wpi.first.math.kinematics.SwerveModuleState;
|
||||
import edu.wpi.first.math.proto.Kinematics.ProtobufSwerveModuleState;
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
import us.hebi.quickbuf.Descriptors.Descriptor;
|
||||
|
||||
public class SwerveModuleStateProto
|
||||
implements Protobuf<SwerveModuleState, ProtobufSwerveModuleState> {
|
||||
@Override
|
||||
public Class<SwerveModuleState> getTypeClass() {
|
||||
return SwerveModuleState.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Descriptor getDescriptor() {
|
||||
return ProtobufSwerveModuleState.getDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Protobuf<?, ?>[] getNested() {
|
||||
return new Protobuf<?, ?>[] {Rotation2d.proto};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtobufSwerveModuleState createMessage() {
|
||||
return ProtobufSwerveModuleState.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SwerveModuleState unpack(ProtobufSwerveModuleState msg) {
|
||||
return new SwerveModuleState(msg.getSpeed(), Rotation2d.proto.unpack(msg.getAngle()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ProtobufSwerveModuleState msg, SwerveModuleState value) {
|
||||
msg.setSpeed(value.speedMetersPerSecond);
|
||||
Rotation2d.proto.pack(msg.getMutableAngle(), value.angle);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.kinematics.struct;
|
||||
|
||||
import edu.wpi.first.math.kinematics.ChassisSpeeds;
|
||||
import edu.wpi.first.util.struct.Struct;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class ChassisSpeedsStruct implements Struct<ChassisSpeeds> {
|
||||
@Override
|
||||
public Class<ChassisSpeeds> getTypeClass() {
|
||||
return ChassisSpeeds.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeString() {
|
||||
return "struct:ChassisSpeeds";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return kSizeDouble * 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchema() {
|
||||
return "double vx;double vy;double omega";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChassisSpeeds unpack(ByteBuffer bb) {
|
||||
double vx = bb.getDouble();
|
||||
double vy = bb.getDouble();
|
||||
double omega = bb.getDouble();
|
||||
return new ChassisSpeeds(vx, vy, omega);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ByteBuffer bb, ChassisSpeeds value) {
|
||||
bb.putDouble(value.vxMetersPerSecond);
|
||||
bb.putDouble(value.vyMetersPerSecond);
|
||||
bb.putDouble(value.omegaRadiansPerSecond);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.kinematics.struct;
|
||||
|
||||
import edu.wpi.first.math.kinematics.DifferentialDriveKinematics;
|
||||
import edu.wpi.first.util.struct.Struct;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class DifferentialDriveKinematicsStruct implements Struct<DifferentialDriveKinematics> {
|
||||
@Override
|
||||
public Class<DifferentialDriveKinematics> getTypeClass() {
|
||||
return DifferentialDriveKinematics.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeString() {
|
||||
return "struct:DifferentialDriveKinematics";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return kSizeDouble;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchema() {
|
||||
return "double track_width";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DifferentialDriveKinematics unpack(ByteBuffer bb) {
|
||||
double trackWidth = bb.getDouble();
|
||||
return new DifferentialDriveKinematics(trackWidth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ByteBuffer bb, DifferentialDriveKinematics value) {
|
||||
bb.putDouble(value.trackWidthMeters);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.kinematics.struct;
|
||||
|
||||
import edu.wpi.first.math.kinematics.DifferentialDriveWheelSpeeds;
|
||||
import edu.wpi.first.util.struct.Struct;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class DifferentialDriveWheelSpeedsStruct implements Struct<DifferentialDriveWheelSpeeds> {
|
||||
@Override
|
||||
public Class<DifferentialDriveWheelSpeeds> getTypeClass() {
|
||||
return DifferentialDriveWheelSpeeds.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeString() {
|
||||
return "struct:DifferentialDriveWheelSpeeds";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return kSizeDouble * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchema() {
|
||||
return "double left;double right";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DifferentialDriveWheelSpeeds unpack(ByteBuffer bb) {
|
||||
double left = bb.getDouble();
|
||||
double right = bb.getDouble();
|
||||
return new DifferentialDriveWheelSpeeds(left, right);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ByteBuffer bb, DifferentialDriveWheelSpeeds value) {
|
||||
bb.putDouble(value.leftMetersPerSecond);
|
||||
bb.putDouble(value.rightMetersPerSecond);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.kinematics.struct;
|
||||
|
||||
import edu.wpi.first.math.geometry.Translation2d;
|
||||
import edu.wpi.first.math.kinematics.MecanumDriveKinematics;
|
||||
import edu.wpi.first.util.struct.Struct;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class MecanumDriveKinematicsStruct implements Struct<MecanumDriveKinematics> {
|
||||
@Override
|
||||
public Class<MecanumDriveKinematics> getTypeClass() {
|
||||
return MecanumDriveKinematics.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeString() {
|
||||
return "struct:MecanumDriveKinematics";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 4 * Translation2d.struct.getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchema() {
|
||||
return "Translation2d front_left;Translation2d front_right;Translation2d rear_left;"
|
||||
+ "Translation2d rear_right";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Struct<?>[] getNested() {
|
||||
return new Struct<?>[] {Translation2d.struct};
|
||||
}
|
||||
|
||||
@Override
|
||||
public MecanumDriveKinematics unpack(ByteBuffer bb) {
|
||||
Translation2d frontLeft = Translation2d.struct.unpack(bb);
|
||||
Translation2d frontRight = Translation2d.struct.unpack(bb);
|
||||
Translation2d rearLeft = Translation2d.struct.unpack(bb);
|
||||
Translation2d rearRight = Translation2d.struct.unpack(bb);
|
||||
return new MecanumDriveKinematics(frontLeft, frontRight, rearLeft, rearRight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ByteBuffer bb, MecanumDriveKinematics value) {
|
||||
Translation2d.struct.pack(bb, value.getFrontLeft());
|
||||
Translation2d.struct.pack(bb, value.getFrontRight());
|
||||
Translation2d.struct.pack(bb, value.getRearLeft());
|
||||
Translation2d.struct.pack(bb, value.getRearRight());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.kinematics.struct;
|
||||
|
||||
import edu.wpi.first.math.kinematics.MecanumDriveWheelPositions;
|
||||
import edu.wpi.first.util.struct.Struct;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class MecanumDriveWheelPositionsStruct implements Struct<MecanumDriveWheelPositions> {
|
||||
@Override
|
||||
public Class<MecanumDriveWheelPositions> getTypeClass() {
|
||||
return MecanumDriveWheelPositions.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeString() {
|
||||
return "struct:MecanumDriveWheelPositions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return kSizeDouble * 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchema() {
|
||||
return "double front_left;double front_right;double rear_left;double rear_right";
|
||||
}
|
||||
|
||||
@Override
|
||||
public MecanumDriveWheelPositions unpack(ByteBuffer bb) {
|
||||
double frontLeft = bb.getDouble();
|
||||
double frontRight = bb.getDouble();
|
||||
double rearLeft = bb.getDouble();
|
||||
double rearRight = bb.getDouble();
|
||||
return new MecanumDriveWheelPositions(frontLeft, frontRight, rearLeft, rearRight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ByteBuffer bb, MecanumDriveWheelPositions value) {
|
||||
bb.putDouble(value.frontLeftMeters);
|
||||
bb.putDouble(value.frontRightMeters);
|
||||
bb.putDouble(value.rearLeftMeters);
|
||||
bb.putDouble(value.rearRightMeters);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.kinematics.struct;
|
||||
|
||||
import edu.wpi.first.math.kinematics.MecanumDriveWheelSpeeds;
|
||||
import edu.wpi.first.util.struct.Struct;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class MecanumDriveWheelSpeedsStruct implements Struct<MecanumDriveWheelSpeeds> {
|
||||
@Override
|
||||
public Class<MecanumDriveWheelSpeeds> getTypeClass() {
|
||||
return MecanumDriveWheelSpeeds.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeString() {
|
||||
return "struct:MecanumDriveWheelSpeeds";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return kSizeDouble * 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchema() {
|
||||
return "double front_left;double front_right;double rear_left;double rear_right";
|
||||
}
|
||||
|
||||
@Override
|
||||
public MecanumDriveWheelSpeeds unpack(ByteBuffer bb) {
|
||||
double frontLeft = bb.getDouble();
|
||||
double frontRight = bb.getDouble();
|
||||
double rearLeft = bb.getDouble();
|
||||
double rearRight = bb.getDouble();
|
||||
return new MecanumDriveWheelSpeeds(frontLeft, frontRight, rearLeft, rearRight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ByteBuffer bb, MecanumDriveWheelSpeeds value) {
|
||||
bb.putDouble(value.frontLeftMetersPerSecond);
|
||||
bb.putDouble(value.frontRightMetersPerSecond);
|
||||
bb.putDouble(value.rearLeftMetersPerSecond);
|
||||
bb.putDouble(value.rearRightMetersPerSecond);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.kinematics.struct;
|
||||
|
||||
import edu.wpi.first.math.geometry.Rotation2d;
|
||||
import edu.wpi.first.math.kinematics.SwerveModulePosition;
|
||||
import edu.wpi.first.util.struct.Struct;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class SwerveModulePositionStruct implements Struct<SwerveModulePosition> {
|
||||
@Override
|
||||
public Class<SwerveModulePosition> getTypeClass() {
|
||||
return SwerveModulePosition.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeString() {
|
||||
return "struct:SwerveModulePosition";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return kSizeDouble + Rotation2d.struct.getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchema() {
|
||||
return "double distance;Rotation2d angle";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Struct<?>[] getNested() {
|
||||
return new Struct<?>[] {Rotation2d.struct};
|
||||
}
|
||||
|
||||
@Override
|
||||
public SwerveModulePosition unpack(ByteBuffer bb) {
|
||||
double distance = bb.getDouble();
|
||||
Rotation2d angle = Rotation2d.struct.unpack(bb);
|
||||
return new SwerveModulePosition(distance, angle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ByteBuffer bb, SwerveModulePosition value) {
|
||||
bb.putDouble(value.distanceMeters);
|
||||
Rotation2d.struct.pack(bb, value.angle);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.kinematics.struct;
|
||||
|
||||
import edu.wpi.first.math.geometry.Rotation2d;
|
||||
import edu.wpi.first.math.kinematics.SwerveModuleState;
|
||||
import edu.wpi.first.util.struct.Struct;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class SwerveModuleStateStruct implements Struct<SwerveModuleState> {
|
||||
@Override
|
||||
public Class<SwerveModuleState> getTypeClass() {
|
||||
return SwerveModuleState.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeString() {
|
||||
return "struct:SwerveModuleState";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return kSizeDouble + Rotation2d.struct.getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchema() {
|
||||
return "double speed;Rotation2d angle";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Struct<?>[] getNested() {
|
||||
return new Struct<?>[] {Rotation2d.struct};
|
||||
}
|
||||
|
||||
@Override
|
||||
public SwerveModuleState unpack(ByteBuffer bb) {
|
||||
double speed = bb.getDouble();
|
||||
Rotation2d angle = Rotation2d.struct.unpack(bb);
|
||||
return new SwerveModuleState(speed, angle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ByteBuffer bb, SwerveModuleState value) {
|
||||
bb.putDouble(value.speedMetersPerSecond);
|
||||
Rotation2d.struct.pack(bb, value.angle);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
package edu.wpi.first.math.system.plant;
|
||||
|
||||
import edu.wpi.first.math.system.plant.proto.DCMotorProto;
|
||||
import edu.wpi.first.math.system.plant.struct.DCMotorStruct;
|
||||
import edu.wpi.first.math.util.Units;
|
||||
|
||||
/** Holds the constants for a DC motor. */
|
||||
@@ -17,6 +19,9 @@ public class DCMotor {
|
||||
public final double KvRadPerSecPerVolt;
|
||||
public final double KtNMPerAmp;
|
||||
|
||||
public static final DCMotorProto proto = new DCMotorProto();
|
||||
public static final DCMotorStruct struct = new DCMotorStruct();
|
||||
|
||||
/**
|
||||
* Constructs a DC motor.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.system.plant.proto;
|
||||
|
||||
import edu.wpi.first.math.proto.Plant.ProtobufDCMotor;
|
||||
import edu.wpi.first.math.system.plant.DCMotor;
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
import us.hebi.quickbuf.Descriptors.Descriptor;
|
||||
|
||||
public class DCMotorProto implements Protobuf<DCMotor, ProtobufDCMotor> {
|
||||
@Override
|
||||
public Class<DCMotor> getTypeClass() {
|
||||
return DCMotor.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Descriptor getDescriptor() {
|
||||
return ProtobufDCMotor.getDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtobufDCMotor createMessage() {
|
||||
return ProtobufDCMotor.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DCMotor unpack(ProtobufDCMotor msg) {
|
||||
return new DCMotor(
|
||||
msg.getNominalVoltage(),
|
||||
msg.getStallTorque(),
|
||||
msg.getStallCurrent(),
|
||||
msg.getFreeCurrent(),
|
||||
msg.getFreeSpeed(),
|
||||
1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ProtobufDCMotor msg, DCMotor value) {
|
||||
msg.setNominalVoltage(value.nominalVoltageVolts);
|
||||
msg.setStallTorque(value.stallTorqueNewtonMeters);
|
||||
msg.setStallCurrent(value.stallCurrentAmps);
|
||||
msg.setFreeCurrent(value.freeCurrentAmps);
|
||||
msg.setFreeSpeed(value.freeSpeedRadPerSec);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.system.plant.struct;
|
||||
|
||||
import edu.wpi.first.math.system.plant.DCMotor;
|
||||
import edu.wpi.first.util.struct.Struct;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class DCMotorStruct implements Struct<DCMotor> {
|
||||
@Override
|
||||
public Class<DCMotor> getTypeClass() {
|
||||
return DCMotor.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeString() {
|
||||
return "struct:DCMotor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return kSizeDouble * 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchema() {
|
||||
return "double nominal_voltage;double stall_torque;double stall_current;"
|
||||
+ "double free_current;double free_speed";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DCMotor unpack(ByteBuffer bb) {
|
||||
double nominalVoltage = bb.getDouble();
|
||||
double stallTorque = bb.getDouble();
|
||||
double stallCurrent = bb.getDouble();
|
||||
double freeCurrent = bb.getDouble();
|
||||
double freeSpeed = bb.getDouble();
|
||||
return new DCMotor(nominalVoltage, stallTorque, stallCurrent, freeCurrent, freeSpeed, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ByteBuffer bb, DCMotor value) {
|
||||
bb.putDouble(value.nominalVoltageVolts);
|
||||
bb.putDouble(value.stallTorqueNewtonMeters);
|
||||
bb.putDouble(value.stallCurrentAmps);
|
||||
bb.putDouble(value.freeCurrentAmps);
|
||||
bb.putDouble(value.freeSpeedRadPerSec);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@ package edu.wpi.first.math.trajectory;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import edu.wpi.first.math.geometry.Pose2d;
|
||||
import edu.wpi.first.math.geometry.Transform2d;
|
||||
import edu.wpi.first.math.trajectory.proto.TrajectoryProto;
|
||||
import edu.wpi.first.math.trajectory.proto.TrajectoryStateProto;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -17,6 +19,8 @@ import java.util.stream.Collectors;
|
||||
* represent the pose, curvature, time elapsed, velocity, and acceleration at that point.
|
||||
*/
|
||||
public class Trajectory {
|
||||
public static final TrajectoryProto proto = new TrajectoryProto();
|
||||
|
||||
private final double m_totalTimeSeconds;
|
||||
private final List<State> m_states;
|
||||
|
||||
@@ -264,6 +268,8 @@ public class Trajectory {
|
||||
* represent the pose, curvature, time elapsed, velocity, and acceleration at that point.
|
||||
*/
|
||||
public static class State {
|
||||
public static final TrajectoryStateProto proto = new TrajectoryStateProto();
|
||||
|
||||
// The time elapsed since the beginning of the trajectory.
|
||||
@JsonProperty("time")
|
||||
public double timeSeconds;
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.trajectory.proto;
|
||||
|
||||
import edu.wpi.first.math.proto.Trajectory.ProtobufTrajectory;
|
||||
import edu.wpi.first.math.proto.Trajectory.ProtobufTrajectoryState;
|
||||
import edu.wpi.first.math.trajectory.Trajectory;
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
import java.util.ArrayList;
|
||||
import us.hebi.quickbuf.Descriptors.Descriptor;
|
||||
|
||||
public class TrajectoryProto implements Protobuf<Trajectory, ProtobufTrajectory> {
|
||||
@Override
|
||||
public Class<Trajectory> getTypeClass() {
|
||||
return Trajectory.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Descriptor getDescriptor() {
|
||||
return ProtobufTrajectory.getDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Protobuf<?, ?>[] getNested() {
|
||||
return new Protobuf<?, ?>[] {Trajectory.State.proto};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtobufTrajectory createMessage() {
|
||||
return ProtobufTrajectory.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Trajectory unpack(ProtobufTrajectory msg) {
|
||||
ArrayList<Trajectory.State> states = new ArrayList<>(msg.getStates().length());
|
||||
for (ProtobufTrajectoryState protoState : msg.getStates()) {
|
||||
states.add(Trajectory.State.proto.unpack(protoState));
|
||||
}
|
||||
|
||||
return new Trajectory(states);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ProtobufTrajectory msg, Trajectory value) {
|
||||
var states = msg.getMutableStates().reserve(value.getStates().size());
|
||||
for (var item : value.getStates()) {
|
||||
Trajectory.State.proto.pack(states.next(), item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math.trajectory.proto;
|
||||
|
||||
import edu.wpi.first.math.geometry.Pose2d;
|
||||
import edu.wpi.first.math.proto.Trajectory.ProtobufTrajectoryState;
|
||||
import edu.wpi.first.math.trajectory.Trajectory;
|
||||
import edu.wpi.first.util.protobuf.Protobuf;
|
||||
import us.hebi.quickbuf.Descriptors.Descriptor;
|
||||
|
||||
public class TrajectoryStateProto implements Protobuf<Trajectory.State, ProtobufTrajectoryState> {
|
||||
@Override
|
||||
public Class<Trajectory.State> getTypeClass() {
|
||||
return Trajectory.State.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Descriptor getDescriptor() {
|
||||
return ProtobufTrajectoryState.getDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Protobuf<?, ?>[] getNested() {
|
||||
return new Protobuf<?, ?>[] {Pose2d.proto};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtobufTrajectoryState createMessage() {
|
||||
return ProtobufTrajectoryState.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Trajectory.State unpack(ProtobufTrajectoryState msg) {
|
||||
return new Trajectory.State(
|
||||
msg.getTime(),
|
||||
msg.getVelocity(),
|
||||
msg.getAcceleration(),
|
||||
Pose2d.proto.unpack(msg.getPose()),
|
||||
msg.getCurvature());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(ProtobufTrajectoryState msg, Trajectory.State value) {
|
||||
msg.setTime(value.timeSeconds);
|
||||
msg.setVelocity(value.velocityMetersPerSecond);
|
||||
msg.setAcceleration(value.accelerationMetersPerSecondSq);
|
||||
Pose2d.proto.pack(msg.getMutablePose(), value.poseMeters);
|
||||
msg.setCurvature(value.curvatureRadPerMeter);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/controller/proto/ArmFeedforwardProto.h"
|
||||
|
||||
#include "controller.pb.h"
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<frc::ArmFeedforward>::New(
|
||||
google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<
|
||||
wpi::proto::ProtobufArmFeedforward>(arena);
|
||||
}
|
||||
|
||||
frc::ArmFeedforward wpi::Protobuf<frc::ArmFeedforward>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m = static_cast<const wpi::proto::ProtobufArmFeedforward*>(&msg);
|
||||
return frc::ArmFeedforward{
|
||||
units::volt_t{m->ks()},
|
||||
units::volt_t{m->kg()},
|
||||
units::unit_t<frc::ArmFeedforward::kv_unit>{m->kv()},
|
||||
units::unit_t<frc::ArmFeedforward::ka_unit>{m->ka()},
|
||||
};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<frc::ArmFeedforward>::Pack(
|
||||
google::protobuf::Message* msg, const frc::ArmFeedforward& value) {
|
||||
auto m = static_cast<wpi::proto::ProtobufArmFeedforward*>(msg);
|
||||
m->set_ks(value.kS.value());
|
||||
m->set_kg(value.kG.value());
|
||||
m->set_kv(value.kV.value());
|
||||
m->set_ka(value.kA.value());
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/controller/proto/DifferentialDriveWheelVoltagesProto.h"
|
||||
|
||||
#include "controller.pb.h"
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<
|
||||
frc::DifferentialDriveWheelVoltages>::New(google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<
|
||||
wpi::proto::ProtobufDifferentialDriveWheelVoltages>(arena);
|
||||
}
|
||||
|
||||
frc::DifferentialDriveWheelVoltages
|
||||
wpi::Protobuf<frc::DifferentialDriveWheelVoltages>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m =
|
||||
static_cast<const wpi::proto::ProtobufDifferentialDriveWheelVoltages*>(
|
||||
&msg);
|
||||
return frc::DifferentialDriveWheelVoltages{
|
||||
units::volt_t{m->left()},
|
||||
units::volt_t{m->right()},
|
||||
};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<frc::DifferentialDriveWheelVoltages>::Pack(
|
||||
google::protobuf::Message* msg,
|
||||
const frc::DifferentialDriveWheelVoltages& value) {
|
||||
auto m =
|
||||
static_cast<wpi::proto::ProtobufDifferentialDriveWheelVoltages*>(msg);
|
||||
m->set_left(value.left.value());
|
||||
m->set_right(value.right.value());
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/controller/proto/ElevatorFeedforwardProto.h"
|
||||
|
||||
#include "controller.pb.h"
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<frc::ElevatorFeedforward>::New(
|
||||
google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<
|
||||
wpi::proto::ProtobufElevatorFeedforward>(arena);
|
||||
}
|
||||
|
||||
frc::ElevatorFeedforward wpi::Protobuf<frc::ElevatorFeedforward>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m = static_cast<const wpi::proto::ProtobufElevatorFeedforward*>(&msg);
|
||||
return frc::ElevatorFeedforward{
|
||||
units::volt_t{m->ks()},
|
||||
units::volt_t{m->kg()},
|
||||
units::unit_t<frc::ElevatorFeedforward::kv_unit>{m->kv()},
|
||||
units::unit_t<frc::ElevatorFeedforward::ka_unit>{m->ka()},
|
||||
};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<frc::ElevatorFeedforward>::Pack(
|
||||
google::protobuf::Message* msg, const frc::ElevatorFeedforward& value) {
|
||||
auto m = static_cast<wpi::proto::ProtobufElevatorFeedforward*>(msg);
|
||||
m->set_ks(value.kS());
|
||||
m->set_kg(value.kG());
|
||||
m->set_kv(value.kV());
|
||||
m->set_ka(value.kA());
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/controller/struct/ArmFeedforwardStruct.h"
|
||||
|
||||
namespace {
|
||||
constexpr size_t kKsOff = 0;
|
||||
constexpr size_t kKgOff = kKsOff + 8;
|
||||
constexpr size_t kKvOff = kKgOff + 8;
|
||||
constexpr size_t kKaOff = kKvOff + 8;
|
||||
} // namespace
|
||||
|
||||
using StructType = wpi::Struct<frc::ArmFeedforward>;
|
||||
|
||||
frc::ArmFeedforward StructType::Unpack(std::span<const uint8_t, kSize> data) {
|
||||
return frc::ArmFeedforward{
|
||||
units::volt_t{wpi::UnpackStruct<double, kKsOff>(data)},
|
||||
units::volt_t{wpi::UnpackStruct<double, kKgOff>(data)},
|
||||
units::unit_t<frc::ArmFeedforward::kv_unit>{
|
||||
wpi::UnpackStruct<double, kKvOff>(data)},
|
||||
units::unit_t<frc::ArmFeedforward::ka_unit>{
|
||||
wpi::UnpackStruct<double, kKaOff>(data)},
|
||||
};
|
||||
}
|
||||
|
||||
void StructType::Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::ArmFeedforward& value) {
|
||||
wpi::PackStruct<kKsOff>(data, value.kS());
|
||||
wpi::PackStruct<kKgOff>(data, value.kG());
|
||||
wpi::PackStruct<kKvOff>(data, value.kV());
|
||||
wpi::PackStruct<kKaOff>(data, value.kA());
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/controller/struct/DifferentialDriveWheelVoltagesStruct.h"
|
||||
|
||||
namespace {
|
||||
constexpr size_t kLeftOff = 0;
|
||||
constexpr size_t kRightOff = kLeftOff + 8;
|
||||
} // namespace
|
||||
|
||||
using StructType = wpi::Struct<frc::DifferentialDriveWheelVoltages>;
|
||||
|
||||
frc::DifferentialDriveWheelVoltages StructType::Unpack(
|
||||
std::span<const uint8_t, kSize> data) {
|
||||
return frc::DifferentialDriveWheelVoltages{
|
||||
units::volt_t{wpi::UnpackStruct<double, kLeftOff>(data)},
|
||||
units::volt_t{wpi::UnpackStruct<double, kRightOff>(data)},
|
||||
};
|
||||
}
|
||||
|
||||
void StructType::Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::DifferentialDriveWheelVoltages& value) {
|
||||
wpi::PackStruct<kLeftOff>(data, value.left.value());
|
||||
wpi::PackStruct<kRightOff>(data, value.right.value());
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/controller/struct/ElevatorFeedforwardStruct.h"
|
||||
|
||||
namespace {
|
||||
constexpr size_t kKsOff = 0;
|
||||
constexpr size_t kKgOff = kKsOff + 8;
|
||||
constexpr size_t kKvOff = kKgOff + 8;
|
||||
constexpr size_t kKaOff = kKvOff + 8;
|
||||
} // namespace
|
||||
|
||||
using StructType = wpi::Struct<frc::ElevatorFeedforward>;
|
||||
|
||||
frc::ElevatorFeedforward StructType::Unpack(
|
||||
std::span<const uint8_t, kSize> data) {
|
||||
return frc::ElevatorFeedforward{
|
||||
units::volt_t{wpi::UnpackStruct<double, kKsOff>(data)},
|
||||
units::volt_t{wpi::UnpackStruct<double, kKgOff>(data)},
|
||||
units::unit_t<frc::ElevatorFeedforward::kv_unit>{
|
||||
wpi::UnpackStruct<double, kKvOff>(data)},
|
||||
units::unit_t<frc::ElevatorFeedforward::ka_unit>{
|
||||
wpi::UnpackStruct<double, kKaOff>(data)},
|
||||
};
|
||||
}
|
||||
|
||||
void StructType::Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::ElevatorFeedforward& value) {
|
||||
wpi::PackStruct<kKsOff>(data, value.kS());
|
||||
wpi::PackStruct<kKgOff>(data, value.kG());
|
||||
wpi::PackStruct<kKvOff>(data, value.kV());
|
||||
wpi::PackStruct<kKaOff>(data, value.kA());
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/kinematics/proto/ChassisSpeedsProto.h"
|
||||
|
||||
#include "kinematics.pb.h"
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<frc::ChassisSpeeds>::New(
|
||||
google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<
|
||||
wpi::proto::ProtobufChassisSpeeds>(arena);
|
||||
}
|
||||
|
||||
frc::ChassisSpeeds wpi::Protobuf<frc::ChassisSpeeds>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m = static_cast<const wpi::proto::ProtobufChassisSpeeds*>(&msg);
|
||||
return frc::ChassisSpeeds{
|
||||
units::meters_per_second_t{m->vx()},
|
||||
units::meters_per_second_t{m->vy()},
|
||||
units::radians_per_second_t{m->omega()},
|
||||
};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<frc::ChassisSpeeds>::Pack(google::protobuf::Message* msg,
|
||||
const frc::ChassisSpeeds& value) {
|
||||
auto m = static_cast<wpi::proto::ProtobufChassisSpeeds*>(msg);
|
||||
m->set_vx(value.vx.value());
|
||||
m->set_vy(value.vy.value());
|
||||
m->set_omega(value.omega.value());
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/kinematics/proto/DifferentialDriveKinematicsProto.h"
|
||||
|
||||
#include "kinematics.pb.h"
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<frc::DifferentialDriveKinematics>::New(
|
||||
google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<
|
||||
wpi::proto::ProtobufDifferentialDriveKinematics>(arena);
|
||||
}
|
||||
|
||||
frc::DifferentialDriveKinematics
|
||||
wpi::Protobuf<frc::DifferentialDriveKinematics>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m =
|
||||
static_cast<const wpi::proto::ProtobufDifferentialDriveKinematics*>(&msg);
|
||||
return frc::DifferentialDriveKinematics{
|
||||
units::meter_t{m->track_width()},
|
||||
};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<frc::DifferentialDriveKinematics>::Pack(
|
||||
google::protobuf::Message* msg,
|
||||
const frc::DifferentialDriveKinematics& value) {
|
||||
auto m = static_cast<wpi::proto::ProtobufDifferentialDriveKinematics*>(msg);
|
||||
m->set_track_width(value.trackWidth.value());
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/kinematics/proto/DifferentialDriveWheelSpeedsProto.h"
|
||||
|
||||
#include "kinematics.pb.h"
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<
|
||||
frc::DifferentialDriveWheelSpeeds>::New(google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<
|
||||
wpi::proto::ProtobufDifferentialDriveWheelSpeeds>(arena);
|
||||
}
|
||||
|
||||
frc::DifferentialDriveWheelSpeeds
|
||||
wpi::Protobuf<frc::DifferentialDriveWheelSpeeds>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m = static_cast<const wpi::proto::ProtobufDifferentialDriveWheelSpeeds*>(
|
||||
&msg);
|
||||
return frc::DifferentialDriveWheelSpeeds{
|
||||
units::meters_per_second_t{m->left()},
|
||||
units::meters_per_second_t{m->right()},
|
||||
};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<frc::DifferentialDriveWheelSpeeds>::Pack(
|
||||
google::protobuf::Message* msg,
|
||||
const frc::DifferentialDriveWheelSpeeds& value) {
|
||||
auto m = static_cast<wpi::proto::ProtobufDifferentialDriveWheelSpeeds*>(msg);
|
||||
m->set_left(value.left.value());
|
||||
m->set_right(value.right.value());
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/kinematics/proto/MecanumDriveKinematicsProto.h"
|
||||
|
||||
#include "kinematics.pb.h"
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<frc::MecanumDriveKinematics>::New(
|
||||
google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<
|
||||
wpi::proto::ProtobufMecanumDriveKinematics>(arena);
|
||||
}
|
||||
|
||||
frc::MecanumDriveKinematics wpi::Protobuf<frc::MecanumDriveKinematics>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m = static_cast<const wpi::proto::ProtobufMecanumDriveKinematics*>(&msg);
|
||||
return frc::MecanumDriveKinematics{
|
||||
wpi::UnpackProtobuf<frc::Translation2d>(m->front_left()),
|
||||
wpi::UnpackProtobuf<frc::Translation2d>(m->front_right()),
|
||||
wpi::UnpackProtobuf<frc::Translation2d>(m->rear_left()),
|
||||
wpi::UnpackProtobuf<frc::Translation2d>(m->rear_right()),
|
||||
};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<frc::MecanumDriveKinematics>::Pack(
|
||||
google::protobuf::Message* msg, const frc::MecanumDriveKinematics& value) {
|
||||
auto m = static_cast<wpi::proto::ProtobufMecanumDriveKinematics*>(msg);
|
||||
wpi::PackProtobuf(m->mutable_front_left(), value.GetFrontLeftWheel());
|
||||
wpi::PackProtobuf(m->mutable_front_right(), value.GetFrontRightWheel());
|
||||
wpi::PackProtobuf(m->mutable_rear_left(), value.GetRearLeftWheel());
|
||||
wpi::PackProtobuf(m->mutable_rear_right(), value.GetRearRightWheel());
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/kinematics/proto/MecanumDriveWheelPositionsProto.h"
|
||||
|
||||
#include "kinematics.pb.h"
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<frc::MecanumDriveWheelPositions>::New(
|
||||
google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<
|
||||
wpi::proto::ProtobufMecanumDriveWheelPositions>(arena);
|
||||
}
|
||||
|
||||
frc::MecanumDriveWheelPositions
|
||||
wpi::Protobuf<frc::MecanumDriveWheelPositions>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m =
|
||||
static_cast<const wpi::proto::ProtobufMecanumDriveWheelPositions*>(&msg);
|
||||
return frc::MecanumDriveWheelPositions{
|
||||
units::meter_t{m->front_left()},
|
||||
units::meter_t{m->front_right()},
|
||||
units::meter_t{m->rear_left()},
|
||||
units::meter_t{m->rear_right()},
|
||||
};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<frc::MecanumDriveWheelPositions>::Pack(
|
||||
google::protobuf::Message* msg,
|
||||
const frc::MecanumDriveWheelPositions& value) {
|
||||
auto m = static_cast<wpi::proto::ProtobufMecanumDriveWheelPositions*>(msg);
|
||||
m->set_front_left(value.frontLeft.value());
|
||||
m->set_front_right(value.frontRight.value());
|
||||
m->set_rear_left(value.rearLeft.value());
|
||||
m->set_rear_right(value.rearRight.value());
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/kinematics/proto/MecanumDriveWheelSpeedsProto.h"
|
||||
|
||||
#include "kinematics.pb.h"
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<frc::MecanumDriveWheelSpeeds>::New(
|
||||
google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<
|
||||
wpi::proto::ProtobufMecanumDriveWheelSpeeds>(arena);
|
||||
}
|
||||
|
||||
frc::MecanumDriveWheelSpeeds
|
||||
wpi::Protobuf<frc::MecanumDriveWheelSpeeds>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m =
|
||||
static_cast<const wpi::proto::ProtobufMecanumDriveWheelSpeeds*>(&msg);
|
||||
return frc::MecanumDriveWheelSpeeds{
|
||||
units::meters_per_second_t{m->front_left()},
|
||||
units::meters_per_second_t{m->front_right()},
|
||||
units::meters_per_second_t{m->rear_left()},
|
||||
units::meters_per_second_t{m->rear_right()},
|
||||
};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<frc::MecanumDriveWheelSpeeds>::Pack(
|
||||
google::protobuf::Message* msg, const frc::MecanumDriveWheelSpeeds& value) {
|
||||
auto m = static_cast<wpi::proto::ProtobufMecanumDriveWheelSpeeds*>(msg);
|
||||
m->set_front_left(value.frontLeft.value());
|
||||
m->set_front_right(value.frontRight.value());
|
||||
m->set_rear_left(value.rearLeft.value());
|
||||
m->set_rear_right(value.rearRight.value());
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/kinematics/proto/SwerveModulePositionProto.h"
|
||||
|
||||
#include "kinematics.pb.h"
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<frc::SwerveModulePosition>::New(
|
||||
google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<
|
||||
wpi::proto::ProtobufSwerveModulePosition>(arena);
|
||||
}
|
||||
|
||||
frc::SwerveModulePosition wpi::Protobuf<frc::SwerveModulePosition>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m = static_cast<const wpi::proto::ProtobufSwerveModulePosition*>(&msg);
|
||||
return frc::SwerveModulePosition{
|
||||
units::meter_t{m->distance()},
|
||||
wpi::UnpackProtobuf<frc::Rotation2d>(m->angle()),
|
||||
};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<frc::SwerveModulePosition>::Pack(
|
||||
google::protobuf::Message* msg, const frc::SwerveModulePosition& value) {
|
||||
auto m = static_cast<wpi::proto::ProtobufSwerveModulePosition*>(msg);
|
||||
m->set_distance(value.distance.value());
|
||||
wpi::PackProtobuf(m->mutable_angle(), value.angle);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/kinematics/proto/SwerveModuleStateProto.h"
|
||||
|
||||
#include "kinematics.pb.h"
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<frc::SwerveModuleState>::New(
|
||||
google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<
|
||||
wpi::proto::ProtobufSwerveModuleState>(arena);
|
||||
}
|
||||
|
||||
frc::SwerveModuleState wpi::Protobuf<frc::SwerveModuleState>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m = static_cast<const wpi::proto::ProtobufSwerveModuleState*>(&msg);
|
||||
return frc::SwerveModuleState{
|
||||
units::meters_per_second_t{m->speed()},
|
||||
wpi::UnpackProtobuf<frc::Rotation2d>(m->angle()),
|
||||
};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<frc::SwerveModuleState>::Pack(
|
||||
google::protobuf::Message* msg, const frc::SwerveModuleState& value) {
|
||||
auto m = static_cast<wpi::proto::ProtobufSwerveModuleState*>(msg);
|
||||
m->set_speed(value.speed.value());
|
||||
wpi::PackProtobuf(m->mutable_angle(), value.angle);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/kinematics/struct/ChassisSpeedsStruct.h"
|
||||
|
||||
namespace {
|
||||
constexpr size_t kVxOff = 0;
|
||||
constexpr size_t kVyOff = kVxOff + 8;
|
||||
constexpr size_t kOmegaOff = kVyOff + 8;
|
||||
} // namespace
|
||||
|
||||
using StructType = wpi::Struct<frc::ChassisSpeeds>;
|
||||
|
||||
frc::ChassisSpeeds StructType::Unpack(std::span<const uint8_t, kSize> data) {
|
||||
return frc::ChassisSpeeds{
|
||||
units::meters_per_second_t{wpi::UnpackStruct<double, kVxOff>(data)},
|
||||
units::meters_per_second_t{wpi::UnpackStruct<double, kVyOff>(data)},
|
||||
units::radians_per_second_t{wpi::UnpackStruct<double, kOmegaOff>(data)},
|
||||
};
|
||||
}
|
||||
|
||||
void StructType::Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::ChassisSpeeds& value) {
|
||||
wpi::PackStruct<kVxOff>(data, value.vx.value());
|
||||
wpi::PackStruct<kVyOff>(data, value.vy.value());
|
||||
wpi::PackStruct<kOmegaOff>(data, value.omega.value());
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/kinematics/struct/DifferentialDriveKinematicsStruct.h"
|
||||
|
||||
namespace {
|
||||
constexpr size_t kTrackWidthOff = 0;
|
||||
} // namespace
|
||||
|
||||
using StructType = wpi::Struct<frc::DifferentialDriveKinematics>;
|
||||
|
||||
frc::DifferentialDriveKinematics StructType::Unpack(
|
||||
std::span<const uint8_t, kSize> data) {
|
||||
return frc::DifferentialDriveKinematics{
|
||||
units::meter_t{wpi::UnpackStruct<double, kTrackWidthOff>(data)},
|
||||
};
|
||||
}
|
||||
|
||||
void StructType::Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::DifferentialDriveKinematics& value) {
|
||||
wpi::PackStruct<kTrackWidthOff>(data, value.trackWidth.value());
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/kinematics/struct/DifferentialDriveWheelSpeedsStruct.h"
|
||||
|
||||
namespace {
|
||||
constexpr size_t kLeftOff = 0;
|
||||
constexpr size_t kRightOff = kLeftOff + 8;
|
||||
} // namespace
|
||||
|
||||
using StructType = wpi::Struct<frc::DifferentialDriveWheelSpeeds>;
|
||||
|
||||
frc::DifferentialDriveWheelSpeeds StructType::Unpack(
|
||||
std::span<const uint8_t, kSize> data) {
|
||||
return frc::DifferentialDriveWheelSpeeds{
|
||||
units::meters_per_second_t{wpi::UnpackStruct<double, kLeftOff>(data)},
|
||||
units::meters_per_second_t{wpi::UnpackStruct<double, kRightOff>(data)},
|
||||
};
|
||||
}
|
||||
|
||||
void StructType::Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::DifferentialDriveWheelSpeeds& value) {
|
||||
wpi::PackStruct<kLeftOff>(data, value.left.value());
|
||||
wpi::PackStruct<kRightOff>(data, value.right.value());
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/kinematics/struct/MecanumDriveKinematicsStruct.h"
|
||||
|
||||
namespace {
|
||||
constexpr size_t kFrontLeftOff = 0;
|
||||
constexpr size_t kFrontRightOff =
|
||||
kFrontLeftOff + wpi::Struct<frc::Translation2d>::kSize;
|
||||
constexpr size_t kRearLeftOff =
|
||||
kFrontRightOff + wpi::Struct<frc::Translation2d>::kSize;
|
||||
constexpr size_t kRearRightOff =
|
||||
kRearLeftOff + wpi::Struct<frc::Translation2d>::kSize;
|
||||
} // namespace
|
||||
|
||||
using StructType = wpi::Struct<frc::MecanumDriveKinematics>;
|
||||
|
||||
frc::MecanumDriveKinematics StructType::Unpack(
|
||||
std::span<const uint8_t, kSize> data) {
|
||||
return frc::MecanumDriveKinematics{
|
||||
wpi::UnpackStruct<frc::Translation2d, kFrontLeftOff>(data),
|
||||
wpi::UnpackStruct<frc::Translation2d, kFrontRightOff>(data),
|
||||
wpi::UnpackStruct<frc::Translation2d, kRearLeftOff>(data),
|
||||
wpi::UnpackStruct<frc::Translation2d, kRearRightOff>(data),
|
||||
};
|
||||
}
|
||||
|
||||
void StructType::Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::MecanumDriveKinematics& value) {
|
||||
wpi::PackStruct<kFrontLeftOff>(data, value.GetFrontLeftWheel());
|
||||
wpi::PackStruct<kFrontRightOff>(data, value.GetFrontRightWheel());
|
||||
wpi::PackStruct<kRearLeftOff>(data, value.GetRearLeftWheel());
|
||||
wpi::PackStruct<kRearRightOff>(data, value.GetRearRightWheel());
|
||||
}
|
||||
|
||||
void StructType::ForEachNested(
|
||||
std::invocable<std::string_view, std::string_view> auto fn) {
|
||||
wpi::ForEachStructSchema<frc::Translation2d>(fn);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/kinematics/struct/MecanumDriveWheelPositionsStruct.h"
|
||||
|
||||
namespace {
|
||||
constexpr size_t kFrontLeftOff = 0;
|
||||
constexpr size_t kFrontRightOff = kFrontLeftOff + 8;
|
||||
constexpr size_t kRearLeftOff = kFrontRightOff + 8;
|
||||
constexpr size_t kRearRightOff = kRearLeftOff + 8;
|
||||
} // namespace
|
||||
|
||||
using StructType = wpi::Struct<frc::MecanumDriveWheelPositions>;
|
||||
|
||||
frc::MecanumDriveWheelPositions StructType::Unpack(
|
||||
std::span<const uint8_t, kSize> data) {
|
||||
return frc::MecanumDriveWheelPositions{
|
||||
units::meter_t{wpi::UnpackStruct<double, kFrontLeftOff>(data)},
|
||||
units::meter_t{wpi::UnpackStruct<double, kFrontRightOff>(data)},
|
||||
units::meter_t{wpi::UnpackStruct<double, kRearLeftOff>(data)},
|
||||
units::meter_t{wpi::UnpackStruct<double, kRearRightOff>(data)},
|
||||
};
|
||||
}
|
||||
|
||||
void StructType::Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::MecanumDriveWheelPositions& value) {
|
||||
wpi::PackStruct<kFrontLeftOff>(data, value.frontLeft.value());
|
||||
wpi::PackStruct<kFrontRightOff>(data, value.frontRight.value());
|
||||
wpi::PackStruct<kRearLeftOff>(data, value.rearLeft.value());
|
||||
wpi::PackStruct<kRearRightOff>(data, value.rearRight.value());
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/kinematics/struct/MecanumDriveWheelSpeedsStruct.h"
|
||||
|
||||
namespace {
|
||||
constexpr size_t kFrontLeftOff = 0;
|
||||
constexpr size_t kFrontRightOff = kFrontLeftOff + 8;
|
||||
constexpr size_t kRearLeftOff = kFrontRightOff + 8;
|
||||
constexpr size_t kRearRightOff = kRearLeftOff + 8;
|
||||
} // namespace
|
||||
|
||||
using StructType = wpi::Struct<frc::MecanumDriveWheelSpeeds>;
|
||||
|
||||
frc::MecanumDriveWheelSpeeds StructType::Unpack(
|
||||
std::span<const uint8_t, kSize> data) {
|
||||
return frc::MecanumDriveWheelSpeeds{
|
||||
units::meters_per_second_t{
|
||||
wpi::UnpackStruct<double, kFrontLeftOff>(data)},
|
||||
units::meters_per_second_t{
|
||||
wpi::UnpackStruct<double, kFrontRightOff>(data)},
|
||||
units::meters_per_second_t{wpi::UnpackStruct<double, kRearLeftOff>(data)},
|
||||
units::meters_per_second_t{
|
||||
wpi::UnpackStruct<double, kRearRightOff>(data)},
|
||||
};
|
||||
}
|
||||
|
||||
void StructType::Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::MecanumDriveWheelSpeeds& value) {
|
||||
wpi::PackStruct<kFrontLeftOff>(data, value.frontLeft.value());
|
||||
wpi::PackStruct<kFrontRightOff>(data, value.frontRight.value());
|
||||
wpi::PackStruct<kRearLeftOff>(data, value.rearLeft.value());
|
||||
wpi::PackStruct<kRearRightOff>(data, value.rearRight.value());
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/kinematics/struct/SwerveModulePositionStruct.h"
|
||||
|
||||
namespace {
|
||||
constexpr size_t kDistanceOff = 0;
|
||||
constexpr size_t kAngleOff = kDistanceOff + 8;
|
||||
} // namespace
|
||||
|
||||
using StructType = wpi::Struct<frc::SwerveModulePosition>;
|
||||
|
||||
frc::SwerveModulePosition StructType::Unpack(
|
||||
std::span<const uint8_t, kSize> data) {
|
||||
return frc::SwerveModulePosition{
|
||||
units::meter_t{wpi::UnpackStruct<double, kDistanceOff>(data)},
|
||||
wpi::UnpackStruct<frc::Rotation2d, kAngleOff>(data),
|
||||
};
|
||||
}
|
||||
|
||||
void StructType::Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::SwerveModulePosition& value) {
|
||||
wpi::PackStruct<kDistanceOff>(data, value.distance.value());
|
||||
wpi::PackStruct<kAngleOff>(data, value.angle);
|
||||
}
|
||||
|
||||
void StructType::ForEachNested(
|
||||
std::invocable<std::string_view, std::string_view> auto fn) {
|
||||
wpi::ForEachStructSchema<frc::Rotation2d>(fn);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/kinematics/struct/SwerveModuleStateStruct.h"
|
||||
|
||||
namespace {
|
||||
constexpr size_t kSpeedOff = 0;
|
||||
constexpr size_t kAngleOff = kSpeedOff + 8;
|
||||
} // namespace
|
||||
|
||||
using StructType = wpi::Struct<frc::SwerveModuleState>;
|
||||
|
||||
frc::SwerveModuleState StructType::Unpack(
|
||||
std::span<const uint8_t, kSize> data) {
|
||||
return frc::SwerveModuleState{
|
||||
units::meters_per_second_t{wpi::UnpackStruct<double, kSpeedOff>(data)},
|
||||
wpi::UnpackStruct<frc::Rotation2d, kAngleOff>(data),
|
||||
};
|
||||
}
|
||||
|
||||
void StructType::Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::SwerveModuleState& value) {
|
||||
wpi::PackStruct<kSpeedOff>(data, value.speed.value());
|
||||
wpi::PackStruct<kAngleOff>(data, value.angle);
|
||||
}
|
||||
|
||||
void StructType::ForEachNested(
|
||||
std::invocable<std::string_view, std::string_view> auto fn) {
|
||||
wpi::ForEachStructSchema<frc::Rotation2d>(fn);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/system/plant/proto/DCMotorProto.h"
|
||||
|
||||
#include "plant.pb.h"
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<frc::DCMotor>::New(
|
||||
google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<wpi::proto::ProtobufDCMotor>(
|
||||
arena);
|
||||
}
|
||||
|
||||
frc::DCMotor wpi::Protobuf<frc::DCMotor>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m = static_cast<const wpi::proto::ProtobufDCMotor*>(&msg);
|
||||
return frc::DCMotor{
|
||||
units::volt_t{m->nominal_voltage()},
|
||||
units::newton_meter_t{m->stall_torque()},
|
||||
units::ampere_t{m->stall_current()},
|
||||
units::ampere_t{m->free_current()},
|
||||
units::radians_per_second_t{m->free_speed()},
|
||||
};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<frc::DCMotor>::Pack(google::protobuf::Message* msg,
|
||||
const frc::DCMotor& value) {
|
||||
auto m = static_cast<wpi::proto::ProtobufDCMotor*>(msg);
|
||||
m->set_nominal_voltage(value.nominalVoltage.value());
|
||||
m->set_stall_torque(value.stallTorque.value());
|
||||
m->set_stall_current(value.stallCurrent.value());
|
||||
m->set_free_current(value.freeCurrent.value());
|
||||
m->set_free_speed(value.freeSpeed.value());
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/system/plant/struct/DCMotorStruct.h"
|
||||
|
||||
namespace {
|
||||
constexpr size_t kNominalVoltageOff = 0;
|
||||
constexpr size_t kStallTorqueOff = kNominalVoltageOff + 8;
|
||||
constexpr size_t kStallCurrentOff = kStallTorqueOff + 8;
|
||||
constexpr size_t kFreeCurrentOff = kStallCurrentOff + 8;
|
||||
constexpr size_t kFreeSpeedOff = kFreeCurrentOff + 8;
|
||||
} // namespace
|
||||
|
||||
using StructType = wpi::Struct<frc::DCMotor>;
|
||||
|
||||
frc::DCMotor StructType::Unpack(std::span<const uint8_t, kSize> data) {
|
||||
return frc::DCMotor{
|
||||
units::volt_t{wpi::UnpackStruct<double, kNominalVoltageOff>(data)},
|
||||
units::newton_meter_t{wpi::UnpackStruct<double, kStallTorqueOff>(data)},
|
||||
units::ampere_t{wpi::UnpackStruct<double, kStallCurrentOff>(data)},
|
||||
units::ampere_t{wpi::UnpackStruct<double, kFreeCurrentOff>(data)},
|
||||
units::radians_per_second_t{
|
||||
wpi::UnpackStruct<double, kFreeSpeedOff>(data)},
|
||||
};
|
||||
}
|
||||
|
||||
void StructType::Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::DCMotor& value) {
|
||||
wpi::PackStruct<kNominalVoltageOff>(data, value.nominalVoltage.value());
|
||||
wpi::PackStruct<kStallTorqueOff>(data, value.stallTorque.value());
|
||||
wpi::PackStruct<kStallCurrentOff>(data, value.stallCurrent.value());
|
||||
wpi::PackStruct<kFreeCurrentOff>(data, value.freeCurrent.value());
|
||||
wpi::PackStruct<kFreeSpeedOff>(data, value.freeSpeed.value());
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/trajectory/proto/TrajectoryProto.h"
|
||||
|
||||
#include "trajectory.pb.h"
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<frc::Trajectory>::New(
|
||||
google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<wpi::proto::ProtobufTrajectory>(
|
||||
arena);
|
||||
}
|
||||
|
||||
frc::Trajectory wpi::Protobuf<frc::Trajectory>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m = static_cast<const wpi::proto::ProtobufTrajectory*>(&msg);
|
||||
std::vector<frc::Trajectory::State> states;
|
||||
states.reserve(m->states().size());
|
||||
for (const auto& protoState : m->states()) {
|
||||
states.push_back(wpi::UnpackProtobuf<frc::Trajectory::State>(protoState));
|
||||
}
|
||||
return frc::Trajectory{states};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<frc::Trajectory>::Pack(google::protobuf::Message* msg,
|
||||
const frc::Trajectory& value) {
|
||||
auto m = static_cast<wpi::proto::ProtobufTrajectory*>(msg);
|
||||
m->mutable_states()->Reserve(value.States().size());
|
||||
for (const auto& state : value.States()) {
|
||||
wpi::PackProtobuf(m->add_states(), state);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/trajectory/proto/TrajectoryStateProto.h"
|
||||
|
||||
#include "trajectory.pb.h"
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<frc::Trajectory::State>::New(
|
||||
google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<
|
||||
wpi::proto::ProtobufTrajectoryState>(arena);
|
||||
}
|
||||
|
||||
frc::Trajectory::State wpi::Protobuf<frc::Trajectory::State>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m = static_cast<const wpi::proto::ProtobufTrajectoryState*>(&msg);
|
||||
return frc::Trajectory::State{
|
||||
units::second_t{m->time()},
|
||||
units::meters_per_second_t{m->velocity()},
|
||||
units::meters_per_second_squared_t{m->acceleration()},
|
||||
wpi::UnpackProtobuf<frc::Pose2d>(m->pose()),
|
||||
units::curvature_t{m->curvature()},
|
||||
};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<frc::Trajectory::State>::Pack(
|
||||
google::protobuf::Message* msg, const frc::Trajectory::State& value) {
|
||||
auto m = static_cast<wpi::proto::ProtobufTrajectoryState*>(msg);
|
||||
m->set_time(value.t.value());
|
||||
m->set_velocity(value.velocity.value());
|
||||
m->set_acceleration(value.acceleration.value());
|
||||
wpi::PackProtobuf(m->mutable_pose(), value.pose);
|
||||
m->set_curvature(value.curvature.value());
|
||||
}
|
||||
@@ -169,3 +169,6 @@ class WPILIB_DLLEXPORT ArmFeedforward {
|
||||
units::unit_t<ka_unit> kA{0};
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/controller/proto/ArmFeedforwardProto.h"
|
||||
#include "frc/controller/struct/ArmFeedforwardStruct.h"
|
||||
|
||||
@@ -17,3 +17,6 @@ struct DifferentialDriveWheelVoltages {
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/controller/proto/DifferentialDriveWheelVoltagesProto.h"
|
||||
#include "frc/controller/struct/DifferentialDriveWheelVoltagesStruct.h"
|
||||
|
||||
@@ -176,3 +176,6 @@ class ElevatorFeedforward {
|
||||
units::unit_t<ka_unit> kA{0};
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/controller/proto/ElevatorFeedforwardProto.h"
|
||||
#include "frc/controller/struct/ElevatorFeedforwardStruct.h"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/controller/ArmFeedforward.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::ArmFeedforward> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::ArmFeedforward Unpack(const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::ArmFeedforward& value);
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/controller/DifferentialDriveWheelVoltages.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::DifferentialDriveWheelVoltages> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::DifferentialDriveWheelVoltages Unpack(
|
||||
const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::DifferentialDriveWheelVoltages& value);
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/controller/ElevatorFeedforward.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::ElevatorFeedforward> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::ElevatorFeedforward Unpack(const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::ElevatorFeedforward& value);
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/controller/ArmFeedforward.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::ArmFeedforward> {
|
||||
static constexpr std::string_view kTypeString = "struct:ArmFeedforward";
|
||||
static constexpr size_t kSize = 32;
|
||||
static constexpr std::string_view kSchema =
|
||||
"double ks;double kg;double kv;double ka";
|
||||
|
||||
static frc::ArmFeedforward Unpack(std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::ArmFeedforward& value);
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/controller/DifferentialDriveWheelVoltages.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::DifferentialDriveWheelVoltages> {
|
||||
static constexpr std::string_view kTypeString =
|
||||
"struct:DifferentialDriveWheelVoltages";
|
||||
static constexpr size_t kSize = 16;
|
||||
static constexpr std::string_view kSchema = "double left;double right";
|
||||
|
||||
static frc::DifferentialDriveWheelVoltages Unpack(
|
||||
std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::DifferentialDriveWheelVoltages& value);
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/controller/ElevatorFeedforward.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::ElevatorFeedforward> {
|
||||
static constexpr std::string_view kTypeString = "struct:ElevatorFeedforward";
|
||||
static constexpr size_t kSize = 32;
|
||||
static constexpr std::string_view kSchema =
|
||||
"double ks;double kg;double kv;double ka";
|
||||
|
||||
static frc::ElevatorFeedforward Unpack(std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::ElevatorFeedforward& value);
|
||||
};
|
||||
@@ -251,3 +251,6 @@ struct WPILIB_DLLEXPORT ChassisSpeeds {
|
||||
}
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/kinematics/proto/ChassisSpeedsProto.h"
|
||||
#include "frc/kinematics/struct/ChassisSpeedsStruct.h"
|
||||
|
||||
@@ -91,3 +91,6 @@ class WPILIB_DLLEXPORT DifferentialDriveKinematics
|
||||
units::meter_t trackWidth;
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/kinematics/proto/DifferentialDriveKinematicsProto.h"
|
||||
#include "frc/kinematics/struct/DifferentialDriveKinematicsStruct.h"
|
||||
|
||||
@@ -112,3 +112,6 @@ struct WPILIB_DLLEXPORT DifferentialDriveWheelSpeeds {
|
||||
}
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/kinematics/proto/DifferentialDriveWheelSpeedsProto.h"
|
||||
#include "frc/kinematics/struct/DifferentialDriveWheelSpeedsStruct.h"
|
||||
|
||||
@@ -138,6 +138,11 @@ class WPILIB_DLLEXPORT MecanumDriveKinematics
|
||||
*/
|
||||
Twist2d ToTwist2d(const MecanumDriveWheelPositions& wheelDeltas) const;
|
||||
|
||||
const Translation2d GetFrontLeftWheel() const { return m_frontLeftWheel; }
|
||||
const Translation2d GetFrontRightWheel() const { return m_frontRightWheel; }
|
||||
const Translation2d GetRearLeftWheel() const { return m_rearLeftWheel; }
|
||||
const Translation2d GetRearRightWheel() const { return m_rearRightWheel; }
|
||||
|
||||
private:
|
||||
mutable Matrixd<4, 3> m_inverseKinematics;
|
||||
Eigen::HouseholderQR<Matrixd<4, 3>> m_forwardKinematics;
|
||||
@@ -165,3 +170,6 @@ class WPILIB_DLLEXPORT MecanumDriveKinematics
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/kinematics/proto/MecanumDriveKinematicsProto.h"
|
||||
#include "frc/kinematics/struct/MecanumDriveKinematicsStruct.h"
|
||||
|
||||
@@ -60,3 +60,6 @@ struct WPILIB_DLLEXPORT MecanumDriveWheelPositions {
|
||||
}
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/kinematics/proto/MecanumDriveWheelPositionsProto.h"
|
||||
#include "frc/kinematics/struct/MecanumDriveWheelPositionsStruct.h"
|
||||
|
||||
@@ -120,3 +120,6 @@ struct WPILIB_DLLEXPORT MecanumDriveWheelSpeeds {
|
||||
}
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/kinematics/proto/MecanumDriveWheelSpeedsProto.h"
|
||||
#include "frc/kinematics/struct/MecanumDriveWheelSpeedsStruct.h"
|
||||
|
||||
@@ -42,3 +42,6 @@ struct WPILIB_DLLEXPORT SwerveModulePosition {
|
||||
}
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/kinematics/proto/SwerveModulePositionProto.h"
|
||||
#include "frc/kinematics/struct/SwerveModulePositionStruct.h"
|
||||
|
||||
@@ -47,3 +47,6 @@ struct WPILIB_DLLEXPORT SwerveModuleState {
|
||||
const Rotation2d& currentAngle);
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/kinematics/proto/SwerveModuleStateProto.h"
|
||||
#include "frc/kinematics/struct/SwerveModuleStateStruct.h"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/kinematics/ChassisSpeeds.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::ChassisSpeeds> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::ChassisSpeeds Unpack(const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::ChassisSpeeds& value);
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/kinematics/DifferentialDriveKinematics.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::DifferentialDriveKinematics> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::DifferentialDriveKinematics Unpack(
|
||||
const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::DifferentialDriveKinematics& value);
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/kinematics/DifferentialDriveWheelSpeeds.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::DifferentialDriveWheelSpeeds> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::DifferentialDriveWheelSpeeds Unpack(
|
||||
const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::DifferentialDriveWheelSpeeds& value);
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/kinematics/MecanumDriveKinematics.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::MecanumDriveKinematics> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::MecanumDriveKinematics Unpack(
|
||||
const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::MecanumDriveKinematics& value);
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/kinematics/MecanumDriveWheelPositions.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::MecanumDriveWheelPositions> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::MecanumDriveWheelPositions Unpack(
|
||||
const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::MecanumDriveWheelPositions& value);
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/kinematics/MecanumDriveWheelSpeeds.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::MecanumDriveWheelSpeeds> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::MecanumDriveWheelSpeeds Unpack(
|
||||
const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::MecanumDriveWheelSpeeds& value);
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/kinematics/SwerveModulePosition.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::SwerveModulePosition> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::SwerveModulePosition Unpack(const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::SwerveModulePosition& value);
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/kinematics/SwerveModuleState.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::SwerveModuleState> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::SwerveModuleState Unpack(const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::SwerveModuleState& value);
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/kinematics/ChassisSpeeds.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::ChassisSpeeds> {
|
||||
static constexpr std::string_view kTypeString = "struct:ChassisSpeeds";
|
||||
static constexpr size_t kSize = 24;
|
||||
static constexpr std::string_view kSchema =
|
||||
"double vx;double vy;double omega";
|
||||
|
||||
static frc::ChassisSpeeds Unpack(std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::ChassisSpeeds& value);
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/kinematics/DifferentialDriveKinematics.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::DifferentialDriveKinematics> {
|
||||
static constexpr std::string_view kTypeString =
|
||||
"struct:DifferentialDriveKinematics";
|
||||
static constexpr size_t kSize = 8;
|
||||
static constexpr std::string_view kSchema = "double track_width";
|
||||
|
||||
static frc::DifferentialDriveKinematics Unpack(
|
||||
std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::DifferentialDriveKinematics& value);
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/kinematics/DifferentialDriveWheelSpeeds.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::DifferentialDriveWheelSpeeds> {
|
||||
static constexpr std::string_view kTypeString =
|
||||
"struct:DifferentialDriveWheelSpeeds";
|
||||
static constexpr size_t kSize = 16;
|
||||
static constexpr std::string_view kSchema = "double left;double right";
|
||||
|
||||
static frc::DifferentialDriveWheelSpeeds Unpack(
|
||||
std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::DifferentialDriveWheelSpeeds& value);
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/kinematics/MecanumDriveKinematics.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::MecanumDriveKinematics> {
|
||||
static constexpr std::string_view kTypeString =
|
||||
"struct:MecanumDriveKinematics";
|
||||
static constexpr size_t kSize = 4 * wpi::Struct<frc::Translation2d>::kSize;
|
||||
static constexpr std::string_view kSchema =
|
||||
"Translation2d front_left;Translation2d front_right;Translation2d "
|
||||
"rear_left;Translation2d rear_right";
|
||||
|
||||
static frc::MecanumDriveKinematics Unpack(
|
||||
std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::MecanumDriveKinematics& value);
|
||||
static void ForEachNested(
|
||||
std::invocable<std::string_view, std::string_view> auto fn);
|
||||
};
|
||||
|
||||
static_assert(wpi::HasNestedStruct<frc::MecanumDriveKinematics>);
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/kinematics/MecanumDriveWheelPositions.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::MecanumDriveWheelPositions> {
|
||||
static constexpr std::string_view kTypeString =
|
||||
"struct:MecanumDriveWheelPositions";
|
||||
static constexpr size_t kSize = 32;
|
||||
static constexpr std::string_view kSchema =
|
||||
"double front_left;double front_right;double rear_left;double rear_right";
|
||||
|
||||
static frc::MecanumDriveWheelPositions Unpack(
|
||||
std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::MecanumDriveWheelPositions& value);
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/kinematics/MecanumDriveWheelSpeeds.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::MecanumDriveWheelSpeeds> {
|
||||
static constexpr std::string_view kTypeString =
|
||||
"struct:MecanumDriveWheelSpeeds";
|
||||
static constexpr size_t kSize = 32;
|
||||
static constexpr std::string_view kSchema =
|
||||
"double front_left;double front_right;double rear_left;double rear_right";
|
||||
|
||||
static frc::MecanumDriveWheelSpeeds Unpack(
|
||||
std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::MecanumDriveWheelSpeeds& value);
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/kinematics/SwerveModulePosition.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::SwerveModulePosition> {
|
||||
static constexpr std::string_view kTypeString = "struct:SwerveModulePosition";
|
||||
static constexpr size_t kSize = 8 + wpi::Struct<frc::Rotation2d>::kSize;
|
||||
static constexpr std::string_view kSchema =
|
||||
"double distance;Rotation2d angle";
|
||||
|
||||
static frc::SwerveModulePosition Unpack(std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::SwerveModulePosition& value);
|
||||
static void ForEachNested(
|
||||
std::invocable<std::string_view, std::string_view> auto fn);
|
||||
};
|
||||
|
||||
static_assert(wpi::HasNestedStruct<frc::SwerveModulePosition>);
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/kinematics/SwerveModuleState.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::SwerveModuleState> {
|
||||
static constexpr std::string_view kTypeString = "struct:SwerveModuleState";
|
||||
static constexpr size_t kSize = 8 + wpi::Struct<frc::Rotation2d>::kSize;
|
||||
static constexpr std::string_view kSchema = "double speed;Rotation2d angle";
|
||||
|
||||
static frc::SwerveModuleState Unpack(std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::SwerveModuleState& value);
|
||||
static void ForEachNested(
|
||||
std::invocable<std::string_view, std::string_view> auto fn);
|
||||
};
|
||||
|
||||
static_assert(wpi::HasNestedStruct<frc::SwerveModuleState>);
|
||||
@@ -239,3 +239,6 @@ class WPILIB_DLLEXPORT DCMotor {
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/system/plant/proto/DCMotorProto.h"
|
||||
#include "frc/system/plant/struct/DCMotorStruct.h"
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/system/plant/DCMotor.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::DCMotor> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::DCMotor Unpack(const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg, const frc::DCMotor& value);
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user