sensor
κ³ λ λ°μ΄ν° νμΈ
from time import sleep
from e_drone.drone import *
from e_drone.protocol import *
def eventAltitude(altitude):
print("eventAltitude()")
print("- Temperature: {0:.3f}".format(altitude.temperature))
print("- Pressure: {0:.3f}".format(altitude.pressure))
print("- Altitude: {0:.3f}".format(altitude.altitude))
print("- Range Height: {0:.3f}".format(altitude.rangeHeight))
if __name__ == '__main__':
drone = Drone()
drone.open()
# μ΄λ²€νΈ νΈλ€λ§ ν¨μ λ±λ‘
drone.setEventHandler(DataType.Altitude, eventAltitude)
# Altitude μ 보 μμ²
drone.sendRequest(DeviceType.Drone, DataType.Altitude)
sleep(0.1)
drone.close()
λ μΈμ§ μΌμ νμΈ
from time import sleep
from e_drone.drone import *
from e_drone.protocol import *
def eventRange(range):
print("eventRange()")
print("- left: {0:4d}" .format(range.left))
print("- front: {0:4d}" .format(range.front))
print("- right: {0:4d}" .format(range.right))
print("- bottom: {0:4d}" .format(range.bottom))
if __name__ == '__main__':
drone = Drone()
drone.open()
# μ΄λ²€νΈ νΈλ€λ§ ν¨μ λ±λ‘
drone.setEventHandler(DataType.Range, eventRange)
# Range μ 보 μμ²
drone.sendRequest(DeviceType.Drone, DataType.Range)
sleep(0.1)
drone.close()
Motion μΌμ λ°μ΄ν° νμΈ
from time import sleep
from e_drone.drone import *
from e_drone.protocol import *
def eventMotion(motion):
print("eventMotion()")
print("- Accel: {0:5}, {1:5}, {2:5}".format(motion.accelX, motion.accelY, motion.accelZ))
print("- Gyro: {0:5}, {1:5}, {2:5}".format(motion.gyroRoll, motion.gyroPitch, motion.gyroYaw))
print("- Angle: {0:5}, {1:5}, {2:5}".format(motion.angleRoll, motion.anglePitch, motion.angleYaw))
if __name__ == '__main__':
drone = Drone()
drone.open()
# μ΄λ²€νΈ νΈλ€λ§ ν¨μ λ±λ‘
drone.setEventHandler(DataType.Motion, eventMotion)
# Motion μ 보 μμ²
drone.sendRequest(DeviceType.Drone, DataType.Motion)
sleep(0.1)
drone.close()
μμΈ νμΈ
from time import sleep
from e_drone.drone import *
from e_drone.protocol import *
def eventAttitude(attitude):
print("eventAttitude() / {0:0.1f}, {1:0.1f}, {2:0.1f}".format(attitude.roll, attitude.pitch, attitude.yaw))
if __name__ == '__main__':
drone = Drone()
drone.open()
# μ΄λ²€νΈ νΈλ€λ§ ν¨μ λ±λ‘
drone.setEventHandler(DataType.Attitude, eventAttitude)
# Attitude μ 보 μμ²
drone.sendRequest(DeviceType.Drone, DataType.Attitude)
sleep(0.1)
drone.close()
Last updated