Skip to content

Commit d669883

Browse files
committed
Add comments
1 parent dcd4a7a commit d669883

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tools/system_id/collect_data.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,6 @@ def _ramp_motors(self):
596596
self._cf.param.set_value("motorPowerSet.enable", 2)
597597
print("Collecting data without battery compensation")
598598

599-
# base speed
600-
self._applyThrust(PWM_MIN, 2.0)
601-
602599
self._ramp_motors_chirp()
603600
self._ramp_motors_step()
604601

@@ -648,6 +645,9 @@ def _ramp_motors_step(self, duration: float = 1.0):
648645
self._applyThrust(PWM_MIN, 2 * duration)
649646

650647
def _ramp_motors_chirp(self):
648+
# base speed
649+
self._applyThrust(PWM_MAX / 4, 2.0)
650+
651651
chirp_duration = 30 # s
652652
chirp_send_frequency = 100 # Hz
653653
chirp_f0 = 0.1 # Hz
@@ -657,21 +657,25 @@ def _ramp_motors_chirp(self):
657657

658658
t = np.linspace(0, chirp_duration, chirp_duration * chirp_send_frequency)
659659
c = chirp(t, chirp_f0, chirp_duration, chirp_f1, method="lin", phi=180)
660+
# [PWM_MIN, PWM_MIN+PWM_MAX/4]
660661
for sine in c:
661662
sine = (sine + 1) / 2 # Scaling to [0,1]
662663
pwm = sine * PWM_MAX / 4 + PWM_MIN # Scaling to useful PWM values
663664
self._applyThrust(pwm, 1 / chirp_send_frequency)
664665

666+
# [PWM_MIN, PWM_MIN+PWM_MAX/2]
665667
for sine in c:
666668
sine = (sine + 1) / 2 # Scaling to [0,1]
667669
pwm = sine * PWM_MAX / 2 + PWM_MIN # Scaling to useful PWM values
668670
self._applyThrust(pwm, 1 / chirp_send_frequency)
669671

672+
# [PWM_MAX/4, PWM_MAX*3/4]
670673
for sine in c:
671674
sine = (sine + 1) / 2 # Scaling to [0,1]
672-
pwm = sine * (PWM_MAX - PWM_MIN) + PWM_MIN # Scaling to useful PWM values
675+
pwm = sine * PWM_MAX / 2 + PWM_MAX / 4 # Scaling to useful PWM values
673676
self._applyThrust(pwm, 1 / chirp_send_frequency)
674677

678+
# [PWM_MAX/2, PWM_MAX]
675679
for sine in c:
676680
sine = (sine + 1) / 2 # Scaling to [0,1]
677681
pwm = sine * PWM_MAX / 2 + PWM_MAX / 2 # Scaling to useful PWM values

0 commit comments

Comments
 (0)