-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example script that uses the ParamFileHelper.
The script will write all supplied parameters to the crazyflie and store them Re-format code to code standard
- Loading branch information
Showing
3 changed files
with
101 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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 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,60 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# ,---------, ____ _ __ | ||
# | ,-^-, | / __ )(_) /_______________ _____ ___ | ||
# | ( O ) | / __ / / __/ ___/ ___/ __ `/_ / / _ \ | ||
# | / ,--' | / /_/ / / /_/ /__/ / / /_/ / / /_/ __/ | ||
# +------` /_____/_/\__/\___/_/ \__,_/ /___/\___/ | ||
# | ||
# Copyright (C) 2024 Bitcraze AB | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, in version 3. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
""" | ||
Example to show how to write several persistent parameters from a yaml file. | ||
The params in the file should be formatted like this; | ||
params: | ||
activeMarker.back: | ||
default_value: 3 | ||
is_stored: true | ||
stored_value: 30 | ||
type: persistent_param_state | ||
version: '1' | ||
""" | ||
import argparse | ||
import logging | ||
|
||
import cflib.crtp | ||
from cflib.crazyflie import Crazyflie | ||
from cflib.crazyflie.syncCrazyflie import SyncCrazyflie | ||
from cflib.utils import uri_helper | ||
from cflib.utils.param_file_helper import ParamFileHelper | ||
|
||
|
||
uri = uri_helper.uri_from_env(default='radio://0/80/2M/E7E7E7E7E7') | ||
|
||
# Only output errors from the logging framework | ||
logging.basicConfig(level=logging.ERROR) | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-f', '--file', type=str, help='The yaml file containing the arguments. ') | ||
args = parser.parse_args() | ||
|
||
cflib.crtp.init_drivers() | ||
|
||
cf = Crazyflie(rw_cache='./cache') | ||
with SyncCrazyflie(uri, cf=cf) as scf: | ||
writer = ParamFileHelper(scf.cf) | ||
writer.store_params_from_file(args.file) |
This file contains 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