이유진

드론 좌표 이동

1 +import CoDrone
2 +from CoDrone.system import Direction
3 +
4 +
5 +def getPosition(drone):
6 + position = drone.get_opt_flow_position() # 상대좌표 (시작 0,0)
7 + height = drone.get_height() # 고
8 + print("x={} y={} z={}".format(position.X, position.Y, height)) # 단위(mm)
9 +
10 +
11 +def main():
12 + drone = CoDrone.CoDrone()
13 + drone.connect()
14 +
15 + drone.takeoff()
16 + getPosition(drone)
17 + drone.move(-5, 4, 0, 0) # move(roll 좌우, pitch 전후, yaw, throttle)
18 + # drone.go(Direction.FORWARD, 0.5)
19 + # print('forward')
20 + # getPosition(drone)
21 + # drone.go(Direction.LEFT, 1)
22 + # print('left')
23 + getPosition(drone)
24 + drone.hover(3)
25 + getPosition(drone)
26 + print('land')
27 + getPosition(drone)
28 + drone.land()
29 +
30 +
31 +if __name__ == '__main__':
32 + main()
33 +
34 +
35 +