Example #1
0
 def _connect(self):
     self.at_client = ATClient(self.host, self.at_port)
     self.navdata_client = NavDataClient(self.host, self.navdata_port)
     self.at_client.connect()
     self.navdata_client.connect()
Example #2
0
 def _connect(self):
     self.at_client = ATClient(self.host, self.at_port)
     self.navdata_client = NavDataClient(self.host, self.navdata_port)
     self.at_client.connect()
     self.navdata_client.connect()
Example #3
0
class ARDroneBase(BaseClient):
    def __init__(self,
                 *,
                 host='192.168.1.1',
                 at_port=5556,
                 navdata_port=5554,
                 video_port=5555,
                 watchdog_interval=0.5,
                 timeout=0.01,
                 bind=True,
                 connect=True):
        self.host = host
        self.at_port = at_port
        self.navdata_port = navdata_port
        self.video_port = video_port
        self.watchdog_interval = watchdog_interval
        self.timeout = timeout
        self.bind = bind

        if connect:
            self.connect()

    @property
    def navdata(self):
        return self.navdata_client.navdata

    @property
    def state(self):
        '''
        The latest state from :py:class:`~pyardrone.navdata.NavData`.

            >>> drone.state.fly_mask
            True  # drone is flying
            >>> drone.state.video
            True  # video is enabled

        See :py:class:`~pyardrone.navdata.states.DroneState`
        for the full list of states.
        '''
        return DroneState(self.navdata.metadata.state)

    @property
    def navdata_ready(self):
        return self.navdata_client.navdata_ready

    def send(self, command):
        '''
        :param ~pyardrone.at.base.ATCommand command: command to send

        Sends the command to the drone,
        with an internal increasing sequence number.
        this method is thread-safe.
        '''
        self.at_client.send(command)

    def _connect(self):
        self.at_client = ATClient(self.host, self.at_port)
        self.navdata_client = NavDataClient(self.host, self.navdata_port)
        self.at_client.connect()
        self.navdata_client.connect()

    def _close(self):
        self.at_client.close()
        self.navdata_client.close()
Example #4
0
class ARDroneBase(BaseClient):

    def __init__(
        self,
        *,
        host='192.168.1.1',
        at_port=5556,
        navdata_port=5554,
        video_port=5555,
        watchdog_interval=0.5,
        timeout=0.01,
        bind=True,
        connect=True
    ):
        self.host = host
        self.at_port = at_port
        self.navdata_port = navdata_port
        self.video_port = video_port
        self.watchdog_interval = watchdog_interval
        self.timeout = timeout
        self.bind = bind

        if connect:
            self.connect()

    @property
    def navdata(self):
        return self.navdata_client.navdata

    @property
    def state(self):
        '''
        The latest state from :py:class:`~pyardrone.navdata.NavData`.

            >>> drone.state.fly_mask
            True  # drone is flying
            >>> drone.state.video
            True  # video is enabled

        See :py:class:`~pyardrone.navdata.states.DroneState`
        for the full list of states.
        '''
        return DroneState(self.navdata.metadata.state)

    @property
    def navdata_ready(self):
        return self.navdata_client.navdata_ready

    def send(self, command):
        '''
        :param ~pyardrone.at.base.ATCommand command: command to send

        Sends the command to the drone,
        with an internal increasing sequence number.
        this method is thread-safe.
        '''
        self.at_client.send(command)

    def _connect(self):
        self.at_client = ATClient(self.host, self.at_port)
        self.navdata_client = NavDataClient(self.host, self.navdata_port)
        self.at_client.connect()
        self.navdata_client.connect()

    def _close(self):
        self.at_client.close()
        self.navdata_client.close()