# sensor

### 고도 데이터 확인 <a href="#heading" id="heading"></a>

```python
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()
```

### 레인지 센서 확인 <a href="#heading" id="heading"></a>

```python
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 센서 데이터 확인 <a href="#heading-motion" id="heading-motion"></a>

```python
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()
```

### 자세 확인 <a href="#heading" id="heading"></a>

```python
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()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://robolink.gitbook.io/codrone-mini/codrone_lib/codrone_python_main/sensor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
