Class SystemState
Manages the overall state of the system. More...
#include <state.h>
Public Attributes
| Type | Name |
|---|---|
| const fixed | angleToStep = {0.1125}Conversion factor from angle to motor steps. |
| ConfigParameters | config Runtime configuration parameters. |
| std::array< Target, 32 > | cvTarget |
| const int | h_max = 500Maximum horizontal position. |
| const int | h_min = -500Minimum horizontal position. |
| std::array< Target, 3 > | radarTarget |
| Target * | selectedTarget = &staticTarget |
| Target | staticTarget |
| const int | stepFraction = 16Microstep fraction for the stepper motors. |
| AccelStepper | stepperA Stepper motor A instance. |
| AccelStepper | stepperB Stepper motor B instance. |
| TargetSource | target_source |
| const int | v_max = 1000Maximum vertical position. |
| const int | v_min = -1000Minimum vertical position. |
Public Functions
| Type | Name |
|---|---|
| SystemState () |
|
| void | actualizeState () Updates the physical state of the system to match the desired state. |
| void | clearFire (bool active) |
| const fixed | currentPitch () |
| TurretStrategy | currentStrategy () const |
| Target * | currentTarget () |
| std::span< Target > | currentTargetArray () Return the current target array, based on which target system is active. |
| const fixed | currentYaw () |
| uint8_t | fetchNearestTarget2dIdx (const PositionVector & point) |
| uint8_t | fetchNearestTargetIdx (const PositionVector & point) |
| Target & | fetchTarget (const uint8_t idx) |
| bool | getFireState () |
| bool | getMoveState () |
| void | processCommandQueue () Processes the command queue, executing any commands that are due. |
| void | queueCeaseFire (uint16_t milliseconds) |
| void | queueFire (uint16_t milliseconds) |
| void | queueSelectTarget (TargetSource source, uint8_t index) |
| void | setFire (bool active) |
| void | setMove (bool active) |
| void | setStance (TurretStance stance) |
| void | setStrategy (TurretStrategy strategy) |
| void | setTarget (TargetSource source, uint8_t index, uint8_t speed=0xFF) |
| bool | shouldCheckFiringConditions () |
| bool | shouldCheckTargetValidity () |
| size_t | size () |
| bool | targetIsPotentiallyValid () |
| fixed | targetTravelDistance () |
| void | updateConfig (cerializer::Config * config) |
| void | updateNearestTarget (const bool valid, PositionVector & newPosition, const uint16_t indifferenceMargin=0) |
| void | updateNearestTarget2d (const bool valid, PositionVector & newPosition, const uint16_t indifferenceMargin=0) |
| void | updateTarget (auto & targetArray, const uint8_t idx, const bool valid, PositionVector & newPosition, const uint16_t indifferenceMargin=0) |
| void | updateTargetById (auto & targetArray, const uint8_t id, const bool valid, PositionVector & newPosition, const uint16_t indifferenceMargin=0) |
Detailed Description
This class encapsulates all system components, including motors, targets, and the command queue. It provides an interface for updating and controlling the system's behavior.
Public Attributes Documentation
variable angleToStep
Conversion factor from angle to motor steps.
const fixed SystemState::angleToStep;
variable config
Runtime configuration parameters.
ConfigParameters SystemState::config;
variable cvTarget
std::array<Target, 32> SystemState::cvTarget;
variable h_max
Maximum horizontal position.
const int SystemState::h_max;
variable h_min
Minimum horizontal position.
const int SystemState::h_min;
variable radarTarget
std::array<Target, 3> SystemState::radarTarget;
variable selectedTarget
Target* SystemState::selectedTarget;
variable staticTarget
Target SystemState::staticTarget;
variable stepFraction
Microstep fraction for the stepper motors.
const int SystemState::stepFraction;
variable stepperA
Stepper motor A instance.
AccelStepper SystemState::stepperA;
variable stepperB
Stepper motor B instance.
AccelStepper SystemState::stepperB;
variable target_source
TargetSource SystemState::target_source;
variable v_max
Maximum vertical position.
const int SystemState::v_max;
variable v_min
Minimum vertical position.
const int SystemState::v_min;
Public Functions Documentation
function SystemState
SystemState::SystemState ()
function actualizeState
Updates the physical state of the system to match the desired state.
void SystemState::actualizeState ()
function clearFire
void SystemState::clearFire (
bool active
)
function currentPitch
inline const fixed SystemState::currentPitch ()
function currentStrategy
inline TurretStrategy SystemState::currentStrategy () const
function currentTarget
Target * SystemState::currentTarget ()
function currentTargetArray
Return the current target array, based on which target system is active.
std::span< Target > SystemState::currentTargetArray ()
Returns:
a span of targets, referencing the correct target buffer.
function currentYaw
inline const fixed SystemState::currentYaw ()
function fetchNearestTarget2dIdx
inline uint8_t SystemState::fetchNearestTarget2dIdx (
const PositionVector & point
)
function fetchNearestTargetIdx
inline uint8_t SystemState::fetchNearestTargetIdx (
const PositionVector & point
)
function fetchTarget
inline Target & SystemState::fetchTarget (
const uint8_t idx
)
function getFireState
bool SystemState::getFireState ()
function getMoveState
bool SystemState::getMoveState ()
function processCommandQueue
Processes the command queue, executing any commands that are due.
void SystemState::processCommandQueue ()
function queueCeaseFire
void SystemState::queueCeaseFire (
uint16_t milliseconds
)
function queueFire
void SystemState::queueFire (
uint16_t milliseconds
)
function queueSelectTarget
void SystemState::queueSelectTarget (
TargetSource source,
uint8_t index
)
function setFire
void SystemState::setFire (
bool active
)
function setMove
void SystemState::setMove (
bool active
)
function setStance
void SystemState::setStance (
TurretStance stance
)
function setStrategy
void SystemState::setStrategy (
TurretStrategy strategy
)
function setTarget
void SystemState::setTarget (
TargetSource source,
uint8_t index,
uint8_t speed=0xFF
)
function shouldCheckFiringConditions
bool SystemState::shouldCheckFiringConditions ()
function shouldCheckTargetValidity
bool SystemState::shouldCheckTargetValidity ()
function size
inline size_t SystemState::size ()
function targetIsPotentiallyValid
inline bool SystemState::targetIsPotentiallyValid ()
function targetTravelDistance
fixed SystemState::targetTravelDistance ()
function updateConfig
void SystemState::updateConfig (
cerializer::Config * config
)
function updateNearestTarget
void SystemState::updateNearestTarget (
const bool valid,
PositionVector & newPosition,
const uint16_t indifferenceMargin=0
)
function updateNearestTarget2d
void SystemState::updateNearestTarget2d (
const bool valid,
PositionVector & newPosition,
const uint16_t indifferenceMargin=0
)
function updateTarget
inline void SystemState::updateTarget (
auto & targetArray,
const uint8_t idx,
const bool valid,
PositionVector & newPosition,
const uint16_t indifferenceMargin=0
)
function updateTargetById
inline void SystemState::updateTargetById (
auto & targetArray,
const uint8_t id,
const bool valid,
PositionVector & newPosition,
const uint16_t indifferenceMargin=0
)
The documentation for this class was generated from the following file state.h