Skip to content

This repository provides the basic framework and considerations when trying to connect Crazyflie with Jevois or Raspberry Pi.

License

Notifications You must be signed in to change notification settings

Residualstress/Crazyflie_Jevois_RaspberryPi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crazyflie_Jevois_RaspberryPi

This repository is a few notes of caution when trying to connect Crazyflie with Jevois or Raspberry Pi. The main steps run on a Raspberry Pi with an operating system similar to Jevois. And the specification will be given when the steps turn to different on Jevois.

Platform

  1. Crazyflie 2.0 and Crazyflie Bolt
  2. Jevois-A33
  3. Raspberry Pi 4

UART communication

Overall, the UART connection can be established by referring to this tutorial. However, there are still a lot of things to keep in mind and will be described below.

Building and flashing on Crazyflie

Building and flashing are used several times during the configuration of the connection. This official document can be used as a reference. In response to it, here are a few suggestions:

  1. Among three ways, using the ARM tool chain is recommded for simple installation and faster compilation speed.

  2. To build the firmware on crazyflie Bolt, you will need to configure it by

    make bolt_defconfig
    

    Or using kbuild

    make menuconfig
    

    In Platform configuration-> Platform to build-> Build for Bolt. image

  3. To compile in App layer, both "make bolt_defconfig" and "make menuconfig" will faile. So you need to add parametes in app-config. For example, in crazyflie-firmware/examples/app_hello_world/app-config:

    CONFIG_ENABLE_CPX = y
    CONFIG_ENABLE_CPX_ON_UART2 = y
    CONFIG_CPX_UART2_BAUDRATE = 115200
    CONFIG_DECK_FORCE = "cpxOverUART2"
    CONFIG_DECK_CPX_HOST_ON_UART2 = y
    

    image You also can find the revised example cfg file in this repository Crazyflie_Jevois_RaspberryPi/Crazyflie/app_stm_jevois_cpx/app-config

Pyserial configuration

When you use with SyncCrazyflie(URI) as scf: to connect with Crazyflie, It will check if the list returned by serial.tools.list_ports contains the URI. However, on both Jevois and Raspberry pi, when you use python3 -m serial.tools.list_ports -v to look at the ports, pyserial filters out the ttysS0 port. The reason is clearly stated under this topic. And you also could check this discussion in Crazyflie repository which gives a complete description of the cause and solution of the error. Please remeber to reinstall Pyserial after you change its' source code.

Crazyflie-lib-python

This is a python library to communicate with Crazyflie. WHen you run SyncCrazyflie(URI) as scf: in this tutorial. It will call the self.cpx = CPX(UARTTransport(device, 576000)) with the default baudrate of 576000. This baudrate can not change automatically. So if you modify baudrated fo the UART, you should manually replace 576000 here. Otherwise, the scripy will hang at SyncCrazyflie(URI) as scf: with information printed on the command line Connecting to UART on /dev/ttyS0 @ 576000. Please remeber to reinstall Crazyflie-lib-python after you change its' source code.

Python package installation on Jevois

Python package installation is difficult on Jevois because it is a embedded offline system. For basic python package installation, you can refer to this tuotorial. Except from intalling by .whl file, we also can download the source code from packages' github repository and install it by typing !python pip install /jevois/packages/pyesrial/ or !python /jevois/packages/pyesrial/setup.py in the console of JeVois.All above methods are only workable on only pure-python packages with no compiled dependencies. The reason are explained here.

!pip install --upgrade --no-index --no-build-isolation /jevois/packages/libusb-package-main/libusb-package-main try no-build-isolation to install libusb.

Note: Since the default time of jevois is in 1970, we need to change the system time to the present before installing the package with this command date 040815242024 in the console of JeVois. date 040815242024 means on 8 April 2024 at 3.15 p.m.

For the installation of Crazyflie-lib-python, I didn't install it in a right way because the cross-compile is too difficult for me to conduct. Since we only will use the source code related to the CPX in Crazyflie-lib-python. So I run !python pip install /jevois/packages/cflib/ with revising the install_requires: in setup.py to delete the packages which are not purly written in Python.

Installing packages on jevois can be a long and painful process, as each package has requirements for other packages, so you need to satisfy all of them one by one! Usually, it will take the whole day to equiped your Jevois with the packages you need.

CPX in Raspberry Pi

We use The Crazyflie Packet eXchange protocol (CPX) to enable communications between Crazyflie 2.0 and the host. Here is the example on Raspberry PI and Crazyflie 2.0. We will use this two scripts to complete the work that ]Raspberry Pi send the frame number](https://github.com/Residualstress/Crazyflie_Jevois_RaspberryPi/blob/main/Raspberry%20Pi/Pi_to_Crazyflie.py) and Crazyflie will receive and print it.

CPX in Jevois

The script run on Crazyflie to receive data from Jevois is same as above Crazyflie will receive and print it.

The script used in Jevois to send data to Crazyflie is in Crazyflie_Jevois_RaspberryPi/Crazyflie/app_stm_jevois_cpx/stm_jevois_cpx.c. Because Jevois will processNoUSB() is called on every frame, it will run something we can't see between two frames, i.e., after one frame and before the later frame. I have tested many times that if we do not add elf.SerialSend.reset_output_buffer() at the beginning of processNoUSB, the crazyflie always recieved only the first number [1] and report the UART error. It's just like Jevois write something into the buffer. But we cann't see that even if I use jevois.LINFO('buff is {}'.format(buff)) to show every buffers, results shown that they are totaly same.

And the /jevois/config/initscript.cfg and /jevois/config/params.cfg is also need to be revised to enable PythonTest module run in Headless mode.

In the end, You have to pay special attention to the format of the packet when transferring data to crazyflie. It must perfectly match crazyflie's requirements. Otherwise, once the crazyflie receives a packet that fails to meet the requirements, it will report an error : 8afb19ab04403d5a2bc122aa1d13acc

Sometimes the problem is not from the data, it's the underlying jevois program that's sending some data to crazyflie, so you need to keep a tight rein on jevois's port outputs, as well as other related outputs. You can run setpar serout None in the console of JeVois or add lines in /jevois/config/initscript.cfg.

About

This repository provides the basic framework and considerations when trying to connect Crazyflie with Jevois or Raspberry Pi.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published