diff --git a/src/cfclient/configs/log/PID_tuning/Attitude.json b/src/cfclient/configs/log/PID_tuning/Attitude.json new file mode 100644 index 000000000..31fd691e8 --- /dev/null +++ b/src/cfclient/configs/log/PID_tuning/Attitude.json @@ -0,0 +1,46 @@ +{ + "logconfig": { + "logblock": { + "variables": [ + { + "name": "controller.pitch", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "controller.roll", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "controller.yaw", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.pitch", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.roll", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.yaw", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + } + ], + "name": "Attitude", + "period": 10 + } + } +} \ No newline at end of file diff --git a/src/cfclient/configs/log/PID_tuning/Attitude_rate.json b/src/cfclient/configs/log/PID_tuning/Attitude_rate.json new file mode 100644 index 000000000..c7635c906 --- /dev/null +++ b/src/cfclient/configs/log/PID_tuning/Attitude_rate.json @@ -0,0 +1,46 @@ +{ + "logconfig": { + "logblock": { + "variables": [ + { + "name": "controller.pitchRate", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "controller.rollRate", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "controller.yawRate", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "gyro.x", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "gyro.y", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "gyro.z", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + } + ], + "name": "Attitude rate", + "period": 10 + } + } +} diff --git a/src/cfclient/configs/log/PID_tuning/Position.json b/src/cfclient/configs/log/PID_tuning/Position.json new file mode 100644 index 000000000..01f7d35ad --- /dev/null +++ b/src/cfclient/configs/log/PID_tuning/Position.json @@ -0,0 +1,46 @@ +{ + "logconfig": { + "logblock": { + "variables": [ + { + "name": "posCtl.targetX", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "posCtl.targetY", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "posCtl.targetZ", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.x", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.y", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.z", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + } + ], + "name": "Position", + "period": 10 + } + } +} \ No newline at end of file diff --git a/src/cfclient/configs/log/PID_tuning/Velocity.json b/src/cfclient/configs/log/PID_tuning/Velocity.json new file mode 100644 index 000000000..8e2ceac0c --- /dev/null +++ b/src/cfclient/configs/log/PID_tuning/Velocity.json @@ -0,0 +1,46 @@ +{ + "logconfig": { + "logblock": { + "variables": [ + { + "name": "posCtl.targetVX", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "posCtl.targetVY", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "posCtl.targetVZ", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.vx", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.vy", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.vz", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + } + ], + "name": "Velocity", + "period": 10 + } + } +} \ No newline at end of file diff --git a/src/cfclient/configs/log/PID_tuning_components/Pitch.json b/src/cfclient/configs/log/PID_tuning_components/Pitch.json new file mode 100644 index 000000000..d340a921b --- /dev/null +++ b/src/cfclient/configs/log/PID_tuning_components/Pitch.json @@ -0,0 +1,22 @@ +{ + "logconfig": { + "logblock": { + "variables": [ + { + "name": "controller.pitch", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.pitch", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + } + ], + "name": "Pitch", + "period": 10 + } + } +} diff --git a/src/cfclient/configs/log/PID_tuning_components/Pitch_rate.json b/src/cfclient/configs/log/PID_tuning_components/Pitch_rate.json new file mode 100644 index 000000000..96af00d8a --- /dev/null +++ b/src/cfclient/configs/log/PID_tuning_components/Pitch_rate.json @@ -0,0 +1,22 @@ +{ + "logconfig": { + "logblock": { + "variables": [ + { + "name": "controller.pitchRate", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "gyro.y", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + } + ], + "name": "Pitch rate", + "period": 10 + } + } +} diff --git a/src/cfclient/configs/log/PID_tuning_components/Position_x.json b/src/cfclient/configs/log/PID_tuning_components/Position_x.json new file mode 100644 index 000000000..309420a42 --- /dev/null +++ b/src/cfclient/configs/log/PID_tuning_components/Position_x.json @@ -0,0 +1,22 @@ +{ + "logconfig": { + "logblock": { + "variables": [ + { + "name": "posCtl.targetX", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.x", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + } + ], + "name": "Position x", + "period": 10 + } + } +} \ No newline at end of file diff --git a/src/cfclient/configs/log/PID_tuning_components/Position_y.json b/src/cfclient/configs/log/PID_tuning_components/Position_y.json new file mode 100644 index 000000000..8ebf32ad6 --- /dev/null +++ b/src/cfclient/configs/log/PID_tuning_components/Position_y.json @@ -0,0 +1,22 @@ +{ + "logconfig": { + "logblock": { + "variables": [ + { + "name": "posCtl.targetY", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.y", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + } + ], + "name": "Position y", + "period": 10 + } + } +} \ No newline at end of file diff --git a/src/cfclient/configs/log/PID_tuning_components/Position_z.json b/src/cfclient/configs/log/PID_tuning_components/Position_z.json new file mode 100644 index 000000000..0a5e615ec --- /dev/null +++ b/src/cfclient/configs/log/PID_tuning_components/Position_z.json @@ -0,0 +1,22 @@ +{ + "logconfig": { + "logblock": { + "variables": [ + { + "name": "posCtl.targetZ", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.z", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + } + ], + "name": "Position z", + "period": 10 + } + } +} \ No newline at end of file diff --git a/src/cfclient/configs/log/PID_tuning_components/Roll.json b/src/cfclient/configs/log/PID_tuning_components/Roll.json new file mode 100644 index 000000000..aadd00353 --- /dev/null +++ b/src/cfclient/configs/log/PID_tuning_components/Roll.json @@ -0,0 +1,22 @@ +{ + "logconfig": { + "logblock": { + "variables": [ + { + "name": "controller.roll", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.roll", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + } + ], + "name": "Roll", + "period": 10 + } + } +} \ No newline at end of file diff --git a/src/cfclient/configs/log/PID_tuning_components/Roll_rate.json b/src/cfclient/configs/log/PID_tuning_components/Roll_rate.json new file mode 100644 index 000000000..6f41cd15e --- /dev/null +++ b/src/cfclient/configs/log/PID_tuning_components/Roll_rate.json @@ -0,0 +1,22 @@ +{ + "logconfig": { + "logblock": { + "variables": [ + { + "name": "controller.rollRate", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "gyro.x", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + } + ], + "name": "Roll rate", + "period": 10 + } + } +} \ No newline at end of file diff --git a/src/cfclient/configs/log/PID_tuning_components/Velocity_x.json b/src/cfclient/configs/log/PID_tuning_components/Velocity_x.json new file mode 100644 index 000000000..1dce36248 --- /dev/null +++ b/src/cfclient/configs/log/PID_tuning_components/Velocity_x.json @@ -0,0 +1,22 @@ +{ + "logconfig": { + "logblock": { + "variables": [ + { + "name": "posCtl.targetVX", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.vx", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + } + ], + "name": "Velocity x", + "period": 10 + } + } +} \ No newline at end of file diff --git a/src/cfclient/configs/log/PID_tuning_components/Velocity_y.json b/src/cfclient/configs/log/PID_tuning_components/Velocity_y.json new file mode 100644 index 000000000..649df46bb --- /dev/null +++ b/src/cfclient/configs/log/PID_tuning_components/Velocity_y.json @@ -0,0 +1,22 @@ +{ + "logconfig": { + "logblock": { + "variables": [ + { + "name": "posCtl.targetVY", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.vy", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + } + ], + "name": "Velocity y", + "period": 10 + } + } +} \ No newline at end of file diff --git a/src/cfclient/configs/log/PID_tuning_components/Velocity_z.json b/src/cfclient/configs/log/PID_tuning_components/Velocity_z.json new file mode 100644 index 000000000..133c098e7 --- /dev/null +++ b/src/cfclient/configs/log/PID_tuning_components/Velocity_z.json @@ -0,0 +1,22 @@ +{ + "logconfig": { + "logblock": { + "variables": [ + { + "name": "posCtl.targetVZ", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.vz", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + } + ], + "name": "Velocity z", + "period": 10 + } + } +} \ No newline at end of file diff --git a/src/cfclient/configs/log/PID_tuning_components/Yaw.json b/src/cfclient/configs/log/PID_tuning_components/Yaw.json new file mode 100644 index 000000000..6e5e9ac9c --- /dev/null +++ b/src/cfclient/configs/log/PID_tuning_components/Yaw.json @@ -0,0 +1,22 @@ +{ + "logconfig": { + "logblock": { + "variables": [ + { + "name": "controller.yaw", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "stateEstimate.yaw", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + } + ], + "name": "Yaw", + "period": 10 + } + } +} diff --git a/src/cfclient/configs/log/PID_tuning_components/Yaw_rate.json b/src/cfclient/configs/log/PID_tuning_components/Yaw_rate.json new file mode 100644 index 000000000..6d9f19ca3 --- /dev/null +++ b/src/cfclient/configs/log/PID_tuning_components/Yaw_rate.json @@ -0,0 +1,22 @@ +{ + "logconfig": { + "logblock": { + "variables": [ + { + "name": "controller.yawRate", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + }, + { + "name": "gyro.z", + "stored_as": "", + "fetch_as": "float", + "type": "TOC" + } + ], + "name": "Yaw rate", + "period": 10 + } + } +} diff --git a/src/cfclient/utils/logconfigreader.py b/src/cfclient/utils/logconfigreader.py index 1e2aafa79..ed5e1237a 100644 --- a/src/cfclient/utils/logconfigreader.py +++ b/src/cfclient/utils/logconfigreader.py @@ -7,7 +7,7 @@ # +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/ # || || /_____/_/\__/\___/_/ \__,_/ /___/\___/ # -# Copyright (C) 2011-2023 Bitcraze AB +# Copyright (C) 2011-2024 Bitcraze AB # # Crazyflie Nano Quadcopter Client # @@ -27,15 +27,11 @@ # MA 02110-1301, USA. """ -The input module that will read joysticks/input devices and send control set- -points to the Crazyflie. It will also accept settings from the UI. - -This module can use different drivers for reading the input device data. -Currently it can just use the PySdl2 driver but in the future there will be a -Linux and Windows driver that can bypass PySdl2. +The logconfigreader module is responsible for reading and parsing log +configuration data. This data is used to control what information is logged +in the client. """ -import glob import json import logging import os @@ -68,10 +64,7 @@ def __init__(self, crazyflie): # Check if user config exists, otherwise copy files if (not os.path.exists(cfclient.config_path + "/log")): logger.info("No user config found, copying dist files") - os.makedirs(cfclient.config_path + "/log") - for f in glob.glob( - cfclient.module_path + "/configs/log/[A-Za-z]*.json"): - shutil.copy2(f, cfclient.config_path + "/log") + shutil.copytree(cfclient.module_path + "/configs/log", cfclient.config_path + "/log") self._cf = crazyflie self._cf.connected.add_callback(self._connected) @@ -206,27 +199,27 @@ def _read_config_categories(self): self._log_configs = {'Default': []} log_path = os.path.join(cfclient.config_path, 'log') - for cathegory in os.listdir(log_path): + for category in os.listdir(log_path): - cathegory_path = os.path.join(log_path, cathegory) + category_path = os.path.join(log_path, category) try: - if (os.path.isdir(cathegory_path)): + if (os.path.isdir(category_path)): # create a new cathegory - self._log_configs[cathegory] = [] - for conf in os.listdir(cathegory_path): + self._log_configs[category] = [] + for conf in os.listdir(category_path): if conf.endswith('.json'): - conf_path = os.path.join(cathegory_path, conf) + conf_path = os.path.join(category_path, conf) log_conf = self._get_conf(conf_path) # add the log configuration to the cathegory - self._log_configs[cathegory].append(log_conf) + self._log_configs[category].append(log_conf) else: # if it's not a directory, the log config is placed # in the 'Default' cathegory - if cathegory_path.endswith('.json'): - log_conf = self._get_conf(cathegory_path) + if category_path.endswith('.json'): + log_conf = self._get_conf(category_path) self._log_configs['Default'].append(log_conf) except Exception as e: