Monthly Archives: July 2020

Crazyflie firmware(2)-Commander Framework

The Commander module 具体在crazyflie firmware的代码参考src/modules/src/commander.c。Crazyflie无人机的setpoints可以 set directly set by a python script using 电脑端的cflib/ cfclientor 手机端的app layer(下图中的蓝色blue pathways) set by the high-level commander module (下图中的紫色pathway) 上图中可以发现,High-level commander可以can be controlled remotely from the python library(从off-board的手机或者电脑端) or from inside the Crazyflie(从onboard的firmware)。 需要指出的是, the commander module会检查上一次接收到的setpoint是多久以前。如果很长时间(时长有常量COMMANDER_WDT_TIMEOUT_STABILIZE定义在commander.c)没有收到新的setpoint,那么就会把参考姿态角设置为0,以防止飞机失控。如果等了超过COMMANDER_WDT_TIMEOUT_SHUTDOWN的时间,那么a null setpoint就会给出,使得无人机关掉电机并着陆。如果你使用的是high level commander,以上的事情不会发生。 Setpoint structure setpoint的数据结构是定义在crazyflie firmware上的src/modules/interface/stabilizer_types.h中的变量setpoint_t。 有2层需要去控制,即 Position(X,Y,Z) Attitude(pitch, roll, yaw or…

Read More

Crazyflie firmware(4)-Controller

有了state estimation, Crazyflie就知道了 where it is,那么我们接下来要知道where it wants to go,这可以通过high level commander(作为crazyswarm project的部分实现)或者set-points(由地面站上的CFclient 给出)或者直接from scripts using Crazyflie python lib。具体关于Crazyflie无人机的动力学,可以参考Demystifying Drone Dynamics!。 针对Crazyflie的控制器,可以有多种,如下图: Cascaded PID controller 在Crazyflie的firmware上默认的控制器就是PID,上图中的第一个。 INDI Controller INDI控制器是 Incremental Nonlinear Dynamic Inversion控制器的缩写。这是一个很新的addition to the Crazyflie firmware。它是基于2016年发表于AIAA的Journal of Guidance, Control, and Dynamics的文章Adaptive incremental nonlinear dynamic inversion for attitude control of micro air vehicles而实现的。其中position controller还是和第一个Cascaded PID controller的一样。我们还没有完全test it…

Read More

Crazyflie firmware(3)-State estimation

在Crazyflie上有两种类型的state estimators: Complementary Filter Extended Kalman Filter Complementary Filter(CF) 该CF最初的输入为IMU上的gyroscope(测量角速度)和accelerator, 后面增加了 Zranger deck(The Z-ranger deck v2 uses a laser sensor to measure the distance to the ground and adds the possibility to fly with precise height control)测量的ToF distance(Time-of-Flight)。滤波器的输出为Crazyflie的姿态角(roll, pitch, yaw)和高度(Z轴的Altitude)。滤波器的输出可以供controller用,也用于manual control(手动操控飞行)。如果你对具体的代码实现感兴趣,可以去参看firmware上的两个C文件:estimator_complementary.c 以及sensfusion6.c。该complementary filter 为Crazyflie firmware上默认的state estimator。下图给出了该滤波器的架构。 Extended Kalman Filter 该滤波器比默认的complementary filter更加复杂,因为它可以接受更多的sensor inputs,both internal与external sensors。具体详细关于EKF,可以参考ETH的课程。 我们偏爱Kalman filter in…

Read More

Crazyflie firmware(1)-Position control

我们一直努力试图为Crazyflie 2.0开发a local positioning system, 我们现在完成了主要的两步:(1)improve the stabilizer code architecture, (2)move the position control code into the firmware.  从an external system获取position, 但是为了控制Crazyflie在desired position,我们依然需要去控制pitch, roll and yaw。之前,我们一直在an external computer(即在Crazyflie之外)跑控制算法,但是现在我们可以将该控制算法移到the Crazyflie itself上跑。该控制算法是一个简单的PID控制器,并且还可以继续改善,这项工作的主要目的是improve the architecture in this area。我们还没有在firmware上实现estimation of the position,但是现在这个architecture可以支持开发者进行该implementation。 我们的整体架构architecture如下: 上图架构中的Crazyflie上的sensors(传感器)有gyroscope, accelerometer and pressure sensor。我们未来可以加入更多,例如 position和altitude的测量 。 上图架构中的state estimator(状态估计器)利用传感器的测量值,尽可能准确地估计Crazyflie的状态。状态包括Crazyflie的姿态角 (roll, pitch, yaw), position和speed。 目前我们的state estimator有针对姿态角和高度。在不久的将来,将会估计完整的position。 上图架构中的commander会给出让Crazyflie跟踪的setpoint。目前是通过Crazyradio或者bluetooth从地面站上的CFclient对Crazyflie发送commander…

Read More