How to use the cfclient.config_path function in cfclient

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 / 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 / src / cfclient / ui / main.py View on Github external
def _open_config_folder(self):
        QDesktopServices.openUrl(
            QUrl("file:///" +
                 QDir.toNativeSeparators(cfclient.config_path)))
github bitcraze / crazyflie-clients-python / src / cfclient / ui / toolboxes / CrtpSharkToolbox.py View on Github external
def _save_data(self):
        dir = os.path.join(cfclient.config_path, "logdata")
        fname = os.path.join(dir, "shark_data.csv")
        if not os.path.exists(dir):
            os.makedirs(dir)
        f = open(fname, 'w')
        for s in self._data:
            f.write("%s\n" % s)
        f.close()
github bitcraze / crazyflie-clients-python / src / cfclient / ui / main.py View on Github external
border-radius: 5px;
                        text-align: center;
                    }
                    QProgressBar::chunk {
                        background-color: """ + COLOR_BLUE + """;
                    }
                 """
                self.setStyleSheet(tcss)

            else:
                logger.info("Pre-Yosemite - skinny bar stylesheet not applied")

        ######################################################

        self.cf = Crazyflie(ro_cache=None,
                            rw_cache=cfclient.config_path + "/cache")

        cflib.crtp.init_drivers(enable_debug_driver=Config()
                                .get("enable_debug_driver"))

        zmq_params = ZMQParamAccess(self.cf)
        zmq_params.start()

        zmq_leds = ZMQLEDDriver(self.cf)
        zmq_leds.start()

        self.scanner = ScannerThread()
        self.scanner.interfaceFoundSignal.connect(self.foundInterfaces)
        self.scanner.start()

        # Create and start the Input Reader
        self._statusbar_label = QLabel("No input-device found, insert one to"
github bitcraze / crazyflie-clients-python / src / cfclient / ui / main.py View on Github external
border-radius: 5px;
                        text-align: center;
                    }
                    QProgressBar::chunk {
                        background-color: """ + COLOR_BLUE + """;
                    }
                 """
                self.setStyleSheet(tcss)

            else:
                logger.info("Pre-Yosemite - skinny bar stylesheet not applied")

        ######################################################

        self.cf = Crazyflie(ro_cache=None,
                            rw_cache=cfclient.config_path + "/cache")

        cflib.crtp.init_drivers(enable_debug_driver=Config()
                                .get("enable_debug_driver"))

        zmq_params = ZMQParamAccess(self.cf)
        zmq_params.start()

        zmq_leds = ZMQLEDDriver(self.cf)
        zmq_leds.start()

        self.scanner = ScannerThread()
        self.scanner.interfaceFoundSignal.connect(self.foundInterfaces)
        self.scanner.start()

        # Create and start the Input Reader
        self._statusbar_label = QLabel("No input-device found, insert one to"
github bitcraze / crazyflie-clients-python / src / cfclient / utils / config_manager.py View on Github external
from .singleton import Singleton
from cflib.utils.callbacks import Caller

import cfclient

__author__ = 'Bitcraze AB/Allyn Bauer'
__all__ = ['ConfigManager']

logger = logging.getLogger(__name__)


class ConfigManager(metaclass=Singleton):
    """ Singleton class for managing input processing """
    conf_needs_reload = Caller()
    configs_dir = cfclient.config_path + "/input"

    def __init__(self):
        """Initialize and create empty config list"""
        self._list_of_configs = []

    def get_config(self, config_name):
        """Get the button and axis mappings for an input device."""
        try:
            idx = self._list_of_configs.index(config_name)
            return self._input_config[idx]
        except:
            return None

    def get_settings(self, config_name):
        """Get the settings for an input device."""
        try:
github bitcraze / crazyflie-clients-python / src / cfclient / utils / config.py View on Github external
def __init__(self):
        """ Initializes the singleton and reads the config files """
        self._dist_config = cfclient.module_path + "/configs/config.json"
        self._config = cfclient.config_path + "/config.json"

        [self._readonly, self._data] = self._read_distfile()

        user_config = self._read_config()
        if (user_config):
            self._data.update(user_config)
github bitcraze / crazyflie-clients-python / src / cfzmq / __init__.py View on Github external
def __init__(self, base_url):
        """Start threads and bind ports"""
        cflib.crtp.init_drivers(enable_debug_driver=True)
        self._cf = Crazyflie(ro_cache=None,
                             rw_cache=cfclient.config_path + "/cache")

        signal.signal(signal.SIGINT, signal.SIG_DFL)

        self._base_url = base_url
        self._context = zmq.Context()

        cmd_srv = self._bind_zmq_socket(zmq.REP, "cmd", ZMQ_SRV_PORT)
        log_srv = self._bind_zmq_socket(zmq.PUB, "log", ZMQ_LOG_PORT)
        param_srv = self._bind_zmq_socket(zmq.PUB, "param", ZMQ_PARAM_PORT)
        ctrl_srv = self._bind_zmq_socket(zmq.PULL, "ctrl", ZMQ_CTRL_PORT)
        conn_srv = self._bind_zmq_socket(zmq.PUB, "conn", ZMQ_CONN_PORT)

        self._scan_thread = _SrvThread(cmd_srv, log_srv, param_srv, conn_srv,
                                       self._cf)
        self._scan_thread.start()
github bitcraze / crazyflie-clients-python / src / cfclient / ui / tabs / GpsTab.py View on Github external
def __init__(self, tabWidget, helper, *args):
        super(GpsTab, self).__init__(*args)
        self.setupUi(self)

        self.tabName = "GPS"
        self.menuName = "GPS"

        self.tabWidget = tabWidget
        self.helper = helper
        self._cf = helper.cf

        view = self.view = QtWebKit.QWebView()

        cache = QtNetwork.QNetworkDiskCache()
        cache.setCacheDirectory(cfclient.config_path + "/cache")
        view.page().networkAccessManager().setCache(cache)
        view.page().networkAccessManager()

        view.page().mainFrame().addToJavaScriptWindowObject("MainWindow", self)
        view.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
        view.load(QtCore.QUrl(cfclient.module_path + "/resources/map.html"))
        view.loadFinished.connect(self.onLoadFinished)
        view.linkClicked.connect(QtGui.QDesktopServices.openUrl)

        self.map_layout.addWidget(view)

        self._reset_max_btn.clicked.connect(self._reset_max)

        # Connect the signals
        self._log_data_signal.connect(self._log_data_received)
        self._log_error_signal.connect(self._logging_error)