mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 16:13:34 +08:00
fixed sine output
This commit is contained in:
@@ -148,6 +148,9 @@ int motor_ramp_main(int argc, char *argv[])
|
|||||||
if (strcmp(argv[3], "-s") == 0) {
|
if (strcmp(argv[3], "-s") == 0) {
|
||||||
_sine_output = true;
|
_sine_output = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_sine_output = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(_ramp_time > 0)) {
|
if (!(_ramp_time > 0)) {
|
||||||
@@ -311,10 +314,10 @@ int motor_ramp_thread_main(int argc, char *argv[])
|
|||||||
} else {
|
} else {
|
||||||
// sine outpout with period T = _ramp_time and magnitude between [0,1]
|
// sine outpout with period T = _ramp_time and magnitude between [0,1]
|
||||||
// phase shift makes sure that it starts at zero when timer is zero
|
// phase shift makes sure that it starts at zero when timer is zero
|
||||||
output = 0.5f * (1.0f + sinf(M_TWOPI_F * timer / (_ramp_time * 1e6f) - M_PI_2_F));
|
output = 0.5f * (1.0f + sinf(M_TWOPI_F * timer / _ramp_time - M_PI_2_F));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((output > 1.0f && !_sine_output) || (timer > 3.0f * _ramp_time * 1e6f && _sine_output)) {
|
if ((output > 1.0f && !_sine_output) || (timer > 3.0f * _ramp_time && _sine_output)) {
|
||||||
// for ramp mode we set output to 1, for sine mode we just leave it as is
|
// for ramp mode we set output to 1, for sine mode we just leave it as is
|
||||||
output = _sine_output ? output : 1.0f;
|
output = _sine_output ? output : 1.0f;
|
||||||
start = hrt_absolute_time();
|
start = hrt_absolute_time();
|
||||||
|
|||||||
Reference in New Issue
Block a user