mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -8,7 +8,7 @@
|
||||
#include "wpi/system/Watchdog.hpp"
|
||||
#include "wpi/units/time.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* IterativeRobotBase implements a specific type of robot program framework,
|
||||
@@ -200,7 +200,7 @@ class IterativeRobotBase : public RobotBase {
|
||||
/**
|
||||
* Gets time period between calls to Periodic() functions.
|
||||
*/
|
||||
units::second_t GetPeriod() const;
|
||||
wpi::units::second_t GetPeriod() const;
|
||||
|
||||
/**
|
||||
* Prints list of epochs added so far and their times.
|
||||
@@ -212,7 +212,7 @@ class IterativeRobotBase : public RobotBase {
|
||||
*
|
||||
* @param period Period.
|
||||
*/
|
||||
explicit IterativeRobotBase(units::second_t period);
|
||||
explicit IterativeRobotBase(wpi::units::second_t period);
|
||||
|
||||
~IterativeRobotBase() override = default;
|
||||
|
||||
@@ -229,7 +229,7 @@ class IterativeRobotBase : public RobotBase {
|
||||
enum class Mode { kNone, kDisabled, kAutonomous, kTeleop, kTest };
|
||||
|
||||
Mode m_lastMode = Mode::kNone;
|
||||
units::second_t m_period;
|
||||
wpi::units::second_t m_period;
|
||||
Watchdog m_watchdog;
|
||||
bool m_ntFlushEnabled = true;
|
||||
bool m_calledDsConnected = false;
|
||||
@@ -237,4 +237,4 @@ class IterativeRobotBase : public RobotBase {
|
||||
void PrintLoopOverrunMessage();
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "wpi/util/mutex.hpp"
|
||||
#include "wpi/util/string.h"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
int RunHALInitialization();
|
||||
|
||||
@@ -28,7 +28,7 @@ void ResetMotorSafety();
|
||||
#endif
|
||||
|
||||
template <class Robot>
|
||||
void RunRobot(wpi::mutex& m, Robot** robot) {
|
||||
void RunRobot(wpi::util::mutex& m, Robot** robot) {
|
||||
try {
|
||||
static Robot theRobot;
|
||||
{
|
||||
@@ -36,7 +36,7 @@ void RunRobot(wpi::mutex& m, Robot** robot) {
|
||||
*robot = &theRobot;
|
||||
}
|
||||
theRobot.StartCompetition();
|
||||
} catch (const frc::RuntimeError& e) {
|
||||
} catch (const wpi::RuntimeError& e) {
|
||||
e.Report();
|
||||
FRC_ReportError(
|
||||
err::Error,
|
||||
@@ -75,8 +75,8 @@ int StartRobot() {
|
||||
return halInit;
|
||||
}
|
||||
|
||||
static wpi::mutex m;
|
||||
static wpi::condition_variable cv;
|
||||
static wpi::util::mutex m;
|
||||
static wpi::util::condition_variable cv;
|
||||
static Robot* robot = nullptr;
|
||||
static bool exited = false;
|
||||
|
||||
@@ -124,7 +124,7 @@ int StartRobot() {
|
||||
}
|
||||
|
||||
#ifndef __FRC_SYSTEMCORE__
|
||||
frc::impl::ResetMotorSafety();
|
||||
wpi::impl::ResetMotorSafety();
|
||||
#endif
|
||||
HAL_Shutdown();
|
||||
|
||||
@@ -277,4 +277,4 @@ class RobotBase {
|
||||
NT_Listener connListenerHandle;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Robot state utility functions.
|
||||
@@ -56,4 +56,4 @@ class RobotState {
|
||||
static bool IsTest();
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "wpi/units/time.hpp"
|
||||
#include "wpi/util/priority_queue.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* TimedRobot implements the IterativeRobotBase robot program framework.
|
||||
@@ -49,14 +49,14 @@ class TimedRobot : public IterativeRobotBase {
|
||||
*
|
||||
* @param period The period of the robot loop function.
|
||||
*/
|
||||
explicit TimedRobot(units::second_t period = kDefaultPeriod);
|
||||
explicit TimedRobot(wpi::units::second_t period = kDefaultPeriod);
|
||||
|
||||
/**
|
||||
* Constructor for TimedRobot.
|
||||
*
|
||||
* @param frequency The frequency of the robot loop function.
|
||||
*/
|
||||
explicit TimedRobot(units::hertz_t frequency);
|
||||
explicit TimedRobot(wpi::units::hertz_t frequency);
|
||||
|
||||
TimedRobot(TimedRobot&&) = default;
|
||||
TimedRobot& operator=(TimedRobot&&) = default;
|
||||
@@ -86,8 +86,8 @@ class TimedRobot : public IterativeRobotBase {
|
||||
* for scheduling a callback in a different timeslot relative
|
||||
* to TimedRobot.
|
||||
*/
|
||||
void AddPeriodic(std::function<void()> callback, units::second_t period,
|
||||
units::second_t offset = 0_s);
|
||||
void AddPeriodic(std::function<void()> callback, wpi::units::second_t period,
|
||||
wpi::units::second_t offset = 0_s);
|
||||
|
||||
private:
|
||||
class Callback {
|
||||
@@ -110,7 +110,7 @@ class TimedRobot : public IterativeRobotBase {
|
||||
period{period},
|
||||
expirationTime(
|
||||
startTime + offset + period +
|
||||
(std::chrono::microseconds{frc::RobotController::GetFPGATime()} -
|
||||
(std::chrono::microseconds{wpi::RobotController::GetFPGATime()} -
|
||||
startTime) /
|
||||
period * period) {}
|
||||
|
||||
@@ -119,12 +119,12 @@ class TimedRobot : public IterativeRobotBase {
|
||||
}
|
||||
};
|
||||
|
||||
hal::Handle<HAL_NotifierHandle, HAL_CleanNotifier> m_notifier;
|
||||
wpi::hal::Handle<HAL_NotifierHandle, HAL_CleanNotifier> m_notifier;
|
||||
std::chrono::microseconds m_startTime;
|
||||
uint64_t m_loopStartTimeUs = 0;
|
||||
|
||||
wpi::priority_queue<Callback, std::vector<Callback>, std::greater<Callback>>
|
||||
wpi::util::priority_queue<Callback, std::vector<Callback>, std::greater<Callback>>
|
||||
m_callbacks;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/opmode/TimedRobot.hpp"
|
||||
#include "wpi/units/time.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* TimesliceRobot extends the TimedRobot robot program framework to provide
|
||||
@@ -75,7 +75,7 @@ namespace frc {
|
||||
* If the robot periodic functions and the controller periodic functions have a
|
||||
* lot of scheduling jitter that cause them to occasionally overlap with later
|
||||
* timeslices, consider giving the main robot thread a real-time priority using
|
||||
* frc::SetCurrentThreadPriority(). An RT priority of 15 is a reasonable choice.
|
||||
* wpi::SetCurrentThreadPriority(). An RT priority of 15 is a reasonable choice.
|
||||
*
|
||||
* If you do enable RT though, <i>make sure your periodic functions do not
|
||||
* block</i>. If they do, the operating system will lock up, and you'll have to
|
||||
@@ -92,8 +92,8 @@ class TimesliceRobot : public TimedRobot {
|
||||
* allocations should be less than or equal to this
|
||||
* value.
|
||||
*/
|
||||
explicit TimesliceRobot(units::second_t robotPeriodicAllocation,
|
||||
units::second_t controllerPeriod);
|
||||
explicit TimesliceRobot(wpi::units::second_t robotPeriodicAllocation,
|
||||
wpi::units::second_t controllerPeriod);
|
||||
|
||||
/**
|
||||
* Schedule a periodic function with the constructor's controller period and
|
||||
@@ -109,11 +109,11 @@ class TimesliceRobot : public TimedRobot {
|
||||
* @param allocation The function's runtime allocation out of the controller
|
||||
* period.
|
||||
*/
|
||||
void Schedule(std::function<void()> func, units::second_t allocation);
|
||||
void Schedule(std::function<void()> func, wpi::units::second_t allocation);
|
||||
|
||||
private:
|
||||
units::second_t m_nextOffset;
|
||||
units::second_t m_controllerPeriod;
|
||||
wpi::units::second_t m_nextOffset;
|
||||
wpi::units::second_t m_controllerPeriod;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
Reference in New Issue
Block a user