How to use cfclient - 10 common examples

To help you get started, we’ve selected a few cfclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bitcraze / crazyflie-clients-python / src / cfclient / ui / tabs / QualisysTab.py View on Github external
self.model = QStandardItemModel(10, 4)
        self.model.setHorizontalHeaderItem(0, QStandardItem('X (m)'))
        self.model.setHorizontalHeaderItem(1, QStandardItem('Y (m)'))
        self.model.setHorizontalHeaderItem(2, QStandardItem('Z (m)'))
        self.model.setHorizontalHeaderItem(3, QStandardItem('Yaw (deg)'))

        # Populate the table with data
        if (len(self.flight_paths) == 0):
            return
        current = self.flight_paths[self.pathSelector.currentIndex()]
        for i in range(1, len(current)):
            for j in range(0, 4):
                self.model.setItem(i - 1, j,
                                   QStandardItem(str(current[i][j])))
        self._flight_path_set_model.emit(self.model)
        Config().set("flight_paths", self.flight_paths)
github bitcraze / crazyflie-clients-python / lib / cfclient / ui / dialogs / logconfigdialogue.py View on Github external
logger.warning("Could not load config")
        else:
            self.resetTrees()
            self.loggingPeriod.setText("%d" % config.getPeriod())
            self.period = config.getPeriod()
            for v in config.getVariables():
                if (v.getVarType() == LogVariable.TOC_TYPE):
                    parts = v.getName().split(".")
                    varParent = parts[0]
                    varName = parts[1]
                    if self.moveNodeByName(self.logTree,
                                            self.varTree,
                                            varParent,
                                            varName) == False:
                        logger.warning("Could not find node!!")
                elif (v.getVarType() == LogVariable.MEM_TYPE):
                    logger.warning("Error: Mem vars not supported!")
github bitcraze / crazyflie-clients-python / src / cfclient / ui / main.py View on Github external
from PyQt5.QtWidgets import QMessageBox

from .dialogs.cf1config import Cf1ConfigDialog
from .dialogs.cf2config import Cf2ConfigDialog
from .dialogs.inputconfigdialogue import InputConfigDialogue
from .dialogs.logconfigdialogue import LogConfigDialogue

__author__ = 'Bitcraze AB'
__all__ = ['MainUI']

logger = logging.getLogger(__name__)

INTERFACE_PROMPT_TEXT = 'Select an interface'

(main_window_class,
 main_windows_base_class) = (uic.loadUiType(cfclient.module_path +
                                            '/ui/main.ui'))


class MyDockWidget(QtWidgets.QDockWidget):
    closed = pyqtSignal()

    def closeEvent(self, event):
        super(MyDockWidget, self).closeEvent(event)
        self.closed.emit()


class UIState:
    DISCONNECTED = 0
    CONNECTING = 1
    CONNECTED = 2
    SCANNING = 3
github bitcraze / crazyflie-clients-python / src / cfclient / ui / tabs / PlotTab.py View on Github external
from cfclient.ui.widgets.plotwidget import PlotWidget
from PyQt5 import uic
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtCore import QAbstractItemModel
from PyQt5.QtCore import QModelIndex
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QMessageBox

import cfclient

__author__ = 'Bitcraze AB'
__all__ = ['PlotTab']

logger = logging.getLogger(__name__)

plot_tab_class = uic.loadUiType(cfclient.module_path +
                                "/ui/tabs/plotTab.ui")[0]


class LogConfigModel(QAbstractItemModel):
    """Model for log configurations in the ComboBox"""

    def __init__(self, parent=None):
        super(LogConfigModel, self).__init__(parent)
        self._nodes = []

    def add_block(self, block):
        self._nodes.append(block)
        self.layoutChanged.emit()

    def parent(self, index):
        """Re-implemented method to get the parent of the given index"""
github bitcraze / crazyflie-clients-python / src / cfclient / ui / tabs / PlotTab.py View on Github external
if not index.isValid() or not 0 <= index.row() < len(self._nodes):
            return None
        if role == Qt.DisplayRole:
            return self._nodes[index.row()].name
        return None

    def reset(self):
        """Reset the model"""
        self._nodes = []
        self.layoutChanged.emit()

    def get_config(self, i):
        return self._nodes[i]


class PlotTab(Tab, plot_tab_class):
    """Tab for plotting logging data"""

    _log_data_signal = pyqtSignal(int, object, object)
    _log_error_signal = pyqtSignal(object, str)
    _disconnected_signal = pyqtSignal(str)
    _connected_signal = pyqtSignal(str)

    colors = [
        (60, 200, 60),    # green
        (40, 100, 255),   # blue
        (255, 130, 240),  # magenta
        (255, 26, 28),    # red
        (255, 170, 0),    # orange
        (40, 180, 240),   # cyan
        (153, 153, 153),  # grey
        (176, 96, 50),    # brown
github bitcraze / crazyflie-clients-python / src / cfclient / ui / tabs / ParamTab.py View on Github external
"""Re-implemented function for getting the flags for a certain index"""
        flag = super(ParamBlockModel, self).flags(index)
        node = index.internalPointer()
        if index.column() == 3 and node.parent and node.access == "RW":
            flag |= Qt.ItemIsEditable
        return flag

    def reset(self):
        """Reset the model"""
        self._nodes = []
        super(ParamBlockModel, self).beginResetModel()
        super(ParamBlockModel, self).endResetModel()
        self.layoutChanged.emit()


class ParamTab(Tab, param_tab_class):
    """
    Show all the parameters in the TOC and give the user the ability to edit
    them
    """
    _expand_all_signal = pyqtSignal()
    _connected_signal = pyqtSignal(str)
    _disconnected_signal = pyqtSignal(str)

    def __init__(self, tabWidget, helper, *args):
        """Create the parameter tab"""
        super(ParamTab, self).__init__(*args)
        self.setupUi(self)

        self.tabName = "Parameters"
        self.menuName = "Parameters"
github bitcraze / crazyflie-clients-python / src / cfclient / ui / tabs / QualisysTab.py View on Github external
self.discovering = True
        start_async_task(self._discover_qtm(interface))

    async def _discover_qtm(self, interface):
        try:
            async for qtm_instance in qtm.Discover(interface):
                info = qtm_instance.info.decode("utf-8").split(",")[0]
                self.discoveredQTM.emit(info, qtm_instance.host)

        except Exception as e:
            logger.info("Exception during qtm discovery: %s", e)

        self.discovering = False


class QualisysTab(Tab, qualisys_tab_class):
    """
        Tab for controlling the crazyflie using
        Qualisys Motion Capturing system
    """

    _connected_signal = pyqtSignal(str)
    _disconnected_signal = pyqtSignal(str)
    _log_data_signal = pyqtSignal(int, object, object)
    _log_error_signal = pyqtSignal(object, str)
    _param_updated_signal = pyqtSignal(str, str)
    _imu_data_signal = pyqtSignal(int, object, object)

    _flight_path_select_row = pyqtSignal(int)
    _flight_path_set_model = pyqtSignal(object)
    _path_selector_add_item = pyqtSignal(str)
    _path_selector_set_index = pyqtSignal(int)
github bitcraze / crazyflie-clients-python / src / cfclient / gui.py View on Github external
's:%(levelname)s:%(message)s')
        filename = "debug-%s.log" % datetime.datetime.now()
        filehandler = logging.FileHandler(filename)
        filehandler.setLevel(logging.DEBUG)
        filehandler.setFormatter(formatter)
        cflogger.addHandler(filehandler)
    elif ("debug" in debug):
        logging.basicConfig(level=logging.DEBUG)
    elif ("minimal" in debug):
        logging.basicConfig(level=logging.WARNING)
    elif ("info" in debug):
        logging.basicConfig(level=logging.INFO)

    logger = logging.getLogger(__name__)

    logger.debug("Using config path {}".format(cfclient.config_path))
    logger.debug("sys.path={}".format(sys.path))

    # Try all the imports used in the project here to control what happens....
    try:
        import usb  # noqa
    except ImportError:
        logger.critical("No pyusb installation found, exiting!")
        sys.exit(1)

    if not sys.platform.startswith('linux'):
        try:
            import sdl2  # noqa
        except ImportError:
            logger.critical("No pysdl2 installation found, exiting!")
            sys.exit(1)
github bitcraze / crazyflie-clients-python / src / cfclient / headless.py View on Github external
def list_controllers(self):
        """List the available controllers and input mapping"""
        print("\nAvailable controllers:")
        for i, dev in enumerate(self._devs):
            print(" - Controller #{}: {}".format(i, dev))
        print("\nAvailable input mapping:")
        for map in os.listdir(cfclient.config_path + '/input'):
            print(" - " + map.split(".json")[0])
github bitcraze / crazyflie-clients-python / lib / cfclient / ui / tabs / FlightTab.py View on Github external
def uiSetupReady(self):
        flightComboIndex = self.flightModeCombo.findText(
                             GuiConfig().get("flightmode"), Qt.MatchFixedString)
        if (flightComboIndex < 0):
            self.flightModeCombo.setCurrentIndex(0)
            self.flightModeCombo.currentIndexChanged.emit(0)
        else:
            self.flightModeCombo.setCurrentIndex(flightComboIndex)
            self.flightModeCombo.currentIndexChanged.emit(flightComboIndex)