mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -5,7 +5,7 @@
|
||||
#include "wpi/apriltag/AprilTagDetector.hpp"
|
||||
|
||||
int main() {
|
||||
frc::AprilTagDetector detector;
|
||||
wpi::apriltag::AprilTagDetector detector;
|
||||
detector.AddFamily("tag16h5");
|
||||
detector.SetConfig({.refineEdges = false});
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
#include "tag16h5.h"
|
||||
#include "tag36h11.h"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi::apriltag;
|
||||
|
||||
static bool FamilyToImage(wpi::RawFrame* frame, apriltag_family_t* family,
|
||||
static bool FamilyToImage(wpi::util::RawFrame* frame, apriltag_family_t* family,
|
||||
int id) {
|
||||
image_u8_t* image = apriltag_to_image(family, id);
|
||||
size_t totalDataSize = image->height * image->stride;
|
||||
@@ -37,25 +37,25 @@ static bool FamilyToImage(wpi::RawFrame* frame, apriltag_family_t* family,
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool AprilTag::Generate36h11AprilTagImage(wpi::RawFrame* frame, int id) {
|
||||
bool AprilTag::Generate36h11AprilTagImage(wpi::util::RawFrame* frame, int id) {
|
||||
apriltag_family_t* tagFamily = tag36h11_create();
|
||||
bool rv = FamilyToImage(frame, tagFamily, id);
|
||||
tag36h11_destroy(tagFamily);
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool AprilTag::Generate16h5AprilTagImage(wpi::RawFrame* frame, int id) {
|
||||
bool AprilTag::Generate16h5AprilTagImage(wpi::util::RawFrame* frame, int id) {
|
||||
apriltag_family_t* tagFamily = tag16h5_create();
|
||||
bool rv = FamilyToImage(frame, tagFamily, id);
|
||||
tag16h5_destroy(tagFamily);
|
||||
return rv;
|
||||
}
|
||||
|
||||
void frc::to_json(wpi::json& json, const AprilTag& apriltag) {
|
||||
json = wpi::json{{"ID", apriltag.ID}, {"pose", apriltag.pose}};
|
||||
void wpi::apriltag::to_json(wpi::util::json& json, const AprilTag& apriltag) {
|
||||
json = wpi::util::json{{"ID", apriltag.ID}, {"pose", apriltag.pose}};
|
||||
}
|
||||
|
||||
void frc::from_json(const wpi::json& json, AprilTag& apriltag) {
|
||||
void wpi::apriltag::from_json(const wpi::util::json& json, AprilTag& apriltag) {
|
||||
apriltag.ID = json.at("ID").get<int>();
|
||||
apriltag.pose = json.at("pose").get<Pose3d>();
|
||||
apriltag.pose = json.at("pose").get<wpi::math::Pose3d>();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#include "apriltag.h"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi::apriltag;
|
||||
|
||||
static_assert(sizeof(AprilTagDetection) == sizeof(apriltag_detection_t),
|
||||
"structure sizes don't match");
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "tag16h5.h"
|
||||
#include "tag36h11.h"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi::apriltag;
|
||||
|
||||
AprilTagDetector::Results::Results(void* impl, const private_init&)
|
||||
: span{reinterpret_cast<AprilTagDetection**>(
|
||||
|
||||
@@ -14,26 +14,26 @@
|
||||
#include "wpi/util/json.hpp"
|
||||
#include "wpi/util/raw_ostream.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi::apriltag;
|
||||
|
||||
AprilTagFieldLayout::AprilTagFieldLayout(std::string_view path) {
|
||||
auto fileBuffer = wpi::MemoryBuffer::GetFile(path);
|
||||
auto fileBuffer = wpi::util::MemoryBuffer::GetFile(path);
|
||||
if (!fileBuffer) {
|
||||
throw std::runtime_error(fmt::format("Cannot open file: {}", path));
|
||||
}
|
||||
|
||||
wpi::json json = wpi::json::parse(fileBuffer.value()->GetCharBuffer());
|
||||
wpi::util::json json = wpi::util::json::parse(fileBuffer.value()->GetCharBuffer());
|
||||
|
||||
for (const auto& tag : json.at("tags").get<std::vector<AprilTag>>()) {
|
||||
m_apriltags[tag.ID] = tag;
|
||||
}
|
||||
m_fieldWidth = units::meter_t{json.at("field").at("width").get<double>()};
|
||||
m_fieldLength = units::meter_t{json.at("field").at("length").get<double>()};
|
||||
m_fieldWidth = wpi::units::meter_t{json.at("field").at("width").get<double>()};
|
||||
m_fieldLength = wpi::units::meter_t{json.at("field").at("length").get<double>()};
|
||||
}
|
||||
|
||||
AprilTagFieldLayout::AprilTagFieldLayout(std::vector<AprilTag> apriltags,
|
||||
units::meter_t fieldLength,
|
||||
units::meter_t fieldWidth)
|
||||
wpi::units::meter_t fieldLength,
|
||||
wpi::units::meter_t fieldWidth)
|
||||
: m_fieldLength(std::move(fieldLength)),
|
||||
m_fieldWidth(std::move(fieldWidth)) {
|
||||
for (const auto& tag : apriltags) {
|
||||
@@ -41,11 +41,11 @@ AprilTagFieldLayout::AprilTagFieldLayout(std::vector<AprilTag> apriltags,
|
||||
}
|
||||
}
|
||||
|
||||
units::meter_t AprilTagFieldLayout::GetFieldLength() const {
|
||||
wpi::units::meter_t AprilTagFieldLayout::GetFieldLength() const {
|
||||
return m_fieldLength;
|
||||
}
|
||||
|
||||
units::meter_t AprilTagFieldLayout::GetFieldWidth() const {
|
||||
wpi::units::meter_t AprilTagFieldLayout::GetFieldWidth() const {
|
||||
return m_fieldWidth;
|
||||
}
|
||||
|
||||
@@ -61,26 +61,26 @@ std::vector<AprilTag> AprilTagFieldLayout::GetTags() const {
|
||||
void AprilTagFieldLayout::SetOrigin(OriginPosition origin) {
|
||||
switch (origin) {
|
||||
case OriginPosition::kBlueAllianceWallRightSide:
|
||||
SetOrigin(Pose3d{});
|
||||
SetOrigin(wpi::math::Pose3d{});
|
||||
break;
|
||||
case OriginPosition::kRedAllianceWallRightSide:
|
||||
SetOrigin(Pose3d{Translation3d{m_fieldLength, m_fieldWidth, 0_m},
|
||||
Rotation3d{0_deg, 0_deg, 180_deg}});
|
||||
SetOrigin(wpi::math::Pose3d{wpi::math::Translation3d{m_fieldLength, m_fieldWidth, 0_m},
|
||||
wpi::math::Rotation3d{0_deg, 0_deg, 180_deg}});
|
||||
break;
|
||||
default:
|
||||
throw std::invalid_argument("Invalid origin");
|
||||
}
|
||||
}
|
||||
|
||||
void AprilTagFieldLayout::SetOrigin(const Pose3d& origin) {
|
||||
void AprilTagFieldLayout::SetOrigin(const wpi::math::Pose3d& origin) {
|
||||
m_origin = origin;
|
||||
}
|
||||
|
||||
Pose3d AprilTagFieldLayout::GetOrigin() const {
|
||||
wpi::math::Pose3d AprilTagFieldLayout::GetOrigin() const {
|
||||
return m_origin;
|
||||
}
|
||||
|
||||
std::optional<frc::Pose3d> AprilTagFieldLayout::GetTagPose(int ID) const {
|
||||
std::optional<wpi::math::Pose3d> AprilTagFieldLayout::GetTagPose(int ID) const {
|
||||
const auto& it = m_apriltags.find(ID);
|
||||
if (it == m_apriltags.end()) {
|
||||
return std::nullopt;
|
||||
@@ -91,43 +91,43 @@ std::optional<frc::Pose3d> AprilTagFieldLayout::GetTagPose(int ID) const {
|
||||
void AprilTagFieldLayout::Serialize(std::string_view path) {
|
||||
std::error_code error_code;
|
||||
|
||||
wpi::raw_fd_ostream output{path, error_code};
|
||||
wpi::util::raw_fd_ostream output{path, error_code};
|
||||
if (error_code) {
|
||||
throw std::runtime_error(fmt::format("Cannot open file: {}", path));
|
||||
}
|
||||
|
||||
wpi::json json = *this;
|
||||
wpi::util::json json = *this;
|
||||
output << json;
|
||||
output.flush();
|
||||
}
|
||||
|
||||
void frc::to_json(wpi::json& json, const AprilTagFieldLayout& layout) {
|
||||
void wpi::apriltag::to_json(wpi::util::json& json, const AprilTagFieldLayout& layout) {
|
||||
std::vector<AprilTag> tagVector;
|
||||
tagVector.reserve(layout.m_apriltags.size());
|
||||
for (const auto& pair : layout.m_apriltags) {
|
||||
tagVector.push_back(pair.second);
|
||||
}
|
||||
|
||||
json = wpi::json{{"field",
|
||||
json = wpi::util::json{{"field",
|
||||
{{"length", layout.m_fieldLength.value()},
|
||||
{"width", layout.m_fieldWidth.value()}}},
|
||||
{"tags", tagVector}};
|
||||
}
|
||||
|
||||
void frc::from_json(const wpi::json& json, AprilTagFieldLayout& layout) {
|
||||
void wpi::apriltag::from_json(const wpi::util::json& json, AprilTagFieldLayout& layout) {
|
||||
layout.m_apriltags.clear();
|
||||
for (const auto& tag : json.at("tags").get<std::vector<AprilTag>>()) {
|
||||
layout.m_apriltags[tag.ID] = tag;
|
||||
}
|
||||
|
||||
layout.m_fieldLength =
|
||||
units::meter_t{json.at("field").at("length").get<double>()};
|
||||
wpi::units::meter_t{json.at("field").at("length").get<double>()};
|
||||
layout.m_fieldWidth =
|
||||
units::meter_t{json.at("field").at("width").get<double>()};
|
||||
wpi::units::meter_t{json.at("field").at("width").get<double>()};
|
||||
}
|
||||
|
||||
// Use namespace declaration for forward declaration
|
||||
namespace frc {
|
||||
namespace wpi::apriltag {
|
||||
|
||||
// C++ generated from resource files
|
||||
std::string_view GetResource_2022_rapidreact_json();
|
||||
@@ -136,7 +136,7 @@ std::string_view GetResource_2024_crescendo_json();
|
||||
std::string_view GetResource_2025_reefscape_welded_json();
|
||||
std::string_view GetResource_2025_reefscape_andymark_json();
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi::apriltag
|
||||
|
||||
AprilTagFieldLayout AprilTagFieldLayout::LoadField(AprilTagField field) {
|
||||
std::string_view fieldString;
|
||||
@@ -160,10 +160,10 @@ AprilTagFieldLayout AprilTagFieldLayout::LoadField(AprilTagField field) {
|
||||
throw std::invalid_argument("Invalid Field");
|
||||
}
|
||||
|
||||
wpi::json json = wpi::json::parse(fieldString);
|
||||
wpi::util::json json = wpi::util::json::parse(fieldString);
|
||||
return json.get<AprilTagFieldLayout>();
|
||||
}
|
||||
|
||||
AprilTagFieldLayout frc::LoadAprilTagLayoutField(AprilTagField field) {
|
||||
AprilTagFieldLayout wpi::apriltag::LoadAprilTagLayoutField(AprilTagField field) {
|
||||
return AprilTagFieldLayout::LoadField(field);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi::apriltag;
|
||||
|
||||
double AprilTagPoseEstimate::GetAmbiguity() const {
|
||||
auto min = (std::min)(error1, error2);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "apriltag.h"
|
||||
#include "apriltag_pose.h"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi::apriltag;
|
||||
|
||||
static Eigen::Matrix3d OrthogonalizeRotationMatrix(
|
||||
const Eigen::Matrix3d& input) {
|
||||
@@ -42,14 +42,14 @@ static Eigen::Matrix3d OrthogonalizeRotationMatrix(
|
||||
return Q;
|
||||
}
|
||||
|
||||
static Transform3d MakePose(const apriltag_pose_t& pose) {
|
||||
static wpi::math::Transform3d MakePose(const apriltag_pose_t& pose) {
|
||||
if (!pose.R || !pose.t) {
|
||||
return {};
|
||||
}
|
||||
return {Translation3d{units::meter_t{pose.t->data[0]},
|
||||
units::meter_t{pose.t->data[1]},
|
||||
units::meter_t{pose.t->data[2]}},
|
||||
Rotation3d{OrthogonalizeRotationMatrix(
|
||||
return {wpi::math::Translation3d{wpi::units::meter_t{pose.t->data[0]},
|
||||
wpi::units::meter_t{pose.t->data[1]},
|
||||
wpi::units::meter_t{pose.t->data[2]}},
|
||||
wpi::math::Rotation3d{OrthogonalizeRotationMatrix(
|
||||
Eigen::Map<Eigen::Matrix<double, 3, 3, Eigen::RowMajor>>{
|
||||
pose.R->data})}};
|
||||
}
|
||||
@@ -80,7 +80,7 @@ static apriltag_detection_t MakeBasicDet(
|
||||
return detection;
|
||||
}
|
||||
|
||||
static Transform3d DoEstimateHomography(
|
||||
static wpi::math::Transform3d DoEstimateHomography(
|
||||
const apriltag_detection_t* detection,
|
||||
const AprilTagPoseEstimator::Config& config) {
|
||||
auto info = MakeDetectionInfo(detection, config);
|
||||
@@ -89,13 +89,13 @@ static Transform3d DoEstimateHomography(
|
||||
return MakePose(pose);
|
||||
}
|
||||
|
||||
Transform3d AprilTagPoseEstimator::EstimateHomography(
|
||||
wpi::math::Transform3d AprilTagPoseEstimator::EstimateHomography(
|
||||
const AprilTagDetection& detection) const {
|
||||
return DoEstimateHomography(
|
||||
reinterpret_cast<const apriltag_detection_t*>(&detection), m_config);
|
||||
}
|
||||
|
||||
Transform3d AprilTagPoseEstimator::EstimateHomography(
|
||||
wpi::math::Transform3d AprilTagPoseEstimator::EstimateHomography(
|
||||
std::span<const double, 9> homography) const {
|
||||
auto detection = MakeBasicDet(homography, nullptr);
|
||||
auto rv = DoEstimateHomography(&detection, m_config);
|
||||
@@ -130,7 +130,7 @@ AprilTagPoseEstimate AprilTagPoseEstimator::EstimateOrthogonalIteration(
|
||||
return rv;
|
||||
}
|
||||
|
||||
static Transform3d DoEstimate(const apriltag_detection_t* detection,
|
||||
static wpi::math::Transform3d DoEstimate(const apriltag_detection_t* detection,
|
||||
const AprilTagPoseEstimator::Config& config) {
|
||||
auto info = MakeDetectionInfo(detection, config);
|
||||
apriltag_pose_t pose;
|
||||
@@ -138,13 +138,13 @@ static Transform3d DoEstimate(const apriltag_detection_t* detection,
|
||||
return MakePose(pose);
|
||||
}
|
||||
|
||||
Transform3d AprilTagPoseEstimator::Estimate(
|
||||
wpi::math::Transform3d AprilTagPoseEstimator::Estimate(
|
||||
const AprilTagDetection& detection) const {
|
||||
return DoEstimate(reinterpret_cast<const apriltag_detection_t*>(&detection),
|
||||
m_config);
|
||||
}
|
||||
|
||||
Transform3d AprilTagPoseEstimator::Estimate(
|
||||
wpi::math::Transform3d AprilTagPoseEstimator::Estimate(
|
||||
std::span<const double, 9> homography,
|
||||
std::span<const double, 8> corners) const {
|
||||
auto detection = MakeBasicDet(homography, &corners);
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
#include "wpi/apriltag/AprilTagDetector.hpp"
|
||||
#include "wpi/apriltag/AprilTagPoseEstimator.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::apriltag;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
static JavaVM* jvm = nullptr;
|
||||
|
||||
@@ -162,7 +162,7 @@ static AprilTagDetector::QuadThresholdParameters FromJavaDetectorQTP(
|
||||
return {
|
||||
FIELD(int, Int, minClusterPixels),
|
||||
FIELD(int, Int, maxNumMaxima),
|
||||
.criticalAngle = units::radian_t{static_cast<double>(
|
||||
.criticalAngle = wpi::units::radian_t{static_cast<double>(
|
||||
env->GetDoubleField(jparams, criticalAngleField))},
|
||||
FIELD(float, Float, maxLineFitMSE),
|
||||
FIELD(int, Int, minWhiteBlackDiff),
|
||||
@@ -256,7 +256,7 @@ static jobject MakeJObject(
|
||||
static_cast<jboolean>(params.deglitch));
|
||||
}
|
||||
|
||||
static jobject MakeJObject(JNIEnv* env, const Translation3d& xlate) {
|
||||
static jobject MakeJObject(JNIEnv* env, const wpi::math::Translation3d& xlate) {
|
||||
static jmethodID constructor =
|
||||
env->GetMethodID(translation3dCls, "<init>", "(DDD)V");
|
||||
if (!constructor) {
|
||||
@@ -268,7 +268,7 @@ static jobject MakeJObject(JNIEnv* env, const Translation3d& xlate) {
|
||||
static_cast<jdouble>(xlate.Y()), static_cast<jdouble>(xlate.Z()));
|
||||
}
|
||||
|
||||
static jobject MakeJObject(JNIEnv* env, const Quaternion& q) {
|
||||
static jobject MakeJObject(JNIEnv* env, const wpi::math::Quaternion& q) {
|
||||
static jmethodID constructor =
|
||||
env->GetMethodID(quaternionCls, "<init>", "(DDDD)V");
|
||||
if (!constructor) {
|
||||
@@ -281,7 +281,7 @@ static jobject MakeJObject(JNIEnv* env, const Quaternion& q) {
|
||||
static_cast<jdouble>(q.Z()));
|
||||
}
|
||||
|
||||
static jobject MakeJObject(JNIEnv* env, const Rotation3d& rot) {
|
||||
static jobject MakeJObject(JNIEnv* env, const wpi::math::Rotation3d& rot) {
|
||||
static jmethodID constructor = env->GetMethodID(
|
||||
rotation3dCls, "<init>", "(Lorg/wpilib/math/geometry/Quaternion;)V");
|
||||
if (!constructor) {
|
||||
@@ -292,7 +292,7 @@ static jobject MakeJObject(JNIEnv* env, const Rotation3d& rot) {
|
||||
return env->NewObject(rotation3dCls, constructor, q.obj());
|
||||
}
|
||||
|
||||
static jobject MakeJObject(JNIEnv* env, const Transform3d& xform) {
|
||||
static jobject MakeJObject(JNIEnv* env, const wpi::math::Transform3d& xform) {
|
||||
static jmethodID constructor =
|
||||
env->GetMethodID(transform3dCls, "<init>",
|
||||
"(Lorg/wpilib/math/geometry/Translation3d;"
|
||||
@@ -517,7 +517,7 @@ Java_org_wpilib_vision_apriltag_jni_AprilTagJNI_estimatePoseHomography
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AprilTagPoseEstimator estimator({units::meter_t{tagSize}, fx, fy, cx, cy});
|
||||
AprilTagPoseEstimator estimator({wpi::units::meter_t{tagSize}, fx, fy, cx, cy});
|
||||
return MakeJObject(env, estimator.EstimateHomography(harr));
|
||||
}
|
||||
|
||||
@@ -553,7 +553,7 @@ Java_org_wpilib_vision_apriltag_jni_AprilTagJNI_estimatePoseOrthogonalIteration
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AprilTagPoseEstimator estimator({units::meter_t{tagSize}, fx, fy, cx, cy});
|
||||
AprilTagPoseEstimator estimator({wpi::units::meter_t{tagSize}, fx, fy, cx, cy});
|
||||
return MakeJObject(env,
|
||||
estimator.EstimateOrthogonalIteration(harr, carr, nIters));
|
||||
}
|
||||
@@ -590,7 +590,7 @@ Java_org_wpilib_vision_apriltag_jni_AprilTagJNI_estimatePose
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AprilTagPoseEstimator estimator({units::meter_t{tagSize}, fx, fy, cx, cy});
|
||||
AprilTagPoseEstimator estimator({wpi::units::meter_t{tagSize}, fx, fy, cx, cy});
|
||||
return MakeJObject(env, estimator.Estimate(harr, carr));
|
||||
}
|
||||
|
||||
@@ -603,13 +603,13 @@ JNIEXPORT void JNICALL
|
||||
Java_org_wpilib_vision_apriltag_jni_AprilTagJNI_generate16h5AprilTagImage
|
||||
(JNIEnv* env, jclass, jobject frameObj, jlong framePtr, jint id)
|
||||
{
|
||||
auto* frame = reinterpret_cast<wpi::RawFrame*>(framePtr);
|
||||
auto* frame = reinterpret_cast<wpi::util::RawFrame*>(framePtr);
|
||||
if (!frame) {
|
||||
nullPointerEx.Throw(env, "frame is null");
|
||||
return;
|
||||
}
|
||||
bool newData = AprilTag::Generate16h5AprilTagImage(frame, id);
|
||||
wpi::SetFrameData(env, rawFrameCls, frameObj, *frame, newData);
|
||||
wpi::util::SetFrameData(env, rawFrameCls, frameObj, *frame, newData);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -621,14 +621,14 @@ JNIEXPORT void JNICALL
|
||||
Java_org_wpilib_vision_apriltag_jni_AprilTagJNI_generate36h11AprilTagImage
|
||||
(JNIEnv* env, jclass, jobject frameObj, jlong framePtr, jint id)
|
||||
{
|
||||
auto* frame = reinterpret_cast<wpi::RawFrame*>(framePtr);
|
||||
auto* frame = reinterpret_cast<wpi::util::RawFrame*>(framePtr);
|
||||
if (!frame) {
|
||||
nullPointerEx.Throw(env, "frame is null");
|
||||
return;
|
||||
}
|
||||
// function might reallocate
|
||||
bool newData = AprilTag::Generate36h11AprilTagImage(frame, id);
|
||||
wpi::SetFrameData(env, rawFrameCls, frameObj, *frame, newData);
|
||||
wpi::util::SetFrameData(env, rawFrameCls, frameObj, *frame, newData);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
#include "wpi/util/json_fwd.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi::apriltag {
|
||||
|
||||
/**
|
||||
* Represents an AprilTag's metadata.
|
||||
@@ -19,18 +19,18 @@ struct WPILIB_DLLEXPORT AprilTag {
|
||||
int ID;
|
||||
|
||||
/// The tag's pose.
|
||||
Pose3d pose;
|
||||
wpi::math::Pose3d pose;
|
||||
|
||||
bool operator==(const AprilTag&) const = default;
|
||||
|
||||
static bool Generate36h11AprilTagImage(wpi::RawFrame* frame, int id);
|
||||
static bool Generate16h5AprilTagImage(wpi::RawFrame* frame, int id);
|
||||
static bool Generate36h11AprilTagImage(wpi::util::RawFrame* frame, int id);
|
||||
static bool Generate16h5AprilTagImage(wpi::util::RawFrame* frame, int id);
|
||||
};
|
||||
|
||||
WPILIB_DLLEXPORT
|
||||
void to_json(wpi::json& json, const AprilTag& apriltag);
|
||||
void to_json(wpi::util::json& json, const AprilTag& apriltag);
|
||||
|
||||
WPILIB_DLLEXPORT
|
||||
void from_json(const wpi::json& json, AprilTag& apriltag);
|
||||
void from_json(const wpi::util::json& json, AprilTag& apriltag);
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi::apriltag
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi::apriltag {
|
||||
|
||||
/**
|
||||
* A detection of an AprilTag tag.
|
||||
@@ -158,4 +158,4 @@ class WPILIB_DLLEXPORT AprilTagDetection final {
|
||||
double p[4][2];
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi::apriltag
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "wpi/util/StringMap.hpp"
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi::apriltag {
|
||||
|
||||
/**
|
||||
* An AprilTag detector engine. This is expensive to set up and tear down, so
|
||||
@@ -98,7 +98,7 @@ class WPILIB_DLLEXPORT AprilTagDetector {
|
||||
* angles that are close to straight or close to 180 degrees. Zero means
|
||||
* that no quads are rejected. Default is 45 degrees.
|
||||
*/
|
||||
units::radian_t criticalAngle = 45_deg;
|
||||
wpi::units::radian_t criticalAngle = 45_deg;
|
||||
|
||||
/**
|
||||
* When fitting lines to the contours, the maximum mean squared error
|
||||
@@ -254,8 +254,8 @@ class WPILIB_DLLEXPORT AprilTagDetector {
|
||||
void DestroyFamily(std::string_view name, void* data);
|
||||
|
||||
void* m_impl;
|
||||
wpi::StringMap<void*> m_families;
|
||||
units::radian_t m_qtpCriticalAngle = 10_deg;
|
||||
wpi::util::StringMap<void*> m_families;
|
||||
wpi::units::radian_t m_qtpCriticalAngle = 10_deg;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi::apriltag
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
|
||||
#include "wpi/apriltag/AprilTagDetector.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi::apriltag {
|
||||
|
||||
inline AprilTagDetector::Results AprilTagDetect(AprilTagDetector& detector,
|
||||
cv::Mat& image) {
|
||||
return detector.Detect(image.cols, image.rows, image.data);
|
||||
}
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi::apriltag
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
#include "wpi/util/json_fwd.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi::apriltag {
|
||||
/**
|
||||
* Class for representing a layout of AprilTags on a field and reading them from
|
||||
* a JSON format.
|
||||
*
|
||||
* The JSON format contains two top-level objects, "tags" and "field".
|
||||
* The "tags" object is a list of all AprilTags contained within a layout. Each
|
||||
* AprilTag serializes to a JSON object containing an ID and a Pose3d. The
|
||||
* AprilTag serializes to a JSON object containing an ID and a wpi::math::Pose3d. The
|
||||
* "field" object is a descriptor of the size of the field in meters with
|
||||
* "width" and "length" values. This is to account for arbitrary field sizes
|
||||
* when transforming the poses.
|
||||
@@ -73,19 +73,19 @@ class WPILIB_DLLEXPORT AprilTagFieldLayout {
|
||||
* @param fieldWidth Width of field the layout is representing.
|
||||
*/
|
||||
AprilTagFieldLayout(std::vector<AprilTag> apriltags,
|
||||
units::meter_t fieldLength, units::meter_t fieldWidth);
|
||||
wpi::units::meter_t fieldLength, wpi::units::meter_t fieldWidth);
|
||||
|
||||
/**
|
||||
* Returns the length of the field the layout is representing.
|
||||
* @return length
|
||||
*/
|
||||
units::meter_t GetFieldLength() const;
|
||||
wpi::units::meter_t GetFieldLength() const;
|
||||
|
||||
/**
|
||||
* Returns the length of the field the layout is representing.
|
||||
* @return width
|
||||
*/
|
||||
units::meter_t GetFieldWidth() const;
|
||||
wpi::units::meter_t GetFieldWidth() const;
|
||||
|
||||
/**
|
||||
* Returns a vector of all the april tags used in this layout.
|
||||
@@ -112,13 +112,13 @@ class WPILIB_DLLEXPORT AprilTagFieldLayout {
|
||||
*
|
||||
* @param origin The new origin for tag transformations
|
||||
*/
|
||||
void SetOrigin(const Pose3d& origin);
|
||||
void SetOrigin(const wpi::math::Pose3d& origin);
|
||||
|
||||
/**
|
||||
* Returns the origin used for tag pose transformation.
|
||||
* @return the origin
|
||||
*/
|
||||
Pose3d GetOrigin() const;
|
||||
wpi::math::Pose3d GetOrigin() const;
|
||||
|
||||
/**
|
||||
* Gets an AprilTag pose by its ID.
|
||||
@@ -127,7 +127,7 @@ class WPILIB_DLLEXPORT AprilTagFieldLayout {
|
||||
* @return The pose corresponding to the ID that was passed in or an empty
|
||||
* optional if a tag with that ID is not found.
|
||||
*/
|
||||
std::optional<Pose3d> GetTagPose(int ID) const;
|
||||
std::optional<wpi::math::Pose3d> GetTagPose(int ID) const;
|
||||
|
||||
/**
|
||||
* Serializes an AprilTagFieldLayout to a JSON file.
|
||||
@@ -143,22 +143,22 @@ class WPILIB_DLLEXPORT AprilTagFieldLayout {
|
||||
|
||||
private:
|
||||
std::unordered_map<int, AprilTag> m_apriltags;
|
||||
units::meter_t m_fieldLength;
|
||||
units::meter_t m_fieldWidth;
|
||||
Pose3d m_origin;
|
||||
wpi::units::meter_t m_fieldLength;
|
||||
wpi::units::meter_t m_fieldWidth;
|
||||
wpi::math::Pose3d m_origin;
|
||||
|
||||
friend WPILIB_DLLEXPORT void to_json(wpi::json& json,
|
||||
friend WPILIB_DLLEXPORT void to_json(wpi::util::json& json,
|
||||
const AprilTagFieldLayout& layout);
|
||||
|
||||
friend WPILIB_DLLEXPORT void from_json(const wpi::json& json,
|
||||
friend WPILIB_DLLEXPORT void from_json(const wpi::util::json& json,
|
||||
AprilTagFieldLayout& layout);
|
||||
};
|
||||
|
||||
WPILIB_DLLEXPORT
|
||||
void to_json(wpi::json& json, const AprilTagFieldLayout& layout);
|
||||
void to_json(wpi::util::json& json, const AprilTagFieldLayout& layout);
|
||||
|
||||
WPILIB_DLLEXPORT
|
||||
void from_json(const wpi::json& json, AprilTagFieldLayout& layout);
|
||||
void from_json(const wpi::util::json& json, AprilTagFieldLayout& layout);
|
||||
|
||||
/**
|
||||
* Loads an AprilTagFieldLayout from a predefined field
|
||||
@@ -171,4 +171,4 @@ void from_json(const wpi::json& json, AprilTagFieldLayout& layout);
|
||||
WPILIB_DLLEXPORT AprilTagFieldLayout
|
||||
LoadAprilTagLayoutField(AprilTagField field);
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi::apriltag
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi::apriltag {
|
||||
|
||||
/**
|
||||
* Loadable AprilTag field layouts.
|
||||
@@ -32,4 +32,4 @@ enum class AprilTagField {
|
||||
kNumFields,
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi::apriltag
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
#include "wpi/math/geometry/Transform3d.hpp"
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi::apriltag {
|
||||
|
||||
/** A pair of AprilTag pose estimates. */
|
||||
struct WPILIB_DLLEXPORT AprilTagPoseEstimate {
|
||||
/** Pose 1. */
|
||||
Transform3d pose1;
|
||||
wpi::math::Transform3d pose1;
|
||||
|
||||
/** Pose 2. */
|
||||
Transform3d pose2;
|
||||
wpi::math::Transform3d pose2;
|
||||
|
||||
/** Object-space error of pose 1. */
|
||||
double error1;
|
||||
@@ -32,4 +32,4 @@ struct WPILIB_DLLEXPORT AprilTagPoseEstimate {
|
||||
double GetAmbiguity() const;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi::apriltag
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/units/length.hpp"
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi::apriltag {
|
||||
|
||||
class AprilTagDetection;
|
||||
|
||||
@@ -23,7 +23,7 @@ class WPILIB_DLLEXPORT AprilTagPoseEstimator {
|
||||
bool operator==(const Config&) const = default;
|
||||
|
||||
/** The tag size. */
|
||||
units::meter_t tagSize;
|
||||
wpi::units::meter_t tagSize;
|
||||
|
||||
/** Camera horizontal focal length, in pixels. */
|
||||
double fx;
|
||||
@@ -65,7 +65,7 @@ class WPILIB_DLLEXPORT AprilTagPoseEstimator {
|
||||
* @param detection Tag detection
|
||||
* @return Pose estimate
|
||||
*/
|
||||
Transform3d EstimateHomography(const AprilTagDetection& detection) const;
|
||||
wpi::math::Transform3d EstimateHomography(const AprilTagDetection& detection) const;
|
||||
|
||||
/**
|
||||
* Estimates the pose of the tag using the homography method described in [1].
|
||||
@@ -73,7 +73,7 @@ class WPILIB_DLLEXPORT AprilTagPoseEstimator {
|
||||
* @param homography Homography 3x3 matrix data
|
||||
* @return Pose estimate
|
||||
*/
|
||||
Transform3d EstimateHomography(std::span<const double, 9> homography) const;
|
||||
wpi::math::Transform3d EstimateHomography(std::span<const double, 9> homography) const;
|
||||
|
||||
/**
|
||||
* Estimates the pose of the tag. This returns one or two possible poses for
|
||||
@@ -123,7 +123,7 @@ class WPILIB_DLLEXPORT AprilTagPoseEstimator {
|
||||
* @param detection Tag detection
|
||||
* @return Pose estimate
|
||||
*/
|
||||
Transform3d Estimate(const AprilTagDetection& detection) const;
|
||||
wpi::math::Transform3d Estimate(const AprilTagDetection& detection) const;
|
||||
|
||||
/**
|
||||
* Estimates tag pose. This method is an easier to use interface to
|
||||
@@ -134,11 +134,11 @@ class WPILIB_DLLEXPORT AprilTagPoseEstimator {
|
||||
* @param corners Corner point array (X and Y for each corner in order)
|
||||
* @return Pose estimate
|
||||
*/
|
||||
Transform3d Estimate(std::span<const double, 9> homography,
|
||||
wpi::math::Transform3d Estimate(std::span<const double, 9> homography,
|
||||
std::span<const double, 8> corners) const;
|
||||
|
||||
private:
|
||||
Config m_config;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi::apriltag
|
||||
|
||||
@@ -4,7 +4,7 @@ functions:
|
||||
from_json:
|
||||
ignore: true
|
||||
classes:
|
||||
frc::AprilTag:
|
||||
wpi::apriltag::AprilTag:
|
||||
attributes:
|
||||
ID:
|
||||
pose:
|
||||
|
||||
@@ -2,7 +2,7 @@ extra_includes:
|
||||
- pybind11/eigen.h
|
||||
|
||||
classes:
|
||||
frc::AprilTagDetection:
|
||||
wpi::apriltag::AprilTagDetection:
|
||||
methods:
|
||||
GetFamily:
|
||||
GetId:
|
||||
@@ -18,7 +18,7 @@ classes:
|
||||
return py::str("<AprilTagDetection tag_family={} tag_id={} hamming={} decision_margin={} center={}>")
|
||||
.format(self.GetFamily(), self.GetId(), self.GetHamming(), self.GetDecisionMargin(), self.GetCenter());
|
||||
})
|
||||
frc::AprilTagDetection::Point:
|
||||
wpi::apriltag::AprilTagDetection::Point:
|
||||
attributes:
|
||||
x:
|
||||
y:
|
||||
|
||||
@@ -2,7 +2,7 @@ extra_includes:
|
||||
- pybind11_typing.h
|
||||
|
||||
classes:
|
||||
frc::AprilTagDetector:
|
||||
wpi::apriltag::AprilTagDetector:
|
||||
methods:
|
||||
AprilTagDetector:
|
||||
SetConfig:
|
||||
@@ -59,7 +59,7 @@ classes:
|
||||
:return: list of results
|
||||
)doc"
|
||||
)
|
||||
frc::AprilTagDetector::Config:
|
||||
wpi::apriltag::AprilTagDetector::Config:
|
||||
attributes:
|
||||
numThreads:
|
||||
quadDecimate:
|
||||
@@ -69,7 +69,7 @@ classes:
|
||||
debug:
|
||||
methods:
|
||||
operator==:
|
||||
frc::AprilTagDetector::QuadThresholdParameters:
|
||||
wpi::apriltag::AprilTagDetector::QuadThresholdParameters:
|
||||
attributes:
|
||||
minClusterPixels:
|
||||
maxNumMaxima:
|
||||
@@ -79,7 +79,7 @@ classes:
|
||||
deglitch:
|
||||
methods:
|
||||
operator==:
|
||||
frc::AprilTagDetector::Results:
|
||||
wpi::apriltag::AprilTagDetector::Results:
|
||||
rename: _Results
|
||||
ignored_bases:
|
||||
- std::span<const AprilTagDetection* const>
|
||||
|
||||
@@ -6,7 +6,7 @@ functions:
|
||||
LoadAprilTagLayoutField:
|
||||
ignore: true
|
||||
classes:
|
||||
frc::AprilTagFieldLayout:
|
||||
wpi::apriltag::AprilTagFieldLayout:
|
||||
enums:
|
||||
OriginPosition:
|
||||
methods:
|
||||
@@ -14,7 +14,7 @@ classes:
|
||||
overloads:
|
||||
'':
|
||||
std::string_view:
|
||||
std::vector<AprilTag>, units::meter_t, units::meter_t:
|
||||
std::vector<AprilTag>, wpi::units::meter_t, wpi::units::meter_t:
|
||||
LoadField:
|
||||
GetFieldLength:
|
||||
GetFieldWidth:
|
||||
@@ -22,7 +22,7 @@ classes:
|
||||
SetOrigin:
|
||||
overloads:
|
||||
OriginPosition:
|
||||
const Pose3d&:
|
||||
const wpi::math::Pose3d&:
|
||||
GetOrigin:
|
||||
GetTagPose:
|
||||
Serialize:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
classes:
|
||||
frc::AprilTagPoseEstimate:
|
||||
wpi::apriltag::AprilTagPoseEstimate:
|
||||
attributes:
|
||||
pose1:
|
||||
pose2:
|
||||
|
||||
@@ -2,7 +2,7 @@ extra_includes:
|
||||
- wpi/apriltag/AprilTagDetection.hpp
|
||||
|
||||
classes:
|
||||
frc::AprilTagPoseEstimator:
|
||||
wpi::apriltag::AprilTagPoseEstimator:
|
||||
methods:
|
||||
AprilTagPoseEstimator:
|
||||
SetConfig:
|
||||
@@ -19,7 +19,7 @@ classes:
|
||||
overloads:
|
||||
const AprilTagDetection& [const]:
|
||||
std::span<const double, 9>, std::span<const double, 8> [const]:
|
||||
frc::AprilTagPoseEstimator::Config:
|
||||
wpi::apriltag::AprilTagPoseEstimator::Config:
|
||||
force_no_default_constructor: true
|
||||
attributes:
|
||||
tagSize:
|
||||
@@ -30,7 +30,7 @@ classes:
|
||||
methods:
|
||||
operator==:
|
||||
inline_code: |
|
||||
.def(py::init([](units::meter_t tagSize, double fx, double fy, double cx, double cy) {
|
||||
.def(py::init([](wpi::units::meter_t tagSize, double fx, double fy, double cx, double cy) {
|
||||
AprilTagPoseEstimator::Config cfg{tagSize, fx, fy, cx, cy};
|
||||
return std::make_unique<AprilTagPoseEstimator::Config>(std::move(cfg));
|
||||
}), py::arg("tagSize"), py::arg("fx"), py::arg("fy"), py::arg("cx"), py::arg("cy"))
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "wpi/apriltag/AprilTagDetector.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi::apriltag;
|
||||
|
||||
TEST(AprilTagDetectorTest, ConfigDefaults) {
|
||||
AprilTagDetector detector;
|
||||
|
||||
@@ -11,17 +11,17 @@
|
||||
#include "wpi/math/geometry/Pose3d.hpp"
|
||||
#include "wpi/util/json.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi::apriltag;
|
||||
|
||||
TEST(AprilTagJsonTest, DeserializeMatches) {
|
||||
auto layout = AprilTagFieldLayout{
|
||||
std::vector{
|
||||
AprilTag{1, Pose3d{}},
|
||||
AprilTag{3, Pose3d{0_m, 1_m, 0_m, Rotation3d{0_deg, 0_deg, 0_deg}}}},
|
||||
AprilTag{1, wpi::math::Pose3d{}},
|
||||
AprilTag{3, wpi::math::Pose3d{0_m, 1_m, 0_m, wpi::math::Rotation3d{0_deg, 0_deg, 0_deg}}}},
|
||||
54_ft, 27_ft};
|
||||
|
||||
AprilTagFieldLayout deserialized;
|
||||
wpi::json json = layout;
|
||||
wpi::util::json json = layout;
|
||||
EXPECT_NO_THROW(deserialized = json.get<AprilTagFieldLayout>());
|
||||
EXPECT_EQ(layout, deserialized);
|
||||
}
|
||||
|
||||
@@ -11,23 +11,23 @@
|
||||
#include "wpi/math/geometry/Pose3d.hpp"
|
||||
#include "wpi/util/json.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi::apriltag;
|
||||
|
||||
TEST(AprilTagPoseSetOriginTest, TransformationMatches) {
|
||||
auto layout = AprilTagFieldLayout{
|
||||
std::vector<AprilTag>{
|
||||
AprilTag{1,
|
||||
Pose3d{0_ft, 0_ft, 0_ft, Rotation3d{0_deg, 0_deg, 0_deg}}},
|
||||
wpi::math::Pose3d{0_ft, 0_ft, 0_ft, wpi::math::Rotation3d{0_deg, 0_deg, 0_deg}}},
|
||||
AprilTag{
|
||||
2, Pose3d{4_ft, 4_ft, 4_ft, Rotation3d{0_deg, 0_deg, 180_deg}}}},
|
||||
2, wpi::math::Pose3d{4_ft, 4_ft, 4_ft, wpi::math::Rotation3d{0_deg, 0_deg, 180_deg}}}},
|
||||
54_ft, 27_ft};
|
||||
|
||||
layout.SetOrigin(
|
||||
AprilTagFieldLayout::OriginPosition::kRedAllianceWallRightSide);
|
||||
|
||||
auto mirrorPose =
|
||||
Pose3d{54_ft, 27_ft, 0_ft, Rotation3d{0_deg, 0_deg, 180_deg}};
|
||||
wpi::math::Pose3d{54_ft, 27_ft, 0_ft, wpi::math::Rotation3d{0_deg, 0_deg, 180_deg}};
|
||||
EXPECT_EQ(mirrorPose, *layout.GetTagPose(1));
|
||||
mirrorPose = Pose3d{50_ft, 23_ft, 4_ft, Rotation3d{0_deg, 0_deg, 0_deg}};
|
||||
mirrorPose = wpi::math::Pose3d{50_ft, 23_ft, 4_ft, wpi::math::Rotation3d{0_deg, 0_deg, 0_deg}};
|
||||
EXPECT_EQ(mirrorPose, *layout.GetTagPose(2));
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/apriltag/AprilTagFieldLayout.hpp"
|
||||
#include "wpi/apriltag/AprilTagFields.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi::apriltag {
|
||||
|
||||
std::vector<AprilTagField> GetAllFields() {
|
||||
std::vector<AprilTagField> output;
|
||||
@@ -27,21 +27,21 @@ TEST(AprilTagFieldsTest, TestLoad2022RapidReact) {
|
||||
|
||||
// Blue Hangar Truss - Hub
|
||||
auto expectedPose =
|
||||
Pose3d{127.272_in, 216.01_in, 67.932_in, Rotation3d{0_deg, 0_deg, 0_deg}};
|
||||
wpi::math::Pose3d{127.272_in, 216.01_in, 67.932_in, wpi::math::Rotation3d{0_deg, 0_deg, 0_deg}};
|
||||
auto maybePose = layout.GetTagPose(1);
|
||||
EXPECT_TRUE(maybePose);
|
||||
EXPECT_EQ(expectedPose, *maybePose);
|
||||
|
||||
// Blue Terminal Near Station
|
||||
expectedPose = Pose3d{4.768_in, 67.631_in, 35.063_in,
|
||||
Rotation3d{0_deg, 0_deg, 46.25_deg}};
|
||||
expectedPose = wpi::math::Pose3d{4.768_in, 67.631_in, 35.063_in,
|
||||
wpi::math::Rotation3d{0_deg, 0_deg, 46.25_deg}};
|
||||
maybePose = layout.GetTagPose(5);
|
||||
EXPECT_TRUE(maybePose);
|
||||
EXPECT_EQ(expectedPose, *maybePose);
|
||||
|
||||
// Upper Hub Blue-Near
|
||||
expectedPose = Pose3d{332.321_in, 183.676_in, 95.186_in,
|
||||
Rotation3d{0_deg, 26.75_deg, 69_deg}};
|
||||
expectedPose = wpi::math::Pose3d{332.321_in, 183.676_in, 95.186_in,
|
||||
wpi::math::Rotation3d{0_deg, 26.75_deg, 69_deg}};
|
||||
maybePose = layout.GetTagPose(53);
|
||||
EXPECT_TRUE(maybePose);
|
||||
EXPECT_EQ(expectedPose, *maybePose);
|
||||
@@ -62,4 +62,4 @@ TEST_P(AllFieldsFixtureTest, CheckEntireEnum) {
|
||||
INSTANTIATE_TEST_SUITE_P(ValuesEnumTestInstTests, AllFieldsFixtureTest,
|
||||
::testing::ValuesIn(GetAllFields()));
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi::apriltag
|
||||
|
||||
@@ -10,17 +10,17 @@
|
||||
#include "wpi/units/length.hpp"
|
||||
#include "wpi/util/array.hpp"
|
||||
|
||||
static constexpr wpi::array<frc::Pose2d, 6> poses{
|
||||
frc::Pose2d{-1_m, 1_m, -90_deg}, frc::Pose2d{-1_m, 2_m, 90_deg},
|
||||
frc::Pose2d{0_m, 0_m, 0_deg}, frc::Pose2d{0_m, 3_m, -90_deg},
|
||||
frc::Pose2d{1_m, 1_m, 90_deg}, frc::Pose2d{1_m, 2_m, 90_deg},
|
||||
static constexpr wpi::util::array<wpi::math::Pose2d, 6> poses{
|
||||
wpi::math::Pose2d{-1_m, 1_m, -90_deg}, wpi::math::Pose2d{-1_m, 2_m, 90_deg},
|
||||
wpi::math::Pose2d{0_m, 0_m, 0_deg}, wpi::math::Pose2d{0_m, 3_m, -90_deg},
|
||||
wpi::math::Pose2d{1_m, 1_m, 90_deg}, wpi::math::Pose2d{1_m, 2_m, 90_deg},
|
||||
};
|
||||
static constexpr int iterations = 100;
|
||||
|
||||
void BM_Transform(benchmark::State& state) {
|
||||
frc::TravelingSalesman traveler{[](auto pose1, auto pose2) {
|
||||
wpi::math::TravelingSalesman traveler{[](auto pose1, auto pose2) {
|
||||
auto transform = pose2 - pose1;
|
||||
return units::math::hypot(transform.X(), transform.Y()).value();
|
||||
return wpi::units::math::hypot(transform.X(), transform.Y()).value();
|
||||
}};
|
||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
||||
for (auto _ : state) {
|
||||
@@ -30,9 +30,9 @@ void BM_Transform(benchmark::State& state) {
|
||||
BENCHMARK(BM_Transform);
|
||||
|
||||
void BM_Twist(benchmark::State& state) {
|
||||
frc::TravelingSalesman traveler{[](auto pose1, auto pose2) {
|
||||
wpi::math::TravelingSalesman traveler{[](auto pose1, auto pose2) {
|
||||
auto twist = (pose2 - pose1).Log();
|
||||
return units::math::hypot(twist.dx, twist.dy).value();
|
||||
return wpi::units::math::hypot(twist.dx, twist.dy).value();
|
||||
}};
|
||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
||||
for (auto _ : state) {
|
||||
|
||||
@@ -59,19 +59,19 @@ bool server = false;
|
||||
struct CameraConfig {
|
||||
std::string name;
|
||||
std::string path;
|
||||
wpi::json config;
|
||||
wpi::util::json config;
|
||||
};
|
||||
|
||||
std::vector<CameraConfig> cameras;
|
||||
|
||||
bool ReadCameraConfig(const wpi::json& config) {
|
||||
bool ReadCameraConfig(const wpi::util::json& config) {
|
||||
CameraConfig c;
|
||||
|
||||
// name
|
||||
try {
|
||||
c.name = config.at("name").get<std::string>();
|
||||
} catch (const wpi::json::exception& e) {
|
||||
wpi::print(stderr, "config error in '{}': could not read camera name: {}\n",
|
||||
} catch (const wpi::util::json::exception& e) {
|
||||
wpi::util::print(stderr, "config error in '{}': could not read camera name: {}\n",
|
||||
configFile, e.what());
|
||||
return false;
|
||||
}
|
||||
@@ -79,8 +79,8 @@ bool ReadCameraConfig(const wpi::json& config) {
|
||||
// path
|
||||
try {
|
||||
c.path = config.at("path").get<std::string>();
|
||||
} catch (const wpi::json::exception& e) {
|
||||
wpi::print(stderr,
|
||||
} catch (const wpi::util::json::exception& e) {
|
||||
wpi::util::print(stderr,
|
||||
"config error in '{}': camera '{}': could not read path: {}\n",
|
||||
configFile, c.name, e.what());
|
||||
return false;
|
||||
@@ -94,26 +94,26 @@ bool ReadCameraConfig(const wpi::json& config) {
|
||||
|
||||
bool ReadConfig() {
|
||||
// open config file
|
||||
auto fileBuffer = wpi::MemoryBuffer::GetFile(configFile);
|
||||
auto fileBuffer = wpi::util::MemoryBuffer::GetFile(configFile);
|
||||
if (!fileBuffer) {
|
||||
wpi::print(stderr, "could not open '{}': {}\n", configFile,
|
||||
wpi::util::print(stderr, "could not open '{}': {}\n", configFile,
|
||||
fileBuffer.error().message());
|
||||
return false;
|
||||
}
|
||||
|
||||
// parse file
|
||||
wpi::json j;
|
||||
wpi::util::json j;
|
||||
try {
|
||||
j = wpi::json::parse(fileBuffer.value()->GetCharBuffer());
|
||||
} catch (const wpi::json::parse_error& e) {
|
||||
wpi::print(stderr, "config error in '{}': byte {}: {}\n", configFile,
|
||||
j = wpi::util::json::parse(fileBuffer.value()->GetCharBuffer());
|
||||
} catch (const wpi::util::json::parse_error& e) {
|
||||
wpi::util::print(stderr, "config error in '{}': byte {}: {}\n", configFile,
|
||||
e.byte, e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
// top level must be an object
|
||||
if (!j.is_object()) {
|
||||
wpi::print(stderr, "config error in '{}': must be JSON object\n",
|
||||
wpi::util::print(stderr, "config error in '{}': must be JSON object\n",
|
||||
configFile);
|
||||
return false;
|
||||
}
|
||||
@@ -121,8 +121,8 @@ bool ReadConfig() {
|
||||
// team number
|
||||
try {
|
||||
team = j.at("team").get<unsigned int>();
|
||||
} catch (const wpi::json::exception& e) {
|
||||
wpi::print(stderr, "config error in '{}': could not read team number: {}\n",
|
||||
} catch (const wpi::util::json::exception& e) {
|
||||
wpi::util::print(stderr, "config error in '{}': could not read team number: {}\n",
|
||||
configFile, e.what());
|
||||
return false;
|
||||
}
|
||||
@@ -131,18 +131,18 @@ bool ReadConfig() {
|
||||
if (j.count("ntmode") != 0) {
|
||||
try {
|
||||
auto str = j.at("ntmode").get<std::string>();
|
||||
if (wpi::equals_lower(str, "client")) {
|
||||
if (wpi::util::equals_lower(str, "client")) {
|
||||
server = false;
|
||||
} else if (wpi::equals_lower(str, "server")) {
|
||||
} else if (wpi::util::equals_lower(str, "server")) {
|
||||
server = true;
|
||||
} else {
|
||||
wpi::print(
|
||||
wpi::util::print(
|
||||
stderr,
|
||||
"config error in '{}': could not understand ntmode value '{}'\n",
|
||||
configFile, str);
|
||||
}
|
||||
} catch (const wpi::json::exception& e) {
|
||||
wpi::print(stderr, "config error in '{}': could not read ntmode: {}\n",
|
||||
} catch (const wpi::util::json::exception& e) {
|
||||
wpi::util::print(stderr, "config error in '{}': could not read ntmode: {}\n",
|
||||
configFile, e.what());
|
||||
}
|
||||
}
|
||||
@@ -154,8 +154,8 @@ bool ReadConfig() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (const wpi::json::exception& e) {
|
||||
wpi::print(stderr, "config error in '{}': could not read cameras: {}\n",
|
||||
} catch (const wpi::util::json::exception& e) {
|
||||
wpi::util::print(stderr, "config error in '{}': could not read cameras: {}\n",
|
||||
configFile, e.what());
|
||||
return false;
|
||||
}
|
||||
@@ -164,9 +164,9 @@ bool ReadConfig() {
|
||||
}
|
||||
|
||||
void StartCamera(const CameraConfig& config) {
|
||||
wpi::print("Starting camera '{}' on {}\n", config.name, config.path);
|
||||
wpi::util::print("Starting camera '{}' on {}\n", config.name, config.path);
|
||||
auto camera =
|
||||
frc::CameraServer::StartAutomaticCapture(config.name, config.path);
|
||||
wpi::CameraServer::StartAutomaticCapture(config.name, config.path);
|
||||
|
||||
camera.SetConfigJson(config.config);
|
||||
}
|
||||
@@ -183,12 +183,12 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
// start NetworkTables
|
||||
auto ntinst = nt::NetworkTableInstance::GetDefault();
|
||||
auto ntinst = wpi::nt::NetworkTableInstance::GetDefault();
|
||||
if (server) {
|
||||
std::puts("Setting up NetworkTables server");
|
||||
ntinst.StartServer();
|
||||
} else {
|
||||
wpi::print("Setting up NetworkTables client for team {}\n", team);
|
||||
wpi::util::print("Setting up NetworkTables client for team {}\n", team);
|
||||
ntinst.StartClient("multicameraserver");
|
||||
ntinst.SetServerTeam(team);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "wpi/util/StringMap.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
static constexpr char const* kPublishName = "/CameraPublisher";
|
||||
|
||||
@@ -61,7 +61,7 @@ struct SourcePublisher {
|
||||
nt::StringArrayPublisher streamsPublisher;
|
||||
nt::StringEntry modeEntry;
|
||||
nt::StringArrayPublisher modesPublisher;
|
||||
wpi::DenseMap<CS_Property, PropertyPublisher> properties;
|
||||
wpi::util::DenseMap<CS_Property, PropertyPublisher> properties;
|
||||
};
|
||||
|
||||
struct Instance {
|
||||
@@ -71,13 +71,13 @@ struct Instance {
|
||||
std::vector<std::string> GetSourceStreamValues(CS_Source source);
|
||||
void UpdateStreamValues();
|
||||
|
||||
wpi::mutex m_mutex;
|
||||
wpi::util::mutex m_mutex;
|
||||
std::atomic<int> m_defaultUsbDevice{0};
|
||||
std::string m_primarySourceName;
|
||||
wpi::StringMap<cs::VideoSource> m_sources;
|
||||
wpi::StringMap<cs::VideoSink> m_sinks;
|
||||
wpi::DenseMap<CS_Sink, CS_Source> m_fixedSources;
|
||||
wpi::DenseMap<CS_Source, SourcePublisher> m_publishers;
|
||||
wpi::util::StringMap<cs::VideoSource> m_sources;
|
||||
wpi::util::StringMap<cs::VideoSink> m_sinks;
|
||||
wpi::util::DenseMap<CS_Sink, CS_Source> m_fixedSources;
|
||||
wpi::util::DenseMap<CS_Source, SourcePublisher> m_publishers;
|
||||
std::shared_ptr<nt::NetworkTable> m_publishTable{
|
||||
nt::NetworkTableInstance::GetDefault().GetTable(kPublishName)};
|
||||
cs::VideoListener m_videoListener;
|
||||
@@ -94,7 +94,7 @@ static Instance& GetInstance() {
|
||||
}
|
||||
|
||||
static std::string_view MakeSourceValue(CS_Source source,
|
||||
wpi::SmallVectorImpl<char>& buf) {
|
||||
wpi::util::SmallVectorImpl<char>& buf) {
|
||||
CS_Status status = 0;
|
||||
buf.clear();
|
||||
switch (cs::GetSourceKind(source, &status)) {
|
||||
@@ -282,7 +282,7 @@ PropertyPublisher::PropertyPublisher(nt::NetworkTable& table,
|
||||
const cs::VideoEvent& event) {
|
||||
std::string name;
|
||||
std::string infoName;
|
||||
if (wpi::starts_with(event.name, "raw_")) {
|
||||
if (wpi::util::starts_with(event.name, "raw_")) {
|
||||
name = fmt::format("RawProperty/{}", event.name);
|
||||
infoName = fmt::format("RawPropertyInfo/{}", event.name);
|
||||
} else {
|
||||
@@ -361,9 +361,9 @@ SourcePublisher::SourcePublisher(Instance& inst,
|
||||
modeEntry{table->GetStringTopic("mode").GetEntry("")},
|
||||
modesPublisher{table->GetStringArrayTopic("modes").Publish()} {
|
||||
CS_Status status = 0;
|
||||
wpi::SmallString<64> buf;
|
||||
wpi::util::SmallString<64> buf;
|
||||
sourcePublisher.Set(MakeSourceValue(source, buf));
|
||||
wpi::SmallString<64> descBuf;
|
||||
wpi::util::SmallString<64> descBuf;
|
||||
descriptionPublisher.Set(cs::GetSourceDescription(source, descBuf, &status));
|
||||
connectedPublisher.Set(cs::IsSourceConnected(source, &status));
|
||||
streamsPublisher.Set(inst.GetSourceStreamValues(source));
|
||||
@@ -404,7 +404,7 @@ Instance::Instance() {
|
||||
case cs::VideoEvent::kSourceConnected:
|
||||
if (auto publisher = GetPublisher(event.sourceHandle)) {
|
||||
// update the description too (as it may have changed)
|
||||
wpi::SmallString<64> descBuf;
|
||||
wpi::util::SmallString<64> descBuf;
|
||||
publisher->descriptionPublisher.Set(cs::GetSourceDescription(
|
||||
event.sourceHandle, descBuf, &status));
|
||||
publisher->connectedPublisher.Set(true);
|
||||
@@ -543,7 +543,7 @@ cs::CvSink CameraServer::GetVideo() {
|
||||
|
||||
cs::CvSink CameraServer::GetVideo(const cs::VideoSource& camera) {
|
||||
auto& inst = ::GetInstance();
|
||||
wpi::SmallString<64> name{"opencv_"};
|
||||
wpi::util::SmallString<64> name{"opencv_"};
|
||||
name += camera.GetName();
|
||||
|
||||
{
|
||||
@@ -570,7 +570,7 @@ cs::CvSink CameraServer::GetVideo(const cs::VideoSource& camera) {
|
||||
cs::CvSink CameraServer::GetVideo(const cs::VideoSource& camera,
|
||||
cs::VideoMode::PixelFormat pixelFormat) {
|
||||
auto& inst = ::GetInstance();
|
||||
wpi::SmallString<64> name{"opencv_"};
|
||||
wpi::util::SmallString<64> name{"opencv_"};
|
||||
name += camera.GetName();
|
||||
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace {
|
||||
class DefaultCameraServerShared : public frc::CameraServerShared {
|
||||
class DefaultCameraServerShared : public wpi::CameraServerShared {
|
||||
public:
|
||||
void ReportUsage(std::string_view resource, std::string_view data) override {}
|
||||
void SetCameraServerErrorV(fmt::string_view format,
|
||||
@@ -25,10 +25,10 @@ class DefaultCameraServerShared : public frc::CameraServerShared {
|
||||
};
|
||||
} // namespace
|
||||
|
||||
static std::unique_ptr<frc::CameraServerShared> cameraServerShared = nullptr;
|
||||
static wpi::mutex setLock;
|
||||
static std::unique_ptr<wpi::CameraServerShared> cameraServerShared = nullptr;
|
||||
static wpi::util::mutex setLock;
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
CameraServerShared* GetCameraServerShared() {
|
||||
std::unique_lock lock(setLock);
|
||||
if (!cameraServerShared) {
|
||||
@@ -36,10 +36,10 @@ CameraServerShared* GetCameraServerShared() {
|
||||
}
|
||||
return cameraServerShared.get();
|
||||
}
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
extern "C" {
|
||||
void CameraServer_SetCameraServerShared(frc::CameraServerShared* shared) {
|
||||
void CameraServer_SetCameraServerShared(wpi::CameraServerShared* shared) {
|
||||
std::unique_lock lock(setLock);
|
||||
cameraServerShared.reset(shared);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "wpi/cameraserver/CameraServerShared.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi::vision;
|
||||
|
||||
VisionRunnerBase::VisionRunnerBase(cs::VideoSource videoSource)
|
||||
: m_image(std::make_unique<cv::Mat>()),
|
||||
@@ -24,7 +24,7 @@ VisionRunnerBase::VisionRunnerBase(cs::VideoSource videoSource)
|
||||
VisionRunnerBase::~VisionRunnerBase() = default;
|
||||
|
||||
void VisionRunnerBase::RunOnce() {
|
||||
auto csShared = frc::GetCameraServerShared();
|
||||
auto csShared = wpi::vision::GetCameraServerShared();
|
||||
auto res = csShared->GetRobotMainThreadId();
|
||||
if (res.second && (std::this_thread::get_id() == res.first)) {
|
||||
csShared->SetVisionRunnerError(
|
||||
@@ -41,7 +41,7 @@ void VisionRunnerBase::RunOnce() {
|
||||
}
|
||||
|
||||
void VisionRunnerBase::RunForever() {
|
||||
auto csShared = frc::GetCameraServerShared();
|
||||
auto csShared = wpi::vision::GetCameraServerShared();
|
||||
auto res = csShared->GetRobotMainThreadId();
|
||||
if (res.second && (std::this_thread::get_id() == res.first)) {
|
||||
csShared->SetVisionRunnerError(
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include "wpi/cs/cscore_cv.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Singleton class for creating and keeping camera servers.
|
||||
@@ -200,4 +200,4 @@ class CameraServer {
|
||||
CameraServer() = default;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
class CameraServerShared {
|
||||
public:
|
||||
virtual ~CameraServerShared() = default;
|
||||
@@ -42,9 +42,9 @@ class CameraServerShared {
|
||||
};
|
||||
|
||||
CameraServerShared* GetCameraServerShared();
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
extern "C" {
|
||||
// Takes ownership
|
||||
void CameraServer_SetCameraServerShared(frc::CameraServerShared* shared);
|
||||
void CameraServer_SetCameraServerShared(wpi::CameraServerShared* shared);
|
||||
} // extern "C"
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace cv {
|
||||
class Mat;
|
||||
} // namespace cv
|
||||
|
||||
namespace frc {
|
||||
namespace wpi::vision {
|
||||
|
||||
/**
|
||||
* A vision pipeline is responsible for running a group of OpenCV algorithms to
|
||||
@@ -26,4 +26,4 @@ class VisionPipeline {
|
||||
*/
|
||||
virtual void Process(cv::Mat& mat) = 0;
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi::vision
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/cs/cscore_cv.hpp"
|
||||
#include "wpi/vision/VisionPipeline.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi::vision {
|
||||
|
||||
/**
|
||||
* Non-template base class for VisionRunner.
|
||||
@@ -111,4 +111,4 @@ class VisionRunner : public VisionRunnerBase {
|
||||
std::function<void(T&)> m_listener;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi::vision
|
||||
|
||||
@@ -8,23 +8,23 @@
|
||||
{%- endmacro %}
|
||||
#include "wpi/commands2/button/Command{{ ConsoleName }}Controller.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
Command{{ ConsoleName }}Controller::Command{{ ConsoleName }}Controller(int port)
|
||||
: CommandGenericHID(port), m_hid{frc::{{ ConsoleName }}Controller(port)} {}
|
||||
: CommandGenericHID(port), m_hid{wpi::{{ ConsoleName }}Controller(port)} {}
|
||||
|
||||
frc::{{ ConsoleName }}Controller& Command{{ ConsoleName }}Controller::GetHID() {
|
||||
wpi::{{ ConsoleName }}Controller& Command{{ ConsoleName }}Controller::GetHID() {
|
||||
return m_hid;
|
||||
}
|
||||
{% for button in buttons %}
|
||||
Trigger Command{{ ConsoleName }}Controller::{{ capitalize_first(button.name) }}(frc::EventLoop* loop) const {
|
||||
return Button(frc::{{ ConsoleName }}Controller::Button::k{{ capitalize_first(button.name) }}, loop);
|
||||
Trigger Command{{ ConsoleName }}Controller::{{ capitalize_first(button.name) }}(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::{{ ConsoleName }}Controller::Button::k{{ capitalize_first(button.name) }}, loop);
|
||||
}
|
||||
{% endfor -%}
|
||||
{% for trigger in triggers -%}
|
||||
{% if trigger.UseThresholdMethods %}
|
||||
Trigger Command{{ ConsoleName }}Controller::{{ capitalize_first(trigger.name) }}(double threshold,
|
||||
frc::EventLoop* loop) const {
|
||||
wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, threshold] {
|
||||
return m_hid.Get{{ capitalize_first(trigger.name) }}Axis() > threshold;
|
||||
});
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
#include "wpi/commands2/CommandScheduler.hpp"
|
||||
#include "wpi/commands2/button/CommandGenericHID.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A version of {@link frc::{{ ConsoleName }}Controller} with {@link Trigger} factories for
|
||||
* A version of {@link wpi::{{ ConsoleName }}Controller} with {@link Trigger} factories for
|
||||
* command-based.
|
||||
*
|
||||
* @see frc::{{ ConsoleName }}Controller
|
||||
* @see wpi::{{ ConsoleName }}Controller
|
||||
*/
|
||||
class Command{{ ConsoleName }}Controller : public CommandGenericHID {
|
||||
public:
|
||||
@@ -35,7 +35,7 @@ class Command{{ ConsoleName }}Controller : public CommandGenericHID {
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
*/
|
||||
frc::{{ ConsoleName }}Controller& GetHID();
|
||||
wpi::{{ ConsoleName }}Controller& GetHID();
|
||||
{% for button in buttons %}
|
||||
/**
|
||||
* Constructs a Trigger instance around the {{ button.DocName|default(button.name) }} button's
|
||||
@@ -46,7 +46,7 @@ class Command{{ ConsoleName }}Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the {{ button.DocName|default(button.name) }} button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger {{ capitalize_first(button.name) }}(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger {{ capitalize_first(button.name) }}(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
{% endfor -%}
|
||||
{% for trigger in triggers -%}
|
||||
@@ -65,7 +65,7 @@ class Command{{ ConsoleName }}Controller : public CommandGenericHID {
|
||||
* exceeds the provided threshold, attached to the given loop
|
||||
*/
|
||||
Trigger {{ capitalize_first(trigger.name) }}(double threshold = 0.5,
|
||||
frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
{% endif -%}
|
||||
{% endfor -%}
|
||||
@@ -87,6 +87,6 @@ class Command{{ ConsoleName }}Controller : public CommandGenericHID {
|
||||
double Get{{ capitalize_first(trigger.name) }}Axis() const;
|
||||
{% endfor %}
|
||||
private:
|
||||
frc::{{ ConsoleName }}Controller m_hid;
|
||||
wpi::{{ ConsoleName }}Controller m_hid;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -6,69 +6,69 @@
|
||||
|
||||
#include "wpi/commands2/button/CommandPS4Controller.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandPS4Controller::CommandPS4Controller(int port)
|
||||
: CommandGenericHID(port), m_hid{frc::PS4Controller(port)} {}
|
||||
: CommandGenericHID(port), m_hid{wpi::PS4Controller(port)} {}
|
||||
|
||||
frc::PS4Controller& CommandPS4Controller::GetHID() {
|
||||
wpi::PS4Controller& CommandPS4Controller::GetHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
Trigger CommandPS4Controller::Square(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS4Controller::Button::kSquare, loop);
|
||||
Trigger CommandPS4Controller::Square(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS4Controller::Button::kSquare, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS4Controller::Cross(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS4Controller::Button::kCross, loop);
|
||||
Trigger CommandPS4Controller::Cross(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS4Controller::Button::kCross, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS4Controller::Circle(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS4Controller::Button::kCircle, loop);
|
||||
Trigger CommandPS4Controller::Circle(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS4Controller::Button::kCircle, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS4Controller::Triangle(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS4Controller::Button::kTriangle, loop);
|
||||
Trigger CommandPS4Controller::Triangle(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS4Controller::Button::kTriangle, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS4Controller::L1(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS4Controller::Button::kL1, loop);
|
||||
Trigger CommandPS4Controller::L1(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS4Controller::Button::kL1, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS4Controller::R1(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS4Controller::Button::kR1, loop);
|
||||
Trigger CommandPS4Controller::R1(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS4Controller::Button::kR1, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS4Controller::L2(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS4Controller::Button::kL2, loop);
|
||||
Trigger CommandPS4Controller::L2(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS4Controller::Button::kL2, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS4Controller::R2(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS4Controller::Button::kR2, loop);
|
||||
Trigger CommandPS4Controller::R2(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS4Controller::Button::kR2, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS4Controller::Share(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS4Controller::Button::kShare, loop);
|
||||
Trigger CommandPS4Controller::Share(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS4Controller::Button::kShare, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS4Controller::Options(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS4Controller::Button::kOptions, loop);
|
||||
Trigger CommandPS4Controller::Options(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS4Controller::Button::kOptions, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS4Controller::L3(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS4Controller::Button::kL3, loop);
|
||||
Trigger CommandPS4Controller::L3(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS4Controller::Button::kL3, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS4Controller::R3(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS4Controller::Button::kR3, loop);
|
||||
Trigger CommandPS4Controller::R3(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS4Controller::Button::kR3, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS4Controller::PS(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS4Controller::Button::kPS, loop);
|
||||
Trigger CommandPS4Controller::PS(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS4Controller::Button::kPS, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS4Controller::Touchpad(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS4Controller::Button::kTouchpad, loop);
|
||||
Trigger CommandPS4Controller::Touchpad(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS4Controller::Button::kTouchpad, loop);
|
||||
}
|
||||
|
||||
double CommandPS4Controller::GetLeftX() const {
|
||||
|
||||
@@ -6,69 +6,69 @@
|
||||
|
||||
#include "wpi/commands2/button/CommandPS5Controller.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandPS5Controller::CommandPS5Controller(int port)
|
||||
: CommandGenericHID(port), m_hid{frc::PS5Controller(port)} {}
|
||||
: CommandGenericHID(port), m_hid{wpi::PS5Controller(port)} {}
|
||||
|
||||
frc::PS5Controller& CommandPS5Controller::GetHID() {
|
||||
wpi::PS5Controller& CommandPS5Controller::GetHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
Trigger CommandPS5Controller::Square(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS5Controller::Button::kSquare, loop);
|
||||
Trigger CommandPS5Controller::Square(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS5Controller::Button::kSquare, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS5Controller::Cross(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS5Controller::Button::kCross, loop);
|
||||
Trigger CommandPS5Controller::Cross(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS5Controller::Button::kCross, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS5Controller::Circle(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS5Controller::Button::kCircle, loop);
|
||||
Trigger CommandPS5Controller::Circle(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS5Controller::Button::kCircle, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS5Controller::Triangle(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS5Controller::Button::kTriangle, loop);
|
||||
Trigger CommandPS5Controller::Triangle(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS5Controller::Button::kTriangle, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS5Controller::L1(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS5Controller::Button::kL1, loop);
|
||||
Trigger CommandPS5Controller::L1(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS5Controller::Button::kL1, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS5Controller::R1(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS5Controller::Button::kR1, loop);
|
||||
Trigger CommandPS5Controller::R1(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS5Controller::Button::kR1, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS5Controller::L2(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS5Controller::Button::kL2, loop);
|
||||
Trigger CommandPS5Controller::L2(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS5Controller::Button::kL2, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS5Controller::R2(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS5Controller::Button::kR2, loop);
|
||||
Trigger CommandPS5Controller::R2(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS5Controller::Button::kR2, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS5Controller::Create(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS5Controller::Button::kCreate, loop);
|
||||
Trigger CommandPS5Controller::Create(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS5Controller::Button::kCreate, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS5Controller::Options(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS5Controller::Button::kOptions, loop);
|
||||
Trigger CommandPS5Controller::Options(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS5Controller::Button::kOptions, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS5Controller::L3(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS5Controller::Button::kL3, loop);
|
||||
Trigger CommandPS5Controller::L3(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS5Controller::Button::kL3, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS5Controller::R3(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS5Controller::Button::kR3, loop);
|
||||
Trigger CommandPS5Controller::R3(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS5Controller::Button::kR3, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS5Controller::PS(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS5Controller::Button::kPS, loop);
|
||||
Trigger CommandPS5Controller::PS(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS5Controller::Button::kPS, loop);
|
||||
}
|
||||
|
||||
Trigger CommandPS5Controller::Touchpad(frc::EventLoop* loop) const {
|
||||
return Button(frc::PS5Controller::Button::kTouchpad, loop);
|
||||
Trigger CommandPS5Controller::Touchpad(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::PS5Controller::Button::kTouchpad, loop);
|
||||
}
|
||||
|
||||
double CommandPS5Controller::GetLeftX() const {
|
||||
|
||||
@@ -6,73 +6,73 @@
|
||||
|
||||
#include "wpi/commands2/button/CommandStadiaController.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandStadiaController::CommandStadiaController(int port)
|
||||
: CommandGenericHID(port), m_hid{frc::StadiaController(port)} {}
|
||||
: CommandGenericHID(port), m_hid{wpi::StadiaController(port)} {}
|
||||
|
||||
frc::StadiaController& CommandStadiaController::GetHID() {
|
||||
wpi::StadiaController& CommandStadiaController::GetHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
Trigger CommandStadiaController::A(frc::EventLoop* loop) const {
|
||||
return Button(frc::StadiaController::Button::kA, loop);
|
||||
Trigger CommandStadiaController::A(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::StadiaController::Button::kA, loop);
|
||||
}
|
||||
|
||||
Trigger CommandStadiaController::B(frc::EventLoop* loop) const {
|
||||
return Button(frc::StadiaController::Button::kB, loop);
|
||||
Trigger CommandStadiaController::B(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::StadiaController::Button::kB, loop);
|
||||
}
|
||||
|
||||
Trigger CommandStadiaController::X(frc::EventLoop* loop) const {
|
||||
return Button(frc::StadiaController::Button::kX, loop);
|
||||
Trigger CommandStadiaController::X(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::StadiaController::Button::kX, loop);
|
||||
}
|
||||
|
||||
Trigger CommandStadiaController::Y(frc::EventLoop* loop) const {
|
||||
return Button(frc::StadiaController::Button::kY, loop);
|
||||
Trigger CommandStadiaController::Y(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::StadiaController::Button::kY, loop);
|
||||
}
|
||||
|
||||
Trigger CommandStadiaController::LeftBumper(frc::EventLoop* loop) const {
|
||||
return Button(frc::StadiaController::Button::kLeftBumper, loop);
|
||||
Trigger CommandStadiaController::LeftBumper(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::StadiaController::Button::kLeftBumper, loop);
|
||||
}
|
||||
|
||||
Trigger CommandStadiaController::RightBumper(frc::EventLoop* loop) const {
|
||||
return Button(frc::StadiaController::Button::kRightBumper, loop);
|
||||
Trigger CommandStadiaController::RightBumper(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::StadiaController::Button::kRightBumper, loop);
|
||||
}
|
||||
|
||||
Trigger CommandStadiaController::LeftStick(frc::EventLoop* loop) const {
|
||||
return Button(frc::StadiaController::Button::kLeftStick, loop);
|
||||
Trigger CommandStadiaController::LeftStick(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::StadiaController::Button::kLeftStick, loop);
|
||||
}
|
||||
|
||||
Trigger CommandStadiaController::RightStick(frc::EventLoop* loop) const {
|
||||
return Button(frc::StadiaController::Button::kRightStick, loop);
|
||||
Trigger CommandStadiaController::RightStick(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::StadiaController::Button::kRightStick, loop);
|
||||
}
|
||||
|
||||
Trigger CommandStadiaController::Ellipses(frc::EventLoop* loop) const {
|
||||
return Button(frc::StadiaController::Button::kEllipses, loop);
|
||||
Trigger CommandStadiaController::Ellipses(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::StadiaController::Button::kEllipses, loop);
|
||||
}
|
||||
|
||||
Trigger CommandStadiaController::Hamburger(frc::EventLoop* loop) const {
|
||||
return Button(frc::StadiaController::Button::kHamburger, loop);
|
||||
Trigger CommandStadiaController::Hamburger(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::StadiaController::Button::kHamburger, loop);
|
||||
}
|
||||
|
||||
Trigger CommandStadiaController::Stadia(frc::EventLoop* loop) const {
|
||||
return Button(frc::StadiaController::Button::kStadia, loop);
|
||||
Trigger CommandStadiaController::Stadia(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::StadiaController::Button::kStadia, loop);
|
||||
}
|
||||
|
||||
Trigger CommandStadiaController::RightTrigger(frc::EventLoop* loop) const {
|
||||
return Button(frc::StadiaController::Button::kRightTrigger, loop);
|
||||
Trigger CommandStadiaController::RightTrigger(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::StadiaController::Button::kRightTrigger, loop);
|
||||
}
|
||||
|
||||
Trigger CommandStadiaController::LeftTrigger(frc::EventLoop* loop) const {
|
||||
return Button(frc::StadiaController::Button::kLeftTrigger, loop);
|
||||
Trigger CommandStadiaController::LeftTrigger(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::StadiaController::Button::kLeftTrigger, loop);
|
||||
}
|
||||
|
||||
Trigger CommandStadiaController::Google(frc::EventLoop* loop) const {
|
||||
return Button(frc::StadiaController::Button::kGoogle, loop);
|
||||
Trigger CommandStadiaController::Google(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::StadiaController::Button::kGoogle, loop);
|
||||
}
|
||||
|
||||
Trigger CommandStadiaController::Frame(frc::EventLoop* loop) const {
|
||||
return Button(frc::StadiaController::Button::kFrame, loop);
|
||||
Trigger CommandStadiaController::Frame(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::StadiaController::Button::kFrame, loop);
|
||||
}
|
||||
|
||||
double CommandStadiaController::GetLeftX() const {
|
||||
|
||||
@@ -6,64 +6,64 @@
|
||||
|
||||
#include "wpi/commands2/button/CommandXboxController.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandXboxController::CommandXboxController(int port)
|
||||
: CommandGenericHID(port), m_hid{frc::XboxController(port)} {}
|
||||
: CommandGenericHID(port), m_hid{wpi::XboxController(port)} {}
|
||||
|
||||
frc::XboxController& CommandXboxController::GetHID() {
|
||||
wpi::XboxController& CommandXboxController::GetHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::A(frc::EventLoop* loop) const {
|
||||
return Button(frc::XboxController::Button::kA, loop);
|
||||
Trigger CommandXboxController::A(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::kA, loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::B(frc::EventLoop* loop) const {
|
||||
return Button(frc::XboxController::Button::kB, loop);
|
||||
Trigger CommandXboxController::B(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::kB, loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::X(frc::EventLoop* loop) const {
|
||||
return Button(frc::XboxController::Button::kX, loop);
|
||||
Trigger CommandXboxController::X(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::kX, loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::Y(frc::EventLoop* loop) const {
|
||||
return Button(frc::XboxController::Button::kY, loop);
|
||||
Trigger CommandXboxController::Y(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::kY, loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::LeftBumper(frc::EventLoop* loop) const {
|
||||
return Button(frc::XboxController::Button::kLeftBumper, loop);
|
||||
Trigger CommandXboxController::LeftBumper(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::kLeftBumper, loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::RightBumper(frc::EventLoop* loop) const {
|
||||
return Button(frc::XboxController::Button::kRightBumper, loop);
|
||||
Trigger CommandXboxController::RightBumper(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::kRightBumper, loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::Back(frc::EventLoop* loop) const {
|
||||
return Button(frc::XboxController::Button::kBack, loop);
|
||||
Trigger CommandXboxController::Back(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::kBack, loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::Start(frc::EventLoop* loop) const {
|
||||
return Button(frc::XboxController::Button::kStart, loop);
|
||||
Trigger CommandXboxController::Start(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::kStart, loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::LeftStick(frc::EventLoop* loop) const {
|
||||
return Button(frc::XboxController::Button::kLeftStick, loop);
|
||||
Trigger CommandXboxController::LeftStick(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::kLeftStick, loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::RightStick(frc::EventLoop* loop) const {
|
||||
return Button(frc::XboxController::Button::kRightStick, loop);
|
||||
Trigger CommandXboxController::RightStick(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::kRightStick, loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::LeftTrigger(double threshold,
|
||||
frc::EventLoop* loop) const {
|
||||
wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, threshold] {
|
||||
return m_hid.GetLeftTriggerAxis() > threshold;
|
||||
});
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::RightTrigger(double threshold,
|
||||
frc::EventLoop* loop) const {
|
||||
wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, threshold] {
|
||||
return m_hid.GetRightTriggerAxis() > threshold;
|
||||
});
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
#include "wpi/commands2/CommandScheduler.hpp"
|
||||
#include "wpi/commands2/button/CommandGenericHID.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A version of {@link frc::PS4Controller} with {@link Trigger} factories for
|
||||
* A version of {@link wpi::PS4Controller} with {@link Trigger} factories for
|
||||
* command-based.
|
||||
*
|
||||
* @see frc::PS4Controller
|
||||
* @see wpi::PS4Controller
|
||||
*/
|
||||
class CommandPS4Controller : public CommandGenericHID {
|
||||
public:
|
||||
@@ -33,7 +33,7 @@ class CommandPS4Controller : public CommandGenericHID {
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
*/
|
||||
frc::PS4Controller& GetHID();
|
||||
wpi::PS4Controller& GetHID();
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the square button's
|
||||
@@ -44,7 +44,7 @@ class CommandPS4Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the square button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Square(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Square(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,7 @@ class CommandPS4Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the cross button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Cross(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Cross(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -68,7 +68,7 @@ class CommandPS4Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the circle button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Circle(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Circle(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ class CommandPS4Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the triangle button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Triangle(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Triangle(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -92,7 +92,7 @@ class CommandPS4Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the left trigger 1 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger L1(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger L1(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ class CommandPS4Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the right trigger 1 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger R1(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger R1(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -116,7 +116,7 @@ class CommandPS4Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the left trigger 2 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger L2(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger L2(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -128,7 +128,7 @@ class CommandPS4Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the right trigger 2 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger R2(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger R2(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -140,7 +140,7 @@ class CommandPS4Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the share button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Share(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Share(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -152,7 +152,7 @@ class CommandPS4Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the options button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Options(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Options(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -164,7 +164,7 @@ class CommandPS4Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the L3 (left stick) button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger L3(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger L3(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -176,7 +176,7 @@ class CommandPS4Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the R3 (right stick) button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger R3(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger R3(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -188,7 +188,7 @@ class CommandPS4Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the PlayStation button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger PS(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger PS(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -200,7 +200,7 @@ class CommandPS4Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the touchpad button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Touchpad(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Touchpad(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -248,6 +248,6 @@ class CommandPS4Controller : public CommandGenericHID {
|
||||
double GetR2Axis() const;
|
||||
|
||||
private:
|
||||
frc::PS4Controller m_hid;
|
||||
wpi::PS4Controller m_hid;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
#include "wpi/commands2/CommandScheduler.hpp"
|
||||
#include "wpi/commands2/button/CommandGenericHID.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A version of {@link frc::PS5Controller} with {@link Trigger} factories for
|
||||
* A version of {@link wpi::PS5Controller} with {@link Trigger} factories for
|
||||
* command-based.
|
||||
*
|
||||
* @see frc::PS5Controller
|
||||
* @see wpi::PS5Controller
|
||||
*/
|
||||
class CommandPS5Controller : public CommandGenericHID {
|
||||
public:
|
||||
@@ -33,7 +33,7 @@ class CommandPS5Controller : public CommandGenericHID {
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
*/
|
||||
frc::PS5Controller& GetHID();
|
||||
wpi::PS5Controller& GetHID();
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the square button's
|
||||
@@ -44,7 +44,7 @@ class CommandPS5Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the square button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Square(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Square(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,7 @@ class CommandPS5Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the cross button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Cross(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Cross(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -68,7 +68,7 @@ class CommandPS5Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the circle button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Circle(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Circle(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ class CommandPS5Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the triangle button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Triangle(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Triangle(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -92,7 +92,7 @@ class CommandPS5Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the left trigger 1 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger L1(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger L1(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ class CommandPS5Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the right trigger 1 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger R1(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger R1(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -116,7 +116,7 @@ class CommandPS5Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the left trigger 2 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger L2(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger L2(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -128,7 +128,7 @@ class CommandPS5Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the right trigger 2 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger R2(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger R2(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -140,7 +140,7 @@ class CommandPS5Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the create button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Create(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Create(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -152,7 +152,7 @@ class CommandPS5Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the options button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Options(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Options(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -164,7 +164,7 @@ class CommandPS5Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the L3 (left stick) button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger L3(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger L3(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -176,7 +176,7 @@ class CommandPS5Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the R3 (right stick) button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger R3(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger R3(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -188,7 +188,7 @@ class CommandPS5Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the PlayStation button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger PS(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger PS(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -200,7 +200,7 @@ class CommandPS5Controller : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the touchpad button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Touchpad(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Touchpad(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -248,6 +248,6 @@ class CommandPS5Controller : public CommandGenericHID {
|
||||
double GetR2Axis() const;
|
||||
|
||||
private:
|
||||
frc::PS5Controller m_hid;
|
||||
wpi::PS5Controller m_hid;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
#include "wpi/commands2/CommandScheduler.hpp"
|
||||
#include "wpi/commands2/button/CommandGenericHID.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A version of {@link frc::StadiaController} with {@link Trigger} factories for
|
||||
* A version of {@link wpi::StadiaController} with {@link Trigger} factories for
|
||||
* command-based.
|
||||
*
|
||||
* @see frc::StadiaController
|
||||
* @see wpi::StadiaController
|
||||
*/
|
||||
class CommandStadiaController : public CommandGenericHID {
|
||||
public:
|
||||
@@ -33,7 +33,7 @@ class CommandStadiaController : public CommandGenericHID {
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
*/
|
||||
frc::StadiaController& GetHID();
|
||||
wpi::StadiaController& GetHID();
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the A button's
|
||||
@@ -44,7 +44,7 @@ class CommandStadiaController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the A button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger A(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger A(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,7 @@ class CommandStadiaController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the B button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger B(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger B(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -68,7 +68,7 @@ class CommandStadiaController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the X button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger X(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger X(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ class CommandStadiaController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the Y button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Y(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Y(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -92,7 +92,7 @@ class CommandStadiaController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the left bumper button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger LeftBumper(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger LeftBumper(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ class CommandStadiaController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the right bumper button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger RightBumper(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger RightBumper(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -116,7 +116,7 @@ class CommandStadiaController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the left stick button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger LeftStick(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger LeftStick(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -128,7 +128,7 @@ class CommandStadiaController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the right stick button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger RightStick(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger RightStick(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -140,7 +140,7 @@ class CommandStadiaController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the ellipses button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Ellipses(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Ellipses(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -152,7 +152,7 @@ class CommandStadiaController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the hamburger button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Hamburger(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Hamburger(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -164,7 +164,7 @@ class CommandStadiaController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the stadia button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Stadia(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Stadia(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -176,7 +176,7 @@ class CommandStadiaController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the right trigger button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger RightTrigger(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger RightTrigger(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -188,7 +188,7 @@ class CommandStadiaController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the left trigger button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger LeftTrigger(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger LeftTrigger(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -200,7 +200,7 @@ class CommandStadiaController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the google button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Google(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Google(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -212,7 +212,7 @@ class CommandStadiaController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the frame button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Frame(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Frame(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -244,6 +244,6 @@ class CommandStadiaController : public CommandGenericHID {
|
||||
double GetRightY() const;
|
||||
|
||||
private:
|
||||
frc::StadiaController m_hid;
|
||||
wpi::StadiaController m_hid;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
#include "wpi/commands2/CommandScheduler.hpp"
|
||||
#include "wpi/commands2/button/CommandGenericHID.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A version of {@link frc::XboxController} with {@link Trigger} factories for
|
||||
* A version of {@link wpi::XboxController} with {@link Trigger} factories for
|
||||
* command-based.
|
||||
*
|
||||
* @see frc::XboxController
|
||||
* @see wpi::XboxController
|
||||
*/
|
||||
class CommandXboxController : public CommandGenericHID {
|
||||
public:
|
||||
@@ -33,7 +33,7 @@ class CommandXboxController : public CommandGenericHID {
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
*/
|
||||
frc::XboxController& GetHID();
|
||||
wpi::XboxController& GetHID();
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the A button's
|
||||
@@ -44,7 +44,7 @@ class CommandXboxController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the A button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger A(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger A(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,7 @@ class CommandXboxController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the B button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger B(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger B(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -68,7 +68,7 @@ class CommandXboxController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the X button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger X(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger X(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ class CommandXboxController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the Y button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Y(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Y(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -92,7 +92,7 @@ class CommandXboxController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the left bumper button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger LeftBumper(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger LeftBumper(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ class CommandXboxController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the right bumper button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger RightBumper(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger RightBumper(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -116,7 +116,7 @@ class CommandXboxController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the back button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Back(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Back(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -128,7 +128,7 @@ class CommandXboxController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the start button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Start(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger Start(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -140,7 +140,7 @@ class CommandXboxController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the left stick button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger LeftStick(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger LeftStick(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -152,7 +152,7 @@ class CommandXboxController : public CommandGenericHID {
|
||||
* @return a Trigger instance representing the right stick button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger RightStick(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
Trigger RightStick(wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -169,7 +169,7 @@ class CommandXboxController : public CommandGenericHID {
|
||||
* exceeds the provided threshold, attached to the given loop
|
||||
*/
|
||||
Trigger LeftTrigger(double threshold = 0.5,
|
||||
frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -186,7 +186,7 @@ class CommandXboxController : public CommandGenericHID {
|
||||
* exceeds the provided threshold, attached to the given loop
|
||||
*/
|
||||
Trigger RightTrigger(double threshold = 0.5,
|
||||
frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
@@ -234,6 +234,6 @@ class CommandXboxController : public CommandGenericHID {
|
||||
double GetRightTriggerAxis() const;
|
||||
|
||||
private:
|
||||
frc::XboxController m_hid;
|
||||
wpi::XboxController m_hid;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
#include "wpi/util/sendable/SendableRegistry.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
Command::Command() {
|
||||
wpi::SendableRegistry::Add(this, GetTypeName(*this));
|
||||
wpi::util::SendableRegistry::Add(this, GetTypeName(*this));
|
||||
}
|
||||
|
||||
Command::~Command() {
|
||||
@@ -32,7 +32,7 @@ void Command::Initialize() {}
|
||||
void Command::Execute() {}
|
||||
void Command::End(bool interrupted) {}
|
||||
|
||||
wpi::SmallSet<Subsystem*, 4> Command::GetRequirements() const {
|
||||
wpi::util::SmallSet<Subsystem*, 4> Command::GetRequirements() const {
|
||||
return m_requirements;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ void Command::AddRequirements(Requirements requirements) {
|
||||
m_requirements.insert(requirements.begin(), requirements.end());
|
||||
}
|
||||
|
||||
void Command::AddRequirements(wpi::SmallSet<Subsystem*, 4> requirements) {
|
||||
void Command::AddRequirements(wpi::util::SmallSet<Subsystem*, 4> requirements) {
|
||||
m_requirements.insert(requirements.begin(), requirements.end());
|
||||
}
|
||||
|
||||
@@ -49,22 +49,22 @@ void Command::AddRequirements(Subsystem* requirement) {
|
||||
}
|
||||
|
||||
void Command::SetName(std::string_view name) {
|
||||
wpi::SendableRegistry::SetName(this, name);
|
||||
wpi::util::SendableRegistry::SetName(this, name);
|
||||
}
|
||||
|
||||
std::string Command::GetName() const {
|
||||
return wpi::SendableRegistry::GetName(this);
|
||||
return wpi::util::SendableRegistry::GetName(this);
|
||||
}
|
||||
|
||||
std::string Command::GetSubsystem() const {
|
||||
return wpi::SendableRegistry::GetSubsystem(this);
|
||||
return wpi::util::SendableRegistry::GetSubsystem(this);
|
||||
}
|
||||
|
||||
void Command::SetSubsystem(std::string_view subsystem) {
|
||||
wpi::SendableRegistry::SetSubsystem(this, subsystem);
|
||||
wpi::util::SendableRegistry::SetSubsystem(this, subsystem);
|
||||
}
|
||||
|
||||
CommandPtr Command::WithTimeout(units::second_t duration) && {
|
||||
CommandPtr Command::WithTimeout(wpi::units::second_t duration) && {
|
||||
return std::move(*this).ToPtr().WithTimeout(duration);
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ bool Command::IsComposed() const {
|
||||
|
||||
void Command::SetComposed(bool isComposed) {
|
||||
if (isComposed) {
|
||||
m_previousComposition = wpi::GetStackTrace(1);
|
||||
m_previousComposition = wpi::util::GetStackTrace(1);
|
||||
} else {
|
||||
m_previousComposition.reset();
|
||||
}
|
||||
@@ -188,7 +188,7 @@ std::optional<std::string> Command::GetPreviousCompositionSite() const {
|
||||
return m_previousComposition;
|
||||
}
|
||||
|
||||
void Command::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void Command::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Command");
|
||||
builder.AddStringProperty(".name", [this] { return GetName(); }, nullptr);
|
||||
builder.AddBooleanProperty(
|
||||
@@ -220,7 +220,7 @@ void Command::InitSendable(wpi::SendableBuilder& builder) {
|
||||
"runsWhenDisabled", [this] { return RunsWhenDisabled(); }, nullptr);
|
||||
}
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
bool RequirementsDisjoint(Command* first, Command* second) {
|
||||
bool disjoint = true;
|
||||
auto&& requirements = second->GetRequirements();
|
||||
@@ -229,4 +229,4 @@ bool RequirementsDisjoint(Command* first, Command* second) {
|
||||
}
|
||||
return disjoint;
|
||||
}
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "wpi/commands2/WrapperCommand.hpp"
|
||||
#include "wpi/system/Errors.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandPtr::CommandPtr(std::unique_ptr<Command>&& command)
|
||||
: m_ptr(std::move(command)) {
|
||||
@@ -32,12 +32,12 @@ CommandPtr::CommandPtr(std::unique_ptr<Command>&& command)
|
||||
CommandPtr::CommandPtr(CommandPtr&& rhs) {
|
||||
m_ptr = std::move(rhs.m_ptr);
|
||||
AssertValid();
|
||||
rhs.m_moveOutSite = wpi::GetStackTrace(1);
|
||||
rhs.m_moveOutSite = wpi::util::GetStackTrace(1);
|
||||
}
|
||||
|
||||
void CommandPtr::AssertValid() const {
|
||||
if (!m_ptr) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Moved-from CommandPtr object used!\nMoved out at:\n{}",
|
||||
m_moveOutSite);
|
||||
}
|
||||
@@ -131,7 +131,7 @@ CommandPtr CommandPtr::BeforeStarting(CommandPtr&& before) && {
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
CommandPtr CommandPtr::WithTimeout(units::second_t duration) && {
|
||||
CommandPtr CommandPtr::WithTimeout(wpi::units::second_t duration) && {
|
||||
AssertValid();
|
||||
std::vector<std::unique_ptr<Command>> temp;
|
||||
temp.emplace_back(std::move(m_ptr));
|
||||
|
||||
@@ -24,39 +24,39 @@
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
#include "wpi/util/sendable/SendableRegistry.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
class CommandScheduler::Impl {
|
||||
public:
|
||||
// A set of the currently-running commands.
|
||||
wpi::SmallSet<Command*, 12> scheduledCommands;
|
||||
wpi::util::SmallSet<Command*, 12> scheduledCommands;
|
||||
|
||||
// A map from required subsystems to their requiring commands. Also used as a
|
||||
// set of the currently-required subsystems.
|
||||
wpi::DenseMap<Subsystem*, Command*> requirements;
|
||||
wpi::util::DenseMap<Subsystem*, Command*> requirements;
|
||||
|
||||
// A map from subsystems registered with the scheduler to their default
|
||||
// commands. Also used as a list of currently-registered subsystems.
|
||||
wpi::DenseMap<Subsystem*, std::unique_ptr<Command>> subsystems;
|
||||
wpi::util::DenseMap<Subsystem*, std::unique_ptr<Command>> subsystems;
|
||||
|
||||
frc::EventLoop defaultButtonLoop;
|
||||
wpi::EventLoop defaultButtonLoop;
|
||||
// The set of currently-registered buttons that will be polled every
|
||||
// iteration.
|
||||
frc::EventLoop* activeButtonLoop{&defaultButtonLoop};
|
||||
wpi::EventLoop* activeButtonLoop{&defaultButtonLoop};
|
||||
|
||||
bool disabled{false};
|
||||
|
||||
// Lists of user-supplied actions to be executed on scheduling events for
|
||||
// every command.
|
||||
wpi::SmallVector<Action, 4> initActions;
|
||||
wpi::SmallVector<Action, 4> executeActions;
|
||||
wpi::SmallVector<InterruptAction, 4> interruptActions;
|
||||
wpi::SmallVector<Action, 4> finishActions;
|
||||
wpi::util::SmallVector<Action, 4> initActions;
|
||||
wpi::util::SmallVector<Action, 4> executeActions;
|
||||
wpi::util::SmallVector<InterruptAction, 4> interruptActions;
|
||||
wpi::util::SmallVector<Action, 4> finishActions;
|
||||
|
||||
// Map of Command* -> CommandPtr for CommandPtrs transferred to the scheduler
|
||||
// via Schedule(CommandPtr&&). These are erased (destroyed) at the very end of
|
||||
// the loop cycle when the command lifecycle is complete.
|
||||
wpi::DenseMap<Command*, CommandPtr> ownedCommands;
|
||||
wpi::util::DenseMap<Command*, CommandPtr> ownedCommands;
|
||||
};
|
||||
|
||||
template <typename TMap, typename TKey>
|
||||
@@ -65,15 +65,15 @@ static bool ContainsKey(const TMap& map, TKey keyToCheck) {
|
||||
}
|
||||
|
||||
CommandScheduler::CommandScheduler()
|
||||
: m_impl(new Impl), m_watchdog(frc::TimedRobot::kDefaultPeriod, [] {
|
||||
: m_impl(new Impl), m_watchdog(wpi::TimedRobot::kDefaultPeriod, [] {
|
||||
std::puts("CommandScheduler loop time overrun.");
|
||||
}) {
|
||||
HAL_ReportUsage("CommandScheduler", "");
|
||||
wpi::SendableRegistry::Add(this, "Scheduler");
|
||||
wpi::util::SendableRegistry::Add(this, "Scheduler");
|
||||
}
|
||||
|
||||
CommandScheduler::~CommandScheduler() {
|
||||
wpi::SendableRegistry::Remove(this);
|
||||
wpi::util::SendableRegistry::Remove(this);
|
||||
std::unique_ptr<Impl>().swap(m_impl);
|
||||
}
|
||||
|
||||
@@ -82,19 +82,19 @@ CommandScheduler& CommandScheduler::GetInstance() {
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
void CommandScheduler::SetPeriod(units::second_t period) {
|
||||
void CommandScheduler::SetPeriod(wpi::units::second_t period) {
|
||||
m_watchdog.SetTimeout(period);
|
||||
}
|
||||
|
||||
frc::EventLoop* CommandScheduler::GetActiveButtonLoop() const {
|
||||
wpi::EventLoop* CommandScheduler::GetActiveButtonLoop() const {
|
||||
return m_impl->activeButtonLoop;
|
||||
}
|
||||
|
||||
void CommandScheduler::SetActiveButtonLoop(frc::EventLoop* loop) {
|
||||
void CommandScheduler::SetActiveButtonLoop(wpi::EventLoop* loop) {
|
||||
m_impl->activeButtonLoop = loop;
|
||||
}
|
||||
|
||||
frc::EventLoop* CommandScheduler::GetDefaultButtonLoop() const {
|
||||
wpi::EventLoop* CommandScheduler::GetDefaultButtonLoop() const {
|
||||
return &(m_impl->defaultButtonLoop);
|
||||
}
|
||||
|
||||
@@ -102,13 +102,13 @@ void CommandScheduler::Schedule(Command* command) {
|
||||
RequireUngrouped(command);
|
||||
|
||||
if (m_impl->disabled || m_impl->scheduledCommands.contains(command) ||
|
||||
(frc::RobotState::IsDisabled() && !command->RunsWhenDisabled())) {
|
||||
(wpi::RobotState::IsDisabled() && !command->RunsWhenDisabled())) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& requirements = command->GetRequirements();
|
||||
|
||||
wpi::SmallVector<Command*, 8> intersection;
|
||||
wpi::util::SmallVector<Command*, 8> intersection;
|
||||
|
||||
bool isDisjoint = true;
|
||||
bool allInterruptible = true;
|
||||
@@ -171,7 +171,7 @@ void CommandScheduler::Run() {
|
||||
// Run the periodic method of all registered subsystems.
|
||||
for (auto&& subsystem : m_impl->subsystems) {
|
||||
subsystem.getFirst()->Periodic();
|
||||
if constexpr (frc::RobotBase::IsSimulation()) {
|
||||
if constexpr (wpi::RobotBase::IsSimulation()) {
|
||||
subsystem.getFirst()->SimulationPeriodic();
|
||||
}
|
||||
m_watchdog.AddEpoch(subsystem.getFirst()->GetName() + ".Periodic()");
|
||||
@@ -179,14 +179,14 @@ void CommandScheduler::Run() {
|
||||
|
||||
// Cache the active instance to avoid concurrency problems if SetActiveLoop()
|
||||
// is called from inside the button bindings.
|
||||
frc::EventLoop* loopCache = m_impl->activeButtonLoop;
|
||||
wpi::EventLoop* loopCache = m_impl->activeButtonLoop;
|
||||
// Poll buttons for new commands to add.
|
||||
loopCache->Poll();
|
||||
m_watchdog.AddEpoch("buttons.Run()");
|
||||
|
||||
bool isDisabled = frc::RobotState::IsDisabled();
|
||||
bool isDisabled = wpi::RobotState::IsDisabled();
|
||||
// create a new set to avoid iterator invalidation.
|
||||
for (Command* command : wpi::SmallSet(m_impl->scheduledCommands)) {
|
||||
for (Command* command : wpi::util::SmallSet(m_impl->scheduledCommands)) {
|
||||
if (!IsScheduled(command)) {
|
||||
continue; // skip as the normal scheduledCommands was modified
|
||||
}
|
||||
@@ -284,7 +284,7 @@ void CommandScheduler::UnregisterAllSubsystems() {
|
||||
void CommandScheduler::SetDefaultCommand(Subsystem* subsystem,
|
||||
CommandPtr&& defaultCommand) {
|
||||
if (!defaultCommand.get()->HasRequirement(subsystem)) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse, "{}",
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse, "{}",
|
||||
"Default commands must require their subsystem!");
|
||||
}
|
||||
RequireUngrouped(defaultCommand.get());
|
||||
@@ -347,7 +347,7 @@ void CommandScheduler::Cancel(std::initializer_list<Command*> commands) {
|
||||
}
|
||||
|
||||
void CommandScheduler::CancelAll() {
|
||||
wpi::SmallVector<Command*, 16> commands;
|
||||
wpi::util::SmallVector<Command*, 16> commands;
|
||||
for (auto&& command : m_impl->scheduledCommands) {
|
||||
commands.emplace_back(command);
|
||||
}
|
||||
@@ -430,7 +430,7 @@ void CommandScheduler::OnCommandFinish(Action action) {
|
||||
void CommandScheduler::RequireUngrouped(const Command* command) {
|
||||
auto stacktrace = command->GetPreviousCompositionSite();
|
||||
if (stacktrace.has_value()) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Commands that have been composed may not be added to "
|
||||
"another composition or scheduled individually!"
|
||||
"\nOriginally composed at:\n{}",
|
||||
@@ -454,7 +454,7 @@ void CommandScheduler::RequireUngrouped(
|
||||
|
||||
void CommandScheduler::RequireUngroupedAndUnscheduled(const Command* command) {
|
||||
if (IsScheduled(command)) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Commands that have been scheduled individually may "
|
||||
"not be added to another composition!");
|
||||
}
|
||||
@@ -475,7 +475,7 @@ void CommandScheduler::RequireUngroupedAndUnscheduled(
|
||||
}
|
||||
}
|
||||
|
||||
void CommandScheduler::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void CommandScheduler::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Scheduler");
|
||||
builder.AddStringArrayProperty(
|
||||
"Names",
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "wpi/util/FunctionExtras.hpp"
|
||||
#include "wpi/util/deprecated.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
// Factories
|
||||
|
||||
@@ -73,7 +73,7 @@ CommandPtr cmd::Print(std::string_view msg) {
|
||||
return PrintCommand(msg).ToPtr();
|
||||
}
|
||||
|
||||
CommandPtr cmd::DeferredProxy(wpi::unique_function<Command*()> supplier) {
|
||||
CommandPtr cmd::DeferredProxy(wpi::util::unique_function<Command*()> supplier) {
|
||||
return Defer(
|
||||
[supplier = std::move(supplier)]() mutable {
|
||||
// There is no non-owning version of AsProxy(), so use the non-owning
|
||||
@@ -83,13 +83,13 @@ CommandPtr cmd::DeferredProxy(wpi::unique_function<Command*()> supplier) {
|
||||
{});
|
||||
}
|
||||
|
||||
CommandPtr cmd::DeferredProxy(wpi::unique_function<CommandPtr()> supplier) {
|
||||
CommandPtr cmd::DeferredProxy(wpi::util::unique_function<CommandPtr()> supplier) {
|
||||
return Defer([supplier = std::move(
|
||||
supplier)]() mutable { return supplier().AsProxy(); },
|
||||
{});
|
||||
}
|
||||
|
||||
CommandPtr cmd::Wait(units::second_t duration) {
|
||||
CommandPtr cmd::Wait(wpi::units::second_t duration) {
|
||||
return WaitCommand(duration).ToPtr();
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ CommandPtr cmd::Either(CommandPtr&& onTrue, CommandPtr&& onFalse,
|
||||
.ToPtr();
|
||||
}
|
||||
|
||||
CommandPtr cmd::Defer(wpi::unique_function<CommandPtr()> supplier,
|
||||
CommandPtr cmd::Defer(wpi::util::unique_function<CommandPtr()> supplier,
|
||||
Requirements requirements) {
|
||||
return DeferredCommand(std::move(supplier), requirements).ToPtr();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
ConditionalCommand::ConditionalCommand(std::unique_ptr<Command>&& onTrue,
|
||||
std::unique_ptr<Command>&& onFalse,
|
||||
@@ -69,7 +69,7 @@ Command::InterruptionBehavior ConditionalCommand::GetInterruptionBehavior()
|
||||
}
|
||||
}
|
||||
|
||||
void ConditionalCommand::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void ConditionalCommand::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
Command::InitSendable(builder);
|
||||
builder.AddStringProperty(
|
||||
"onTrue", [this] { return m_onTrue->GetName(); }, nullptr);
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include "wpi/commands2/Commands.hpp"
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
DeferredCommand::DeferredCommand(wpi::unique_function<CommandPtr()> supplier,
|
||||
DeferredCommand::DeferredCommand(wpi::util::unique_function<CommandPtr()> supplier,
|
||||
Requirements requirements)
|
||||
: m_supplier{std::move(supplier)} {
|
||||
AddRequirements(requirements);
|
||||
@@ -40,7 +40,7 @@ bool DeferredCommand::IsFinished() {
|
||||
return m_command->IsFinished();
|
||||
}
|
||||
|
||||
void DeferredCommand::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void DeferredCommand::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
Command::InitSendable(builder);
|
||||
builder.AddStringProperty(
|
||||
"deferred", [this] { return m_command->GetName(); }, nullptr);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
FunctionalCommand::FunctionalCommand(std::function<void()> onInit,
|
||||
std::function<void()> onExecute,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
InstantCommand::InstantCommand(std::function<void()> toRun,
|
||||
Requirements requirements)
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
NotifierCommand::NotifierCommand(std::function<void()> toRun,
|
||||
units::second_t period,
|
||||
wpi::units::second_t period,
|
||||
Requirements requirements)
|
||||
: m_toRun(toRun), m_notifier{std::move(toRun)}, m_period{period} {
|
||||
AddRequirements(requirements);
|
||||
@@ -24,7 +24,7 @@ NotifierCommand::NotifierCommand(NotifierCommand&& other)
|
||||
NotifierCommand::NotifierCommand(const NotifierCommand& other)
|
||||
: CommandHelper(other),
|
||||
m_toRun(other.m_toRun),
|
||||
m_notifier(frc::Notifier(other.m_toRun)),
|
||||
m_notifier(wpi::Notifier(other.m_toRun)),
|
||||
m_period(other.m_period) {}
|
||||
|
||||
void NotifierCommand::Initialize() {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
ParallelCommandGroup::ParallelCommandGroup(
|
||||
std::vector<std::unique_ptr<Command>>&& commands) {
|
||||
@@ -69,7 +69,7 @@ void ParallelCommandGroup::AddCommands(
|
||||
CommandScheduler::GetInstance().RequireUngroupedAndUnscheduled(commands);
|
||||
|
||||
if (isRunning) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Commands cannot be added to a CommandGroup "
|
||||
"while the group is running");
|
||||
}
|
||||
@@ -85,7 +85,7 @@ void ParallelCommandGroup::AddCommands(
|
||||
}
|
||||
m_commands.emplace_back(std::move(command), false);
|
||||
} else {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Multiple commands in a parallel group cannot "
|
||||
"require the same subsystems");
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
ParallelDeadlineGroup::ParallelDeadlineGroup(
|
||||
std::unique_ptr<Command>&& deadline,
|
||||
@@ -69,7 +69,7 @@ void ParallelDeadlineGroup::AddCommands(
|
||||
CommandScheduler::GetInstance().RequireUngroupedAndUnscheduled(commands);
|
||||
|
||||
if (!m_finished) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Commands cannot be added to a CommandGroup "
|
||||
"while the group is running");
|
||||
}
|
||||
@@ -85,7 +85,7 @@ void ParallelDeadlineGroup::AddCommands(
|
||||
}
|
||||
m_commands.emplace_back(std::move(command), false);
|
||||
} else {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Multiple commands in a parallel group cannot "
|
||||
"require the same subsystems");
|
||||
}
|
||||
@@ -100,7 +100,7 @@ void ParallelDeadlineGroup::SetDeadline(std::unique_ptr<Command>&& deadline) {
|
||||
m_runWhenDisabled &= m_deadline->RunsWhenDisabled();
|
||||
}
|
||||
|
||||
void ParallelDeadlineGroup::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void ParallelDeadlineGroup::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
Command::InitSendable(builder);
|
||||
|
||||
builder.AddStringProperty(
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
ParallelRaceGroup::ParallelRaceGroup(
|
||||
std::vector<std::unique_ptr<Command>>&& commands) {
|
||||
@@ -56,7 +56,7 @@ void ParallelRaceGroup::AddCommands(
|
||||
CommandScheduler::GetInstance().RequireUngroupedAndUnscheduled(commands);
|
||||
|
||||
if (isRunning) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Commands cannot be added to a CommandGroup "
|
||||
"while the group is running");
|
||||
}
|
||||
@@ -72,7 +72,7 @@ void ParallelRaceGroup::AddCommands(
|
||||
}
|
||||
m_commands.emplace_back(std::move(command));
|
||||
} else {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Multiple commands in a parallel group cannot "
|
||||
"require the same subsystems");
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
|
||||
#include "wpi/util/print.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
PrintCommand::PrintCommand(std::string_view message)
|
||||
: CommandHelper{[str = std::string(message)] { wpi::print("{}\n", str); },
|
||||
: CommandHelper{[str = std::string(message)] { wpi::util::print("{}\n", str); },
|
||||
{}} {}
|
||||
|
||||
bool PrintCommand::RunsWhenDisabled() const {
|
||||
|
||||
@@ -12,13 +12,13 @@
|
||||
#include "wpi/util/deprecated.hpp"
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
WPI_IGNORE_DEPRECATED
|
||||
ProxyCommand::ProxyCommand(wpi::unique_function<Command*()> supplier)
|
||||
ProxyCommand::ProxyCommand(wpi::util::unique_function<Command*()> supplier)
|
||||
: m_supplier(std::move(supplier)) {}
|
||||
|
||||
ProxyCommand::ProxyCommand(wpi::unique_function<CommandPtr()> supplier)
|
||||
ProxyCommand::ProxyCommand(wpi::util::unique_function<CommandPtr()> supplier)
|
||||
: ProxyCommand([supplier = std::move(supplier),
|
||||
holder = std::optional<CommandPtr>{}]() mutable {
|
||||
holder = supplier();
|
||||
@@ -38,7 +38,7 @@ ProxyCommand::ProxyCommand(std::unique_ptr<Command> command) {
|
||||
|
||||
void ProxyCommand::Initialize() {
|
||||
m_command = m_supplier();
|
||||
frc2::CommandScheduler::GetInstance().Schedule(m_command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(m_command);
|
||||
}
|
||||
|
||||
void ProxyCommand::End(bool interrupted) {
|
||||
@@ -55,7 +55,7 @@ bool ProxyCommand::IsFinished() {
|
||||
return m_command == nullptr || !m_command->IsScheduled();
|
||||
}
|
||||
|
||||
void ProxyCommand::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void ProxyCommand::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
Command::InitSendable(builder);
|
||||
builder.AddStringProperty(
|
||||
"proxied",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
RepeatCommand::RepeatCommand(std::unique_ptr<Command>&& command) {
|
||||
CommandScheduler::GetInstance().RequireUngroupedAndUnscheduled(command.get());
|
||||
@@ -58,7 +58,7 @@ Command::InterruptionBehavior RepeatCommand::GetInterruptionBehavior() const {
|
||||
return m_command->GetInterruptionBehavior();
|
||||
}
|
||||
|
||||
void RepeatCommand::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void RepeatCommand::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
Command::InitSendable(builder);
|
||||
builder.AddStringProperty(
|
||||
"command", [this] { return m_command->GetName(); }, nullptr);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
RunCommand::RunCommand(std::function<void()> toRun, Requirements requirements)
|
||||
: CommandHelper([] {}, std::move(toRun), [](bool interrupted) {},
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "wpi/commands2/ScheduleCommand.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
ScheduleCommand::ScheduleCommand(std::span<Command* const> toSchedule) {
|
||||
for (auto cmd : toSchedule) {
|
||||
@@ -18,7 +18,7 @@ ScheduleCommand::ScheduleCommand(Command* toSchedule) {
|
||||
|
||||
void ScheduleCommand::Initialize() {
|
||||
for (auto command : m_toSchedule) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
SequentialCommandGroup::SequentialCommandGroup(
|
||||
std::vector<std::unique_ptr<Command>>&& commands) {
|
||||
@@ -68,7 +68,7 @@ void SequentialCommandGroup::AddCommands(
|
||||
CommandScheduler::GetInstance().RequireUngroupedAndUnscheduled(commands);
|
||||
|
||||
if (m_currentCommandIndex != invalid_index) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Commands cannot be added to a CommandGroup "
|
||||
"while the group is running");
|
||||
}
|
||||
@@ -85,7 +85,7 @@ void SequentialCommandGroup::AddCommands(
|
||||
}
|
||||
}
|
||||
|
||||
void SequentialCommandGroup::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void SequentialCommandGroup::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
Command::InitSendable(builder);
|
||||
builder.AddIntegerProperty(
|
||||
"index", [this] { return m_currentCommandIndex; }, nullptr);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
StartEndCommand::StartEndCommand(std::function<void()> onInit,
|
||||
std::function<void()> onEnd,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/commands2/Commands.hpp"
|
||||
#include "wpi/util/Demangle.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
Subsystem::~Subsystem() {
|
||||
CommandScheduler::GetInstance().UnregisterSubsystem(this);
|
||||
}
|
||||
@@ -21,7 +21,7 @@ void Subsystem::Periodic() {}
|
||||
void Subsystem::SimulationPeriodic() {}
|
||||
|
||||
std::string Subsystem::GetName() const {
|
||||
return wpi::GetTypeName(*this);
|
||||
return wpi::util::GetTypeName(*this);
|
||||
}
|
||||
|
||||
void Subsystem::SetDefaultCommand(CommandPtr&& defaultCommand) {
|
||||
@@ -72,6 +72,6 @@ CommandPtr Subsystem::StartRun(std::function<void()> start,
|
||||
return cmd::StartRun(std::move(start), std::move(run), {this});
|
||||
}
|
||||
|
||||
CommandPtr Subsystem::Defer(wpi::unique_function<CommandPtr()> supplier) {
|
||||
CommandPtr Subsystem::Defer(wpi::util::unique_function<CommandPtr()> supplier) {
|
||||
return cmd::Defer(std::move(supplier), {this});
|
||||
}
|
||||
|
||||
@@ -11,19 +11,19 @@
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
#include "wpi/util/sendable/SendableRegistry.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
SubsystemBase::SubsystemBase() {
|
||||
wpi::SendableRegistry::Add(this, GetTypeName(*this));
|
||||
wpi::util::SendableRegistry::Add(this, GetTypeName(*this));
|
||||
CommandScheduler::GetInstance().RegisterSubsystem({this});
|
||||
}
|
||||
|
||||
SubsystemBase::SubsystemBase(std::string_view name) {
|
||||
wpi::SendableRegistry::Add(this, name);
|
||||
wpi::util::SendableRegistry::Add(this, name);
|
||||
CommandScheduler::GetInstance().RegisterSubsystem({this});
|
||||
}
|
||||
|
||||
void SubsystemBase::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void SubsystemBase::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Subsystem");
|
||||
builder.AddBooleanProperty(
|
||||
".hasDefault", [this] { return GetDefaultCommand() != nullptr; },
|
||||
@@ -54,21 +54,21 @@ void SubsystemBase::InitSendable(wpi::SendableBuilder& builder) {
|
||||
}
|
||||
|
||||
std::string SubsystemBase::GetName() const {
|
||||
return wpi::SendableRegistry::GetName(this);
|
||||
return wpi::util::SendableRegistry::GetName(this);
|
||||
}
|
||||
|
||||
void SubsystemBase::SetName(std::string_view name) {
|
||||
wpi::SendableRegistry::SetName(this, name);
|
||||
wpi::util::SendableRegistry::SetName(this, name);
|
||||
}
|
||||
|
||||
std::string SubsystemBase::GetSubsystem() const {
|
||||
return wpi::SendableRegistry::GetSubsystem(this);
|
||||
return wpi::util::SendableRegistry::GetSubsystem(this);
|
||||
}
|
||||
|
||||
void SubsystemBase::SetSubsystem(std::string_view name) {
|
||||
wpi::SendableRegistry::SetSubsystem(this, name);
|
||||
wpi::util::SendableRegistry::SetSubsystem(this, name);
|
||||
}
|
||||
|
||||
void SubsystemBase::AddChild(std::string name, wpi::Sendable* child) {
|
||||
wpi::SendableRegistry::Add(child, GetSubsystem(), name);
|
||||
void SubsystemBase::AddChild(std::string name, wpi::util::Sendable* child) {
|
||||
wpi::util::SendableRegistry::Add(child, GetSubsystem(), name);
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
WaitCommand::WaitCommand(units::second_t duration) : m_duration{duration} {
|
||||
WaitCommand::WaitCommand(wpi::units::second_t duration) : m_duration{duration} {
|
||||
SetName(fmt::format("{}: {}", GetName(), duration));
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ bool WaitCommand::RunsWhenDisabled() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void WaitCommand::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void WaitCommand::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
Command::InitSendable(builder);
|
||||
builder.AddDoubleProperty(
|
||||
"duration", [this] { return m_duration.value(); }, nullptr);
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
|
||||
#include "wpi/system/Timer.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
WaitUntilCommand::WaitUntilCommand(std::function<bool()> condition)
|
||||
: m_condition{std::move(condition)} {}
|
||||
|
||||
WaitUntilCommand::WaitUntilCommand(units::second_t time)
|
||||
: m_condition{[=] { return frc::Timer::GetMatchTime() - time > 0_s; }} {}
|
||||
WaitUntilCommand::WaitUntilCommand(wpi::units::second_t time)
|
||||
: m_condition{[=] { return wpi::Timer::GetMatchTime() - time > 0_s; }} {}
|
||||
|
||||
bool WaitUntilCommand::IsFinished() {
|
||||
return m_condition();
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "wpi/commands2/Command.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
WrapperCommand::WrapperCommand(std::unique_ptr<Command>&& command) {
|
||||
CommandScheduler::GetInstance().RequireUngroupedAndUnscheduled(command.get());
|
||||
@@ -42,6 +42,6 @@ Command::InterruptionBehavior WrapperCommand::GetInterruptionBehavior() const {
|
||||
return m_command->GetInterruptionBehavior();
|
||||
}
|
||||
|
||||
wpi::SmallSet<Subsystem*, 4> WrapperCommand::GetRequirements() const {
|
||||
wpi::util::SmallSet<Subsystem*, 4> WrapperCommand::GetRequirements() const {
|
||||
return m_command->GetRequirements();
|
||||
}
|
||||
|
||||
@@ -4,128 +4,128 @@
|
||||
|
||||
#include "wpi/commands2/button/CommandGamepad.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandGamepad::CommandGamepad(int port)
|
||||
: CommandGenericHID(port), m_hid{frc::Gamepad(port)} {}
|
||||
: CommandGenericHID(port), m_hid{wpi::Gamepad(port)} {}
|
||||
|
||||
frc::Gamepad& CommandGamepad::GetHID() {
|
||||
wpi::Gamepad& CommandGamepad::GetHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::SouthFace(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kSouthFace, loop);
|
||||
Trigger CommandGamepad::SouthFace(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kSouthFace, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::EastFace(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kEastFace, loop);
|
||||
Trigger CommandGamepad::EastFace(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kEastFace, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::WestFace(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kWestFace, loop);
|
||||
Trigger CommandGamepad::WestFace(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kWestFace, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::NorthFace(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kNorthFace, loop);
|
||||
Trigger CommandGamepad::NorthFace(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kNorthFace, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Back(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kBack, loop);
|
||||
Trigger CommandGamepad::Back(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kBack, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Guide(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kGuide, loop);
|
||||
Trigger CommandGamepad::Guide(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kGuide, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Start(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kStart, loop);
|
||||
Trigger CommandGamepad::Start(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kStart, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::LeftStick(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kLeftStick, loop);
|
||||
Trigger CommandGamepad::LeftStick(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kLeftStick, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::RightStick(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kRightStick, loop);
|
||||
Trigger CommandGamepad::RightStick(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kRightStick, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::LeftShoulder(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kLeftShoulder, loop);
|
||||
Trigger CommandGamepad::LeftShoulder(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kLeftShoulder, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::RightShoulder(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kRightShoulder, loop);
|
||||
Trigger CommandGamepad::RightShoulder(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kRightShoulder, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::DpadUp(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kDpadUp, loop);
|
||||
Trigger CommandGamepad::DpadUp(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kDpadUp, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::DpadDown(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kDpadDown, loop);
|
||||
Trigger CommandGamepad::DpadDown(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kDpadDown, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::DpadLeft(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kDpadLeft, loop);
|
||||
Trigger CommandGamepad::DpadLeft(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kDpadLeft, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::DpadRight(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kDpadRight, loop);
|
||||
Trigger CommandGamepad::DpadRight(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kDpadRight, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Misc1(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kMisc1, loop);
|
||||
Trigger CommandGamepad::Misc1(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kMisc1, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::RightPaddle1(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kRightPaddle1, loop);
|
||||
Trigger CommandGamepad::RightPaddle1(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kRightPaddle1, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::LeftPaddle1(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kLeftPaddle1, loop);
|
||||
Trigger CommandGamepad::LeftPaddle1(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kLeftPaddle1, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::RightPaddle2(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kRightPaddle2, loop);
|
||||
Trigger CommandGamepad::RightPaddle2(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kRightPaddle2, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::LeftPaddle2(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kLeftPaddle2, loop);
|
||||
Trigger CommandGamepad::LeftPaddle2(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kLeftPaddle2, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Touchpad(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kTouchpad, loop);
|
||||
Trigger CommandGamepad::Touchpad(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kTouchpad, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Misc2(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kMisc2, loop);
|
||||
Trigger CommandGamepad::Misc2(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kMisc2, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Misc3(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kMisc3, loop);
|
||||
Trigger CommandGamepad::Misc3(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kMisc3, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Misc4(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kMisc4, loop);
|
||||
Trigger CommandGamepad::Misc4(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kMisc4, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Misc5(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kMisc5, loop);
|
||||
Trigger CommandGamepad::Misc5(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kMisc5, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::Misc6(frc::EventLoop* loop) const {
|
||||
return Button(frc::Gamepad::Button::kMisc6, loop);
|
||||
Trigger CommandGamepad::Misc6(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Gamepad::Button::kMisc6, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::LeftTrigger(double threshold,
|
||||
frc::EventLoop* loop) const {
|
||||
wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, threshold] {
|
||||
return m_hid.GetLeftTriggerAxis() > threshold;
|
||||
});
|
||||
}
|
||||
|
||||
Trigger CommandGamepad::RightTrigger(double threshold,
|
||||
frc::EventLoop* loop) const {
|
||||
wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, threshold] {
|
||||
return m_hid.GetRightTriggerAxis() > threshold;
|
||||
});
|
||||
|
||||
@@ -4,87 +4,87 @@
|
||||
|
||||
#include "wpi/commands2/button/CommandGenericHID.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandGenericHID::CommandGenericHID(int port) : m_hid{port} {}
|
||||
|
||||
frc::GenericHID& CommandGenericHID::GetHID() {
|
||||
wpi::GenericHID& CommandGenericHID::GetHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::Button(int button, frc::EventLoop* loop) const {
|
||||
Trigger CommandGenericHID::Button(int button, wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, button] { return m_hid.GetRawButton(button); });
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POV(frc::DriverStation::POVDirection angle,
|
||||
frc::EventLoop* loop) const {
|
||||
Trigger CommandGenericHID::POV(wpi::DriverStation::POVDirection angle,
|
||||
wpi::EventLoop* loop) const {
|
||||
return POV(0, angle, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POV(int pov, frc::DriverStation::POVDirection angle,
|
||||
frc::EventLoop* loop) const {
|
||||
Trigger CommandGenericHID::POV(int pov, wpi::DriverStation::POVDirection angle,
|
||||
wpi::EventLoop* loop) const {
|
||||
return Trigger(loop,
|
||||
[this, pov, angle] { return m_hid.GetPOV(pov) == angle; });
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVUp(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kUp, loop);
|
||||
Trigger CommandGenericHID::POVUp(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kUp, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVUpRight(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kUpRight, loop);
|
||||
Trigger CommandGenericHID::POVUpRight(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kUpRight, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVRight(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kRight, loop);
|
||||
Trigger CommandGenericHID::POVRight(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kRight, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVDownRight(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kDownRight, loop);
|
||||
Trigger CommandGenericHID::POVDownRight(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kDownRight, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVDown(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kDown, loop);
|
||||
Trigger CommandGenericHID::POVDown(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kDown, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVDownLeft(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kDownLeft, loop);
|
||||
Trigger CommandGenericHID::POVDownLeft(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kDownLeft, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVLeft(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kLeft, loop);
|
||||
Trigger CommandGenericHID::POVLeft(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kLeft, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVUpLeft(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kUpLeft, loop);
|
||||
Trigger CommandGenericHID::POVUpLeft(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kUpLeft, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::POVCenter(frc::EventLoop* loop) const {
|
||||
return POV(frc::DriverStation::POVDirection::kCenter, loop);
|
||||
Trigger CommandGenericHID::POVCenter(wpi::EventLoop* loop) const {
|
||||
return POV(wpi::DriverStation::POVDirection::kCenter, loop);
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::AxisLessThan(int axis, double threshold,
|
||||
frc::EventLoop* loop) const {
|
||||
wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, axis, threshold]() {
|
||||
return m_hid.GetRawAxis(axis) < threshold;
|
||||
});
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::AxisGreaterThan(int axis, double threshold,
|
||||
frc::EventLoop* loop) const {
|
||||
wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, axis, threshold]() {
|
||||
return m_hid.GetRawAxis(axis) > threshold;
|
||||
});
|
||||
}
|
||||
|
||||
Trigger CommandGenericHID::AxisMagnitudeGreaterThan(
|
||||
int axis, double threshold, frc::EventLoop* loop) const {
|
||||
int axis, double threshold, wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, axis, threshold]() {
|
||||
return std::abs(m_hid.GetRawAxis(axis)) > threshold;
|
||||
});
|
||||
}
|
||||
|
||||
void CommandGenericHID::SetRumble(frc::GenericHID::RumbleType type,
|
||||
void CommandGenericHID::SetRumble(wpi::GenericHID::RumbleType type,
|
||||
double value) {
|
||||
m_hid.SetRumble(type, value);
|
||||
}
|
||||
|
||||
@@ -4,28 +4,28 @@
|
||||
|
||||
#include "wpi/commands2/button/CommandJoystick.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandJoystick::CommandJoystick(int port)
|
||||
: CommandGenericHID(port), m_hid{frc::Joystick(port)} {}
|
||||
: CommandGenericHID(port), m_hid{wpi::Joystick(port)} {}
|
||||
|
||||
frc::Joystick& CommandJoystick::GetHID() {
|
||||
wpi::Joystick& CommandJoystick::GetHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
Trigger CommandJoystick::Trigger(frc::EventLoop* loop) const {
|
||||
return Button(frc::Joystick::ButtonType::kTriggerButton, loop);
|
||||
Trigger CommandJoystick::Trigger(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Joystick::ButtonType::kTriggerButton, loop);
|
||||
}
|
||||
|
||||
Trigger CommandJoystick::Top(frc::EventLoop* loop) const {
|
||||
return Button(frc::Joystick::ButtonType::kTopButton, loop);
|
||||
Trigger CommandJoystick::Top(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::Joystick::ButtonType::kTopButton, loop);
|
||||
}
|
||||
|
||||
double CommandJoystick::GetMagnitude() const {
|
||||
return m_hid.GetMagnitude();
|
||||
}
|
||||
|
||||
units::radian_t CommandJoystick::GetDirection() const {
|
||||
wpi::units::radian_t CommandJoystick::GetDirection() const {
|
||||
// https://docs.wpilib.org/en/stable/docs/software/basic-programming/coordinate-system.html#joystick-and-controller-coordinate-system
|
||||
// A positive rotation around the X axis moves the joystick right, and a
|
||||
// positive rotation around the Y axis moves the joystick backward. When
|
||||
|
||||
@@ -7,23 +7,23 @@
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
NetworkButton::NetworkButton(nt::BooleanTopic topic)
|
||||
NetworkButton::NetworkButton(wpi::nt::BooleanTopic topic)
|
||||
: NetworkButton(topic.Subscribe(false)) {}
|
||||
|
||||
NetworkButton::NetworkButton(nt::BooleanSubscriber sub)
|
||||
: Trigger([sub = std::make_shared<nt::BooleanSubscriber>(std::move(sub))] {
|
||||
NetworkButton::NetworkButton(wpi::nt::BooleanSubscriber sub)
|
||||
: Trigger([sub = std::make_shared<wpi::nt::BooleanSubscriber>(std::move(sub))] {
|
||||
return sub->GetTopic().GetInstance().IsConnected() && sub->Get();
|
||||
}) {}
|
||||
|
||||
NetworkButton::NetworkButton(std::shared_ptr<nt::NetworkTable> table,
|
||||
NetworkButton::NetworkButton(std::shared_ptr<wpi::nt::NetworkTable> table,
|
||||
std::string_view field)
|
||||
: NetworkButton(table->GetBooleanTopic(field)) {}
|
||||
|
||||
NetworkButton::NetworkButton(std::string_view table, std::string_view field)
|
||||
: NetworkButton(nt::NetworkTableInstance::GetDefault(), table, field) {}
|
||||
: NetworkButton(wpi::nt::NetworkTableInstance::GetDefault(), table, field) {}
|
||||
|
||||
NetworkButton::NetworkButton(nt::NetworkTableInstance inst,
|
||||
NetworkButton::NetworkButton(wpi::nt::NetworkTableInstance inst,
|
||||
std::string_view table, std::string_view field)
|
||||
: NetworkButton(inst.GetTable(table), field) {}
|
||||
|
||||
@@ -6,20 +6,20 @@
|
||||
|
||||
#include "wpi/driverstation/DriverStation.hpp"
|
||||
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
Trigger RobotModeTriggers::Autonomous() {
|
||||
return Trigger{&frc::DriverStation::IsAutonomousEnabled};
|
||||
return Trigger{&wpi::DriverStation::IsAutonomousEnabled};
|
||||
}
|
||||
|
||||
Trigger RobotModeTriggers::Teleop() {
|
||||
return Trigger{&frc::DriverStation::IsTeleopEnabled};
|
||||
return Trigger{&wpi::DriverStation::IsTeleopEnabled};
|
||||
}
|
||||
|
||||
Trigger RobotModeTriggers::Disabled() {
|
||||
return Trigger{&frc::DriverStation::IsDisabled};
|
||||
return Trigger{&wpi::DriverStation::IsDisabled};
|
||||
}
|
||||
|
||||
Trigger RobotModeTriggers::Test() {
|
||||
return Trigger{&frc::DriverStation::IsTestEnabled};
|
||||
return Trigger{&wpi::DriverStation::IsTestEnabled};
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#include "wpi/math/filter/Debouncer.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace frc2;
|
||||
using namespace wpi::cmd;
|
||||
|
||||
Trigger::Trigger(const Trigger& other) = default;
|
||||
|
||||
void Trigger::AddBinding(wpi::unique_function<void(bool, bool)>&& body) {
|
||||
void Trigger::AddBinding(wpi::util::unique_function<void(bool, bool)>&& body) {
|
||||
m_loop->Bind([condition = m_condition, previous = m_condition(),
|
||||
body = std::move(body)]() mutable {
|
||||
bool current = condition();
|
||||
@@ -28,7 +28,7 @@ void Trigger::AddBinding(wpi::unique_function<void(bool, bool)>&& body) {
|
||||
Trigger Trigger::OnChange(Command* command) {
|
||||
AddBinding([command](bool previous, bool current) {
|
||||
if (previous != current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
});
|
||||
return *this;
|
||||
@@ -37,7 +37,7 @@ Trigger Trigger::OnChange(Command* command) {
|
||||
Trigger Trigger::OnChange(CommandPtr&& command) {
|
||||
AddBinding([command = std::move(command)](bool previous, bool current) {
|
||||
if (previous != current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
});
|
||||
return *this;
|
||||
@@ -46,7 +46,7 @@ Trigger Trigger::OnChange(CommandPtr&& command) {
|
||||
Trigger Trigger::OnTrue(Command* command) {
|
||||
AddBinding([command](bool previous, bool current) {
|
||||
if (!previous && current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
});
|
||||
return *this;
|
||||
@@ -55,7 +55,7 @@ Trigger Trigger::OnTrue(Command* command) {
|
||||
Trigger Trigger::OnTrue(CommandPtr&& command) {
|
||||
AddBinding([command = std::move(command)](bool previous, bool current) {
|
||||
if (!previous && current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
});
|
||||
return *this;
|
||||
@@ -64,7 +64,7 @@ Trigger Trigger::OnTrue(CommandPtr&& command) {
|
||||
Trigger Trigger::OnFalse(Command* command) {
|
||||
AddBinding([command](bool previous, bool current) {
|
||||
if (previous && !current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
});
|
||||
return *this;
|
||||
@@ -73,7 +73,7 @@ Trigger Trigger::OnFalse(Command* command) {
|
||||
Trigger Trigger::OnFalse(CommandPtr&& command) {
|
||||
AddBinding([command = std::move(command)](bool previous, bool current) {
|
||||
if (previous && !current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
});
|
||||
return *this;
|
||||
@@ -82,7 +82,7 @@ Trigger Trigger::OnFalse(CommandPtr&& command) {
|
||||
Trigger Trigger::WhileTrue(Command* command) {
|
||||
AddBinding([command](bool previous, bool current) {
|
||||
if (!previous && current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
} else if (previous && !current) {
|
||||
command->Cancel();
|
||||
}
|
||||
@@ -93,7 +93,7 @@ Trigger Trigger::WhileTrue(Command* command) {
|
||||
Trigger Trigger::WhileTrue(CommandPtr&& command) {
|
||||
AddBinding([command = std::move(command)](bool previous, bool current) {
|
||||
if (!previous && current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
} else if (previous && !current) {
|
||||
command.Cancel();
|
||||
}
|
||||
@@ -104,7 +104,7 @@ Trigger Trigger::WhileTrue(CommandPtr&& command) {
|
||||
Trigger Trigger::WhileFalse(Command* command) {
|
||||
AddBinding([command](bool previous, bool current) {
|
||||
if (previous && !current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
} else if (!previous && current) {
|
||||
command->Cancel();
|
||||
}
|
||||
@@ -115,7 +115,7 @@ Trigger Trigger::WhileFalse(Command* command) {
|
||||
Trigger Trigger::WhileFalse(CommandPtr&& command) {
|
||||
AddBinding([command = std::move(command)](bool previous, bool current) {
|
||||
if (!previous && current) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
} else if (previous && !current) {
|
||||
command.Cancel();
|
||||
}
|
||||
@@ -129,7 +129,7 @@ Trigger Trigger::ToggleOnTrue(Command* command) {
|
||||
if (command->IsScheduled()) {
|
||||
command->Cancel();
|
||||
} else {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -142,7 +142,7 @@ Trigger Trigger::ToggleOnTrue(CommandPtr&& command) {
|
||||
if (command.IsScheduled()) {
|
||||
command.Cancel();
|
||||
} else {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -155,7 +155,7 @@ Trigger Trigger::ToggleOnFalse(Command* command) {
|
||||
if (command->IsScheduled()) {
|
||||
command->Cancel();
|
||||
} else {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -168,16 +168,16 @@ Trigger Trigger::ToggleOnFalse(CommandPtr&& command) {
|
||||
if (command.IsScheduled()) {
|
||||
command.Cancel();
|
||||
} else {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(command);
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(command);
|
||||
}
|
||||
}
|
||||
});
|
||||
return *this;
|
||||
}
|
||||
|
||||
Trigger Trigger::Debounce(units::second_t debounceTime,
|
||||
frc::Debouncer::DebounceType type) {
|
||||
return Trigger(m_loop, [debouncer = frc::Debouncer(debounceTime, type),
|
||||
Trigger Trigger::Debounce(wpi::units::second_t debounceTime,
|
||||
wpi::math::Debouncer::DebounceType type) {
|
||||
return Trigger(m_loop, [debouncer = wpi::math::Debouncer(debounceTime, type),
|
||||
condition = m_condition]() mutable {
|
||||
return debouncer.Calculate(condition());
|
||||
});
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
|
||||
#include "wpi/sysid/SysIdRoutineLog.hpp"
|
||||
|
||||
using namespace frc2::sysid;
|
||||
using namespace wpi::cmd::sysid;
|
||||
|
||||
frc2::CommandPtr SysIdRoutine::Quasistatic(Direction direction) {
|
||||
frc::sysid::State state;
|
||||
wpi::cmd::CommandPtr SysIdRoutine::Quasistatic(Direction direction) {
|
||||
wpi::sysid::State state;
|
||||
if (direction == Direction::kForward) {
|
||||
state = frc::sysid::State::kQuasistaticForward;
|
||||
state = wpi::sysid::State::kQuasistaticForward;
|
||||
} else { // if (direction == Direction::kReverse) {
|
||||
state = frc::sysid::State::kQuasistaticReverse;
|
||||
state = wpi::sysid::State::kQuasistaticReverse;
|
||||
}
|
||||
|
||||
double outputSign = direction == Direction::kForward ? 1.0 : -1.0;
|
||||
@@ -29,21 +29,21 @@ frc2::CommandPtr SysIdRoutine::Quasistatic(Direction direction) {
|
||||
})
|
||||
.FinallyDo([this] {
|
||||
m_mechanism.m_drive(0_V);
|
||||
m_recordState(frc::sysid::State::kNone);
|
||||
m_recordState(wpi::sysid::State::kNone);
|
||||
timer.Stop();
|
||||
})
|
||||
.WithName("sysid-" +
|
||||
frc::sysid::SysIdRoutineLog::StateEnumToString(state) +
|
||||
wpi::sysid::SysIdRoutineLog::StateEnumToString(state) +
|
||||
"-" + m_mechanism.m_name)
|
||||
.WithTimeout(m_config.m_timeout));
|
||||
}
|
||||
|
||||
frc2::CommandPtr SysIdRoutine::Dynamic(Direction direction) {
|
||||
frc::sysid::State state;
|
||||
wpi::cmd::CommandPtr SysIdRoutine::Dynamic(Direction direction) {
|
||||
wpi::sysid::State state;
|
||||
if (direction == Direction::kForward) {
|
||||
state = frc::sysid::State::kDynamicForward;
|
||||
state = wpi::sysid::State::kDynamicForward;
|
||||
} else { // if (direction == Direction::kReverse) {
|
||||
state = frc::sysid::State::kDynamicReverse;
|
||||
state = wpi::sysid::State::kDynamicReverse;
|
||||
}
|
||||
|
||||
double outputSign = direction == Direction::kForward ? 1.0 : -1.0;
|
||||
@@ -57,10 +57,10 @@ frc2::CommandPtr SysIdRoutine::Dynamic(Direction direction) {
|
||||
}))
|
||||
.FinallyDo([this] {
|
||||
m_mechanism.m_drive(0_V);
|
||||
m_recordState(frc::sysid::State::kNone);
|
||||
m_recordState(wpi::sysid::State::kNone);
|
||||
})
|
||||
.WithName("sysid-" +
|
||||
frc::sysid::SysIdRoutineLog::StateEnumToString(state) + "-" +
|
||||
wpi::sysid::SysIdRoutineLog::StateEnumToString(state) + "-" +
|
||||
m_mechanism.m_name)
|
||||
.WithTimeout(m_config.m_timeout);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "wpi/util/StackTrace.hpp"
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
|
||||
/**
|
||||
* A state machine representing a complete action to be performed by the robot.
|
||||
@@ -37,7 +37,7 @@ namespace frc2 {
|
||||
* @see CommandScheduler
|
||||
* @see CommandHelper
|
||||
*/
|
||||
class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
|
||||
class Command : public wpi::util::Sendable, public wpi::util::SendableHelper<Command> {
|
||||
public:
|
||||
~Command() override;
|
||||
|
||||
@@ -87,7 +87,7 @@ class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
|
||||
* @return the set of subsystems that are required
|
||||
* @see InterruptionBehavior
|
||||
*/
|
||||
virtual wpi::SmallSet<Subsystem*, 4> GetRequirements() const;
|
||||
virtual wpi::util::SmallSet<Subsystem*, 4> GetRequirements() const;
|
||||
|
||||
/**
|
||||
* Adds the specified Subsystem requirements to the command.
|
||||
@@ -121,7 +121,7 @@ class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
|
||||
*
|
||||
* @param requirements the Subsystem requirements to add
|
||||
*/
|
||||
void AddRequirements(wpi::SmallSet<Subsystem*, 4> requirements);
|
||||
void AddRequirements(wpi::util::SmallSet<Subsystem*, 4> requirements);
|
||||
|
||||
/**
|
||||
* Adds the specified Subsystem requirement to the command.
|
||||
@@ -191,7 +191,7 @@ class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
|
||||
* @param duration the timeout duration
|
||||
* @return the command with the timeout added
|
||||
*/
|
||||
CommandPtr WithTimeout(units::second_t duration) &&;
|
||||
CommandPtr WithTimeout(wpi::units::second_t duration) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with an interrupt condition. If the specified
|
||||
@@ -473,14 +473,14 @@ class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
|
||||
*/
|
||||
virtual CommandPtr ToPtr() && = 0;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
protected:
|
||||
Command();
|
||||
|
||||
private:
|
||||
/// Requirements set.
|
||||
wpi::SmallSet<Subsystem*, 4> m_requirements;
|
||||
wpi::util::SmallSet<Subsystem*, 4> m_requirements;
|
||||
|
||||
std::optional<std::string> m_previousComposition;
|
||||
};
|
||||
@@ -493,4 +493,4 @@ class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
|
||||
* @return False if first and second share a requirement.
|
||||
*/
|
||||
bool RequirementsDisjoint(Command* first, Command* second);
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/commands2/Command.hpp"
|
||||
#include "wpi/commands2/CommandPtr.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
|
||||
/**
|
||||
* CRTP implementation to allow polymorphic decorator functions in Command.
|
||||
@@ -33,4 +33,4 @@ class CommandHelper : public Base {
|
||||
std::make_unique<CRTP>(std::move(*static_cast<CRTP*>(this))));
|
||||
}
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/commands2/Command.hpp"
|
||||
#include "wpi/commands2/Requirements.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A wrapper around std::unique_ptr<Command> so commands have move-only
|
||||
* semantics. Commands should only be stored and passed around when held in a
|
||||
@@ -125,7 +125,7 @@ class [[nodiscard]] CommandPtr final {
|
||||
* @param duration the timeout duration
|
||||
* @return the command with the timeout added
|
||||
*/
|
||||
CommandPtr WithTimeout(units::second_t duration) &&;
|
||||
CommandPtr WithTimeout(wpi::units::second_t duration) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with an interrupt condition. If the specified
|
||||
@@ -339,4 +339,4 @@ class [[nodiscard]] CommandPtr final {
|
||||
void AssertValid() const;
|
||||
};
|
||||
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
class Command;
|
||||
class CommandPtr;
|
||||
class Subsystem;
|
||||
@@ -34,8 +34,8 @@ class Subsystem;
|
||||
*
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
class CommandScheduler final : public wpi::Sendable,
|
||||
public wpi::SendableHelper<CommandScheduler> {
|
||||
class CommandScheduler final : public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<CommandScheduler> {
|
||||
public:
|
||||
/**
|
||||
* Returns the Scheduler instance.
|
||||
@@ -56,30 +56,30 @@ class CommandScheduler final : public wpi::Sendable,
|
||||
* Changes the period of the loop overrun watchdog. This should be kept in
|
||||
* sync with the TimedRobot period.
|
||||
*/
|
||||
void SetPeriod(units::second_t period);
|
||||
void SetPeriod(wpi::units::second_t period);
|
||||
|
||||
/**
|
||||
* Get the active button poll.
|
||||
*
|
||||
* @return a reference to the current {@link frc::EventLoop} object polling
|
||||
* @return a reference to the current {@link wpi::EventLoop} object polling
|
||||
* buttons.
|
||||
*/
|
||||
frc::EventLoop* GetActiveButtonLoop() const;
|
||||
wpi::EventLoop* GetActiveButtonLoop() const;
|
||||
|
||||
/**
|
||||
* Replace the button poll with another one.
|
||||
*
|
||||
* @param loop the new button polling loop object.
|
||||
*/
|
||||
void SetActiveButtonLoop(frc::EventLoop* loop);
|
||||
void SetActiveButtonLoop(wpi::EventLoop* loop);
|
||||
|
||||
/**
|
||||
* Get the default button poll.
|
||||
*
|
||||
* @return a reference to the default {@link frc::EventLoop} object polling
|
||||
* @return a reference to the default {@link wpi::EventLoop} object polling
|
||||
* buttons.
|
||||
*/
|
||||
frc::EventLoop* GetDefaultButtonLoop() const;
|
||||
wpi::EventLoop* GetDefaultButtonLoop() const;
|
||||
|
||||
/**
|
||||
* Schedules a command for execution. Does nothing if the command is already
|
||||
@@ -212,7 +212,7 @@ class CommandScheduler final : public wpi::Sendable,
|
||||
template <std::derived_from<Command> T>
|
||||
void SetDefaultCommand(Subsystem* subsystem, T&& defaultCommand) {
|
||||
if (!defaultCommand.HasRequirement(subsystem)) {
|
||||
throw FRC_MakeError(frc::err::CommandIllegalUse,
|
||||
throw FRC_MakeError(wpi::err::CommandIllegalUse,
|
||||
"Default commands must require their subsystem!");
|
||||
}
|
||||
SetDefaultCommandImpl(subsystem, std::make_unique<std::decay_t<T>>(
|
||||
@@ -467,7 +467,7 @@ class CommandScheduler final : public wpi::Sendable,
|
||||
void RequireUngroupedAndUnscheduled(
|
||||
std::initializer_list<const Command*> commands);
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
// Constructor; private as this is a singleton
|
||||
@@ -481,11 +481,11 @@ class CommandScheduler final : public wpi::Sendable,
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> m_impl;
|
||||
|
||||
frc::Watchdog m_watchdog;
|
||||
wpi::Watchdog m_watchdog;
|
||||
|
||||
friend class CommandTestBase;
|
||||
|
||||
template <typename T>
|
||||
friend class CommandTestBaseWithParam;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "wpi/commands2/SelectCommand.hpp"
|
||||
#include "wpi/util/deprecated.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
class Subsystem;
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ CommandPtr Print(std::string_view msg);
|
||||
*
|
||||
* @param duration after how long the command finishes
|
||||
*/
|
||||
CommandPtr Wait(units::second_t duration);
|
||||
CommandPtr Wait(wpi::units::second_t duration);
|
||||
|
||||
/**
|
||||
* Constructs a command that does nothing, finishing once a condition becomes
|
||||
@@ -149,7 +149,7 @@ CommandPtr Select(std::function<Key()> selector,
|
||||
* @param supplier the command supplier
|
||||
* @param requirements the set of requirements for this command
|
||||
*/
|
||||
CommandPtr Defer(wpi::unique_function<CommandPtr()> supplier,
|
||||
CommandPtr Defer(wpi::util::unique_function<CommandPtr()> supplier,
|
||||
Requirements requirements);
|
||||
|
||||
/**
|
||||
@@ -159,7 +159,7 @@ CommandPtr Defer(wpi::unique_function<CommandPtr()> supplier,
|
||||
*
|
||||
* @param supplier the command supplier
|
||||
*/
|
||||
CommandPtr DeferredProxy(wpi::unique_function<Command*()> supplier);
|
||||
CommandPtr DeferredProxy(wpi::util::unique_function<Command*()> supplier);
|
||||
|
||||
/**
|
||||
* Constructs a command that schedules the command returned from the supplier
|
||||
@@ -168,7 +168,7 @@ CommandPtr DeferredProxy(wpi::unique_function<Command*()> supplier);
|
||||
*
|
||||
* @param supplier the command supplier
|
||||
*/
|
||||
CommandPtr DeferredProxy(wpi::unique_function<CommandPtr()> supplier);
|
||||
CommandPtr DeferredProxy(wpi::util::unique_function<CommandPtr()> supplier);
|
||||
// Command Groups
|
||||
|
||||
namespace impl {
|
||||
@@ -263,4 +263,4 @@ CommandPtr Deadline(CommandPtr&& deadline, CommandPtrs&&... commands) {
|
||||
|
||||
} // namespace cmd
|
||||
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/commands2/Command.hpp"
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command composition that runs one of two commands, depending on the value
|
||||
* of the given condition when this command is initialized.
|
||||
@@ -73,7 +73,7 @@ class ConditionalCommand : public CommandHelper<Command, ConditionalCommand> {
|
||||
|
||||
InterruptionBehavior GetInterruptionBehavior() const override;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Command> m_onTrue;
|
||||
@@ -82,4 +82,4 @@ class ConditionalCommand : public CommandHelper<Command, ConditionalCommand> {
|
||||
Command* m_selectedCommand{nullptr};
|
||||
bool m_runsWhenDisabled = true;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/commands2/Requirements.hpp"
|
||||
#include "wpi/util/FunctionExtras.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* Defers Command construction to runtime. Runs the command returned by a
|
||||
* supplier when this command is initialized, and ends when it ends. Useful for
|
||||
@@ -37,7 +37,7 @@ class DeferredCommand : public CommandHelper<Command, DeferredCommand> {
|
||||
* @param requirements The command requirements.
|
||||
*
|
||||
*/
|
||||
DeferredCommand(wpi::unique_function<CommandPtr()> supplier,
|
||||
DeferredCommand(wpi::util::unique_function<CommandPtr()> supplier,
|
||||
Requirements requirements);
|
||||
|
||||
DeferredCommand(DeferredCommand&& other) = default;
|
||||
@@ -50,10 +50,10 @@ class DeferredCommand : public CommandHelper<Command, DeferredCommand> {
|
||||
|
||||
bool IsFinished() override;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
wpi::unique_function<CommandPtr()> m_supplier;
|
||||
wpi::util::unique_function<CommandPtr()> m_supplier;
|
||||
std::unique_ptr<Command> m_command;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
#include "wpi/commands2/Requirements.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command that allows the user to pass in functions for each of the basic
|
||||
* command methods through the constructor. Useful for inline definitions of
|
||||
@@ -56,4 +56,4 @@ class FunctionalCommand : public CommandHelper<Command, FunctionalCommand> {
|
||||
std::function<void(bool)> m_onEnd;
|
||||
std::function<bool()> m_isFinished;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/commands2/FunctionalCommand.hpp"
|
||||
#include "wpi/commands2/Requirements.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A Command that runs instantly; it will initialize, execute once, and end on
|
||||
* the same iteration of the scheduler. Users can either pass in a Runnable and
|
||||
@@ -40,4 +40,4 @@ class InstantCommand : public CommandHelper<FunctionalCommand, InstantCommand> {
|
||||
*/
|
||||
InstantCommand();
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/system/Notifier.hpp"
|
||||
#include "wpi/units/time.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command that starts a notifier to run the given runnable periodically in a
|
||||
* separate thread. Has no end condition as-is; either subclass it or use
|
||||
@@ -34,7 +34,7 @@ class NotifierCommand : public CommandHelper<Command, NotifierCommand> {
|
||||
* @param period the period at which the notifier should run
|
||||
* @param requirements the subsystems required by this command
|
||||
*/
|
||||
NotifierCommand(std::function<void()> toRun, units::second_t period,
|
||||
NotifierCommand(std::function<void()> toRun, wpi::units::second_t period,
|
||||
Requirements requirements = {});
|
||||
|
||||
NotifierCommand(NotifierCommand&& other);
|
||||
@@ -47,7 +47,7 @@ class NotifierCommand : public CommandHelper<Command, NotifierCommand> {
|
||||
|
||||
private:
|
||||
std::function<void()> m_toRun;
|
||||
frc::Notifier m_notifier;
|
||||
units::second_t m_period;
|
||||
wpi::Notifier m_notifier;
|
||||
wpi::units::second_t m_period;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
#include "wpi/util/DecayedDerivedFrom.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command composition that runs a set of commands in parallel, ending when
|
||||
* the last command ends.
|
||||
@@ -51,7 +51,7 @@ class ParallelCommandGroup
|
||||
*
|
||||
* @param commands the commands to include in this composition.
|
||||
*/
|
||||
template <wpi::DecayedDerivedFrom<Command>... Commands>
|
||||
template <wpi::util::DecayedDerivedFrom<Command>... Commands>
|
||||
explicit ParallelCommandGroup(Commands&&... commands) {
|
||||
AddCommands(std::forward<Commands>(commands)...);
|
||||
}
|
||||
@@ -69,7 +69,7 @@ class ParallelCommandGroup
|
||||
*
|
||||
* @param commands Commands to add to the group.
|
||||
*/
|
||||
template <wpi::DecayedDerivedFrom<Command>... Commands>
|
||||
template <wpi::util::DecayedDerivedFrom<Command>... Commands>
|
||||
void AddCommands(Commands&&... commands) {
|
||||
std::vector<std::unique_ptr<Command>> foo;
|
||||
((void)foo.emplace_back(std::make_unique<std::decay_t<Commands>>(
|
||||
@@ -99,7 +99,7 @@ class ParallelCommandGroup
|
||||
Command::InterruptionBehavior::kCancelIncoming};
|
||||
bool isRunning = false;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
#include "wpi/util/DecayedDerivedFrom.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command composition that runs a set of commands in parallel, ending only
|
||||
* when a specific command (the "deadline") ends, interrupting all other
|
||||
@@ -55,8 +55,8 @@ class ParallelDeadlineGroup
|
||||
* @param deadline the command that determines when the composition ends
|
||||
* @param commands the commands to be executed
|
||||
*/
|
||||
template <wpi::DecayedDerivedFrom<Command> T,
|
||||
wpi::DecayedDerivedFrom<Command>... Commands>
|
||||
template <wpi::util::DecayedDerivedFrom<Command> T,
|
||||
wpi::util::DecayedDerivedFrom<Command>... Commands>
|
||||
explicit ParallelDeadlineGroup(T&& deadline, Commands&&... commands) {
|
||||
SetDeadline(std::make_unique<std::decay_t<T>>(std::forward<T>(deadline)));
|
||||
AddCommands(std::forward<Commands>(commands)...);
|
||||
@@ -75,7 +75,7 @@ class ParallelDeadlineGroup
|
||||
*
|
||||
* @param commands Commands to add to the group.
|
||||
*/
|
||||
template <wpi::DecayedDerivedFrom<Command>... Commands>
|
||||
template <wpi::util::DecayedDerivedFrom<Command>... Commands>
|
||||
void AddCommands(Commands&&... commands) {
|
||||
std::vector<std::unique_ptr<Command>> foo;
|
||||
((void)foo.emplace_back(std::make_unique<std::decay_t<Commands>>(
|
||||
@@ -96,7 +96,7 @@ class ParallelDeadlineGroup
|
||||
|
||||
Command::InterruptionBehavior GetInterruptionBehavior() const override;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
void AddCommands(std::vector<std::unique_ptr<Command>>&& commands);
|
||||
@@ -110,7 +110,7 @@ class ParallelDeadlineGroup
|
||||
Command::InterruptionBehavior::kCancelIncoming};
|
||||
bool m_finished{true};
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
#include "wpi/util/DecayedDerivedFrom.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A composition that runs a set of commands in parallel, ending when any one of
|
||||
* the commands ends and interrupting all the others.
|
||||
@@ -40,7 +40,7 @@ class ParallelRaceGroup : public CommandHelper<Command, ParallelRaceGroup> {
|
||||
*/
|
||||
explicit ParallelRaceGroup(std::vector<std::unique_ptr<Command>>&& commands);
|
||||
|
||||
template <wpi::DecayedDerivedFrom<Command>... Commands>
|
||||
template <wpi::util::DecayedDerivedFrom<Command>... Commands>
|
||||
explicit ParallelRaceGroup(Commands&&... commands) {
|
||||
AddCommands(std::forward<Commands>(commands)...);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ class ParallelRaceGroup : public CommandHelper<Command, ParallelRaceGroup> {
|
||||
*
|
||||
* @param commands Commands to add to the group.
|
||||
*/
|
||||
template <wpi::DecayedDerivedFrom<Command>... Commands>
|
||||
template <wpi::util::DecayedDerivedFrom<Command>... Commands>
|
||||
void AddCommands(Commands&&... commands) {
|
||||
std::vector<std::unique_ptr<Command>> foo;
|
||||
((void)foo.emplace_back(std::make_unique<std::decay_t<Commands>>(
|
||||
@@ -89,7 +89,7 @@ class ParallelRaceGroup : public CommandHelper<Command, ParallelRaceGroup> {
|
||||
bool m_finished{false};
|
||||
bool isRunning = false;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
#include "wpi/commands2/InstantCommand.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command that prints a string when initialized.
|
||||
*
|
||||
@@ -30,4 +30,4 @@ class PrintCommand : public CommandHelper<InstantCommand, PrintCommand> {
|
||||
|
||||
bool RunsWhenDisabled() const override;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/util/FunctionExtras.hpp"
|
||||
#include "wpi/util/deprecated.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* Schedules a given command when this command is initialized and ends when it
|
||||
* ends, but does not directly run it. Use this for including a command in a
|
||||
@@ -45,7 +45,7 @@ class ProxyCommand : public CommandHelper<Command, ProxyCommand> {
|
||||
*/
|
||||
WPI_IGNORE_DEPRECATED
|
||||
[[deprecated("Defer a proxy command instead.")]]
|
||||
explicit ProxyCommand(wpi::unique_function<Command*()> supplier);
|
||||
explicit ProxyCommand(wpi::util::unique_function<Command*()> supplier);
|
||||
|
||||
/**
|
||||
* Creates a new ProxyCommand that schedules the supplied command when
|
||||
@@ -64,7 +64,7 @@ class ProxyCommand : public CommandHelper<Command, ProxyCommand> {
|
||||
* @see DeferredCommand
|
||||
*/
|
||||
[[deprecated("Defer a proxy command instead.")]]
|
||||
explicit ProxyCommand(wpi::unique_function<CommandPtr()> supplier);
|
||||
explicit ProxyCommand(wpi::util::unique_function<CommandPtr()> supplier);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
|
||||
/**
|
||||
@@ -94,10 +94,10 @@ class ProxyCommand : public CommandHelper<Command, ProxyCommand> {
|
||||
|
||||
bool IsFinished() override;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
wpi::unique_function<Command*()> m_supplier;
|
||||
wpi::util::unique_function<Command*()> m_supplier;
|
||||
Command* m_command = nullptr;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "wpi/commands2/Command.hpp"
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command that runs another command repeatedly, restarting it when it ends,
|
||||
* until this command is interrupted. Command instances that are passed to it
|
||||
@@ -71,13 +71,13 @@ class RepeatCommand : public CommandHelper<Command, RepeatCommand> {
|
||||
|
||||
Command::InterruptionBehavior GetInterruptionBehavior() const override;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Command> m_command;
|
||||
bool m_ended;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "wpi/commands2/Subsystem.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
|
||||
/**
|
||||
* Represents requirements for a command, which is a set of (pointers to)
|
||||
@@ -43,4 +43,4 @@ class Requirements {
|
||||
std::vector<Subsystem*> m_subsystems;
|
||||
};
|
||||
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/commands2/FunctionalCommand.hpp"
|
||||
#include "wpi/commands2/Requirements.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command that runs a Runnable continuously. Has no end condition as-is;
|
||||
* either subclass it or use Command.WithTimeout() or
|
||||
@@ -35,4 +35,4 @@ class RunCommand : public CommandHelper<FunctionalCommand, RunCommand> {
|
||||
|
||||
RunCommand(const RunCommand& other) = default;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
#include "wpi/util/SmallSet.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* Schedules the given commands when this command is initialized. Useful for
|
||||
* forking off from CommandGroups. Note that if run from a composition, the
|
||||
@@ -42,6 +42,6 @@ class ScheduleCommand : public CommandHelper<Command, ScheduleCommand> {
|
||||
bool RunsWhenDisabled() const override;
|
||||
|
||||
private:
|
||||
wpi::SmallSet<Command*, 4> m_toSchedule;
|
||||
wpi::util::SmallSet<Command*, 4> m_toSchedule;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "wpi/commands2/PrintCommand.hpp"
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command composition that runs one of a selection of commands using a
|
||||
* selector and a key to command mapping.
|
||||
@@ -117,7 +117,7 @@ class SelectCommand : public CommandHelper<Command, SelectCommand<Key>> {
|
||||
return m_interruptBehavior;
|
||||
}
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override {
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override {
|
||||
Command::InitSendable(builder);
|
||||
|
||||
builder.AddStringProperty(
|
||||
@@ -155,7 +155,7 @@ void SelectCommand<T>::Initialize() {
|
||||
m_selectedCommand->Initialize();
|
||||
}
|
||||
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
#include "wpi/util/DecayedDerivedFrom.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
|
||||
const size_t invalid_index = std::numeric_limits<size_t>::max();
|
||||
|
||||
@@ -52,7 +52,7 @@ class SequentialCommandGroup
|
||||
*
|
||||
* @param commands the commands to include in this composition.
|
||||
*/
|
||||
template <wpi::DecayedDerivedFrom<Command>... Commands>
|
||||
template <wpi::util::DecayedDerivedFrom<Command>... Commands>
|
||||
explicit SequentialCommandGroup(Commands&&... commands) {
|
||||
AddCommands(std::forward<Commands>(commands)...);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class SequentialCommandGroup
|
||||
*
|
||||
* @param commands Commands to add, in order of execution.
|
||||
*/
|
||||
template <wpi::DecayedDerivedFrom<Command>... Commands>
|
||||
template <wpi::util::DecayedDerivedFrom<Command>... Commands>
|
||||
void AddCommands(Commands&&... commands) {
|
||||
std::vector<std::unique_ptr<Command>> foo;
|
||||
((void)foo.emplace_back(std::make_unique<std::decay_t<Commands>>(
|
||||
@@ -91,18 +91,18 @@ class SequentialCommandGroup
|
||||
|
||||
Command::InterruptionBehavior GetInterruptionBehavior() const override;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
void AddCommands(std::vector<std::unique_ptr<Command>>&& commands);
|
||||
|
||||
wpi::SmallVector<std::unique_ptr<Command>, 4> m_commands;
|
||||
wpi::util::SmallVector<std::unique_ptr<Command>, 4> m_commands;
|
||||
size_t m_currentCommandIndex{invalid_index};
|
||||
bool m_runWhenDisabled{true};
|
||||
Command::InterruptionBehavior m_interruptBehavior{
|
||||
Command::InterruptionBehavior::kCancelIncoming};
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/commands2/FunctionalCommand.hpp"
|
||||
#include "wpi/commands2/Requirements.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A command that runs a given runnable when it is initialized, and another
|
||||
* runnable when it ends. Useful for running and then stopping a motor, or
|
||||
@@ -38,4 +38,4 @@ class StartEndCommand
|
||||
|
||||
StartEndCommand(const StartEndCommand& other) = default;
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/commands2/CommandScheduler.hpp"
|
||||
#include "wpi/util/FunctionExtras.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
class Command;
|
||||
class CommandPtr;
|
||||
/**
|
||||
@@ -179,6 +179,6 @@ class Subsystem {
|
||||
* @param supplier the command supplier.
|
||||
* @return the command.
|
||||
*/
|
||||
CommandPtr Defer(wpi::unique_function<CommandPtr()> supplier);
|
||||
CommandPtr Defer(wpi::util::unique_function<CommandPtr()> supplier);
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc2 {
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A base for subsystems that handles registration in the constructor, and
|
||||
* provides a more intuitive method for setting the default command.
|
||||
@@ -19,10 +19,10 @@ namespace frc2 {
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
class SubsystemBase : public Subsystem,
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<SubsystemBase> {
|
||||
public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<SubsystemBase> {
|
||||
public:
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
/**
|
||||
* Gets the name of this Subsystem.
|
||||
@@ -59,7 +59,7 @@ class SubsystemBase : public Subsystem,
|
||||
* @param name name to give child
|
||||
* @param child sendable
|
||||
*/
|
||||
void AddChild(std::string name, wpi::Sendable* child);
|
||||
void AddChild(std::string name, wpi::util::Sendable* child);
|
||||
|
||||
protected:
|
||||
/**
|
||||
@@ -73,4 +73,4 @@ class SubsystemBase : public Subsystem,
|
||||
*/
|
||||
explicit SubsystemBase(std::string_view name);
|
||||
};
|
||||
} // namespace frc2
|
||||
} // namespace wpi::cmd
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user