This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
doc:crazyflie:dev:host:client:index [2015-02-11 10:01] macke |
doc:crazyflie:dev:host:client:index [2020-05-12 14:28] (current) kimberly |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <WRAP center round important 60%> | ||
+ | This page has deprecated and moved to the new documentation framework of the main Bitcraze website. Please go to [[https:// | ||
+ | </ | ||
+ | ====== Crazyflie Python client ====== | ||
+ | This page contains generic information about various topics that might be interesting while developing for the Crazyflie Python client. The same kind of information is available here for the Crazyflie Python API. | ||
+ | |||
+ | Here's a quick overview: | ||
+ | * The GUI is made in QT4 (using QTDesigner 4 and loading the .ui files at runtime) | ||
+ | * It uses the SDL2 to read input devices on Windows/Mac OSX and raw jsdevs on Linux. It also supports custom input from [[https:// | ||
+ | |||
+ | ====== Architecture ====== | ||
+ | {{ : | ||
+ | ===== Input devices ===== | ||
+ | The architecture for the input devices in the client strives to give as much flexibility as possible and to make cross platform compatibility smooth. It combines raw readings from input devices with input device mappings to create control values for the Crazyflie and the application. It's also possible to input control values directly. | ||
+ | |||
+ | Below is a walk though of every step of the process, from reading the device to sending the control values to the Crazyflie. | ||
+ | |||
+ | ==== InputDevice ==== | ||
+ | There are two ways to get input into the client: Input readers and input interfaces. On startup the modules // | ||
+ | |||
+ | Once the backends are found the client tries to initialize each backend. If successful it is scanned for devices, otherwise it's quietly discarded (only printing a message to the console). A structure is build where the dependency is reversed (backend-> | ||
+ | |||
+ | The client can now open any device in the list and read it. If the device is from the // | ||
+ | |||
+ | === Input readers === | ||
+ | Currently there' | ||
+ | |||
+ | === Input interfaces === | ||
+ | The input interfaces don't use any mapping, the devices itself directly generate useful values (like roll/ | ||
+ | |||
+ | ==== The MUX ==== | ||
+ | |||
+ | === Scaling and processing === | ||
+ | |||
+ | ==== Input and beyond ==== | ||
+ | |||
+ | ====== Files ====== | ||
+ | To support the application there' | ||
+ | ===== User configuration file ===== | ||
+ | To save the configuration between runs of the application there' | ||
+ | <code json> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | "Sony PLAYSTATION(R)3 Controller": | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | ^ Field ^ Format | ||
+ | | client_side_xmode | boolean | Sets weather the client side X-mode is activated or not (more info here) | | ||
+ | | link_uri | string | The last successfully connected Crazyflie URI. This is used when you click "Quick connect" | ||
+ | | auto_reconnect | boolean | Set's if auto-reconnect is enabled or not | | ||
+ | | ui_update_period | int | The minimum time (in ms) between UI updates for logging values | | ||
+ | | enable_debug_driver | boolean | The Crazyflie API contains a driver for debugging the UI. This driver will act as a Crazyflie and can be used to simulate a number of issues | | ||
+ | | open_tabs | string | A comma-separated list of the open tabs (using the tab.tabName attribute) | | ||
+ | | input_device | string | The readable name of the last used input device | | ||
+ | | device_config_mapping | dict | A dictionary where the keys are readable input device names and the values are the last used mapping for the device | | ||
+ | | input_device_blacklist | string | A regexp that will sort out input devices while scanning. This is to avoid detecting virtual joysticks while using a VM | | ||
+ | | flight_mode | string | The name of the last used flightmode (either Advanced or ?) | | ||
+ | | slew_limit | int | The limit (in %) where the slew-tate limiting kicks in, only applicable in Advanced mode | | ||
+ | | slew_rate | int | The slew rate in %/s that will limit the lowering of the thrust, only applicable in Advanced mode | | ||
+ | | trim_pitch | float | The pitch trim (degrees) | | ||
+ | | trim_roll | float | The roll trim (degrees) | | ||
+ | | max_thrust | float | Max allowed thrust, only applicable in Advanced mode | | ||
+ | | min_thrust | float | Min allowed thrust, only applicable in Advanced mode | | ||
+ | | max_yaw | float | Max allowed yaw rate (degrees/ | ||
+ | | max_rp | float | Max allowed roll/pitch (degrees), only applicable in Advanced mode | | ||
+ | |||
+ | ===== Default configuration file ===== | ||
+ | The source code contains a default configuration file (/// | ||
+ | <code json> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== TOC cache files ===== | ||
+ | In order to speed up the connection procedure for the Crazyflie the TOCs are cached ([[doc: | ||
+ | |||
+ | The TOC cache files are organized in a hierarchical manner after the // | ||
+ | |||
+ | ^ Field ^ Format | ||
+ | | ident | int | The TOC id of the variable | | ||
+ | | group | string | The group the variable belongs to | | ||
+ | | name | string | The name of the variable | | ||
+ | | prototype | string | The Python unpack string of the variable used when unpacking the binary data | | ||
+ | | __class__ | string | The name of the class that can hold this variable (either LogTocElement or ParamTocElement) | | ||
+ | | ctype | string | The variable type in the firmware | | ||
+ | | access | int | The access restrictions mask for the variable (only applicable for parameters). 0 = RW, 1 = RO | | ||
+ | |||
+ | Below is an example of part of the log TOC cache: | ||
+ | <code json> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | .... | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Below is an example of part of the param TOC cache: | ||
+ | <code json> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | " | ||
+ | .... | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Input device configuration ===== | ||
+ | Input device configurations are used to map raw axis (integers) to values such as roll/ | ||
+ | |||
+ | A raw axis can be mapped to one or more values, that way it's possible to split up values on multiple axis. An example of this is using the bumper buttons to control the yaw, where the left one controls CW rotation and the right one controls CCW rotation. | ||
+ | |||
+ | ^ Field ^ Format | ||
+ | | inputconfig | dict | Contains one input device | | ||
+ | | inputdevice | dict | Contains a configuration for an input device | | ||
+ | | updateperiod | int | Specifies how often the device is read (not used) | | ||
+ | | name | string | Readable name of the configuration | | ||
+ | | axis | list | A list of every axis that is mapped | | ||
+ | | scale | float | A scale that should be applied to the axis value (will be divided with the scale). Negative values can be used to invert the axis | | ||
+ | | offset | float | An offset that should be applied to the axis value | | ||
+ | | type | string | Either Input.AXIS or Input.BUTTON depending on if it's an axis or a button that //id// or //ids// refer to | | ||
+ | | id | int | The driver id of the axis (used for single axis mapping) | | ||
+ | | ids | list of ints | The driver ids of the axis (used for split axis configuration). The first one will be the negative part and the second one the positive part | | ||
+ | | key | string | This string is used inside the application to determine what value should be updated using this axis | | ||
+ | | name | string | Readable name of the axis (not used) | | ||
+ | |||
+ | <code json> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | 12, | ||
+ | 13 | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Log configuration files ===== | ||
+ | The user can configure custom logging configurations from the UI ([[doc: | ||
+ | |||
+ | ^ Field ^ Format | ||
+ | | logconfig | dict | Contains a logging configuration | | ||
+ | | logblock | dict | A logging configuration | | ||
+ | | name | string | A readable name of the configuration that will be shown in the UI | | ||
+ | | period | int | The period the logging data should be requested in. Minimum resolution is 10th of ms | | ||
+ | | variables | list | A list of dictionaries, | ||
+ | | name | string | The full name of the variable in the group.name format | | ||
+ | | type | string | Could be either TOC or Memory, currently only TOC is implemented | | ||
+ | | stored_as | string | The format (as C type) that the variable is stored as in the firmware | | ||
+ | | fetch_as | string | The format (as C type) that the variable should be logged as | | ||
+ | |||
+ | Below is an example of a log configuration file: | ||
+ | <code json> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | {" | ||
+ | " | ||
+ | {" | ||
+ | {" | ||
+ | {" | ||
+ | ]} | ||
+ | } | ||
+ | } | ||
+ | </ |