mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
[wpimath] Move math functionality into new wpimath library (#2629)
The wpimath library is a new library designed to separate the reusable math functionality from the common utility library (wpiutil) and the hardware-dependent library (wpilibc/j). Package names / include file names were NOT changed to minimize breakage. In a future year it would be good to revamp these for a more uniform user experience and to reduce the risk of accidental naming conflicts. While theoretically all of this functionality could be placed into wpiutil, several pieces of this library (e.g. DARE) are very time-consuming to compile, so it's nice to avoid this expense for users who only want cscore or ntcore. It also allows for easy future separation of build tasks vs number of workers on memory-constrained machines. This moves the following functionality from wpiutil into wpimath: - Eigen - ejml - Drake - DARE - wpiutil.math package (Matrix etc) - units And the following functionality from wpilibc/j into wpimath: - Geometry - Kinematics - Spline - Trajectory - LinearFilter - MedianFilter - Feed-forward controllers
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -22,6 +22,9 @@ import edu.wpi.first.hal.FRCNetComm.tInstances;
|
||||
import edu.wpi.first.hal.FRCNetComm.tResourceType;
|
||||
import edu.wpi.first.hal.HAL;
|
||||
import edu.wpi.first.hal.HALUtil;
|
||||
import edu.wpi.first.math.MathShared;
|
||||
import edu.wpi.first.math.MathSharedStore;
|
||||
import edu.wpi.first.math.MathUsageId;
|
||||
import edu.wpi.first.networktables.NetworkTableInstance;
|
||||
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
|
||||
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
||||
@@ -78,6 +81,53 @@ public abstract class RobotBase implements AutoCloseable {
|
||||
CameraServerSharedStore.setCameraServerShared(shared);
|
||||
}
|
||||
|
||||
private static void setupMathShared() {
|
||||
MathSharedStore.setMathShared(new MathShared() {
|
||||
@Override
|
||||
public void reportError(String error, StackTraceElement[] stackTrace) {
|
||||
DriverStation.reportError(error, stackTrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportUsage(MathUsageId id, int count) {
|
||||
switch (id) {
|
||||
case kKinematics_DifferentialDrive:
|
||||
HAL.report(tResourceType.kResourceType_Kinematics,
|
||||
tInstances.kKinematics_DifferentialDrive);
|
||||
break;
|
||||
case kKinematics_MecanumDrive:
|
||||
HAL.report(tResourceType.kResourceType_Kinematics,
|
||||
tInstances.kKinematics_MecanumDrive);
|
||||
break;
|
||||
case kKinematics_SwerveDrive:
|
||||
HAL.report(tResourceType.kResourceType_Kinematics,
|
||||
tInstances.kKinematics_SwerveDrive);
|
||||
break;
|
||||
case kTrajectory_TrapezoidProfile:
|
||||
HAL.report(tResourceType.kResourceType_TrapezoidProfile, count);
|
||||
break;
|
||||
case kFilter_Linear:
|
||||
HAL.report(tResourceType.kResourceType_LinearFilter, count);
|
||||
break;
|
||||
case kOdometry_DifferentialDrive:
|
||||
HAL.report(tResourceType.kResourceType_Odometry,
|
||||
tInstances.kOdometry_DifferentialDrive);
|
||||
break;
|
||||
case kOdometry_SwerveDrive:
|
||||
HAL.report(tResourceType.kResourceType_Odometry,
|
||||
tInstances.kOdometry_SwerveDrive);
|
||||
break;
|
||||
case kOdometry_MecanumDrive:
|
||||
HAL.report(tResourceType.kResourceType_Odometry,
|
||||
tInstances.kOdometry_MecanumDrive);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected final DriverStation m_ds;
|
||||
|
||||
/**
|
||||
@@ -90,9 +140,10 @@ public abstract class RobotBase implements AutoCloseable {
|
||||
* to put this code into it's own task that loads on boot so ensure that it runs.
|
||||
*/
|
||||
protected RobotBase() {
|
||||
NetworkTableInstance inst = NetworkTableInstance.getDefault();
|
||||
final NetworkTableInstance inst = NetworkTableInstance.getDefault();
|
||||
m_threadId = Thread.currentThread().getId();
|
||||
setupCameraServerShared();
|
||||
setupMathShared();
|
||||
inst.setNetworkIdentity("Robot");
|
||||
if (isReal()) {
|
||||
inst.startServer("/home/lvuser/networktables.ini");
|
||||
|
||||
Reference in New Issue
Block a user