mirror of
https://github.com/okalachev/flix.git
synced 2026-06-28 05:56:44 +00:00
Implement battery voltage monitoring
Add power subsystem. Add PWR_VOLT_PIN, PWR_VOLT_SCALE, PWR_VOLT_LPF_A parameters. Support BATTERY_STATUS mavlink messages streaming. Add pw cli command. Add voltage field to pyflix library. pyflix@0.12.
This commit is contained in:
@@ -37,6 +37,7 @@ print(flix.connected) # True if connected to the drone
|
||||
print(flix.mode) # current flight mode (str)
|
||||
print(flix.armed) # True if the drone is armed
|
||||
print(flix.landed) # True if the drone is landed
|
||||
print(flix.voltage) # battery voltage
|
||||
print(flix.attitude) # attitude quaternion [w, x, y, z]
|
||||
print(flix.attitude_euler) # attitude as Euler angles [roll, pitch, yaw]
|
||||
print(flix.rates) # angular rates [roll_rate, pitch_rate, yaw_rate]
|
||||
@@ -95,6 +96,7 @@ Full list of events:
|
||||
|`armed`|Armed state update|Armed state *(bool)*|
|
||||
|`mode`|Flight mode update|Flight mode *(str)*|
|
||||
|`landed`|Landed state update|Landed state *(bool)*|
|
||||
|`voltage`|Battery voltage update|Voltage *(float)*|
|
||||
|`print`|The drone prints text to the console|Text|
|
||||
|`attitude`|Attitude update|Attitude quaternion *(list)*|
|
||||
|`attitude_euler`|Attitude update|Euler angles *(list)*|
|
||||
|
||||
@@ -26,6 +26,7 @@ class Flix:
|
||||
mode: str = ''
|
||||
armed: bool = False
|
||||
landed: bool = False
|
||||
voltage: float = 0
|
||||
attitude: List[float]
|
||||
attitude_euler: List[float] # roll, pitch, yaw
|
||||
rates: List[float]
|
||||
@@ -68,7 +69,7 @@ class Flix:
|
||||
self._heartbeat_thread.start()
|
||||
if wait_connection:
|
||||
self.wait('mavlink.HEARTBEAT')
|
||||
time.sleep(0.2) # give some time to receive initial state
|
||||
time.sleep(0.6) # give some time to receive initial state
|
||||
|
||||
def _init_state(self):
|
||||
self.attitude = [1, 0, 0, 0]
|
||||
@@ -190,6 +191,10 @@ class Flix:
|
||||
self._trigger('acc', self.acc)
|
||||
self._trigger('gyro', self.gyro)
|
||||
|
||||
if isinstance(msg, mavlink.MAVLink_battery_status_message):
|
||||
self.voltage = msg.voltages[0] / 1000
|
||||
self._trigger('voltage', self.voltage)
|
||||
|
||||
if isinstance(msg, mavlink.MAVLink_serial_control_message):
|
||||
# new chunk of data
|
||||
text = bytes(msg.data)[:msg.count].decode('utf-8', errors='ignore')
|
||||
|
||||
Reference in New Issue
Block a user