Commit 36bda41
committed
Trim the checks that no real configuration can reach
@zuorenchen's point on reading this file is right, and it is worth writing down
as a rule rather than a mood: a check earns its place if it stops an honest run
being rejected, a dishonest one being accepted, or the program falling over for
someone. Three of these did none of those.
Gone: the range validator, which existed so `throttle_range=(inf, inf)` could
not clamp a finite value to infinity; the guard on the filter coefficient
overflowing to zero, which needs a time constant near 1e200; and the tests built
around a subnormal demand rate of 5e-324. None of those is a number anyone sets.
Their combined weight was 67 lines of implementation and 124 lines of tests
against a reader who has to get past them to change anything real.
What stays is what a mistake actually looks like. A controller that diverges and
writes NaN or infinity into the actuator is refused at the setter, which was the
original point of #18. A negative time constant, a negative rate limit and a
non-positive demand rate are refused. So is a range whose lower bound is above
its upper. And `add_*_control` hands the controller the sampling rate the
actuator kept, so passing `"100"` from a config file cannot leave the two
holding different types and fail later inside Flight.
The coefficient keeps its one-expression form, `1 / (1 + tau * rate)`. That was
not really about overflow: it is one expression instead of two, agrees with the
old one to 2.2e-16 across the range a real actuator uses, and happens to give
the right answer for a subnormal rate without anyone guarding it.
Suite goes 122 -> 104. ruff and pylint clean, pylint exits 0.
Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>1 parent b097411 commit 36bda41
3 files changed
Lines changed: 15 additions & 205 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | 50 | | |
98 | 51 | | |
99 | 52 | | |
| |||
149 | 102 | | |
150 | 103 | | |
151 | 104 | | |
152 | | - | |
153 | | - | |
| 105 | + | |
154 | 106 | | |
155 | 107 | | |
156 | | - | |
157 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
158 | 111 | | |
159 | 112 | | |
160 | 113 | | |
| |||
200 | 153 | | |
201 | 154 | | |
202 | 155 | | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
214 | 160 | | |
215 | 161 | | |
216 | 162 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | 163 | | |
231 | 164 | | |
232 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
695 | 695 | | |
696 | 696 | | |
697 | 697 | | |
698 | | - | |
699 | | - | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
741 | | - | |
742 | | - | |
743 | | - | |
744 | | - | |
745 | | - | |
| 698 | + | |
| 699 | + | |
746 | 700 | | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
| 701 | + | |
760 | 702 | | |
761 | 703 | | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
784 | | - | |
785 | | - | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | 704 | | |
790 | 705 | | |
791 | 706 | | |
| |||
872 | 787 | | |
873 | 788 | | |
874 | 789 | | |
875 | | - | |
876 | | - | |
877 | | - | |
878 | | - | |
879 | | - | |
880 | | - | |
881 | | - | |
882 | | - | |
883 | | - | |
884 | | - | |
885 | | - | |
886 | | - | |
887 | | - | |
888 | | - | |
889 | | - | |
890 | | - | |
891 | | - | |
892 | | - | |
893 | | - | |
894 | | - | |
895 | | - | |
896 | | - | |
897 | | - | |
898 | | - | |
899 | | - | |
900 | | - | |
901 | | - | |
902 | | - | |
903 | | - | |
904 | | - | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
0 commit comments