STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
ControllerLUT.hpp
Go to the documentation of this file.
1#ifndef FSW_CONTROL_CONTROLLER_LUT_HPP
2#define FSW_CONTROL_CONTROLLER_LUT_HPP
3
4#include <cstdint>
5#include <map>
6#include <string>
7#include <vector>
8
9namespace fsw {
10namespace control {
11
12/**
13 * @brief Controller LUT loader with multilinear interpolation.
14 *
15 * Loads binary LUT exported by scripts/controller_lut/export_lut_for_fsw.py.
16 * Used to bypass DDP and output optimal control (u_safe_F, u_safe_O or duty_F, duty_O)
17 * for boolean solenoid actuation.
18 */
20public:
21 ControllerLUT() = default;
22
23 /** Load LUT from binary file. Returns false on error. */
24 bool load(const std::string& path);
25
26 /** True if a LUT is loaded and ready for evaluation. */
27 bool is_loaded() const {
28 return !axes_.empty();
29 }
30
31 /**
32 * Evaluate LUT at the given point.
33 * @param point Map from axis name -> value (e.g. P_u_fuel, P_u_ox, thrust_desired)
34 * @param out Map from output name -> interpolated value (e.g. u_safe_F, u_safe_O, duty_F,
35 * duty_O)
36 * @return true if evaluation succeeded
37 */
38 bool evaluate(const std::map<std::string, double>& point,
39 std::map<std::string, double>& out) const;
40
41private:
42 struct Axis {
43 std::string name;
44 std::vector<double> grid;
45 };
46 struct Output {
47 std::string name;
48 std::vector<double> data;
49 std::vector<uint32_t> shape;
50 };
51
52 std::vector<Axis> axes_;
53 std::vector<Output> outputs_;
54};
55
56} // namespace control
57} // namespace fsw
58
59#endif // FSW_CONTROL_CONTROLLER_LUT_HPP
bool load(const std::string &path)
Load LUT from binary file.
std::vector< Axis > axes_
bool is_loaded() const
True if a LUT is loaded and ready for evaluation.
std::vector< Output > outputs_
bool evaluate(const std::map< std::string, double > &point, std::map< std::string, double > &out) const
Evaluate LUT at the given point.
Motorized ball valve position: raw ADC counts -> % open.