mirror of
https://github.com/okalachev/flix.git
synced 2026-03-29 19:43:31 +00:00
Compare commits
5 Commits
838fe11f6b
...
c08c8ad91c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c08c8ad91c | ||
|
|
e44f32fca7 | ||
|
|
ca03bdb260 | ||
|
|
b3dffe99fb | ||
|
|
6e6a71fa69 |
@@ -35,4 +35,3 @@ Do the following:
|
||||
* **Calibrate the RC** if you use it. Type `cr` command in Serial Monitor and follow the instructions.
|
||||
* **Check the RC data** if you use it. Use `rc` command, `Control` should show correct values between -1 and 1, and between 0 and 1 for the throttle.
|
||||
* **Check the IMU output using QGroundControl**. Connect to the drone using QGroundControl on your computer. Go to the *Analyze* tab, *MAVLINK Inspector*. Plot the data from the `SCALED_IMU` message. The gyroscope and accelerometer data should change according to the drone movement.
|
||||
* **Check the gyroscope only attitude estimation**. Comment out `applyAcc();` line in `estimate.ino` and check if the attitude estimation in QGroundControl. It should be stable, but only drift very slowly.
|
||||
|
||||
@@ -59,6 +59,13 @@ flix.on('disconnected', lambda: print('Disconnected from Flix'))
|
||||
flix.on('print', lambda text: print(f'Flix says: {text}'))
|
||||
```
|
||||
|
||||
Unsubscribe from events using `off` method:
|
||||
|
||||
```python
|
||||
flix.off('print') # unsubscribe from print events
|
||||
flix.off(callback) # unsubscribe specific callback
|
||||
```
|
||||
|
||||
You can also wait for specific events using `wait` method. This method returns the data associated with the event:
|
||||
|
||||
```python
|
||||
|
||||
@@ -87,10 +87,15 @@ class Flix:
|
||||
self._event_listeners[event] = []
|
||||
self._event_listeners[event].append(callback)
|
||||
|
||||
def off(self, callback: Callable):
|
||||
for event in self._event_listeners:
|
||||
if callback in self._event_listeners[event]:
|
||||
self._event_listeners[event].remove(callback)
|
||||
def off(self, event_or_callback: Union[str, Callable]):
|
||||
if isinstance(event_or_callback, str):
|
||||
event = event_or_callback.lower()
|
||||
if event in self._event_listeners:
|
||||
del self._event_listeners[event]
|
||||
else:
|
||||
for event in self._event_listeners:
|
||||
if event_or_callback in self._event_listeners[event]:
|
||||
self._event_listeners[event].remove(event_or_callback)
|
||||
|
||||
def _trigger(self, event: str, *args):
|
||||
event = event.lower()
|
||||
@@ -365,7 +370,9 @@ class Flix:
|
||||
self.mavlink.serial_control_send(0, 0, 0, 0, len(cmd_bytes), cmd_bytes)
|
||||
if not wait_response:
|
||||
return ''
|
||||
response = self.wait('print_full', timeout=0.1, value=lambda text: text.startswith(response_prefix))
|
||||
timeout = 0.1
|
||||
if cmd == 'log': timeout = 10 # log download may take more time
|
||||
response = self.wait('print_full', timeout=timeout, value=lambda text: text.startswith(response_prefix))
|
||||
return response[len(response_prefix):].strip()
|
||||
except TimeoutError:
|
||||
continue
|
||||
|
||||
@@ -24,13 +24,16 @@ def main():
|
||||
if addr in TARGETS: # packet from target
|
||||
if source_addr is None:
|
||||
continue
|
||||
sock.sendto(data, source_addr)
|
||||
try:
|
||||
sock.sendto(data, source_addr)
|
||||
packets += 1
|
||||
except: pass
|
||||
else: # packet from source
|
||||
source_addr = addr
|
||||
for target in TARGETS:
|
||||
sock.sendto(data, target)
|
||||
packets += 1
|
||||
|
||||
packets += 1
|
||||
print(f'\rPackets: {packets}', end='')
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "pyflix"
|
||||
version = "0.8"
|
||||
version = "0.9"
|
||||
description = "Python API for Flix drone"
|
||||
authors = [{ name="Oleg Kalachev", email="okalachev@gmail.com" }]
|
||||
license = "MIT"
|
||||
|
||||
Reference in New Issue
Block a user