Skip to content

Commit 3540f42

Browse files
committed
Remove hard coded values
1 parent 859885a commit 3540f42

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

drone_estimators/ros_nodes/estimators.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ integrator = "euler" # TODO add RK4
1111
jit_compile = false # TODO add jit compilation for faster estimators
1212

1313
[estimator1]
14-
estimator_type = "legacy"
14+
estimator_type = "ukf"
1515
drone_name = "cf52"
16-
drone_config = "cf2x_B500"
17-
dynamics_model = "so_rpy_rotor_drag_dynamics"
16+
drone_config = "cf21B_500"
17+
dynamics_model = "so_rpy_rotor_drag"
1818
estimate_rotor_vel = true
1919
estimate_dist_f = true
2020
estimate_dist_t = false

drone_estimators/ros_nodes/ros2_node.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import toml
3535

3636
# Message types: https://docs.ros2.org/foxy/api/geometry_msgs/index-msg.html
37+
from drone_models.core import load_params
3738
from drone_models.transform import pwm2force
3839
from geometry_msgs.msg import PoseStamped, TwistStamped, WrenchStamped
3940
from munch import Munch, munchify
@@ -168,6 +169,7 @@ def _init_estimator(self):
168169
)
169170
case "ukf":
170171
self.input_needed = True
172+
self.params = load_params(self.settings.dynamics_model, self.settings.drone_config)
171173
self.estimator = KalmanFilter(
172174
dt=1 / self.frequency,
173175
model=self.settings.dynamics_model,
@@ -202,7 +204,7 @@ def _init_estimator(self):
202204

203205
def run(self):
204206
"""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
206208

207209
k = 0
208210
global_time = time.perf_counter()
@@ -231,9 +233,7 @@ def run(self):
231233
# roll (deg), pitch (deg), yaw (deg), thrust (PWM)
232234
# All the models run with rad and N, so we need to convert the RPYT command
233235
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"]
237237
)
238238
cmd[..., :-1] = np.deg2rad(cmd[..., :-1])
239239
self.estimator.set_input(cmd) # TODO # compare times?

0 commit comments

Comments
 (0)