Sha256: a1da3cc19fa78bff14cdb8fc6023d2777d5b9d1f460743c8bbcb29fff33d18f1

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

require 'artoo/adaptors/adaptor'

module Artoo
  module Adaptors
    # This class connects to a ARDrone 2.0
    # @see http://rubydoc.info/gems/hybridgroup-argus/0.2.0/Argus/Drone Argus Drone Documentation
    class Ardrone < Adaptor
      finalizer :finalize
      attr_reader :ardrone

      # Finalizes connection with ARDrone by landing and stopping the device
      def finalize
        if connected?
          ardrone.land
          ardrone.stop
        end
      end

      # Creates Argus Drone connection with device
      # @return [Boolean]
      def connect
        require 'argus' unless defined?(Argus)
        @ardrone = Argus::Drone.new(socket: connect_to_udp, host: port.host, port: port.port)
        super
      end

      # Disconnects device by stopping it and ending connection
      # @return [Boolean]
      def disconnect
        ardrone.stop
        super
      end

      # Calls ardrone actions using method missing
      # @see https://github.com/hybridgroup/argus/blob/master/lib/argus/drone.rb hybridgroup-argus Drone
      def method_missing(method_name, *arguments, &block)
        ardrone.send(method_name, *arguments, &block)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
artoo-ardrone-1.1.0 lib/artoo/adaptors/ardrone.rb
artoo-ardrone-1.0.3 lib/artoo/adaptors/ardrone.rb