< >
Home » LOCO定位系统入门教程 » LOCO定位系统入门教程-在仿真环境下改变crazyflie led灯的颜色

LOCO定位系统入门教程-在仿真环境下改变crazyflie led灯的颜色

说明:

  • 介绍在仿真环境下两只crazyflie同时起飞,led灯的颜色时刻变化

步骤:

  • 进入目录
cd ~/crazyswarm/ros_ws/src/crazyswarm/scripts
  • 执行脚本文件
 python3 led_colors.py --sim
  • 代码如下
#!/usr/bin/env python

import numpy as np

from pycrazyswarm import *
import uav_trajectory

if __name__ == "__main__":
    swarm = Crazyswarm()
    timeHelper = swarm.timeHelper
    allcfs = swarm.allcfs

    # Configure the CFs so that the LED ring displays the solid color.
    # Overrides the launch file and the firmware default.
    for cf in allcfs.crazyflies:
        cf.setParam("ring/effect", 7)

    # Generate all possible on/off rgb values.
    rgb_bits = [tuple((x >> k) & 0x1 for k in range(3)) for x in range(8)]

    allcfs.takeoff(targetHeight=1.0, duration=2.0)
    timeHelper.sleep(2.5)

    TRIALS = 1
    for i in range(TRIALS):
        for rgb in rgb_bits:
            for cf in allcfs.crazyflies:
                cf.setLEDColor(*rgb)
            timeHelper.sleep(1.0)
  • 两只飞机同时起飞,crazyflie led灯的颜色时刻变化着

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: loco定位系统入门教程