Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulate motor noise in the gyros and accels #12431

Open
wants to merge 4 commits into
base: master
from

Conversation

@andyp1per
Copy link
Contributor

andyp1per commented Sep 27, 2019

This PR enables the simulation of motor-based noise for multicopters. Noise is created at the motor rotational frequency for each motor and combined. The rotational frequency is estimated from the thrust.

The benefit of this simulation is that it allows filtering targeting motor peaks to be tested in SITL. The support includes a test for the notch filter including dynamic FFT analysis using the batch sampler.

The simulation is controlled by setting
SIM_VIB_MOT_MAX to the maximum frequency expected from the motors at maximum throttle. The amount of noise added is controlled by the regular SIM_GYR_RND and SIM_ACCEL_RND settings.

@andyp1per andyp1per changed the title Simulator motor noise in the gyros and accels Simulate motor noise in the gyros and accels Oct 8, 2019
@andyp1per andyp1per force-pushed the andyp1per:pr-gyro-motor-noise-sim branch 3 times, most recently from 0cb564c to bce7eed Oct 8, 2019
@andyp1per andyp1per marked this pull request as ready for review Oct 11, 2019
@andyp1per andyp1per requested a review from peterbarker Oct 11, 2019
@andyp1per

This comment has been minimized.

Copy link
Contributor Author

andyp1per commented Oct 11, 2019

@peterbarker I would be grateful for a review!

@andyp1per andyp1per force-pushed the andyp1per:pr-gyro-motor-noise-sim branch from bce7eed to f77c0de Oct 11, 2019
@tridge

This comment has been minimized.

Copy link
Contributor

tridge commented Dec 2, 2019

I'm happy with the SITL C++ changes, just needs peters review on autotest changes

Tools/autotest/arducopter.py Outdated Show resolved Hide resolved
Tools/autotest/common.py Outdated Show resolved Hide resolved
Tools/autotest/arducopter.py Outdated Show resolved Hide resolved
Tools/autotest/arducopter.py Outdated Show resolved Hide resolved
@CraigElder CraigElder removed the DevCallTopic label Dec 2, 2019
@andyp1per andyp1per force-pushed the andyp1per:pr-gyro-motor-noise-sim branch 2 times, most recently from f1b2a2d to 0e2ff3f Dec 3, 2019
@peterbarker

This comment has been minimized.

Copy link
Contributor

peterbarker commented Dec 4, 2019

Copy link
Contributor

peterbarker left a comment

I'm good with the SITL changes.

@andyp1per

This comment has been minimized.

Copy link
Contributor Author

andyp1per commented Dec 4, 2019

On Tue, 3 Dec 2019, Andy Piper wrote: + vibe_log = self.buildlogs_path("ArduCopter-vibration-log.bin") I tried current_onboard_log_filepath() but it fails, just going to stick with the current approach
That's fine. What was the failure, 'though?

Something about index out of range

@andyp1per andyp1per force-pushed the andyp1per:pr-gyro-motor-noise-sim branch from 0e2ff3f to 92a1195 Dec 4, 2019
@andyp1per

This comment has been minimized.

Copy link
Contributor Author

andyp1per commented Dec 4, 2019

Thanks for the logging fix @peterbarker - works well!

@andyp1per

This comment has been minimized.

Copy link
Contributor Author

andyp1per commented Dec 4, 2019

@peterbarker any idea why I would get this:

   self.check_rc_defaults()

  File "/home/travis/build/ArduPilot/ardupilot/Tools/autotest/common.py", line 967, in check_rc_defaults

    raise NotAchievedException("No RC_CHANNELS messages?!")

NotAchievedException: No RC_CHANNELS messages?!
@andyp1per andyp1per force-pushed the andyp1per:pr-gyro-motor-noise-sim branch 2 times, most recently from 5f6961b to c71e033 Dec 5, 2019
@andyp1per

This comment has been minimized.

Copy link
Contributor Author

andyp1per commented Dec 5, 2019

Ok I have rebased and made some tweaks and is passing now. Once the final change gets blessed by CI I will drop the matek commit and it will be ready for merge.

@andyp1per

This comment has been minimized.

Copy link
Contributor Author

andyp1per commented Dec 5, 2019

@peterbarker I got this failure again:
https://travis-ci.org/ArduPilot/ardupilot/jobs/621076962?utm_medium=notification&utm_source=github_status
I feel like this is a symptom of some deeper problem to do with log downloading. Any ideas? Would cleaning up the logs as we go along make the tests run faster?

@andyp1per

This comment has been minimized.

Copy link
Contributor Author

andyp1per commented Dec 5, 2019

@peterbarker so I just watched this test in progress, there are basically three problems:

  • There's only 2min30s left for the test as it comes at the end of a 47min test run and the timeout is 50min - I think we should increase this
  • It generates a 17Mb log file per run which takes 40s to download each time (there are two passes to the test so 1min20s) - some of this is just going to be because of the batch logging, but I wonder whether we are getting a lot of logging from either side of the test that could be removed. Is there a faster way to get the log?
  • The EKF takes forever to settle - is there a way to avoid this or speed this up?
@peterbarker

This comment has been minimized.

Copy link
Contributor

peterbarker commented Dec 6, 2019

@peterbarker so I just watched this test in progress, there are basically three problems:

* There's only 2min30s left for the test as it comes at the end of a 47min test run and the timeout is 50min - I think we should increase this

Yep, it's close! Is it actually running overtime?

* It generates a 17Mb log file per run which takes 40s to download each time (there are two passes to the test so 1min20s) - some of this is just going to be because of the batch logging, but I wonder whether we are getting a lot of logging from either side of the test that could be removed. Is there a faster way to get the log?

Rebooting the vehicle (which you are doing) must start a new log, so it's almost certainly All Your Fault :-P

I did suggest the faster way to get the log - reference it directly using dfreader_for_current_onboard_log. That didn't work straight-up - I really only added that to solve my particular need at the time and didn't extensively test it. Perhaps if you give me instructions on how to reproduce the index-out-of-range bug I could fix that?

* The EKF takes forever to settle - is there a way to avoid this or speed this up?

I've been wondering about pushing stream rates way-down and pushing sim-speedup way-up for periods where we don't really care about anything but simple things like this. Long traverals to waypoints (like the quadplane tests) might also be candidates for this.

But generally, no - there are hard-wired timeouts in the EKF which makes shortening settle-time problematic.

@andyp1per

This comment has been minimized.

Copy link
Contributor Author

andyp1per commented Dec 6, 2019

Ok I have disabled LOG_DISARMED and that has produced a mcuh smaller log that can be downloaded in 5s. Still timing out though ...

@andyp1per andyp1per force-pushed the andyp1per:pr-gyro-motor-noise-sim branch from c54cf45 to 25a7874 Dec 8, 2019
@andyp1per

This comment has been minimized.

Copy link
Contributor Author

andyp1per commented Dec 8, 2019

@peterbarker I got the test working with dfreader_for_current_onboard_log() thanks! Observing the test its slow because of EKF because of GPS fix - is there any way to speed up the GPS fix? I don't remember it being this bad.

@peterbarker

This comment has been minimized.

Copy link
Contributor

peterbarker commented Dec 8, 2019

@andyp1per One option might be setting EKF type 10. I'm really not sure, 'though.

@andyp1per

This comment has been minimized.

Copy link
Contributor Author

andyp1per commented Dec 8, 2019

@peterbarker tests are now clean - good enough? 🙂
SITL copter is 47mins30s, so I don't think I have added to the overhead much now.

@andyp1per andyp1per requested a review from peterbarker Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.