-
Notifications
You must be signed in to change notification settings - Fork 925
Replaced reset estimator in single drone examples #515
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e2a07fa
Removed reset estimator - swarm is used
ArisMorgens 12b02db
Added ResetEstimator util
ArisMorgens 4b70359
Converted reset estimator in autonomy examples
ArisMorgens b50ebfb
Converted reset estimator in lighthouse examples
ArisMorgens 0fa6840
Converted reset estimator in mocap examples
ArisMorgens 76f29c6
Converted reset estimator in positioning examples
ArisMorgens c25aa44
Renamed file to reset_estimator.py
ArisMorgens 86df715
Fixed reset_estimator confirmation message
ArisMorgens 119ce20
Added swarm.reset_estimator in autonomy/swarm example
ArisMorgens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import time | ||
|
|
||
| from cflib.crazyflie.log import LogConfig | ||
| from cflib.crazyflie.syncCrazyflie import SyncCrazyflie | ||
| from cflib.crazyflie.syncLogger import SyncLogger | ||
|
|
||
|
|
||
| def reset_estimator(crazyflie): | ||
| if isinstance(crazyflie, SyncCrazyflie): | ||
| cf = crazyflie.cf | ||
| else: | ||
| cf = crazyflie | ||
| cf.param.set_value('kalman.resetEstimation', '1') | ||
| time.sleep(0.1) | ||
| cf.param.set_value('kalman.resetEstimation', '0') | ||
|
|
||
| _wait_for_position_estimator(cf) | ||
|
|
||
|
|
||
| def _wait_for_position_estimator(cf): | ||
| print('Waiting for estimator to find position...', end='\r') | ||
|
|
||
| log_config = LogConfig(name='Kalman Variance', period_in_ms=500) | ||
| log_config.add_variable('kalman.varPX', 'float') | ||
| log_config.add_variable('kalman.varPY', 'float') | ||
| log_config.add_variable('kalman.varPZ', 'float') | ||
|
|
||
| var_y_history = [1000] * 10 | ||
| var_x_history = [1000] * 10 | ||
| var_z_history = [1000] * 10 | ||
|
|
||
| threshold = 0.001 | ||
|
|
||
| with SyncLogger(cf, log_config) as logger: | ||
| for log_entry in logger: | ||
| data = log_entry[1] | ||
|
|
||
| var_x_history.append(data['kalman.varPX']) | ||
| var_x_history.pop(0) | ||
| var_y_history.append(data['kalman.varPY']) | ||
| var_y_history.pop(0) | ||
| var_z_history.append(data['kalman.varPZ']) | ||
| var_z_history.pop(0) | ||
|
|
||
| min_x = min(var_x_history) | ||
| max_x = max(var_x_history) | ||
| min_y = min(var_y_history) | ||
| max_y = max(var_y_history) | ||
| min_z = min(var_z_history) | ||
| max_z = max(var_z_history) | ||
|
|
||
| if (max_x - min_x) < threshold and ( | ||
| max_y - min_y) < threshold and ( | ||
| max_z - min_z) < threshold: | ||
| print('Waiting for estimator to find position...success!') | ||
| break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.