1#ifndef FSW_CONTROL_CONTROLLER_SERVICE_HPP
2#define FSW_CONTROL_CONTROLLER_SERVICE_HPP
76 const std::string& elodin_host =
"", uint16_t elodin_port = 2240,
77 const std::string& lut_path =
"",
const std::string& thrust_curve_path =
"");
80 bool start(
double loop_rate_hz = 10.0);
153 uint32_t duration_ms);
157 bool sendPWMCommands(
const PWMTarget& t1,
float duty1,
const PWMTarget& t2,
float duty2,
158 float frequency, uint32_t duration_ms);
Controller LUT loader with multilinear interpolation.
std::unique_ptr< elodin::ElodinClient > elodin_subscriber_
std::atomic< bool > fire_active_
std::chrono::steady_clock::time_point fire_start_time_
std::unique_ptr< RobustDDPController > controller_
void stop()
Stop the controller loop.
std::unique_ptr< elodin::ElodinClient > elodin_client_
bool thrust_curve_loaded_
void writeActuationToDB(const RobustDDPController::ActuationCommand &actuation)
void setNavState(const RobustDDPController::NavState &nav)
std::vector< double > thrust_curve_times_
bool isFireGateEnabled() const
RobustDDPController::NavState current_nav_
void sendActuationPWM(const RobustDDPController::ActuationCommand &act)
Send the fuel + ox PWM commands for a given actuation output.
RobustDDPController::ActuationCommand last_actuation_
void setMeasurement(const RobustDDPController::Measurement &meas)
void setFireStateId(uint8_t id)
Sequencer state id that means "firing", for the parity fallback that sniffs the sequencer state packe...
void setFireActive(bool active)
Enable or disable PWM output (FIRE state gate).
void elodinSubscriberLoop()
void setFireGateEnabled(bool enabled)
Master switch for the PWM ignition gate.
double interpolateThrustCurve(double t_elapsed_s) const
bool connectSubscriber()
Connect the subscriber and subscribe to the tables it reads.
RobustDDPController::Measurement current_meas_
void writeMeasurementToDB(const RobustDDPController::Measurement &measurement)
bool start(double loop_rate_hz=10.0)
Start the controller loop at the given rate.
void subscriberReadLoop(std::vector< uint8_t > &rx_buffer)
The read half, one connection's worth.
bool loadThrustCurve(const std::string &path)
RobustDDPController::Diagnostics getLastDiagnostics() const
std::atomic< bool > running_
void writeDiagnosticsToDB(const RobustDDPController::Diagnostics &diagnostics)
std::atomic< float > test_duty_ox_
void setCommand(const RobustDDPController::Command &cmd)
bool sendPWMCommands(const PWMTarget &t1, float duty1, const PWMTarget &t2, float duty2, float frequency, uint32_t duration_ms)
Single UDP packet carrying both channels.
std::thread controller_thread_
std::thread elodin_subscriber_thread_
bool sendPWMCommand(const PWMTarget &target, float duty_cycle, float frequency, uint32_t duration_ms)
Send a PWM actuator command over UDP.
RobustDDPController::Diagnostics last_diagnostics_
void setTestDuty(float fuel, float ox)
Override controller output with fixed duty cycles for open-loop validation.
RobustDDPController::Command current_cmd_
std::atomic< bool > fire_gate_enabled_
bool initialize(const PWMConfig &pwm_config, const RobustDDPController::Config &controller_config, const std::string &elodin_host="", uint16_t elodin_port=2240, const std::string &lut_path="", const std::string &thrust_curve_path="")
Initialize the controller service.
RobustDDPController::ActuationCommand getLastActuation() const
Get last actuation output (for diagnostics / GUI broadcast).
bool registerControllerTables()
std::atomic< float > test_duty_fuel_
std::vector< double > thrust_curve_values_
Motorized ball valve position: raw ADC counts -> % open.
std::string bind_address
Local address PWM commands leave from; "0.0.0.0" leaves the NIC to the kernel.
Where one propellant's PWM commands go.
std::string actuator_name