[wpimath] Explicitly export wpimath symbols

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
This commit is contained in:
Thad House
2021-08-20 09:02:01 -07:00
committed by Peter Johnson
parent 161e211734
commit 382deef750
54 changed files with 207 additions and 101 deletions

View File

@@ -8,7 +8,7 @@ macro(wpilib_add_test name srcdir)
target_compile_definitions(${name}_test PRIVATE -DGTEST_LINKED_AS_SHARED_LIBRARY)
endif()
if (MSVC)
target_compile_options(${name}_test PRIVATE /wd4251 /wd4101)
target_compile_options(${name}_test PRIVATE /wd4101 /wd4251)
endif()
add_test(NAME ${name} COMMAND ${name}_test)
endmacro()

View File

@@ -2,6 +2,6 @@ macro(wpilib_target_warnings target)
if(NOT MSVC)
target_compile_options(${target} PRIVATE -Wall -pedantic -Wextra -Werror -Wno-unused-parameter -Wno-error=deprecated-declarations)
else()
target_compile_options(${target} PRIVATE /wd4244 /wd4267 /wd4146 /WX /wd4996)
target_compile_options(${target} PRIVATE /wd4146 /wd4244 /wd4251 /wd4267 /wd4996 /WX)
endif()
endmacro()

View File

@@ -59,6 +59,8 @@ model {
it.buildable = false
return
}
it.cppCompiler.define 'WPILIB_EXPORTS'
it.cCompiler.define 'WPILIB_EXPORTS'
if (!project.hasProperty('noWpiutil')) {
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
}

View File

@@ -92,10 +92,13 @@ endif()
file(GLOB_RECURSE wpimath_native_src src/main/native/cpp/*.cpp)
list(REMOVE_ITEM wpimath_native_src ${wpimath_jni_src})
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS FALSE)
add_library(wpimath ${wpimath_native_src})
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
set_target_properties(wpimath PROPERTIES DEBUG_POSTFIX "d")
set_property(TARGET wpimath PROPERTY FOLDER "libraries")
target_compile_definitions(wpimath PRIVATE WPILIB_EXPORTS)
target_compile_features(wpimath PUBLIC cxx_std_17)
if (MSVC)

View File

@@ -13,37 +13,6 @@ ext {
apply from: "${rootDir}/shared/jni/setupBuild.gradle"
nativeUtils.exportsConfigs {
wpimath {
x86ExcludeSymbols = [
'_CT??_R0?AV_System_error',
'_CT??_R0?AVexception',
'_CT??_R0?AVfailure',
'_CT??_R0?AVruntime_error',
'_CT??_R0?AVsystem_error',
'_CTA5?AVfailure',
'_TI5?AVfailure',
'_CT??_R0?AVout_of_range',
'_CTA3?AVout_of_range',
'_TI3?AVout_of_range',
'_CT??_R0?AVbad_cast'
]
x64ExcludeSymbols = [
'_CT??_R0?AV_System_error',
'_CT??_R0?AVexception',
'_CT??_R0?AVfailure',
'_CT??_R0?AVruntime_error',
'_CT??_R0?AVsystem_error',
'_CTA5?AVfailure',
'_TI5?AVfailure',
'_CT??_R0?AVout_of_range',
'_CTA3?AVout_of_range',
'_TI3?AVout_of_range',
'_CT??_R0?AVbad_cast'
]
}
}
cppHeadersZip {
from('src/main/native/eigeninclude') {
into '/'

View File

@@ -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/trajectory/constraint/MaxVelocityConstraint.h"
using namespace frc;
MaxVelocityConstraint::MaxVelocityConstraint(
units::meters_per_second_t maxVelocity)
: m_maxVelocity(units::math::abs(maxVelocity)) {}
units::meters_per_second_t MaxVelocityConstraint::MaxVelocity(
const Pose2d& pose, units::curvature_t curvature,
units::meters_per_second_t velocity) const {
return m_maxVelocity;
}
TrajectoryConstraint::MinMax MaxVelocityConstraint::MinMaxAcceleration(
const Pose2d& pose, units::curvature_t curvature,
units::meters_per_second_t speed) const {
return {};
}

View File

@@ -4,6 +4,7 @@
#include <cstdlib>
#include <Eigen/Core>
#include <wpi/SymbolExports.h>
namespace drake {
namespace math {
@@ -20,6 +21,7 @@ namespace math {
/// "On the Numerical Solution of the Discrete-Time Algebraic Riccati Equation"
/// by Thrasyvoulos Pappas, Alan J. Laub, and Nils R. Sandell
///
WPILIB_DLLEXPORT
Eigen::MatrixXd DiscreteAlgebraicRiccatiEquation(
const Eigen::Ref<const Eigen::MatrixXd>& A,
const Eigen::Ref<const Eigen::MatrixXd>& B,
@@ -69,6 +71,7 @@ Eigen::MatrixXd DiscreteAlgebraicRiccatiEquation(
/// @throws std::runtime_error if Q NR⁻¹Nᵀ is not positive semi-definite.
/// @throws std::runtime_error if R is not positive definite.
///
WPILIB_DLLEXPORT
Eigen::MatrixXd DiscreteAlgebraicRiccatiEquation(
const Eigen::Ref<const Eigen::MatrixXd>& A,
const Eigen::Ref<const Eigen::MatrixXd>& B,

View File

@@ -4,6 +4,7 @@
#pragma once
#include <wpi/SymbolExports.h>
#include <wpi/numbers>
#include "units/angle.h"
@@ -17,6 +18,7 @@ namespace frc {
* @param value Value to clip.
* @param deadband Range around zero.
*/
WPILIB_DLLEXPORT
double ApplyDeadband(double value, double deadband);
/**
@@ -46,6 +48,7 @@ constexpr T InputModulus(T input, T minimumInput, T maximumInput) {
*
* @param angle Angle to wrap.
*/
WPILIB_DLLEXPORT
constexpr units::radian_t AngleModulus(units::radian_t angle) {
return InputModulus<units::radian_t>(angle,
units::radian_t{-wpi::numbers::pi},

View File

@@ -9,6 +9,8 @@
#include <random>
#include <type_traits>
#include <wpi/SymbolExports.h>
#include "Eigen/Core"
#include "Eigen/Eigenvalues"
#include "Eigen/QR"
@@ -236,6 +238,7 @@ Eigen::Matrix<double, N, 1> MakeWhiteNoiseVector(
*
* @return The vector.
*/
WPILIB_DLLEXPORT
Eigen::Matrix<double, 3, 1> PoseTo3dVector(const Pose2d& pose);
/**
@@ -245,6 +248,7 @@ Eigen::Matrix<double, 3, 1> PoseTo3dVector(const Pose2d& pose);
*
* @return The vector.
*/
WPILIB_DLLEXPORT
Eigen::Matrix<double, 4, 1> PoseTo4dVector(const Pose2d& pose);
/**
@@ -266,14 +270,14 @@ bool IsStabilizable(const Eigen::Matrix<double, States, States>& A,
// Template specializations are used here to make common state-input pairs
// compile faster.
template <>
bool IsStabilizable<1, 1>(const Eigen::Matrix<double, 1, 1>& A,
const Eigen::Matrix<double, 1, 1>& B);
WPILIB_DLLEXPORT bool IsStabilizable<1, 1>(
const Eigen::Matrix<double, 1, 1>& A, const Eigen::Matrix<double, 1, 1>& B);
// Template specializations are used here to make common state-input pairs
// compile faster.
template <>
bool IsStabilizable<2, 1>(const Eigen::Matrix<double, 2, 2>& A,
const Eigen::Matrix<double, 2, 1>& B);
WPILIB_DLLEXPORT bool IsStabilizable<2, 1>(
const Eigen::Matrix<double, 2, 2>& A, const Eigen::Matrix<double, 2, 1>& B);
/**
* Converts a Pose2d into a vector of [x, y, theta].
@@ -282,6 +286,7 @@ bool IsStabilizable<2, 1>(const Eigen::Matrix<double, 2, 2>& A,
*
* @return The vector.
*/
WPILIB_DLLEXPORT
Eigen::Matrix<double, 3, 1> PoseToVector(const Pose2d& pose);
/**

View File

@@ -5,6 +5,7 @@
#pragma once
#include <wpi/MathExtras.h>
#include <wpi/SymbolExports.h>
#include "units/angle.h"
#include "units/angular_velocity.h"
@@ -16,7 +17,7 @@ namespace frc {
* 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).
*/
class ArmFeedforward {
class WPILIB_DLLEXPORT ArmFeedforward {
public:
using Angle = units::radians;
using Velocity = units::radians_per_second;

View File

@@ -4,6 +4,8 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "frc/controller/PIDController.h"
#include "frc/controller/ProfiledPIDController.h"
#include "frc/geometry/Pose2d.h"
@@ -27,7 +29,7 @@ namespace frc {
* translations, users can specify a custom heading that the drivetrain should
* point toward. This heading reference is profiled for smoothness.
*/
class HolonomicDriveController {
class WPILIB_DLLEXPORT HolonomicDriveController {
public:
/**
* Constructs a holonomic drive controller.

View File

@@ -4,6 +4,7 @@
#pragma once
#include <wpi/SymbolExports.h>
#include <wpi/array.h>
#include "Eigen/Cholesky"
@@ -321,7 +322,7 @@ class LinearQuadraticRegulator
// Template specializations are used here to make common state-input pairs
// compile faster.
template <>
class LinearQuadraticRegulator<1, 1>
class WPILIB_DLLEXPORT LinearQuadraticRegulator<1, 1>
: public detail::LinearQuadraticRegulatorImpl<1, 1> {
public:
template <int Outputs>
@@ -357,7 +358,7 @@ class LinearQuadraticRegulator<1, 1>
// Template specializations are used here to make common state-input pairs
// compile faster.
template <>
class LinearQuadraticRegulator<2, 1>
class WPILIB_DLLEXPORT LinearQuadraticRegulator<2, 1>
: public detail::LinearQuadraticRegulatorImpl<2, 1> {
public:
template <int Outputs>
@@ -393,7 +394,7 @@ class LinearQuadraticRegulator<2, 1>
// Template specializations are used here to make common state-input pairs
// compile faster.
template <>
class LinearQuadraticRegulator<2, 2>
class WPILIB_DLLEXPORT LinearQuadraticRegulator<2, 2>
: public detail::LinearQuadraticRegulatorImpl<2, 2> {
public:
template <int Outputs>

View File

@@ -7,6 +7,7 @@
#include <functional>
#include <limits>
#include <wpi/SymbolExports.h>
#include <wpi/sendable/Sendable.h>
#include <wpi/sendable/SendableHelper.h>
@@ -17,8 +18,9 @@ namespace frc2 {
/**
* Implements a PID control loop.
*/
class PIDController : public wpi::Sendable,
public wpi::SendableHelper<PIDController> {
class WPILIB_DLLEXPORT PIDController
: public wpi::Sendable,
public wpi::SendableHelper<PIDController> {
public:
/**
* Allocates a PIDController with the given constants for Kp, Ki, and Kd.

View File

@@ -9,6 +9,7 @@
#include <functional>
#include <limits>
#include <wpi/SymbolExports.h>
#include <wpi/sendable/Sendable.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableHelper.h>
@@ -20,6 +21,7 @@
namespace frc {
namespace detail {
WPILIB_DLLEXPORT
void ReportProfiledPIDController();
} // namespace detail

View File

@@ -4,6 +4,8 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "frc/geometry/Pose2d.h"
#include "frc/kinematics/ChassisSpeeds.h"
#include "frc/trajectory/Trajectory.h"
@@ -39,7 +41,7 @@ namespace frc {
* See <https://file.tavsys.net/control/controls-engineering-in-frc.pdf> section
* on Ramsete unicycle controller for a derivation and analysis.
*/
class RamseteController {
class WPILIB_DLLEXPORT RamseteController {
public:
/**
* Construct a Ramsete unicycle controller.

View File

@@ -4,6 +4,7 @@
#pragma once
#include <wpi/SymbolExports.h>
#include <wpi/array.h>
#include "Eigen/Core"
@@ -44,7 +45,7 @@ namespace frc {
* <strong>y = [[x, y, theta]]ᵀ </strong> from vision,
* or <strong>y = [[dist_l, dist_r, theta]] </strong> from encoders and gyro.
*/
class DifferentialDrivePoseEstimator {
class WPILIB_DLLEXPORT DifferentialDrivePoseEstimator {
public:
/**
* Constructs a DifferentialDrivePoseEstimator.

View File

@@ -6,6 +6,7 @@
#include <cmath>
#include <wpi/SymbolExports.h>
#include <wpi/array.h>
#include "Eigen/Cholesky"
@@ -209,7 +210,8 @@ class KalmanFilter : public detail::KalmanFilterImpl<States, Inputs, Outputs> {
// Template specializations are used here to make common state-input-output
// triplets compile faster.
template <>
class KalmanFilter<1, 1, 1> : public detail::KalmanFilterImpl<1, 1, 1> {
class WPILIB_DLLEXPORT KalmanFilter<1, 1, 1>
: public detail::KalmanFilterImpl<1, 1, 1> {
public:
KalmanFilter(LinearSystem<1, 1, 1>& plant,
const wpi::array<double, 1>& stateStdDevs,
@@ -223,7 +225,8 @@ class KalmanFilter<1, 1, 1> : public detail::KalmanFilterImpl<1, 1, 1> {
// Template specializations are used here to make common state-input-output
// triplets compile faster.
template <>
class KalmanFilter<2, 1, 1> : public detail::KalmanFilterImpl<2, 1, 1> {
class WPILIB_DLLEXPORT KalmanFilter<2, 1, 1>
: public detail::KalmanFilterImpl<2, 1, 1> {
public:
KalmanFilter(LinearSystem<2, 1, 1>& plant,
const wpi::array<double, 2>& stateStdDevs,

View File

@@ -6,6 +6,7 @@
#include <functional>
#include <wpi/SymbolExports.h>
#include <wpi/array.h>
#include "Eigen/Core"
@@ -42,7 +43,7 @@ namespace frc {
* coords from vision, or <strong> y = [[theta]]ᵀ
* </strong> from the gyro.
*/
class MecanumDrivePoseEstimator {
class WPILIB_DLLEXPORT MecanumDrivePoseEstimator {
public:
/**
* Constructs a MecanumDrivePoseEstimator.

View File

@@ -4,6 +4,8 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "Transform2d.h"
#include "Translation2d.h"
#include "Twist2d.h"
@@ -17,7 +19,7 @@ namespace frc {
/**
* Represents a 2d pose containing translational and rotational elements.
*/
class Pose2d {
class WPILIB_DLLEXPORT Pose2d {
public:
/**
* Constructs a pose at the origin facing toward the positive X axis.
@@ -171,8 +173,10 @@ class Pose2d {
Rotation2d m_rotation;
};
WPILIB_DLLEXPORT
void to_json(wpi::json& json, const Pose2d& pose);
WPILIB_DLLEXPORT
void from_json(const wpi::json& json, Pose2d& pose);
} // namespace frc

View File

@@ -4,6 +4,8 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "units/angle.h"
namespace wpi {
@@ -16,7 +18,7 @@ namespace frc {
* A rotation in a 2d coordinate frame represented a point on the unit circle
* (cosine and sine).
*/
class Rotation2d {
class WPILIB_DLLEXPORT Rotation2d {
public:
/**
* Constructs a Rotation2d with a default angle of 0 degrees.
@@ -160,8 +162,10 @@ class Rotation2d {
double m_sin = 0;
};
WPILIB_DLLEXPORT
void to_json(wpi::json& json, const Rotation2d& rotation);
WPILIB_DLLEXPORT
void from_json(const wpi::json& json, Rotation2d& rotation);
} // namespace frc

View File

@@ -4,16 +4,18 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "Translation2d.h"
namespace frc {
class Pose2d;
class WPILIB_DLLEXPORT Pose2d;
/**
* Represents a transformation for a Pose2d.
*/
class Transform2d {
class WPILIB_DLLEXPORT Transform2d {
public:
/**
* Constructs the transform that maps the initial pose to the final pose.

View File

@@ -4,6 +4,8 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "Rotation2d.h"
#include "units/length.h"
@@ -21,7 +23,7 @@ namespace frc {
* When the robot is placed on the origin, facing toward the X direction,
* moving forward increases the X, whereas moving to the left increases the Y.
*/
class Translation2d {
class WPILIB_DLLEXPORT Translation2d {
public:
/**
* Constructs a Translation2d with X and Y components equal to zero.
@@ -175,8 +177,10 @@ class Translation2d {
units::meter_t m_y = 0_m;
};
WPILIB_DLLEXPORT
void to_json(wpi::json& json, const Translation2d& state);
WPILIB_DLLEXPORT
void from_json(const wpi::json& json, Translation2d& state);
} // namespace frc

View File

@@ -4,6 +4,8 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "units/angle.h"
#include "units/length.h"
#include "units/math.h"
@@ -16,7 +18,7 @@ namespace frc {
*
* A Twist can be used to represent a difference between two poses.
*/
struct Twist2d {
struct WPILIB_DLLEXPORT Twist2d {
/**
* Linear "dx" component
*/

View File

@@ -4,6 +4,8 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "frc/geometry/Rotation2d.h"
#include "units/angular_velocity.h"
#include "units/velocity.h"
@@ -20,7 +22,7 @@ namespace frc {
* never have a dy component because it can never move sideways. Holonomic
* drivetrains such as swerve and mecanum will often have all three components.
*/
struct ChassisSpeeds {
struct WPILIB_DLLEXPORT ChassisSpeeds {
/**
* Represents forward velocity w.r.t the robot frame of reference. (Fwd is +)
*/

View File

@@ -4,6 +4,8 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "frc/kinematics/ChassisSpeeds.h"
#include "frc/kinematics/DifferentialDriveWheelSpeeds.h"
#include "units/angle.h"
@@ -19,7 +21,7 @@ namespace frc {
* velocity components whereas forward kinematics converts left and right
* component velocities into a linear and angular chassis speed.
*/
class DifferentialDriveKinematics {
class WPILIB_DLLEXPORT DifferentialDriveKinematics {
public:
/**
* Constructs a differential drive kinematics object.

View File

@@ -4,6 +4,8 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "DifferentialDriveKinematics.h"
#include "frc/geometry/Pose2d.h"
#include "units/length.h"
@@ -21,7 +23,7 @@ namespace frc {
* It is important that you reset your encoders to zero before using this class.
* Any subsequent pose resets also require the encoders to be reset to zero.
*/
class DifferentialDriveOdometry {
class WPILIB_DLLEXPORT DifferentialDriveOdometry {
public:
/**
* Constructs a DifferentialDriveOdometry object.

View File

@@ -4,13 +4,15 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "units/velocity.h"
namespace frc {
/**
* Represents the wheel speeds for a differential drive drivetrain.
*/
struct DifferentialDriveWheelSpeeds {
struct WPILIB_DLLEXPORT DifferentialDriveWheelSpeeds {
/**
* Speed of the left side of the robot.
*/

View File

@@ -4,6 +4,8 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "Eigen/Core"
#include "Eigen/QR"
#include "frc/geometry/Translation2d.h"
@@ -35,7 +37,7 @@ namespace frc {
* Forward kinematics is also used for odometry -- determining the position of
* the robot on the field using encoders and a gyro.
*/
class MecanumDriveKinematics {
class WPILIB_DLLEXPORT MecanumDriveKinematics {
public:
/**
* Constructs a mecanum drive kinematics object.

View File

@@ -4,6 +4,7 @@
#pragma once
#include <wpi/SymbolExports.h>
#include <wpi/timestamp.h>
#include "frc/geometry/Pose2d.h"
@@ -22,7 +23,7 @@ namespace frc {
* path following. Furthermore, odometry can be used for latency compensation
* when using computer-vision systems.
*/
class MecanumDriveOdometry {
class WPILIB_DLLEXPORT MecanumDriveOdometry {
public:
/**
* Constructs a MecanumDriveOdometry object.

View File

@@ -4,13 +4,15 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "units/velocity.h"
namespace frc {
/**
* Represents the wheel speeds for a mecanum drive drivetrain.
*/
struct MecanumDriveWheelSpeeds {
struct WPILIB_DLLEXPORT MecanumDriveWheelSpeeds {
/**
* Speed of the front-left wheel.
*/

View File

@@ -4,6 +4,8 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "frc/geometry/Rotation2d.h"
#include "units/angle.h"
#include "units/math.h"
@@ -13,7 +15,7 @@ namespace frc {
/**
* Represents the state of one swerve module.
*/
struct SwerveModuleState {
struct WPILIB_DLLEXPORT SwerveModuleState {
/**
* Speed of the wheel of the module.
*/

View File

@@ -4,6 +4,7 @@
#pragma once
#include <wpi/SymbolExports.h>
#include <wpi/array.h>
#include "Eigen/Core"
@@ -13,7 +14,7 @@ namespace frc {
/**
* Represents a hermite spline of degree 3.
*/
class CubicHermiteSpline : public Spline<3> {
class WPILIB_DLLEXPORT CubicHermiteSpline : public Spline<3> {
public:
/**
* Constructs a cubic hermite spline with the specified control vectors. Each

View File

@@ -4,6 +4,7 @@
#pragma once
#include <wpi/SymbolExports.h>
#include <wpi/array.h>
#include "Eigen/Core"
@@ -13,7 +14,7 @@ namespace frc {
/**
* Represents a hermite spline of degree 5.
*/
class QuinticHermiteSpline : public Spline<5> {
class WPILIB_DLLEXPORT QuinticHermiteSpline : public Spline<5> {
public:
/**
* Constructs a quintic hermite spline with the specified control vectors.

View File

@@ -7,6 +7,7 @@
#include <utility>
#include <vector>
#include <wpi/SymbolExports.h>
#include <wpi/array.h>
#include "frc/spline/CubicHermiteSpline.h"
@@ -17,7 +18,7 @@ namespace frc {
* Helper class that is used to generate cubic and quintic splines from user
* provided waypoints.
*/
class SplineHelper {
class WPILIB_DLLEXPORT SplineHelper {
public:
/**
* Returns 2 cubic control vectors from a set of exterior waypoints and

View File

@@ -33,6 +33,8 @@
#include <utility>
#include <vector>
#include <wpi/SymbolExports.h>
#include "frc/spline/Spline.h"
#include "units/angle.h"
#include "units/curvature.h"
@@ -44,7 +46,7 @@ namespace frc {
/**
* Class used to parameterize a spline by its arc length.
*/
class SplineParameterizer {
class WPILIB_DLLEXPORT SplineParameterizer {
public:
using PoseWithCurvature = std::pair<Pose2d, units::curvature_t>;

View File

@@ -4,6 +4,8 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "units/angular_velocity.h"
#include "units/current.h"
#include "units/impedance.h"
@@ -15,7 +17,7 @@ namespace frc {
/**
* Holds the constants for a DC motor.
*/
class DCMotor {
class WPILIB_DLLEXPORT DCMotor {
public:
using radians_per_second_per_volt_t =
units::unit_t<units::compound_unit<units::radians_per_second,

View File

@@ -4,7 +4,8 @@
#pragma once
#include "frc/StateSpaceUtil.h"
#include <wpi/SymbolExports.h>
#include "frc/system/LinearSystem.h"
#include "frc/system/plant/DCMotor.h"
#include "units/acceleration.h"
@@ -16,7 +17,7 @@
#include "units/voltage.h"
namespace frc {
class LinearSystemId {
class WPILIB_DLLEXPORT LinearSystemId {
public:
template <typename Distance>
using Velocity_t = units::unit_t<

View File

@@ -6,6 +6,8 @@
#include <vector>
#include <wpi/SymbolExports.h>
#include "frc/geometry/Pose2d.h"
#include "frc/geometry/Transform2d.h"
#include "units/acceleration.h"
@@ -23,12 +25,12 @@ namespace frc {
* various States that represent the pose, curvature, time elapsed, velocity,
* and acceleration at that point.
*/
class Trajectory {
class WPILIB_DLLEXPORT Trajectory {
public:
/**
* Represents one point on the trajectory.
*/
struct State {
struct WPILIB_DLLEXPORT State {
// The time elapsed since the beginning of the trajectory.
units::second_t t = 0_s;
@@ -171,8 +173,10 @@ class Trajectory {
}
};
WPILIB_DLLEXPORT
void to_json(wpi::json& json, const Trajectory::State& state);
WPILIB_DLLEXPORT
void from_json(const wpi::json& json, Trajectory::State& state);
} // namespace frc

View File

@@ -8,6 +8,8 @@
#include <utility>
#include <vector>
#include <wpi/SymbolExports.h>
#include "frc/kinematics/DifferentialDriveKinematics.h"
#include "frc/kinematics/MecanumDriveKinematics.h"
#include "frc/kinematics/SwerveDriveKinematics.h"
@@ -29,7 +31,7 @@ namespace frc {
* have been defaulted to reasonable values (0, 0, {}, false). These values can
* be changed via the SetXXX methods.
*/
class TrajectoryConfig {
class WPILIB_DLLEXPORT TrajectoryConfig {
public:
/**
* Constructs a config object.

View File

@@ -9,6 +9,8 @@
#include <utility>
#include <vector>
#include <wpi/SymbolExports.h>
#include "frc/spline/SplineParameterizer.h"
#include "frc/trajectory/Trajectory.h"
#include "frc/trajectory/TrajectoryConfig.h"
@@ -19,7 +21,7 @@ namespace frc {
/**
* Helper class used to generate trajectories with various constraints.
*/
class TrajectoryGenerator {
class WPILIB_DLLEXPORT TrajectoryGenerator {
public:
using PoseWithCurvature = std::pair<Pose2d, units::curvature_t>;

View File

@@ -32,6 +32,8 @@
#include <utility>
#include <vector>
#include <wpi/SymbolExports.h>
#include "frc/trajectory/Trajectory.h"
#include "frc/trajectory/constraint/TrajectoryConstraint.h"
@@ -39,7 +41,7 @@ namespace frc {
/**
* Class used to parameterize a trajectory by time.
*/
class TrajectoryParameterizer {
class WPILIB_DLLEXPORT TrajectoryParameterizer {
public:
using PoseWithCurvature = std::pair<Pose2d, units::curvature_t>;

View File

@@ -7,10 +7,12 @@
#include <string>
#include <string_view>
#include <wpi/SymbolExports.h>
#include "frc/trajectory/Trajectory.h"
namespace frc {
class TrajectoryUtil {
class WPILIB_DLLEXPORT TrajectoryUtil {
public:
TrajectoryUtil() = delete;

View File

@@ -4,6 +4,8 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "frc/trajectory/constraint/TrajectoryConstraint.h"
#include "units/acceleration.h"
#include "units/curvature.h"
@@ -20,7 +22,8 @@ namespace frc {
* robot to slow down around tight turns, making it easier to track trajectories
* with sharp turns.
*/
class CentripetalAccelerationConstraint : public TrajectoryConstraint {
class WPILIB_DLLEXPORT CentripetalAccelerationConstraint
: public TrajectoryConstraint {
public:
explicit CentripetalAccelerationConstraint(
units::meters_per_second_squared_t maxCentripetalAcceleration);

View File

@@ -4,6 +4,8 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "frc/kinematics/DifferentialDriveKinematics.h"
#include "frc/trajectory/constraint/TrajectoryConstraint.h"
#include "units/velocity.h"
@@ -15,7 +17,8 @@ namespace frc {
* commanded velocities for both sides of the drivetrain stay below a certain
* limit.
*/
class DifferentialDriveKinematicsConstraint : public TrajectoryConstraint {
class WPILIB_DLLEXPORT DifferentialDriveKinematicsConstraint
: public TrajectoryConstraint {
public:
DifferentialDriveKinematicsConstraint(
const DifferentialDriveKinematics& kinematics,

View File

@@ -4,6 +4,8 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "frc/controller/SimpleMotorFeedforward.h"
#include "frc/kinematics/DifferentialDriveKinematics.h"
#include "frc/trajectory/constraint/TrajectoryConstraint.h"
@@ -17,7 +19,8 @@ namespace frc {
* acceleration of any wheel of the robot while following the trajectory is
* never higher than what can be achieved with the given maximum voltage.
*/
class DifferentialDriveVoltageConstraint : public TrajectoryConstraint {
class WPILIB_DLLEXPORT DifferentialDriveVoltageConstraint
: public TrajectoryConstraint {
public:
/**
* Creates a new DifferentialDriveVoltageConstraint.

View File

@@ -4,6 +4,8 @@
#pragma once
#include <wpi/SymbolExports.h>
#include "frc/trajectory/constraint/TrajectoryConstraint.h"
#include "units/math.h"
#include "units/velocity.h"
@@ -14,26 +16,21 @@ namespace frc {
* with the EllipticalRegionConstraint or RectangularRegionConstraint to enforce
* a max velocity within a region.
*/
class MaxVelocityConstraint : public TrajectoryConstraint {
class WPILIB_DLLEXPORT MaxVelocityConstraint : public TrajectoryConstraint {
public:
/**
* Constructs a new MaxVelocityConstraint.
*
* @param maxVelocity The max velocity.
*/
explicit MaxVelocityConstraint(units::meters_per_second_t maxVelocity)
: m_maxVelocity(units::math::abs(maxVelocity)) {}
explicit MaxVelocityConstraint(units::meters_per_second_t maxVelocity);
units::meters_per_second_t MaxVelocity(
const Pose2d& pose, units::curvature_t curvature,
units::meters_per_second_t velocity) const override {
return m_maxVelocity;
}
units::meters_per_second_t velocity) const override;
MinMax MinMaxAcceleration(const Pose2d& pose, units::curvature_t curvature,
units::meters_per_second_t speed) const override {
return {};
}
units::meters_per_second_t speed) const override;
private:
units::meters_per_second_t m_maxVelocity;

View File

@@ -6,6 +6,8 @@
#include <cmath>
#include <wpi/SymbolExports.h>
#include "frc/kinematics/MecanumDriveKinematics.h"
#include "frc/trajectory/constraint/TrajectoryConstraint.h"
#include "units/velocity.h"
@@ -17,7 +19,8 @@ namespace frc {
* commanded velocities for wheels of the drivetrain stay below a certain
* limit.
*/
class MecanumDriveKinematicsConstraint : public TrajectoryConstraint {
class WPILIB_DLLEXPORT MecanumDriveKinematicsConstraint
: public TrajectoryConstraint {
public:
MecanumDriveKinematicsConstraint(const MecanumDriveKinematics& kinematics,
units::meters_per_second_t maxSpeed);

View File

@@ -12,13 +12,12 @@
namespace frc {
template <size_t NumModules>
/**
* A class that enforces constraints on the swerve drive kinematics.
* This can be used to ensure that the trajectory is constructed so that the
* commanded velocities of the wheels stay below a certain limit.
*/
template <size_t NumModules>
class SwerveDriveKinematicsConstraint : public TrajectoryConstraint {
public:
SwerveDriveKinematicsConstraint(

View File

@@ -10,12 +10,6 @@
namespace frc {
template <size_t NumModules>
/**
* A class that enforces constraints on the swerve drive kinematics.
* This can be used to ensure that the trajectory is constructed so that the
* commanded velocities of the wheels stay below a certain limit.
*/
SwerveDriveKinematicsConstraint<NumModules>::SwerveDriveKinematicsConstraint(
const frc::SwerveDriveKinematics<NumModules>& kinematics,
units::meters_per_second_t maxSpeed)

View File

@@ -6,6 +6,8 @@
#include <limits>
#include <wpi/SymbolExports.h>
#include "frc/geometry/Pose2d.h"
#include "frc/spline/Spline.h"
#include "units/acceleration.h"
@@ -17,7 +19,7 @@ namespace frc {
* An interface for defining user-defined velocity and acceleration constraints
* while generating trajectories.
*/
class TrajectoryConstraint {
class WPILIB_DLLEXPORT TrajectoryConstraint {
public:
TrajectoryConstraint() = default;

View File

@@ -84,6 +84,8 @@
#include <fmt/format.h>
#endif
#include <wpi/SymbolExports.h>
//------------------------------
// STRING FORMATTER
//------------------------------

View File

@@ -7,6 +7,7 @@
#include <memory>
#include <fmt/format.h>
#include <wpi/SymbolExports.h>
namespace wpi::math {
@@ -23,7 +24,7 @@ enum class MathUsageId {
kController_ProfiledPIDController,
};
class MathShared {
class WPILIB_DLLEXPORT MathShared {
public:
virtual ~MathShared() = default;
virtual void ReportErrorV(fmt::string_view format, fmt::format_args args) = 0;
@@ -42,7 +43,7 @@ class MathShared {
}
};
class MathSharedStore {
class WPILIB_DLLEXPORT MathSharedStore {
public:
static MathShared& GetMathShared();

View File

@@ -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
#ifdef _WIN32
#pragma warning(disable : 4251)
#ifdef WPILIB_EXPORTS
#ifdef __GNUC__
#define WPILIB_DLLEXPORT __attribute__((dllexport))
#else
#define WPILIB_DLLEXPORT __declspec(dllexport)
#endif
#else
#define WPILIB_DLLEXPORT
#endif
#else
#define WPILIB_DLLEXPORT __attribute__((visibility("default")))
#endif

View File

@@ -4,6 +4,8 @@
#pragma once
#include "wpi/SymbolExports.h"
namespace wpi {
class SendableBuilder;
@@ -11,7 +13,7 @@ class SendableBuilder;
/**
* Interface for Sendable objects.
*/
class Sendable {
class WPILIB_DLLEXPORT Sendable {
public:
virtual ~Sendable() = default;