Timm Murray

NAME

    UAV::Pilot::Wumpus::Server

SYNOPSIS

    my $backend = UAV::Pilot::Wumpus::Server::Backend::RaspberryPiI2C->new;
    my $server = UAV::Pilot::Wumpus::Server->new({
        backend => $backend,
        packet_callback => sub {
            my ($server, $packet) = @_;
            ...
        },
    });
    $server->start_listen_loop;

DESCRIPTION

A server for running the Wumpus. Listens on specified UDP port, defaulting to <UAV::Pilot::Wumpus-DEFAULT_PORT>>.

ATTRIBUTES

packet_callback

  new({
      ...
      packet_callback => sub {
          my ($server, $packet) = @_;
          ...
      },
  });

An optional callback function that will get every packet from the first StartupRequest onward. This will be called after the Backend has processed the packet.

It is passed the UAV::Pilot::Wumpus::Server object and the packet. The return value is ignored.

METHODS

start_listen_loop

Starts listening on the UDP port. Loops indefinitely.

process_packet

    process_packet( $packet )

Does the right thing with $packet (a UAV::Pilot::Wumpus::Packet object).

ch*_min() and ch*_max()

The channel min/max values that you can set. Channels are numbered 1 through 8.

Note that these are the min/max values that are input to the server. The values output by the backend is set by the backend.

PROTECTED METHODS

_set_ch*_min( $value ) and _set_ch*_max( $value )

Sets the raw min/max value for the associated channel number. Channels are numbered 1 through 8.

_map_value

    _map_value(
        $in_min, $in_max,
        $out_min, $out_max,
        $input,
    )

Given the input min/max settings, maps the input number to an equivalent output between the output min/max. For instance:

    $self->_map_value(
        0, 10,
        0, 30,
        5,
    );

Would return 15.

Note that this returns 0 if $in_max - $in_min == 0, which avoids a divide-by-zero error. This isn't correct behavior and will be fixed Soon(tm). The output min/max settings don't have this problem.

The primary use of this method is for backends to map the channel values held by the Server object into the output needed by the backend connection.

SETTING UP THE RASPBERRY PI CAMERA

On Raspbian, follow the instructions below for installing the Raspicam v4l driver:

http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=16