|
34 | 34 | import toml |
35 | 35 |
|
36 | 36 | # Message types: https://docs.ros2.org/foxy/api/geometry_msgs/index-msg.html |
| 37 | +from drone_models.core import load_params |
37 | 38 | from drone_models.transform import pwm2force |
38 | 39 | from geometry_msgs.msg import PoseStamped, TwistStamped, WrenchStamped |
39 | 40 | from munch import Munch, munchify |
@@ -168,6 +169,7 @@ def _init_estimator(self): |
168 | 169 | ) |
169 | 170 | case "ukf": |
170 | 171 | self.input_needed = True |
| 172 | + self.params = load_params(self.settings.dynamics_model, self.settings.drone_config) |
171 | 173 | self.estimator = KalmanFilter( |
172 | 174 | dt=1 / self.frequency, |
173 | 175 | model=self.settings.dynamics_model, |
@@ -202,7 +204,7 @@ def _init_estimator(self): |
202 | 204 |
|
203 | 205 | def run(self): |
204 | 206 | """Main estimator loop.""" |
205 | | - self._init_estimator() # done here such that error can be raised properly |
| 207 | + self._init_estimator() # done here such that errors can be raised properly |
206 | 208 |
|
207 | 209 | k = 0 |
208 | 210 | global_time = time.perf_counter() |
@@ -231,9 +233,7 @@ def run(self): |
231 | 233 | # roll (deg), pitch (deg), yaw (deg), thrust (PWM) |
232 | 234 | # All the models run with rad and N, so we need to convert the RPYT command |
233 | 235 | cmd[..., -1] = pwm2force( |
234 | | - cmd[..., -1], |
235 | | - 0.18 * 4, # TODO remove hard coded value |
236 | | - 65535, # TODO remove hard coded value |
| 236 | + cmd[..., -1], self.params["thrust_max"] * 4, self.params["pwm_max"] |
237 | 237 | ) |
238 | 238 | cmd[..., :-1] = np.deg2rad(cmd[..., :-1]) |
239 | 239 | self.estimator.set_input(cmd) # TODO # compare times? |
|
0 commit comments