-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathmain.py
More file actions
28 lines (21 loc) · 671 Bytes
/
main.py
File metadata and controls
28 lines (21 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import example_bp as bp
def main() -> None:
# Encode.
drone = bp.Drone()
drone.status = bp.DRONE_STATUS_RISING
drone.position.longitude = 2000
drone.position.latitude = 2000
drone.position.altitude = 1080
drone.flight.acceleration[0] = -1001
drone.power.is_charging = True
drone.propellers[0].direction = bp.ROTATING_DIRECTION_CLOCK_WISE
drone.pressure_sensor.pressures[0] = -11
drone.flight.pose.yaw = -10
s = drone.encode() # bytearray
# Decode
drone_new = bp.Drone()
drone_new.decode(s)
assert drone_new.status == drone.status
print(drone_new.to_json())
if __name__ == "__main__":
main()