sensor

고도 데이터 확인

1
from time import sleep
2
3
from e_drone.drone import *
4
from e_drone.protocol import *
5
6
7
def eventAltitude(altitude):
8
print("eventAltitude()")
9
print("- Temperature: {0:.3f}".format(altitude.temperature))
10
print("- Pressure: {0:.3f}".format(altitude.pressure))
11
print("- Altitude: {0:.3f}".format(altitude.altitude))
12
print("- Range Height: {0:.3f}".format(altitude.rangeHeight))
13
14
if __name__ == '__main__':
15
16
drone = Drone()
17
drone.open()
18
19
# 이벤트 핸들링 함수 등록
20
drone.setEventHandler(DataType.Altitude, eventAltitude)
21
22
# Altitude 정보 요청
23
drone.sendRequest(DeviceType.Drone, DataType.Altitude)
24
sleep(0.1)
25
26
drone.close()
Copied!

레인지 센서 확인

1
from time import sleep
2
3
from e_drone.drone import *
4
from e_drone.protocol import *
5
6
7
def eventRange(range):
8
print("eventRange()")
9
print("- left: {0:4d}" .format(range.left))
10
print("- front: {0:4d}" .format(range.front))
11
print("- right: {0:4d}" .format(range.right))
12
print("- bottom: {0:4d}" .format(range.bottom))
13
14
15
if __name__ == '__main__':
16
17
drone = Drone()
18
drone.open()
19
20
# 이벤트 핸들링 함수 등록
21
drone.setEventHandler(DataType.Range, eventRange)
22
23
# Range 정보 요청
24
drone.sendRequest(DeviceType.Drone, DataType.Range)
25
sleep(0.1)
26
27
drone.close()
28
Copied!

Motion 센서 데이터 확인

1
from time import sleep
2
3
from e_drone.drone import *
4
from e_drone.protocol import *
5
6
7
def eventMotion(motion):
8
print("eventMotion()")
9
print("- Accel: {0:5}, {1:5}, {2:5}".format(motion.accelX, motion.accelY, motion.accelZ))
10
print("- Gyro: {0:5}, {1:5}, {2:5}".format(motion.gyroRoll, motion.gyroPitch, motion.gyroYaw))
11
print("- Angle: {0:5}, {1:5}, {2:5}".format(motion.angleRoll, motion.anglePitch, motion.angleYaw))
12
13
14
if __name__ == '__main__':
15
16
drone = Drone()
17
drone.open()
18
19
# 이벤트 핸들링 함수 등록
20
drone.setEventHandler(DataType.Motion, eventMotion)
21
22
# Motion 정보 요청
23
drone.sendRequest(DeviceType.Drone, DataType.Motion)
24
sleep(0.1)
25
26
drone.close()
Copied!

자세 확인

1
from time import sleep
2
3
from e_drone.drone import *
4
from e_drone.protocol import *
5
6
7
def eventAttitude(attitude):
8
print("eventAttitude() / {0:0.1f}, {1:0.1f}, {2:0.1f}".format(attitude.roll, attitude.pitch, attitude.yaw))
9
10
11
if __name__ == '__main__':
12
13
drone = Drone()
14
drone.open()
15
16
# 이벤트 핸들링 함수 등록
17
drone.setEventHandler(DataType.Attitude, eventAttitude)
18
19
# Attitude 정보 요청
20
drone.sendRequest(DeviceType.Drone, DataType.Attitude)
21
sleep(0.1)
22
23
drone.close()
Copied!
Last modified 5d ago