< >
Home » LOCO定位系统入门教程 » LOCO定位系统入门教程-在仿真环境下crazyflie飞行设置的航点

LOCO定位系统入门教程-在仿真环境下crazyflie飞行设置的航点

说明:

  • 介绍在仿真环境下crazyflie飞行设置的航点

步骤:

  • 进入目录
cd ~/crazyswarm/ros_ws/src/crazyswarm/scripts
  • 执行脚本文件
python3 waypoints_simple.py --sim
  • 代码如下
"""Single CF: takeoff, follow absolute-coords waypoints, land."""

import numpy as np

from pycrazyswarm import Crazyswarm


Z = 1.0
TAKEOFF_DURATION = 2.5
GOTO_DURATION = 3.0
WAYPOINTS = np.array([
    (1.0, 0.0, Z),
    (1.0, 1.0, Z),
    (0.0, 1.0, Z),
    (0.0, 0.0, Z),
])


def main():
    swarm = Crazyswarm()
    timeHelper = swarm.timeHelper
    cf = swarm.allcfs.crazyflies[0]

    cf.takeoff(targetHeight=Z, duration=TAKEOFF_DURATION)
    timeHelper.sleep(TAKEOFF_DURATION + 1.0)

    for p in WAYPOINTS:
        cf.goTo(cf.initialPosition + p, yaw=0.0, duration=GOTO_DURATION)
        timeHelper.sleep(GOTO_DURATION + 1.0)

    cf.land(targetHeight=0.05, duration=TAKEOFF_DURATION)
    timeHelper.sleep(TAKEOFF_DURATION + 1.0)


if __name__ == "__main__":
    main()
  • 一只crazyflie起飞后,飞去不同的航点,然后着陆

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

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


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