diff --git a/docs/cfclient_zmq.md b/docs/cfclient_zmq.md new file mode 100644 index 0000000000000000000000000000000000000000..1d242db4197d2d079537c85561163735d2f19068 --- /dev/null +++ b/docs/cfclient_zmq.md @@ -0,0 +1,141 @@ +The [Crazyflie Python client](/doc/crazyflie/client/pycfclient/index) +runs a number of back-ends where you can set/get information from other +applications via [ZMQ](http://zeromq.org/). + +Here\'s a list of the ports/functions available: + + | Port | Type | Functionality| + | ------| ------| --------------| + | 1213 | REQ | Set parameters| + | 1214 | PUSH | LED-ring memory| + | 1212 | PULL | Input device| + +Parameters +========== + +The parameter back-end gives access to setting parameters in the +Crazyflie. The back-end is enabled by default. + +Protocol +-------- + +Available fields: + +| Field | Format | Comments | +| -------|-- --------| ---------------------------------------------------| +| version| int | Should be set to 1 | +| cmd | string | Command to send (currently only set is supported) | +| name | string | The name of the parameter | +| value | string | The value of the parameter | + + Example of setting the *buzzer.freq* +parameter to 4000. + + { + "version": 1, + "cmd": "set", + "name" : "buzzer.freq", + "value": "4000" + } + +\</WRAP\> \</WRAP\> + +LED-ring +======== + +The LED-ring back-end gives access to the LED-ring memory driver where +the user can write the RGB values for all 12 LEDs on the ring. The +back-end is enabled by default. + +Protocol +-------- + + Available fields: + +| Field | Format | Comments| +| ---------| --------------------------|----- ---------|--------------------------------- + | version | int | Should be set to 1| + | rgbleds | array of 3 item arrays of int | R/G/B value for each LED (starting at 1)| + +\</WRAP\> \<WRAP half column\> Example of setting all LEDs off: + + { + "version": 1, + "rgbleds": [ + [0, 0, 0], + [0, 0, 0], + [0, 0, 0], + [0, 0, 0], + [0, 0, 0], + [0, 0, 0], + [0, 0, 0], + [0, 0, 0], + [0, 0, 0], + [0, 0, 0], + [0, 0, 0], + [0, 0, 0] + ] + } + +\</WRAP\> \</WRAP\> + +Input device +============ + +If you don\'t want to use the API and you don\'t want to bother about +scanning/connecting/logging/etc or there\'s no API for the environment +you use, there\'s an easy way to control the Crazyflie. Just like you +would control the Crazyflie with a gamepad or joystick connected to a +computer, you can use ZMQ to inject control set-points directly into the +client. You still use the client for connecting/logging/graphing/setting +parameters, it\'s just the control part that\'s broken out. + +By default this is disabled in the configuration file and needs to be +enabled. The configuration file parameter is named *enable\_zmq\_input* +(see +[this](/doc/crazyflie/dev/host/client/index#user_configuration_file) to +edit the configuration). To enable controlling by the back-end select +the *ZMQ\@127.0.0.1:1212* input device in the *Input device* menu. + +Protocol +-------- + +Available fields: + +| Field | Format| Comments| +| --------------| --------| ----------| +| version | int | Should be set to 1| +| client\_name | string |Name of the client (currently unused)| +| ctrl | dict |A dictionary with keys and values that match the internal names of controls in the client (see list below)| + +Available keys for the *ctrl* dictionary: + + | Field | Range | Unit | Comments| +|---------|----------|----------------|---------------| +| roll | N/A | degrees | +| pitch | N/A | degrees | +| yaw | N/A | degrees/second | +| thrust | 0-100 | Percent | +| estop | T/F | boolean | Used to stop the Crazyflie and disable the control +| alt1 | T/F | boolean | Alt1 is internally mapped to functionality like switching LED-ring effect +| alt2 | T/F | boolean | Alt2 is internally mapped to functionality like switching LED-ring headlights on/off + +Example: + + { + "version": 1, + "client_name": "ZMQ client", + "ctrl": { + "roll": 0.0, + "pitch": 0.0, + "yaw": 0.0, + "thrust": 0.0 + } + } + + + +**NOTE1**: Altitude hold is currently not working. + +**NOTE2**: The values are used at 100Hz in the client, no matter at what +rate they are sent via ZMQ diff --git a/docs/cfheadless.md b/docs/cfheadless.md new file mode 100644 index 0000000000000000000000000000000000000000..e5ffa33a49c0ff51cd096ff685f303e93724de9f --- /dev/null +++ b/docs/cfheadless.md @@ -0,0 +1,42 @@ +# Crazyflie headless client + + +The *cfheadless* client doesn\'t have a UI, it\'s run directly from the +command line and is suited for headless hosts like the Raspberry Pi. + +## cfheadless + + +The script is located in the *bin* directory in the +*crazyflie-clients-python* repository and client. Here\'s how to use the +script: +``` +$ bin/cfheadless -h + +usage: cfheadless [-h] [-u URI] [-i INPUT] [-d] [-c CONTROLLER] + [--controllers] [-x] + +optional arguments: +-h, --help show this help message and exit +-u URI, --uri URI URI to use for connection to the Crazyradio dongle, + defaults to radio://0/10/250K +-i INPUT, --input INPUT + Input mapping to use for the controller,defaults to + PS3_Mode_1 +-d, --debug Enable debug output +-c CONTROLLER, --controller CONTROLLER + Use controller with specified id, id defaults to 0 +--controllers Only display available controllers and exit +-x, --x-mode Enable client-side X-mode +``` +The client is exited either by taking out the Crazyradio USB dongle or +pressing Ctrl+C + +## Examples + + +Connect to a Crazyflie at channel 100 and speed 250Kbit using input +mapping *PS3\_Mode\_1* +``` +crazyflie-clients-python$ bin/cfheadless -u radio://0/100/250K -PS1_Mode_1 +``` diff --git a/docs/cfloader.md b/docs/cfloader.md new file mode 100644 index 0000000000000000000000000000000000000000..89476f1f34ff086c4e15eadb482d3122de36d324 --- /dev/null +++ b/docs/cfloader.md @@ -0,0 +1,128 @@ +Bootloader the Crazyflie 1.0/2.0 +================================ + +The Crazyflie can be bootloaded from the commandline using the +*cfloader* script. + +**Note:** To enter the bootloader for the Crazyflie 1.0 just restart the +platform. To enter the bootloader for the Crazyflie 2.0 power off the +platform and start it again by pressing the power button for at least +1.5 seconds, but not more than 5. + +Programming Crazyflie from firmware projects +============================================ + +When developping with the Crazyflie firmware projects, either +[crazyflie-firmware](https://github.com/bitcraze/crazyflie-firmware) or +[crazyflie2-nrf-firmware](https://github.com/bitcraze/crazyflie2-nrf-firmware) +you can flash your current build with: + + make cload + +If you want the Crazyflie to restart automatically in bootloader mode +you can enable the warmboot mode. To do so, edit the file +\'tool/make/config.mk\' and add the address of your Crazyflie: + + CLOAD_CMDS = -w radio://0/80/250K/E7E7E7E7E7 + +After this, \'make cload\' will restart the Crazyflie in bootlader mode, +flash it and restart it with the new firmware. + +\<WRAP center round info\> In warmboot mode the bootloader is launched +using a random address. This means that multiple Crazyflie can be +programmed at the same time without collision. \</WRAP\> \<WRAP center +round important\> ***Warning*** If the flashing operation fails or if +the firmware has a bug, it may be impossible to warmboot. In that case +start the bootloader manually and disable warmboot temporarly by +programming with: + + make cload CLOAD_CMDS= + +\</WRAP\> + +cfloader +======== + +The script is located in the *bin* directory in the +*crazyflie-clients-python* repository and client. Here\'s how to use the +script: + + crazyflie-clients-python$ bin/cfclient + + ============================== + CrazyLoader Flash Utility + ============================== + + Usage: bin/cfloader [CRTP options] <action> [parameters] + + The CRTP options are described above + + Crazyload option: + info : Print the info of the bootloader and quit. + Will let the target in bootloader mode + reset : Reset the device in firmware mode + flash <file> [targets] : flash the <img> binary file from the first + possible page in flash and reset to firmware + mode. + +Crazyflie 1.0 examples +---------------------- + + crazyflie-clients-python$ bin/cfloader flash cflie.bin stm32-fw + Restart the Crazyflie you want to bootload in the next 10 seconds ... done! + Connected to bootloader on Crazyflie Nano Quadcopter (1.0) (version=0x1) + Target info: stm32 (0xFF) + Flash pages: 128 | Page size: 1024 | Buffer pages: 10 | Start page: 10 + 118 KBytes of flash avaliable for firmware image. + + Flashing 1 of 1 to stm32 (fw): 56043 bytes (55 pages) ..........10..........10..........10..........10..........10.....5 + Reset in firmware mode ... + +Crazyflie 2.0 examples +---------------------- + +Flashing new firmware for the nRF51 MCU: + + crazyflie-clients-python$ bin/cfloader flash cf2_nrf.bin nrf51-fw + Restart the Crazyflie you want to bootload in the next 10 seconds ... done! + Connected to bootloader on Crazyflie 2.0 (version=0x10) + Target info: nrf51 (0xFE) + Flash pages: 232 | Page size: 1024 | Buffer pages: 1 | Start page: 88 + 144 KBytes of flash avaliable for firmware image. + Target info: stm32 (0xFF) + Flash pages: 1024 | Page size: 1024 | Buffer pages: 10 | Start page: 16 + 1008 KBytes of flash avaliable for firmware image. + + Flashing 1 of 1 to nrf51 (fw): 25151 bytes (25 pages) .1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1 + Reset in firmware mode ... + +Flashing new firmware for the STM32 MCU: + + crazyflie-clients-python$ bin/cfloader flash cflie.bin stm32-fw + Restart the Crazyflie you want to bootload in the next 10 seconds ... done! + Connected to bootloader on Crazyflie 2.0 (version=0x10) + Target info: nrf51 (0xFE) + Flash pages: 232 | Page size: 1024 | Buffer pages: 1 | Start page: 88 + 144 KBytes of flash avaliable for firmware image. + Target info: stm32 (0xFF) + Flash pages: 1024 | Page size: 1024 | Buffer pages: 10 | Start page: 16 + 1008 KBytes of flash avaliable for firmware image. + + Flashing 1 of 1 to stm32 (fw): 76435 bytes (75 pages) ..........10..........10..........10..........10..........10..........10..........10.....5 + Reset in firmware mode ... + +Flash a new firmware package (containing both nRF51 and STM32 firmware): + + crazyflie-clients-python$ bin/cfloader flash cf2_dev_update.zip + Restart the Crazyflie you want to bootload in the next 10 seconds ... done! + Connected to bootloader on Crazyflie 2.0 (version=0x10) + Target info: nrf51 (0xFE) + Flash pages: 232 | Page size: 1024 | Buffer pages: 1 | Start page: 88 + 144 KBytes of flash avaliable for firmware image. + Target info: stm32 (0xFF) + Flash pages: 1024 | Page size: 1024 | Buffer pages: 10 | Start page: 16 + 1008 KBytes of flash avaliable for firmware image. + + Flashing 1 of 2 to stm32 (fw): 76435 bytes (75 pages) ..........10..........10..........10..........10..........10..........10..........10.....5 + Flashing 2 of 2 to nrf51 (fw): 25151 bytes (25 pages) .1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1 + Reset in firmware mode ... diff --git a/docs/client.md b/docs/client.md new file mode 100644 index 0000000000000000000000000000000000000000..084692f46bbf228900d48a241e91262f0ae89e4e --- /dev/null +++ b/docs/client.md @@ -0,0 +1,57 @@ +# Bootloader client implementation + + +## Bootloader file format + + +In order to make bootloading easier across platforms the different +firmwares are packaged together in a ZIP file that contains a manifest +describing which files are used for what. Here\'s an example of a +manifest, it should be called *manifest.json*: + + { + "version": 1, + "files": { + "cflie.bin": { + "platform": "cf2", + "target": "stm32", + "type": "fw" + }, + "nrf_cf2.bin": { + "platform": "cf2", + "target": "nrf51", + "type": "fw" + }, + "nrf_cload.bin": { + "platform": "cf2", + "target": "nrf51", + "type": "bootloader" + }, + "s110.bin": { + "platform": "cf2", + "target": "nrf51", + "type": "softdevice" + } + "cf2_lua.bin": { + "platform": "cf2", + "target": "stm32", + "type": "userapp", + "origin": 524288 + } + } + } + +Each entry in the file describes one file, with the following +attributes: + + +| Attribute | Values |Comments| +| --------------- | ------------------------------------- | ---------------------- | +| platform | cf1, cf2 |Select the target platform | +| target | stm32, nrf51 |Select the target MCU on the target platform| +| type | fw, bootloader, softdevice, userapp |Describe what\'s contained in the binary| +| origin | N/A |Set the address where the app should be flashed| + + +Currently only platform=cf2, target=stm32, target=nrf51 and type=fw is +supported. diff --git a/docs/dev_info_client.md b/docs/dev_info_client.md new file mode 100644 index 0000000000000000000000000000000000000000..f9601a64826161625ec6a5fc2ee7a4d8bac804ca --- /dev/null +++ b/docs/dev_info_client.md @@ -0,0 +1,568 @@ +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 + [LeapMotion](https://www.leapmotion.com/) and + [ZMQ](http://zeromq.org/). + +Architecture +============ + +{:.align-right +width="600"} + +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 *lib/cfclient/utils/inputreaders* and +*lib/cfclient/utils/inputinterfaces* are initialized and these +directories are scanned for implementations that can be used. Each +python file in these directories represent a \"backend\" that handles +input. Each backend can have zero, one or multiple devices that it can +control. The *inputreaders* module is used to read normal +joysticks/gamepads while the *inputinterfaces* module is used to read +any custom interface that\'s not a joystick/gamepad. + +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-\>device to device-\>backend) +and a list of devices (with connected backends) is passed on. + +The client can now open any device in the list and read it. If the +device is from the *inputreaders* module a mapping has to be supplied as +described below. + +#### Input readers + +Currently there\'s two types of *inputreaders*: SDL2 and Linux. The +Linux backend is used on Linux and SDL2 on all other platforms. In order +to use the devices connected to the backend a mapping has to be supplied +to translate the raw axis/buttons indexes (0, 1, 2..) to usable values +(roll/pitch/yaw/thrust..). + +#### Input interfaces + +The input interfaces don\'t use any mapping, the devices itself directly +generate useful values (like roll/pitch/yaw/thrust). Currently there\'s +two implementations: LeapMotion and ZMQ. Values are read the same way as +from normal gamepads/joysticks, at 100Hz. For more information on how +the ZMQ interface works read [here](/doc/crazyflie/zmq/index). + +### The MUX + +#### Scaling and processing + +### Input and beyond + +Files +===== + +To support the application there\'s a number of files around it, such as +configuration and caching. All these use JSON to store information. All +of the user configuration files are stored in the */conf* directory. +Most of the files have default versions in the */lib/configs* directory +that are either copied at the first start up or used in parallel as +read-only copies to complement what ever is stored in the user +configuration directory. + +User configuration file +----------------------- + +To save the configuration between runs of the application there\'s a +configuration file (*/conf/config.json*).The file is updated while the +application runs and settings change. Below is an example of the +configuration file. + +``` {.json} +{ + "client_side_xmode": false, + "link_uri": "radio://0/100/250K", + "input_device": "Sony PLAYSTATION(R)3 Controller", + "slew_limit": 45, + "max_rp": 30, + "ui_update_period": 100, + "trim_pitch": 0.0, + "device_config_mapping": { + "Leapmotion": "LeapMotion", + "Sony PLAYSTATION(R)3 Controller": "PS3_Mode_1_Split-Yaw_Linux", + "PLAYSTATION(R)3 Controller (34:C7:31:8E:CF:0E)": "PS3_Mode_1", + "Microsoft X-Box 360 pad": "xbox360_mode1_linux" + }, + "slew_rate": 30, + "auto_reconnect": false, + "max_yaw": 200, + "flightmode": "Advanced", + "enable_debug_driver": false, + "open_tabs": "Flight Control,Parameters,Console", + "input_device_blacklist": "(VirtualBox|VMware)", + "trim_roll": 0.0, + "max_thrust": 80.0, + "min_thrust": 25.0 +} +``` + + Field Format Comments + -------------------------- --------- ---------------------------------------------------------------------------------------------------------------------------------------------- + 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\" in the application + 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/s), only applicable in Advanced mode + max\_rp float Max allowed roll/pitch (degrees), only applicable in Advanced mode + +Default configuration file +-------------------------- + +The source code contains a default configuration file +(*/lib/cfclient/configs/config.json*). The file contains two parts: The +default writable part and the default read-only part. When the +application is started for the first time (and */conf*/ doesn\'t exists) +the writable part of this configuration file is copied to the +*/conf/config.json* file to create the default values. The read-only +part is used for settings that cannot be changed, but shouldn\'t be +hardcoded in the code. When the application starts and both the user +config in */conf/config.json* and the read-only part of +*/lib/cfclient/configs/config.json* is merged so they can all be +accessed in the application. + +``` {.json} +{ + "writable" : { + "input_device": "", + "link_uri": "", + "flightmode": "Normal", + "open_tabs": "Flight Control", + "trim_pitch": 0.0, + "slew_limit": 45, + "slew_rate": 30, + "trim_roll": 0.0, + "max_thrust": 80, + "min_thrust": 25, + "max_yaw": 200, + "max_rp": 30, + "client_side_xmode": false, + "auto_reconnect": false, + "device_config_mapping": {}, + "enable_debug_driver": false, + "input_device_blacklist": "(VirtualBox|VMware)", + "ui_update_period": 100 + }, + "read-only" : { + "normal_slew_limit": 45, + "normal_slew_rate": 30, + "normal_max_thrust": 80, + "normal_min_thrust": 25, + "normal_max_yaw": 200, + "normal_max_rp": 30, + "default_cf_channel": 10, + "default_cf_speed": 0, + "default_cf_trim": 0 + } +} +``` + +TOC cache files +--------------- + +In order to speed up the connection procedure for the Crazyflie the TOCs +are cached ([more info on logging/parameter frameworks and +TOC](/doc/crazyflie/dev/arch/logparam)). The writable part of the TOC +cache is located in */conf/cache* where each cache is saved in a file +named after the CRC32 (in hex) of the TOC CRC32 (for example +*1CB41680.json*). There\'s also a read-only part of the TOC cache +that\'s located in */lib/cglib/cache* and contains the caches for +official builds. When the application connects to a Crazyflie the CRC32 +of the log and param TOC is requested. When the client receives it will +check if a file with the correct name exists (in both the RW and the RO +TOC cache). If it does it will load the cached TOC, if not it will start +requesting the TOC from the Crazyflie and when it\'s done it will save +it in the cache. + +The TOC cache files are organized in a hierarchical manner after the +*group.name* concept. In the examples below you first see the group +*acc* which contains the variables *y*,*x*,*z*,*zw* and *mag2*. Each of +these variables have a set of attributes that are described below. + + | Field | Format | Comments| + | --------------| ------- | --------| +| 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]{.underline} | 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: + +``` {.json} +{ + "acc": { + "y": { + "ident": 8, + "group": "acc", + "name": "y", + "pytype": "<f", + "__class__": "LogTocElement", + "ctype": "float", + "access": 0 + }, + "x": { + "ident": 7, + "group": "acc", + "name": "x", + "pytype": "<f", + "__class__": "LogTocElement", + "ctype": "float", + "access": 0 + }, + "z": { + "ident": 9, + "group": "acc", + "name": "z", + "pytype": "<f", + "__class__": "LogTocElement", + "ctype": "float", + "access": 0 + }, + "zw": { + "ident": 10, + "group": "acc", + "name": "zw", + "pytype": "<f", + "__class__": "LogTocElement", + "ctype": "float", + "access": 0 + }, + "mag2": { + "ident": 11, + "group": "acc", + "name": "mag2", + "pytype": "<f", + "__class__": "LogTocElement", + "ctype": "float", + "access": 0 + } + }, + "mag": { + "y": { + "ident": 39, + "group": "mag", + "name": "y", + "pytype": "<f", + "__class__": "LogTocElement", + "ctype": "float", + "access": 0 + }, + "x": { + "ident": 38, + "group": "mag", + "name": "x", + "pytype": "<f", + "__class__": "LogTocElement", + "ctype": "float", + "access": 0 + }, + "z": { + "ident": 40, + "group": "mag", + "name": "z", + "pytype": "<f", + "__class__": "LogTocElement", + "ctype": "float", + "access": 0 + } + }, + "stabilizer": { + .... + } +} +``` + +Below is an example of part of the param TOC cache: + +``` {.json} +{ + "imu_sensors": { + "HMC5883L": { + "ident": 0, + "group": "imu_sensors", + "name": "HMC5883L", + "pytype": "<B", + "__class__": "ParamTocElement", + "ctype": "uint8_t", + "access": 1 + }, + "MS5611": { + "ident": 1, + "group": "imu_sensors", + "name": "MS5611", + "pytype": "<B", + "__class__": "ParamTocElement", + "ctype": "uint8_t", + "access": 1 + } + }, + "sensorfusion6": { + "ki": { + "ident": 30, + "group": "sensorfusion6", + "name": "ki", + "pytype": "<f", + "__class__": "ParamTocElement", + "ctype": "float", + "access": 0 + }, + "kp": { + "ident": 29, + "group": "sensorfusion6", + "name": "kp", + "pytype": "<f", + "__class__": "ParamTocElement", + "ctype": "float", + "access": 0 + } + }, + "flightmode": { + "althold": { + "ident": 10, + "group": "flightmode", + "name": "althold", + "pytype": "<B", + "__class__": "ParamTocElement", + "ctype": "uint8_t", + "access": 0 + } + }, + "firmware": { + "revision0": { + "ident": 57, + "group": "firmware", + "name": "revision0", + "pytype": "<L", + "__class__": "ParamTocElement", + "ctype": "uint32_t", + "access": 1 + }, + "revision1": { + "ident": 58, + "group": "firmware", + "name": "revision1", + "pytype": "<H", + "__class__": "ParamTocElement", + "ctype": "uint16_t", + "access": 1 + }, + "modified": { + "ident": 59, + "group": "firmware", + "name": "modified", + "pytype": "<B", + "__class__": "ParamTocElement", + "ctype": "uint8_t", + "access": 1 + } + }, + "cpu": { + .... + } +} +``` + +Input device configuration +-------------------------- + +Input device configurations are used to map raw axis (integers) to +values such as roll/pitch/yaw/thrust (more info above). The +configurations are stored in */conf/input*, one file for each +configuration. The default configurations are stored in +*/lib/cfclient/configs*. The first time the configuration starts up (if +*/conf/input* doesn\'t exist) the default configurations are copied into +this directory and can then be used. + +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 | Comments| +| --------| ------| --------------| + | 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)| + +``` {.json} +{ + "inputconfig": { + "inputdevice": { + "updateperiod": 10, + "name": "PS3_Mode_1_Split-Yaw_Linux", + "axis": [ + { + "scale": -1.0, + "type": "Input.AXIS", + "id": 3, + "key": "thrust", + "name": "thrust", + "offset": 1.0, + }, + { + "scale": 1.0, + "type": "Input.AXIS", + "ids": [ + 12, + 13 + ], + "key": "yaw", + "name": "yaw" + }, + { + "scale": 1.0, + "type": "Input.AXIS", + "id": 0, + "key": "roll", + "name": "roll" + }, + { + "scale": -1.0, + "type": "Input.AXIS", + "id": 1, + "key": "pitch", + "name": "pitch" + }, + { + "scale": -1.0, + "type": "Input.BUTTON", + "id": 6, + "key": "pitchcal", + "name": "pitchNeg" + }, + { + "scale": 1.0, + "type": "Input.BUTTON", + "id": 4, + "key": "pitchcal", + "name": "pitchPos" + }, + { + "scale": 1.0, + "type": "Input.BUTTON", + "id": -1, + "key": "estop", + "name": "killswitch" + }, + { + "scale": -1.0, + "type": "Input.BUTTON", + "id": 7, + "key": "rollcal", + "name": "rollNeg" + }, + { + "scale": 1.0, + "type": "Input.BUTTON", + "id": 5, + "key": "rollcal", + "name": "rollPos" + }, + { + "scale": 1.0, + "type": "Input.BUTTON", + "id": 14, + "key": "althold", + "name": "althold" + }, + { + "scale": 1.0, + "type": "Input.BUTTON", + "id": 12, + "key": "exit", + "name": "exitapp" + } + ] + } + } +} +``` + +Log configuration files +----------------------- + +The user can configure custom logging configurations from the UI (more +information on logging/parameter +frameworks (/doc/crazyflie/dev/arch/logparam) ). These will be saved in +the */conf/log* directory, one file for each configuration. Default +logging configurations are stored in the */lib/cfclient/configs/log* and +are copied into the user configuration directory on the first status (if +*/conf/log* doesn\'t exist). + +| Field | Format | Comments| + | ------------ | --------| +| 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, one for each variable in the configuration | +| 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: + +``` {.json} +{ + "logconfig": { + "logblock": + {"name": "Stabilizer", "period":20, + "variables": [ + {"name":"stabilizer.roll", "type":"TOC", "stored_as":"float", "fetch_as":"float"}, + {"name":"stabilizer.pitch", "type":"TOC", "stored_as":"float", "fetch_as":"float"}, + {"name":"stabilizer.yaw", "type":"TOC", "stored_as":"float", "fetch_as":"float"} + ]} + } +} +``` diff --git a/docs/images/cf_client_1.png b/docs/images/cf_client_1.png new file mode 100644 index 0000000000000000000000000000000000000000..c3e128b7356f6749c2bff31a5720b5f01de8a3dc Binary files /dev/null and b/docs/images/cf_client_1.png differ diff --git a/docs/images/cfclient_anchor_identification.png b/docs/images/cfclient_anchor_identification.png new file mode 100644 index 0000000000000000000000000000000000000000..ecdead4ca3edf451ffbad4367a2d67b48cffafd0 Binary files /dev/null and b/docs/images/cfclient_anchor_identification.png differ diff --git a/docs/images/cfclient_cf2_config.png b/docs/images/cfclient_cf2_config.png new file mode 100644 index 0000000000000000000000000000000000000000..48849c7b920af6e3c583bf1ed219a3e94a25efd6 Binary files /dev/null and b/docs/images/cfclient_cf2_config.png differ diff --git a/docs/images/cfclient_connect_dialog.png b/docs/images/cfclient_connect_dialog.png new file mode 100644 index 0000000000000000000000000000000000000000..40d5798fbea7074da2907b4183bb3e0eac38ebda Binary files /dev/null and b/docs/images/cfclient_connect_dialog.png differ diff --git a/docs/images/cfclient_connected.png b/docs/images/cfclient_connected.png new file mode 100644 index 0000000000000000000000000000000000000000..c1fa6c96e73237911bd4669de17d83d6c61c8cb4 Binary files /dev/null and b/docs/images/cfclient_connected.png differ diff --git a/docs/images/cfclient_console_marked.png b/docs/images/cfclient_console_marked.png new file mode 100644 index 0000000000000000000000000000000000000000..e04a6f803e239e04ed68d392e99b04916c5e9913 Binary files /dev/null and b/docs/images/cfclient_console_marked.png differ diff --git a/docs/images/cfclient_devconfig_axis.png b/docs/images/cfclient_devconfig_axis.png new file mode 100644 index 0000000000000000000000000000000000000000..0e4f68d3b14af5cc7136c03d665b052f36007a5f Binary files /dev/null and b/docs/images/cfclient_devconfig_axis.png differ diff --git a/docs/images/cfclient_devconfig_dialog.png b/docs/images/cfclient_devconfig_dialog.png new file mode 100644 index 0000000000000000000000000000000000000000..e33285fbea6ee6c3ed64299155e8aab749272a92 Binary files /dev/null and b/docs/images/cfclient_devconfig_dialog.png differ diff --git a/docs/images/cfclient_devconfig_feedback.png b/docs/images/cfclient_devconfig_feedback.png new file mode 100644 index 0000000000000000000000000000000000000000..ef691ec8007b482281b03c1c3b77b6d01b19f346 Binary files /dev/null and b/docs/images/cfclient_devconfig_feedback.png differ diff --git a/docs/images/cfclient_devconfig_select.png b/docs/images/cfclient_devconfig_select.png new file mode 100644 index 0000000000000000000000000000000000000000..30713ebfbe842ba1c9b9b8c6525a604ae649f699 Binary files /dev/null and b/docs/images/cfclient_devconfig_select.png differ diff --git a/docs/images/cfclient_flightab.png b/docs/images/cfclient_flightab.png new file mode 100644 index 0000000000000000000000000000000000000000..ce94980681745b22bb31e829b42ccc945d17fbed Binary files /dev/null and b/docs/images/cfclient_flightab.png differ diff --git a/docs/images/cfclient_input_mux_configured.png b/docs/images/cfclient_input_mux_configured.png new file mode 100644 index 0000000000000000000000000000000000000000..26cef8cb6a61a539b78abd52308ee38752770dad Binary files /dev/null and b/docs/images/cfclient_input_mux_configured.png differ diff --git a/docs/images/cfclient_input_mux_select.png b/docs/images/cfclient_input_mux_select.png new file mode 100644 index 0000000000000000000000000000000000000000..37c046b8fef35dfc53172757684b67517f49081e Binary files /dev/null and b/docs/images/cfclient_input_mux_select.png differ diff --git a/docs/images/cfclient_input_normal.png b/docs/images/cfclient_input_normal.png new file mode 100644 index 0000000000000000000000000000000000000000..fccf5742d1bbd9786750f138f5575da36a0ee164 Binary files /dev/null and b/docs/images/cfclient_input_normal.png differ diff --git a/docs/images/cfclient_input_student.png b/docs/images/cfclient_input_student.png new file mode 100644 index 0000000000000000000000000000000000000000..58f38c6e5853f26565eedd567083b906a84f633d Binary files /dev/null and b/docs/images/cfclient_input_student.png differ diff --git a/docs/images/cfclient_input_student_device.png b/docs/images/cfclient_input_student_device.png new file mode 100644 index 0000000000000000000000000000000000000000..672086ec557b556b6b5a418a98f629ed83328621 Binary files /dev/null and b/docs/images/cfclient_input_student_device.png differ diff --git a/docs/images/cfclient_input_teacher.png b/docs/images/cfclient_input_teacher.png new file mode 100644 index 0000000000000000000000000000000000000000..9933d6aaedfe91d129813f29fd78cd76e561fb98 Binary files /dev/null and b/docs/images/cfclient_input_teacher.png differ diff --git a/docs/images/cfclient_input_teacher_device.png b/docs/images/cfclient_input_teacher_device.png new file mode 100644 index 0000000000000000000000000000000000000000..9300f93e9a060352b9d9f3921dd7a2fbd9d50624 Binary files /dev/null and b/docs/images/cfclient_input_teacher_device.png differ diff --git a/docs/images/cfclient_logblocks_marked.png b/docs/images/cfclient_logblocks_marked.png new file mode 100644 index 0000000000000000000000000000000000000000..055657dbcb406039bfc01585bc0df5dea6a5a92f Binary files /dev/null and b/docs/images/cfclient_logblocks_marked.png differ diff --git a/docs/images/cfclient_main_ui.png b/docs/images/cfclient_main_ui.png new file mode 100644 index 0000000000000000000000000000000000000000..55f688fd13977b692554960fcca4d618e0a1af20 Binary files /dev/null and b/docs/images/cfclient_main_ui.png differ diff --git a/docs/images/cfclient_overview.png b/docs/images/cfclient_overview.png new file mode 100644 index 0000000000000000000000000000000000000000..918c05e9fae048333f46b8a3fe9cdf94d1b33bf1 Binary files /dev/null and b/docs/images/cfclient_overview.png differ diff --git a/docs/images/cfclient_param.png b/docs/images/cfclient_param.png new file mode 100644 index 0000000000000000000000000000000000000000..251a186fa23041511542e62762d7caf44327c7b8 Binary files /dev/null and b/docs/images/cfclient_param.png differ diff --git a/docs/images/cfclient_ploter.png b/docs/images/cfclient_ploter.png new file mode 100644 index 0000000000000000000000000000000000000000..cae7f30210f448fcb1b27f3db6706761dbcaa28c Binary files /dev/null and b/docs/images/cfclient_ploter.png differ diff --git a/docs/images/cfclient_position_estimate.png b/docs/images/cfclient_position_estimate.png new file mode 100644 index 0000000000000000000000000000000000000000..0a185b0cc9b36f96f0f1226fdfe3015e01c64fc2 Binary files /dev/null and b/docs/images/cfclient_position_estimate.png differ diff --git a/docs/images/cfclient_pycharm_windows_miniconda.png b/docs/images/cfclient_pycharm_windows_miniconda.png new file mode 100644 index 0000000000000000000000000000000000000000..c820cac474f17015e6a425d878038881818202b9 Binary files /dev/null and b/docs/images/cfclient_pycharm_windows_miniconda.png differ diff --git a/docs/images/client_log-configuration_anotated.png b/docs/images/client_log-configuration_anotated.png new file mode 100644 index 0000000000000000000000000000000000000000..cff478785ec7f8d6ba59b907926854aef8dfb991 Binary files /dev/null and b/docs/images/client_log-configuration_anotated.png differ diff --git a/docs/images/configure_cf1.png b/docs/images/configure_cf1.png new file mode 100644 index 0000000000000000000000000000000000000000..716c5745537d08da61460e0b9730469ac9dacf6c Binary files /dev/null and b/docs/images/configure_cf1.png differ diff --git a/docs/images/crazyflie_bootloading.png b/docs/images/crazyflie_bootloading.png new file mode 100644 index 0000000000000000000000000000000000000000..216168e893d0b00bbc18253f29531c474165404f Binary files /dev/null and b/docs/images/crazyflie_bootloading.png differ diff --git a/docs/images/image00.png b/docs/images/image00.png new file mode 100644 index 0000000000000000000000000000000000000000..72b7614102b885a50cb32878d6f5ebe4b908adb2 Binary files /dev/null and b/docs/images/image00.png differ diff --git a/docs/images/image01.png b/docs/images/image01.png new file mode 100644 index 0000000000000000000000000000000000000000..86cf1815e0cc1a5cbd2b7ab9a8ba667b9646479a Binary files /dev/null and b/docs/images/image01.png differ diff --git a/docs/images/image02.png b/docs/images/image02.png new file mode 100644 index 0000000000000000000000000000000000000000..e96c3111e36491f24c261979ad486a1a6507da06 Binary files /dev/null and b/docs/images/image02.png differ diff --git a/docs/images/image03.png b/docs/images/image03.png new file mode 100644 index 0000000000000000000000000000000000000000..3028c694c26b9916cd08f921fdc38074c44eec28 Binary files /dev/null and b/docs/images/image03.png differ diff --git a/docs/images/image04.png b/docs/images/image04.png new file mode 100644 index 0000000000000000000000000000000000000000..32b3293eb1f1ba0b0b1433095475fbe5cf655e04 Binary files /dev/null and b/docs/images/image04.png differ diff --git a/docs/images/image05.png b/docs/images/image05.png new file mode 100644 index 0000000000000000000000000000000000000000..0c95ea9e987a75769258131734fcefbc346e7e7d Binary files /dev/null and b/docs/images/image05.png differ diff --git a/docs/images/image06.png b/docs/images/image06.png new file mode 100644 index 0000000000000000000000000000000000000000..bbe6340d74b3e902a5bfbfc7966bfb9850fa5cd1 Binary files /dev/null and b/docs/images/image06.png differ diff --git a/docs/images/input-arch-mux.png b/docs/images/input-arch-mux.png new file mode 100644 index 0000000000000000000000000000000000000000..8bbd64f59c4cf84f1c64d50158ad6e1e0a325e8c Binary files /dev/null and b/docs/images/input-arch-mux.png differ diff --git a/docs/index.md b/docs/index.md index 1d5f47d2fbd2e29a4ab5aa231b002d81b36e02a2..f3bb1072b6ec6a8e5580bbe1e1f6c48e92ddb0be 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,8 +4,17 @@ The Crazyflie PC client enables flashing and controlling the Crazyflie. It imple - Introduction -- Build and run instructions +- Run and Use instructions - [Run from source](run_from_source.md) + - [Installing Crazyflie client with macPorts](macports.md) + - [Userguide GUI](userguide_client.md) + - [Crazyflie headless client](cfheadless.md) + - [Input devices](inputdevices.md) - Explanation Functionalities + - [Crazyflie bootloader](cfloader.md) + - [Bootloader client implementation](client.md) + - [Client ZMQ](cfclient_zmq.md) - Development Instructions + - [Development info](dev_info_client.md) + diff --git a/docs/inputdevices.md b/docs/inputdevices.md new file mode 100644 index 0000000000000000000000000000000000000000..dab8ebcb1dc25a77ee85194e8cfba998b710fda2 --- /dev/null +++ b/docs/inputdevices.md @@ -0,0 +1,142 @@ +Input-devices for the Crazyflie client +====================================== + +The Crazyflie graphical control client needs an input-device (joystick) +with a minimum of 4 analogue axes to be able to pilot the Crazyflie. The +Playstation 3 controller is supported out of the box but the application +supports creating new configurations that uses other controllers. This +page details what controllers are supported out of the box, how to +create a new configurations and how to debug problems. + +Limitations +----------- + +First of all there\'s currently a few limitations in the client (that +will be fixed in the future): + +- ~~After entering the configuration dialogue the application needs to + be restarted.~~ Fixed in 2013.4.2 +- ~~There\'s only support for one input device. If you have multiple + connected the application will choose the first one.~~ Fixed in + 2013.4.1 + +Steps to get the controller working +----------------------------------- + +Here\'s a few steps that you have to go though in order to get the +input-device working. If any of the steps are not working then the +input-device will not be usable for piloting the Crazyflie: + +- The input-device needs to be recognized by the host operating + system. This means that it should be seen in the operating system + and be usable in other applications or utilities. +- When using the Crazyflie graphical control client you need at least + the correct mappings for roll/pitch/yaw/thrust. This can be checked + by opening the *Flight Data* tab. If the input-device is found and + opened then you should see values in the *Target* fields for + *Roll*,*Pitch*,*Yaw* and *Thrust*. Moving the analogue axis should + show you output here. Make sure that you get the full span according + to the settings on the left side of the tab. I.e if the setting for + *Max roll/pitch* is 20 then you should be able to get from -20 to + + 20 in the target field (and the same for yaw and thrust). Also make + sure that none of the axis interact (like moving roll will also move + pitch). +- If you aren\'t getting any output at all and you are using the + Playstation 3 controller, then press the \"Playstation\" button in + the middle on the controller once. +- If the mappings are not correct in the previous point go to the menu + *Input-device-\>Configure device mapping*, select the device you + would like to configure and go though the configuration by clicking + detect on each of the items in the dialog (everything has to be + configured). Lastly enter the name of the configuration (without + file extension) and press save. Now restart the application and try + again. + +**Please note!!** In the 2013.4.1 and previous versions there\'s a bug +where the loading of a previous configuration will not work correctly. +The values are not loaded but the configuration call still be saved. +This results in a configuration file that will not work and an error +will be shown when trying to use it. In order to fix this manually +delete the contents of the user config folder (win: +*C:\\Users\\your\_user\\AppData\\Roaming\\cfclient*, linux: +*\~/.config/cfclient*) and create a new configuration from scratch as +described above. + +Input device overview +===================== + +Below is a list of controllers and the status for different OSs. The +list is far from complete so if you have more info please edit or drop +us an email. + + | **Controller** | **Linux USB** | **Linux BT** | **Win XP USB** | **Win XP BT** | **Win7 USB** | **Win7 BT** | **Win8 USB** | **Mac OSX USB** | **Mac OSX BT**| +|--|--|--|--|--|--|--|--|--|--|--| + | Playstation 3 (or copy) | Works | [Instructions](#linux_using_bluetooth) | Works | [Instructions?](#winxp_using_bluetooth) | [Motion joy instructions?](#win7_using_usb) | [Motion joy instructions?](#win7_using_bluetooth) | [Instructions](http://www.wikihow.com/Set-Up-USB-Game-Controllers-on-Windows-8) | Works | [Instructions](#max_osx_using_usb)| + Xbox 360 (or copy) | [Instructions](#linux_using_usb) | N/A | Works | N/A | Works | N/A | Not tested | Not tested| + +Playstation 3 controller +======================== + +Linux using Bluetooth +--------------------- + +[How to set up Sixaxis on +Ubuntu](https://help.ubuntu.com/community/Sixaxis) (tested on Ubuntu +13.10) + +WinXP using Bluetooth +--------------------- + +**TODO** + +Win7 using USB +-------------- + +There\'s support for this using MotionJoy, **but** the mapping of the +axis is not the same as for Windows XP/Linux and has to be configured. +**TODO** Insert instructions for re-mapping. + +[Video on how to get started with +MotionJoy](http://youtu.be/b2lUxNShIDs). + +Win7 using Bluetooth +-------------------- + +Should work using MotionJoy but this needs confirmation. + +Mac OSX with Bluetooth +---------------------- + +Works. To pair the controller follow the steps outlined +[here](https://gist.github.com/statico/3172711). **TODO**: This +procedure is somewhat shaky. Figure out and add a solid set of steps +here. + +**NOTE**: To shut down the controller you need to disconnect the +controller from OSX. This is easiest done if you enable in in System +Preferences -\> Bluetooth enable Show Bluetooth status in menu bar. From +the menu bar item you can easily disconnect it. + +Xbox 360 controller +=================== + +Linux using USB +--------------- + +\<WRAP center round tip 80%\> **INFO** + +All modern Linux distribution now have a kernel driver for the x-box +gamepad. Thus it is unlikely the *xboxdrv* user-space driver is needed. +\</WRAP\> + +If you are having problems getting this to work the userspace driver +`xboxdrv` might be needed. It can be installed (on Ubuntu) by running: + + sudo apt-get install xboxdrv + +And then started by running: + + sudo xboxdrv + +More info about the `xboxdrv` is available +[here](http://pingus.seul.org/~grumbel/xboxdrv/). diff --git a/docs/macports.md b/docs/macports.md new file mode 100644 index 0000000000000000000000000000000000000000..56b9c31946af91dc3b0817f0dd192ce70e0cc967 --- /dev/null +++ b/docs/macports.md @@ -0,0 +1,74 @@ +Installing Crazyflie client with macPorts +========================================= + +This procedure has been tested on a just-installed Yosemite +installation. Commands in code blocks have to be executed in a terminal +window. + +Prerequisite +------------ + +Download and install macport installer from +<https://www.macports.org/install.php> + +Install the command line developer tools: + + xcode-select --install + +I found that installing only the command line developer tools is enough +for Crazyflie client dependencies. However installing Xcode seems to be +recommended. I installed the command line developer tools: + + + + + +Update mac ports + + sudo port selfupdate + +Update already installed ports (none on a fresh installation) + + sudo port upgrade outdated + +Mandatory dependencies +---------------------- + +Install Crazyflie client dependencies + + sudo port install libusb python27 py27-pyusb py27-SDL2 py27-pyqt4 + +Most but not all packages are pre-compiled so this installation takes +some time. It took about 12 minutes for me, YMMV. + + + +Now you are able to clone and run the Crazyflie client! + + cd Documents + git clone https://github.com/bitcraze/crazyflie-clients-python + cd crazyflie-clients-python + /opt/local/bin/python2.7 bin/cfclient + + + +Optional dependencies +--------------------- + +If you want to use the plotter tab, to graph in real time Crazyflie log +variables, you need to install pyqtgraph. It installs a lot of +dependencies and took about 5 minutes (The ports install time varies a +lot depending on how many ports are pre-compiled): + + sudo port install py27-pyqtgraph + + + +You can now access the plotter tab: + + /opt/local/bin/python2.7 bin/cfclient + + + +Troubleshooting +--------------- diff --git a/docs/run_from_source.md b/docs/run_from_source.md index f19d9c5d44f2c5f0a460216abe4ffb7051defa38..d1c152a632b8c302e1c56db78e9d6bdc0ff5312c 100644 --- a/docs/run_from_source.md +++ b/docs/run_from_source.md @@ -1,12 +1,3 @@ -# Crazyflie PC client [](https://travis-ci.org/bitcraze/crazyflie-clients-python) [](https://ci.appveyor.com/project/bitcraze/crazyflie-clients-python) - - -The Crazyflie PC client enables flashing and controlling the Crazyflie. -It implements the user interface and high-level control (for example gamepad handling). -The communication with Crazyflie and the implementation of the CRTP protocol to control the Crazflie is handled by the [cflib](https://github.com/bitcraze/crazyflie-lib-python) project. - -For more info see our [wiki](http://wiki.bitcraze.se/ "Bitcraze Wiki"). - # Running from source The Crazyflie client requires [cflib](https://github.com/bitcraze/crazyflie-lib-python). diff --git a/docs/userguide_client.md b/docs/userguide_client.md new file mode 100644 index 0000000000000000000000000000000000000000..3d59a628cb1082f59b1de73e52b0bf10a1ee4ab2 --- /dev/null +++ b/docs/userguide_client.md @@ -0,0 +1,529 @@ +Overview +======== + +This page is intended to give an overview on how to use the Crazyflie +client, not for installing it. For install instructions go +[here](https://github.com/bitcraze/crazyflie-clients-python/blob/develop/README.md). + +The Crazyflie client is used for controlling the Crazyflie, flashing +firmware, setting parameters and logging data. The main UI is built up +of a number of tabs, where each tab is used for a specific +functionality. + +This page uses the terms +[roll/pitch/yaw](http://en.wikipedia.org/wiki/Flight_dynamics_(fixed_wing_aircraft)) +extensively. For that to make any sense for a quadcopter we need to know +where the front is ([Crazyflie +1.0](https://wiki.bitcraze.io/projects:crazyflie:userguide:index#the_crazyflie), [Crazyflie +2.0](https://wiki.bitcraze.io/projects:crazyflie2:userguide:index)). + +How to get flying +================= + +- Start up the application +- Insert the joystick and Crazyradio (PA) +- Before you connect to the Crazyflie make sure that the joystick is + working as expected and that the **thrust is zero**. The joystick + values should be visible in the flight data box under target. +- Press *Scan* +- Wait for the scanning to complete +- In the drop-down menu to the left of the Connect button select the + Crazyflie you want to connect to. Connect to the URI e.g. + radio://0/80/250k. +- The client will now connect to the Crazyflie and handshake +- When the handshake is done you can start flying the Crazyflie. + Remember the most tricky part is the thrust so start out easy\... + +For more info on LED indicators etc. have a look at the +[Crazyflie](https://wiki.bitcraze.io/projects:crazyflie:userguide:index#the_crazyflie) or +[Crazyflie 2.0](https://wiki.bitcraze.io/projects:crazyflie2:userguide:index) user guide. + +Main UI +======= + + + +1. The window title will show the connection status +2. Connect/disconnect, scan and the drop-down connection list as well + as Address and auto reconnect. + + + + * *Scan:* Will scan for availible Crazyflies within the chosen address. + * *Connect:* Will connect to the selected URI in the connection list + * *Disconnect:* Will disconnect the current Crazyflie + * *Address:* The address to scan for. If you didn't change this [in the configuration]( https://wiki.bitcraze.io/doc:crazyflie:client:pycfclient:index#firmware_configuration), then leave the default of 0xE7E7E7E7E7 + * *Auto Reconnect:* Try to automatically reconnect when connection is lost. + - Battery and link quality (from 0% to 100%) + - Tabs with specific functionality (see below for details) + - The selected and used input interface + +Functionality +============= + +Below are a few guides on how to accomplish specific tasks with the +client. + +Firmware upgrade +---------------- + +For updating the Crazyflie firmware there\'s the possibility to enter +bootloader mode and flash [new +firmware](https://wiki.bitcraze.io/misc:downloads:index) from within the +client. The bootloader mode is accessed from the menu +*Crazyflie-\>Bootloader*. If there is any problem during the flashing or +a wrong firmware is flashed the process can just be started again. + + + +To update the firmware in the Crazyflie 1.0/2.0 do the following: + +- Make sure that the Crazyflie is disconnected from the client and + powered off +- Go to the menu *Crazyflie-\>Bootloader* +- For Crazyflie 2.0 hold the button for about 3 seconds when turning + it on until the blue LED M2 starts to blink to get into bootloader + mode. If a wrong nRF51 firmware has been flashed you might have to + start from an un-powered state. Then hold the button and connect + power. +- Click \"Initiate bootloader cold boot\" +- For Crazyflie 1.0 now power it on **within 5 seconds** using the + battery (not USB), the booloader should now connect +- Press \"Browse\" and select the binary you want to download *(e.g. + cflie.bin)*. **Note:** A \*.bin file will be flashed to the STM32xxx + only. Or select a [zip](https://wiki.bitcraze.io/doc:crazyflie:bootloader:index) file + containing firmware for both nRF51 and STM32F405 for Crazyflie 2.0 + as well as firmware for the STM32F103 for the Crazyflie 1.0. +- Press \"Program\" and wait +- Press \"Restart in firmware mode\" + +To check the firmware version, under the *View* menu, open up +*Tabs-\>Console* tab and look at the output when connecting to the +Crazyflie 1.0/2.0. + +Firmware configuration +---------------------- + +It is possible to set another channel to communicate with the Crazyflie +1.0/2.0. It can be wise to do this if there exist other wireless +networks that can interfere, especially WiFi. It is also possible to +permanently store the trim values for pitch and roll. + +It is currently possible to change the following parameters which are +stored in a none volatile memory: + +- **Pitch trim** Can be programmed permanently with the trim values + found to work good in the flight tab. +- **Roll trim** Can be programmed permanently with the trim values + found to work good in the flight tab. +- **Radio channel** Can be set to anything between 0 and 125, + correspond to a frequency from 2400MHz to 2525MHz. In most countries + channel 0 to 80 is OK to use but this should be checked with you + local regulations. If using 2M datarate, the copter channels should + be 2 apart (2MHz). +- **Radio bandwidth** This can set the radio bandwidth to 250k, 1M or + 2M. A lower bandwidth has longer range but has higher chance of + collision. When used inside sometimes it is better to use 1M or 2M + as it decreases the risk of collision with WiFi. +- **Radio address** (advanced) will set the shock burst address used + for communicating. Note that if you change this then you will have + to set the address correctly in the connect dialog. + +The procedure is described below and the parameters can be changed again +any time the same way. + + +| **Crazyflie 1.0** **Crazyflie 2.0** | +|-----|------------| +| Click on the menu **\"Crazyflie-\>Configure 1.0\"** and then connect the bootloader by clicking on the \"cold boot\" button and by restarting the Crazyflie. | First connect to the Crazyflie 2.0 with the normal connect button. Then open **\"Crazyflie-\>Configure 2.0\"** to reach the configure 2.0 dialog | + | {:width="500"} | {:width="500"} | + | Once the settings has been made press the program button to save them permanently in the Crazyflie flash. | Once the settings has been made press the write button to save them permanently in the Crazyflie 2.0 EEPROM. | + + +Logging +------- + +The Crazyflie logging framework allows to log the state of Crazyflie +variables in real-time. This subsystem is used by the client to show +information like pose or battery level. + +The list of log variable can be seen in the \"log TOC\" tab in the +client. + +Variables are logged in block: one log block is a list of variable that +are logged at the same time. You can setup custom log blocks that can be +plotted in the plotter and saved to file in the log block tab. + +To setup a new log block click on the menu \"settings/logging +configuration\", You then see the following toolbox: + +{:align-center} + +1. List of log variable in the Crazyflie +2. Log variables in the current log block +3. Add the selected Crazyflie log variable in the log block +4. Remove the selected log block variable from the log block +5. Period at which the variables are sampled and the block is send by + the Crazyflie to the client. The minimum possible period is 10ms + (100Hz) and it can be set by step of 10ms up to 2550ms. +6. Space taken by the variables in the log block. +7. Name of the new or existing log blocks. You can choose an existing + block from the list or type the name of a new one +8. Load existing log block configuration +9. Save log block configuration + +Flight settings +--------------- + +By using the settings on the [Flight control +tab](#flightcontrol) you can set +things such as the max roll/pitch and thrust. + +Input devices +------------- + +In order to control the Crazyflie you are connected to you will need +some input-device. Normally this would be a gamepad, but any +input-device with at least 4 analog axis will do. Here\'s [a +list](input_devices.md) of some input-devices +that are used. + +In order to make sense of the input from the device a mapping has to be +supplied. This mapping will convert raw axis values on the input-device +to useful values like roll/pitch/yaw/thrust. There\'s a few default +mappings shipped with the client, but it\'s easy to create your own. + +### Creating new mappings + +The software comes bundled with mappings for Xbox and PS3/4 controllers, +but if you have another input-device then it\'s quick to create your own +configuration. Go to the menu *Input device -\> Configure device +mapping*. + +{:align-center +width="700"} + +Select the device you would like to configure and press *Configure*. + +{:align-center +width="700"} + +For each functionality that can be mapped there\'s a *Detect* button, by +pressing it the following dialog will appear. + +{:align-center +width="300"} + +Follow the instructions to detect the axis or button that you would like +to map to the functionality. If you would like to map the functionality +to two axis (like right/left sholder-button) then select *Combined axis +detection* and follow the instructions. + +Go though all the functionality you would like to map by pressing the +*Detect* button for each. To be able to save the mapping you will at +least have to map roll, pitch, yaw and thrust. + +{:align-center +width="700"} + +Once you have mapped functionality you will be able to see the feedback +directly in the configuration dialog (when you\'re not detecting a +button). Make sure to check that the response is what you intended. When +you are finished with the mapping then enter the map name and press +save. + +If you would like to start from a previous configuration and change it +(either to update or to create a new one) then select the appropriate +mapping in the drop-down and press *Load*. Once you have made the +changes you would like to do then either press *Save* without changing +the name to update the mapping or enter a new name and press *Save* to +create a new one. + +### Selecting device + +The current input device and mapping can be selected from the *Input +device* menu. + +The *Input device* menu contains a number of different \"modes\" that +can be used for controlling a Crazyflie. Currently there\'s thee to +choose from. The alternatives will only be enabled if there\'s enough +input devices connected to use them. + +- *Normal:* Just like it says this is the normal mode using only one + controller to control a Crazyflie +- *Teacher (RP):* This mode requires two input-devices, where one will + be configured for roll and pitch and the other one for the rest of + the functionality. By using the *Mux switch* functionality (mapped + in the configuration) the second controller can take over roll and + pitch as well +- *Teacher (RPYT):* This mode requires two input-devices, where one + will be configured for roll, pitch yaw and thrust, and the other one + for the rest of the functionality. By using the *Mux switch* + functionality (mapped in the configuration) the second controller + can take over roll, pitch, yaw and thrust as well + +For normal usage just enter the *Normal* menu, select the device you +would like to use and the correct mapping. As a device is selected the +list of mappings are enabled. + +{:align-center +width="700"} + +If more than one input device is connected then it\'s possible to switch +to one of the teacher modes. + +{:align-center +width="700"} + +First select the device that should be used for the teacher and then +it\'s mapping. + +{:align-center +width="700"} + +Then select the device that should be used for the student and then +it\'s mapping. + +{:align-center +width="700"} + +Once this is done you will be able to see the open devices and +configurations at the bottom of the user interface. + +{:align-center +width="700"} + +Tabs +==== + +The main interface is built up of different tabs that can be +shown/hidden from the *View-\>Tabs* menu. + +Flightcontrol +------------- + +The normal view used when flying is the one seen below. +{:align-center} + +1. Flight mode selector (Normal and Advanced) + + + + * *Normal:* Recommended for beginners + * *Advanced:* Will unlock flight settings in 3 + - Assisted mode selection. The assisted mode is enabled when the assisted mode button is pressed on the Gamepad. + * *Altitude hold*: Keeps the Crazyflie at its current altitude automatically. Thrust control becomes height velocity control. + * *Position hold*: Keeps the Crazyflie at its current 3D position. Pitch/Roll/Thrust control becomes X/Y/Z velocity control. + * *Height hold*: When activated, keeps the Crazyflie at 40cm above the ground. Thrust control becomes height velocity control. Requires a height sensor like the [Z-Ranger deck](https://wiki.bitcraze.io/projects:crazyflie2:expansionboards:zranger). + - Roll/pitch trim can be set either in the UI or using the controller (if the correct buttons are mapped). This will offset the input to the Crazyflie for correcting imbalance and reducing drift. + - Advanced flight control settings are available if Advanced mode has been selected (settings are in %): + * *Max angle:* Set the max roll/pitch angle allowed + * *Max yaw rate:*Set the max yaw rate allowed + * *Max thrust:* Set the max thrust allowed + * *Min thrust:* Minimum thrust before 0 is sent to the Crazyflie + * *Slew limit:* Set the percentage where the thrust is slew controlled (the thrust value lowering will be limited). This makes the Crazyflie a bit easier to fly for beginners + * *Slew rate:* When the thrust is below the slew limit, this is the maximum rate of lowering the thrust + - Settings for flight decks, currently the LED-ring effect and headlights can be set (if the ring is attached) + - Target values sent from the client for controlling the Crazyflie + - Actual values logged from the Crazyflie + - Motor output on the Crazyflie + - Horizon indicator + +Plotter +------- + +The plotter tab can be used to visualize data logged from the Crazyflie +{:align-center +width="700"} + +1. Select logging configuration to plot. Read about how to create + configurations \<here\>. +2. Legend for the logging configuration that is being plotted. +3. Logged data, zooming and panning can be done with the mouse. +4. Number of samples showed in the plot. After this is filled the plot + will start scrolling the data +5. Auto-scaling or fixed scaling for the Y-axis +6. Auto update graph. If this is disabled the plot will stop updating + (but data will still be collected in the background) + +Parameters +---------- + +The Crazyflie supports parameters, variables stored in the Crazyflie +that can be changed in real-time. The parameter tab can be used to view +and update parameters. For more information about parameters see +logging and parameter frameworks LINK TO CF-FIRMWARE! + +{:align-center +width="700"} + +1. Parameter information fields + + + + * *Name:* The name of the parameter or group. + * *Type:* The C-type of the variable stored in the Crazyflie (you cannot set values outside this) + * *Access:* RW parameters can be written from the client while RO parameters can only be read + * *Value:* The value of the parameter + - Group: To make things easier each group has it's members organized as sub-nodes to the group + - Parameters: The full name of each parameter is the group combined with the name (group.name) + +Log blocks +---------- + +The log blocks tab shows all log configurations that are saved and if +they are started. It\'s also possible to start/stop them as well as +write the logged data to file. + +{:align-center +width="700"} + +1. Fields + - *ID:* Block id in Crazyflie + - *Name:* Block name in client + - *Period:* The period of which the data is sent back to the + client + - *Start:* Marked if started, click to start/stop block. Note that + some of the blocks are used for the user interface, so if they + are stopped the user interface will stop updating + - *Write to <file:*> Marked if writing to file, clock to + start/stop writing. The data will be written in the + configuration folder for the client (see \<here\> how to find + it). + - *Contents:* The variables contained in the block (named by + group.name) +2. Information for log configurations are folded by group by default, + opening them up will show in detail what variables are in the group + + The data written to file will be in +the configuration folder under *logdata*. Each directory is timestamped +after when the client was started and each file timestamped after when +the writing to file was started (i.e starting/stopping and +starting/stopping again will yield two files in the same directory). The +data logged to the file is in CSV format with the headers for the data +at the top. A timestamp is automatically added for each entry and shows +the number of milliseconds passed since the Crazyflie started (sent +together with the log data). + +Example data +of what\'s logged when logging the battery level: + + Timestamp,pm.vbat + 9103,3.74252200127 + 10103,3.74252200127 + 11103,3.74252200127 + 12103,3.74252200127 + 13103,3.74252200127 + + + +Console +------- + +The console tab will show printouts from the Crazyflie firmware as it\'s +running. +{:align-center +width="700"} + +1. Console output from the Crazyflie + +Loco Positioning +---------------- + +The Loco Positioning tab shows information from the Loco Positioning +system when present. + +There are three graphs showing 2D projections of the system from three +directions. The top left graph shows the system from above, the bottom +left shows is it from the front (along the y-axis) while the bottom +right shows it from the right side (along the negative x-axis). The +graphs can be zoomed and scrolled. + +The tab can be used in two modes that is selected with the radio buttons +to the right + +To setup the LPS anchor system mode (TWR or TDoA), see the [Configure +LPS positioning mode wirelessly](https://wiki.bitcraze.io/doc:lps:configure-mode) documentation. + +### Position estimate mode + +Displays the configured anchor positions and the estimated position of +the Crazyflie. Can be used to make sure the system is set up correctly +and that the estimated position is reasonable. + +{:align-center +width="700"} + +1. Plot for X/Y (top view) showing anchors and Crazyflie +2. Plot for X/Z showing anchors and Crazyflie +3. Plot for Y/Z showing anchors and Crazyflie +4. Sets the graph mode + - *Position estimate* - Normal viewing mode + - *Anchor identification* - Enhanced mode where anchor id and + marker becomes larger when Crazyflie is closer +5. Indicates if anchors are communicating with Crazyflie (i.e anchors + are up and running) +6. Fit and center all data in graphs +7. Used to set anchor positions (see below) + +When setting the anchor position there\'s three colors to indicate the +status: + +- *White* - No position exists for this anchor (i.e the position has + not been read yet) +- *Red* - Position has been read from the anchor and it differs from + the currently shown value in the input box +- *Green* - Position has been read from the anchor and it is the same + as the currently shown value in the input box + +The positions of the anchors is continuously read in the background and +as positions comes in or input box values changes the colors will be set +accordingly. There\'s also two buttons used for the settings: + +- *Get from anchors* - Fills the input boxes with the positions read + from the anchors +- *Write to anchors* - Writes the currently shown values in the input + boxes to the anchors. In order to check that the write has been + successful wait about 10s and all the fields should turn green as + the positions are read back. If some of the fields are still red, + try pressing the button again. + +### Anchor identification mode + +displays the configured anchor positions. When the crazyflie is close to +an anchor this is indicated in the graphs by highlighting it. This mode +is useful to identify anchors and verify that the system is correctly +configured. +{:align-center +width="700"} + +1. Plot for X/Y (top view) showing anchors and Crazyflie +2. Plot for X/Z showing anchors and Crazyflie +3. Plot for Y/Z showing anchors and Crazyflie +4. Sets the graph mode + - *Position estimate* - Normal viewing mode + - *Anchor identification* - Enhanced mode where anchor id and + marker becomes larger when Crazyflie is closer +5. Current system mode indication. The system must be in TWR mode for + the anchor identification mode to be available. + +ZMQ backends +============ + +The UI is normally used to get/set parameters, view logged data and send +control commands to the Crazyflie. Aside from this there\'s also the +possibility to connect via ZMQ to the client and control several things: + +- [Parameters](cfclient_zmq.md#parameters): + Get/set parameters by name +- [LED-ring memory](cfclient_zmq.md#led-ring): + Write LED ring memory +- [Input-device](cfclient_zmq.md#input_device): + Act as an input device + +The benefit of using this approach instead of the [stand-alone ZMQ +server](/doc/crazyflie/client/cfzmq/index) is that you will not have to +take care of everything, just the parts you are interested in for the +moment. An example is [this video](https://vine.co/v/eZ3jZqxmeZh) where +the light/sound is controlled via ZMQ though the client, but everything +else is like normal (flying, input device, etc).