User Tools

Site Tools


projects:crazyflie:pc_utils:pylib

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
projects:crazyflie:pc_utils:pylib [2013-08-19 09:43]
tobias [Simple code example]
projects:crazyflie:pc_utils:pylib [2014-02-12 13:37]
tobias [Examples]
Line 6: Line 6:
   * Firmware implementation of the [[projects:crazyflie:firmware:log | logging]] or [[projects:crazyflie:firmware:param | parameters]]   * Firmware implementation of the [[projects:crazyflie:firmware:log | logging]] or [[projects:crazyflie:firmware:param | parameters]]
  
-===== Structure of the library ===== +====== Structure of the library ====== 
-**TODO**+The library is asynchronous and based on callbacks for events. Functions like ''open_link'' will return immediately, and the callback ''connected'' will be called when the link is opened. The library doesn't contain any threads or locks that will keep the application running, it's up to the application that is using the library to do this.
  
-===== Connection- and link-callbacks ===== +===== Uniform Resource Identifier (URI) ===== 
-The library uses callbacks for asynchronous events such as when the connection is dropped or when new logging data arrives. Here's a list of linkstatus callbacks: +All communication links are identified using an URI build up of the following: %%InterfaceType://InterfaceId/InterfaceChannel/InterfaceSpeed%%
-    * //connectionInitiated// - Called when a request has been made to the library to establish a connection +
-    * //connectSetupFinished// - Called when the connection has been established and the log/param TOC has been downloaded +
-    * //disconnected// - Called when the connection has been closed (both when requested and not requested to close) +
-    * //connectionLost// - Called when the connection has been closed (without being requested to be closed) +
-    * //connectionFailed// - Called if the connection fails when it is being established (between the request and connection setup finished) +
-    * //linkQuality// - Called periodically to report link status. This is done at the discretion of the link drivers+
  
-To register for callbacks the following is used:+Currently only //radio// and //debug// interfaces are used but there's ideas for more like //udp//, //serial//, //usb//, etc...Here are some examples: 
 +  * %%Radio interface, USB dongle number 0, radio channel 10 and radio speed 250 Kbit/s: radio://0/10/250K %% 
 +  * %%Debug interface, id 0, channel 1: debug://0/1%% 
 + 
 +===== Variables and logging ===== 
 +The library supports setting up logging configurations that are used for logging variables from the firmware. Each log configuration contains a number of variables that should be logged as well as a time period (in ms) of how often the data should be sent back to the host. Once the log configuration is added to the firmware the firmware will automatically send back the data at every period. These configurations are used in the following way: 
 +  * Connect to the Crazyflie (log configurations needs a TOC to work) 
 +  * Create a log configuration that contains a number of variables to log and a period at which they should be logged 
 +  * Add the log configuration. This will also validate that the log configuration is sane (i.e uses a supported period and all variables are in the TOC) 
 +  * After checking that the configuration is valid, set up callbacks for the data in your application and start the log configuration 
 +  * Each time the firmware sends data back to the host the callback will the called with a time-stamp and the data 
 + 
 +There's a few limitations that needs to be taken into account: 
 +  * Each packet is limited to 32bytes, which means that the data that is logged and the packet that is sent to set it up cannot be larger than this. It limits the logging to about 14 variables, but this is dependent on what types they are 
 +  * The minimum period of a for a log configuration is multiples of 10ms 
 + 
 +===== Parameters ===== 
 +The library supports reading and writing parameters at run-time to the firmware. This is intended to be used for data that is not continuously being changed by the firmware, like setting regulation parameters and reading out if the power-on self-tests passed. Parameters should only change in the firmware when being set from the host or during start-up. The library doesn't continuously update the parameter values, this should only be done once after connecting. After each write to a parameter the firmware will send back the updated value and this will be forwarded to callbacks registered for reading this parameter. The parameters should be used in the following way: 
 +  * Register parameter updated callbacks at any time in your application 
 +  * Connect to your Crazyflie (this will download the parameter TOC) 
 +  * Request updates for all the parameters 
 +  * The library will call all the callbacks registered 
 +  * The host can now write parameters that will be forwarded to the firmware 
 +  * For each write all the callbacks registered for this parameter will be called back 
 + 
 +===== Variable and parameter names ===== 
 +All names of parameters and log variables use the same structure: ''group.name'' 
 + 
 +The group should be used to bundle together logical groups, like everything that has to do with the stabilizer should be in the group ''stabilizer''
 + 
 +There's a limit of 28 chars in total and here are some examples: 
 +  * stabilizer.roll 
 +  * stabilizer.pitch 
 +  * pm.vbat 
 +  * imu_tests.MPU6050 
 +  * pid_attitide.pitch_kd 
 + 
 +====== Utilities ====== 
 +===== Callbacks ===== 
 +All callbacks are handled using the ''Caller'' class that contains the following methods:
 <code python> <code python>
-    crazyflie = Crazyflie() +    add_callback(cb
-    crazyflie.linkQuality.addCallback(linkQualityCallback)+        """ Register cb as a new callbackWill not register duplicates""" 
 + 
 +    remove_callback(cb) 
 +        """ Un-register cb from the callbacks """ 
 + 
 +    call(*args) 
 +        """ Call the callbacks registered with the arguments args """
 </code> </code>
  
-There are more callbacks than this available in the Crazyflie but these are the ones most useful.+===== Debug driver ===== 
 +The library contains a special link driver, named ''DebugDriver''. This driver will emulate a Crazyflie and is used for testing of the UI and libraryNormally this will be hidden from the user except if explicitly enabled. The driver supports the following: 
 +  * Connecting a download param and log TOCs 
 +  * Setting up log configurations and sending back fake data 
 +  * Setting and reading parameters 
 +  * Bootloading
  
-===== Uniform Resource Identifier (URI) ===== +There are a number of different URIs that will be returned from the driver. These will have different functions, like always returning a random TOC CRC to always trigger TOC downloading or failing during connect. The driver also has support for sending back data with random delays to trigger random re-sending by the library.
-All communication links are identified using an URI build up of the following: %%InterfaceType://InterfaceId/InterfaceChannel/InterfaceSpeed%%+
  
-Currently only //radio// and //debug// interfaces are used but there's ideas for more like //udp//, //serial//, //usb//, etc...Here are some examples: +====== Initiating the link drivers ====== 
-  * %%radio://0/10/250K (Radio interface, USB dongle number 0, radio channel 10 and radio speed 250 Kbit/s)%% +Before the library can be used the link drivers have to he initialized. This will search for available drivers and instantiate them.
-  * %%debug://0/1 (Debug interface, id 0, channel 1)%%+
  
-===== Variable and parameter names ===== +<code python> 
-All names of parameters and loggable variables use the same structure: //group.name//+    init_drivers(enable_debug_driver=False) 
 +       """ Search for and initialize link drivers. If enable_debug_driver is True then the DebugDriver will also be used.""" 
 +</code>
  
-There's a limit of 28 chars in total **(?)** and here are some examples: +====== Connection- and link-callbacks ====== 
-  * stabalizer.roll +Operations on the link and connection will return directly and will call the following callbacks when events occur: 
-  * system.battery+ 
 +<code python> 
 +    # Called on disconnect, no matter the reason 
 +    disconnected = Caller() 
 +    # Called on unintentional disconnect only 
 +    connection_lost = Caller() 
 +    # Called when the first packet in a new link is received 
 +    link_established = Caller() 
 +    # Called when the user requests a connection 
 +    connection_requested = Caller() 
 +    # Called when the link is established and the TOCs (that are not cached) 
 +    # have been downloaded 
 +    connected = Caller() 
 +    # Called if establishing of the link fails (i.e times out) 
 +    connection_failed = Caller() 
 +    # Called for every packet received 
 +    packet_received = Caller() 
 +    # Called for every packet sent 
 +    packet_sent = Caller() 
 +    # Called when the link driver updates the link quality measurement 
 +    link_quality_updated = Caller() 
 +</code> 
 + 
 +To register for callbacks the following is used: 
 +<code python> 
 +    crazyflie = Crazyflie() 
 +    crazyflie.connected.add_callback(crazyflie_connected) 
 +</code>
  
-===== Finding a Crazyflie and connecting ===== +====== Finding a Crazyflie and connecting ======
 The first thing to do is to find a Crazyflie quadcopter that we can connect to. This is done by queuing the library that will scan all the available interfaces (currently the debug and radio interface). The first thing to do is to find a Crazyflie quadcopter that we can connect to. This is done by queuing the library that will scan all the available interfaces (currently the debug and radio interface).
 <code python> <code python>
Line 52: Line 123:
 <code python> <code python>
     crazyflie = Crazyflie()     crazyflie = Crazyflie()
 +    crazyflie.connected.add_callback(crazyflie_connected)
     crazyflie.open_link("radio://0/10/250K")     crazyflie.open_link("radio://0/10/250K")
-    # Do stuff+</code> 
 + 
 +Then you can use the following to close the link again: 
 +<code python>
     crazyflie.close_link()     crazyflie.close_link()
 </code> </code>
-===== Sending control commands ===== + 
-Currently all the communication is either parameters, logging or control commands. The special case of control commands is to minimize latency since it's a faster way than using parameters.+====== Sending control commands ====== 
 +The control commands are not implemented as parameters, instead they have a special API. 
 + 
 +<code python> 
 +    send_setpoint(roll, pitch, yaw, thrust): 
 +        """ 
 +        Send a new control set-point for roll/pitch/yaw/thust to the copter 
 + 
 +        The arguments roll/pitch/yaw/trust is the new set-points that should 
 +        be sent to the copter 
 +        """ 
 +</code>
  
 To send a new control set-point use the following: To send a new control set-point use the following:
Line 68: Line 154:
 </code> </code>
  
-Thrust is an integer value ranging from 10001 (next to no power) to 60000 (full power). Sending a command makes it apply for 0.5 seconds, after which the firmware will cut out the power. Depending on where the Crazyflie is, this can be a Bad Thing! With this in mind, you need to try and maintain a thrust level, with a tick being sent at least once every 2 seconds. Ideally you should be sending one tick every 0.01 seconds, for 100 commands a second. This has a nice added benefit of allowing for very precise control. +Thrust is an integer value ranging from 10001 (next to no power) to 60000 (full power). Sending a command makes it apply for 500 ms, after which the firmware will cut out the power. With this in mind, you need to try and maintain a thrust level, with a tick being sent at least once every 2 seconds. Ideally you should be sending one tick every 10 ms, for 100 commands a second. This has a nice added benefit of allowing for very precise control. 
-===== Parameters =====+ 
 +====== Parameters ======
 The parameter framework is used to read and set parameters. This functionality should be used when: The parameter framework is used to read and set parameters. This functionality should be used when:
   * The parameter is not changed by the Crazyflie but by the client   * The parameter is not changed by the Crazyflie but by the client
Line 77: Line 164:
 To set a parameter you have to the connected to the Crazyflie. A parameter is set using: To set a parameter you have to the connected to the Crazyflie. A parameter is set using:
 <code python> <code python>
-    parameterName = "group.name" +    param_name = "group.name" 
-    parameterValue = 3 +    param_value = 3 
-    crazyflie.param.setParamValue(parameterNameparameterValue)+    crazyflie.param.set_value(param_nameparam_value)
 </code> </code>
  
-The parameter reading is done using callbacks. When the connection is established to the Crazyflie all the parameters are read. When a parameter is updated from the client (using the code above) the parameter will be requested again by the library and this will trigger the callbacks. Parameter callbacks can be added at any time (you don't have to be connected to a Crazyflie).+The parameter reading is done using callbacks. When a parameter is updated from the host (using the code above) the parameter will be read back by the library and this will trigger the callbacks. Parameter callbacks can be added at any time (you don't have to be connected to a Crazyflie). 
 <code python> <code python>
-    crazyflie.param.addParamUpdateCallback("group.name", paramUpdateCallback)+    add_update_callback(group, name=None, cb=None) 
 +        """ 
 +        Add a callback for a specific parameter name or group. If not name is specified then 
 +        all parameters in the group will trigger the callback. This callback will be executed 
 +        when a new value is read from the Crazyflie. 
 +        """
  
-    def paramUpdateCallback(name, value): +    request_param_update(complete_name
-        print "%s has value %d(name, value)+        """ Request an update of the value for the supplied parameter. """ 
 + 
 +    set_value(complete_name, value) 
 +        """ Set the value for the supplied parameter. """
 </code> </code>
  
-A callback can also be removed using:+Here's an example of how to use the calls.
 <code python> <code python>
-crazyflie.param.addParamUpdateCallback("group.name", paramUpdateCallback)+    crazyflie.param.add_update_callback(group="group", name="name", param_updated_callback) 
 + 
 +    def param_updated_callback(name, value): 
 +        print "%s has value %d" % (namevalue)
 </code> </code>
  
-===== Logging =====+====== Logging ======
 The logging framework is used to enable the "automatic" sending of variable values at specified intervals to the client. This functionality should be used when: The logging framework is used to enable the "automatic" sending of variable values at specified intervals to the client. This functionality should be used when:
   * The variable is changed by the Crazyflie and not by the client   * The variable is changed by the Crazyflie and not by the client
Line 101: Line 200:
 If this is not the case then the parameter framework should be used instead. If this is not the case then the parameter framework should be used instead.
  
-To create a logging configuration the following can be used: 
-<code python> 
-    periodInMilliSeconds = 10 
-    logconf = LogConfig("Logging", periodInMilliSeconds) 
-    logconf.addVariable(LogVariable("group1.name1", "float")) 
-    logconf.addVariable(LogVariable("group1.name2", "uint8_t")) 
-    logconf.addVariable(LogVariable("group2.name1", "int16_t")) 
-</code> 
  
-The datatype should match what has been configured in the Crazyflie firmware. The valid datatypes are: 
-  * float 
-  * uint8_t and int8_t 
-  * uint16_t and int16_t 
-  * uint32_t and int32_t 
-  * FP16 (this is a fixed point version of floating point) 
  
-The logging cannot be started until your are connected to a Crazyflie:+The API to create and get information from LogConfig:
 <code python> <code python>
-    # Callback called when the connection is established to the Crazyflie +    # Called when new logging data arrives 
-    def connected(linkURI): +    data_received_cb = Caller() 
-        logpacket = crazyflie.log.newLogPacket(logconf)+    # Called when there's an error 
 +    error_cb = Caller() 
 +    # Called when the log configuration is confirmed to be started 
 +    started_cb = Caller() 
 +    # Called when the log configuration is confirmed to be added 
 +    added_cb = Caller()
  
-        if (logpacket != None): +    add_variable(name, fetch_as=None) 
-            logpacket.dataReceived.addCallback(dataCallback) +        """Add a new variable to the configuration.
-            logpacket.startLogging(+
-        else: +
-            print "One or more of the variables in the configuration was not found in log TOCNo logging will be possible."+
  
-    def dataCallback(data): +        name - Complete name of the variable in the form group.name 
-        # Print all the keys and values for them +        fetch_as - String representation of the type the variable should be 
-        for k in data.keys(): +                   fetched as (i.e uint8_tfloat, FP16, etc)
-            print "Key: %s=%s" % (kstr(data[k])+
-</code>+
  
 +        If no fetch_as type is supplied, then the stored as type will be used
 +        (i.e the type of the fetched variable is the same as it's stored in the
 +        Crazyflie)."""
  
-====== Logging and parameter examples ====== +    start() 
-Below are the two examples described in the video <insert link to video here when done> that shows the parameter and logging framework. They have been re-written to fit outside the QT context so they do not match the video 1:1 but they show the same concept.+        """Start the logging for this entry"""
  
-Remember that if you use the callbacks for parameters and logging together with QT and the callbacks manipulate objects in the UI then they have to be wrapped using signals. Otherwise you will en up with timing issues that will (at some pointcrash the application since UI objects should only be updated with the same thread that draws the objects.+    stop() 
 +        """Stop the logging for this entry"""
  
-===== Adding a parameter ===== +    delete() 
-In this example we will add a parameter that will be used to "freezethe LED update function. This isn't very useful but it shows how to use parameters :-) +        """Delete this entry in the Crazyflie"""
- +
-First of all we need to add the parameter to the firmware, this is done by using the macros PARAM_GROUP_START, PARAM_ADD and PARAM_GROUP_STOP. In //crazyflie-firmware/drivers/src/led.c// we insert the following to add a parameter: +
-<code c> +
-#include "param.h" +
- +
-bool ledFreeze = false; +
- +
-PARAM_GROUP_START(led) +
-PARAM_ADD(PARAM_UINT8, freeze, &ledFreeze) +
-PARAM_GROUP_STOP(led)+
 </code> </code>
  
-This will add a parameter in the TOC named //led.freeze// of the type uint8_t.+The API for the log in the Crazyflie: 
 +<code python> 
 +    add_config(logconf) 
 +        """Add a log configuration to the logging framework.
  
-Now we should use this parameter on the client side. This can either be done by reading or writing the parameterFirst we add the code to write the parameter: +        When doing this the contents of the log configuration will be validated 
-<code python> +        and listeners for new log configurations will be notifiedWhen 
-# crazyflie is an instance of the Crazyflie class that has been instantiated and connected +        validating the configuration the variables are checked against the TOC 
-    crazyflie.param.setParamValue("led.freeze", True)+        to see that they actually exist. If they don't then the configuration 
 +        cannot be used. Since a valid TOC is required, a Crazyflie has to be 
 +        connected when calling this method, otherwise it will fail."""
 </code> </code>
  
-The parameter-framework relies on the fact that the parameters are changed from the client or that the client polls the value of parameters. If you are interested in logging changes that the Crazyflie does itself then the logging-framework is better. If you are interested in reading a parameter this should be done using a callback that will be called from the framework when the value for the parameter is updated. This happens in two cases: 
-  * When the Crazyflie has connected values for all the parameters in the TOC are fetched 
-  * When the client changes a value for a parameter the new value will be sent back from the Crazyflie 
  
-To register for callback and to implement the callback the following is used:+To create logging configuration the following can be used:
 <code python> <code python>
-    crazyflie Crazyflie() +    logconf LogConfig(name="Logging", period_in_ms=100
-    crazyflie.param.addParamUpdateCallback("led.freeze", paramUpdateCallback) +    logconf.add_variable("group1.name1", "float"
- +    logconf.add_variable("group1.name2""uint8_t"
-    def paramUpdateCallback(namevalue): +    logconf.add_variable("group2.name1", "int16_t")
-        print "%s has value %s% (namevalue# This will in our example print: led.freeze has value True+
 </code> </code>
  
-===== Adding loggable variables ===== +The datatype should match what has been configured in the Crazyflie firmwareThe valid datatypes are: 
-In this example we will add logging for the raw gyro values read from the sensor.+  * float 
 +  * uint8_t and int8_t 
 +  * uint16_t and int16_t 
 +  * uint32_t and int32_t 
 +  * FP16 (this is a fixed point version of floating point)
  
-First of all we add the variables to the logging TOC by using the macros LOG_GROUP_START, LOG_ADD and LOG_GROUP_STOP. In our example we edit the file //crazyflie-firmware/modules/src/stabalizer.c//: +The logging cannot be started until your are connected to a Crazyflie:
-<code c> +
-#include "log.h" +
-// The raw gyro values are stored in the gyro struct +
-LOG_GROUP_START(gyro) +
-LOG_ADD(LOG_FLOAT, x, &gyro.x) +
-LOG_ADD(LOG_FLOAT, y, &gyro.y) +
-LOG_ADD(LOG_FLOAT, z, &gyro.z) +
-LOG_GROUP_STOP(gyro) +
-</code> +
- +
-This will add the variables //gyro.x//, //gyro.y// and //gyro.z// to the logging TOC as floats. +
- +
-On the client side we now add the log configuration, start the logging and then callback will be called every 10 ms when data arrives from the Crazyflie:+
 <code python> <code python>
     # Callback called when the connection is established to the Crazyflie     # Callback called when the connection is established to the Crazyflie
-    def connected(linkURI): +    def connected(link_uri): 
-        gyroconf = LogConfig("Gyro", 10) +        crazyflie.log.add_config(logconf)
-        gyroconf.addVariable(LogVariable("gyro.x", "float")) +
-        gyroconf.addVariable(LogVariable("gyro.y", "float")) +
-        gyroconf.addVariable(LogVariable("gyro.z", "float"))+
  
-        # crazyflie is an instance of the Crazyflie class that has been instantiated and connected +        if logconf.valid: 
-        gyrolog = crazyflie.log.newLogPacket(gyroconf) +            logconf.data_received_cb.add_callback(data_received_callback
- +            logconf.error_cb.add_callback(logging_error
-        if (gyrolog != None): +            logconf.start()
-            gyrolog.dataReceived.addCallback(gyroData+
-            gyrolog.startLogging()+
         else:         else:
-            print "gyro.x/y/not found in log TOC+            print "One or more of the variables in the configuration was not found in log TOC. No logging will be possible."
- +
-    def gyroData(data): +
-        print "Gyrodata: x=%.2f, y=%.2f, z=%.2f" % (data["gyro.x"], data["gyro.y"], data["gyro.z"])+
  
 +    def data_received_callback(timestamp, data, logconf):
 +        print "[%d][%s]: %s" % (timestamp, logconf.name, data)
 +            
 +    def logging_error(logconf, msg):
 +        print "Error when logging %s" % logconf.name
 </code> </code>
  
-====== Code example to add accelerometer logging====== +====== Examples ====== 
-<code python> +The examples are now placed in the repository in the examples folder.
-import logging+
  
-import cflib.crtp 
-from cfclient.utils.logconfigreader import LogConfig 
-from cfclient.utils.logconfigreader import LogVariable 
-from cflib.crazyflie import Crazyflie 
  
-logging.basicConfig(level=logging.DEBUG) 
- 
- 
-class Main: 
-    """ 
-    Class is required so that methods can access the object fields. 
-    """ 
-    def __init__(self): 
-        """ 
-        Connect to Crazyflie, initialize drivers and set up callback. 
- 
-        The callback takes care of logging the accelerometer values. 
-        """ 
-        self.crazyflie = Crazyflie() 
-        cflib.crtp.init_drivers() 
- 
-        self.crazyflie.connectSetupFinished.add_callback( 
-                                                    self.connectSetupFinished) 
- 
-        self.crazyflie.open_link("radio://0/10/250K") 
- 
-    def connectSetupFinished(self, linkURI): 
-        """ 
-        Configure the logger to log accelerometer values and start recording. 
- 
-        The logging variables are added one after another to the logging 
-        configuration. Then the configuration is used to create a log packet 
-        which is cached on the Crazyflie. If the log packet is None, the 
-        program exits. Otherwise the logging packet receives a callback when 
-        it receives data, which prints the data from the logging packet's 
-        data dictionary as logging info. 
-        """ 
-        # Set accelerometer logging config 
-        accel_log_conf = LogConfig("Accel", 10) 
-        accel_log_conf.addVariable(LogVariable("acc.x", "float")) 
-        accel_log_conf.addVariable(LogVariable("acc.y", "float")) 
-        accel_log_conf.addVariable(LogVariable("acc.z", "float")) 
- 
-        # Now that the connection is established, start logging 
-        self.accel_log = self.crazyflie.log.create_log_packet(accel_log_conf) 
- 
-        if self.accel_log is not None: 
-            self.accel_log.dataReceived.add_callback(self.log_accel_data) 
-            self.accel_log.start() 
-        else: 
-            print("acc.x/y/z not found in log TOC") 
- 
-    def log_accel_data(self, data): 
-        logging.info("Accelerometer: x=%.2f, y=%.2f, z=%.2f" % 
-                        (data["acc.x"], data["acc.y"], data["acc.z"])) 
- 
-Main() 
-</code> 
- 
-====== Simple code example ====== 
-As a starter guide, this application connects to the Crazyflie, turns on the motors and then asks the user to set the thrust level. 
- 
-<code python> 
-import time 
-from threading import Thread 
- 
-import cflib.crtp 
-from cflib.crazyflie import Crazyflie 
- 
- 
-class Main: 
- 
-    # Initial values, you can use these to set trim etc. 
-    roll = 0.0 
-    pitch = 0.0 
-    yawrate = 0 
-    thrust = 10001 
- 
-    def __init__(self): 
-        self.crazyflie = Crazyflie() 
-        cflib.crtp.init_drivers() 
- 
-        # You may need to update this value if your Crazyradio uses a different frequency. 
-        self.crazyflie.open_link("radio://0/10/250K") 
- 
-        self.crazyflie.connectSetupFinished.add_callback(self.connectSetupFinished) 
- 
-    def connectSetupFinished(self, linkURI): 
-        # Keep the commands alive so the firmware kill-switch doesn't kick in. 
-        Thread(target=self.pulse_command).start() 
- 
-        while 1: 
-            self.thrust = int(raw_input("Set thrust (10001-60000):")) 
- 
-            if self.thrust == 0: 
-                self.crazyflie.close_link() 
-                break 
-            elif self.thrust <= 10000: 
-                self.thrust = 10001 
-            elif self.thrust > 60000: 
-                self.thrust = 60000 
- 
-    def pulse_command(self): 
-        self.crazyflie.commander.send_setpoint(self.roll, self.pitch, self.yawrate, self.thrust) 
-        time.sleep(0.1) 
- 
-        # ..and go again! 
-        self.pulse_command() 
- 
-Main() 
-</code> 
projects/crazyflie/pc_utils/pylib.txt · Last modified: 2021-06-24 16:58 by kimberly