Module player

The player module is a high-level Erlang abstraction module, providing basic robot's functions.

Authors: Sten Gruener.

Description

The player module is a high-level Erlang abstraction module, providing basic robot's functions. This module should be suitable for students, who want to start playing with KERL without worrying about server PIDs and KERL's architecture. It is supposed, that the low-level modules are going to be used after the provided functionality of the player module is not longer satisfying the user.
Originally the functionality was provided by module itself but, now it uses the low-level modules. This naive module can only control 1 robot per process. Please note that most of the movement functions are artificially made blocking in the player module.

Data Types

movemode()

movemode() = full | position | difference | distance | speed

movevalue()

movevalue() = {float(), float()} | {float(), float(), float()} | float()

rotationmode()

rotationmode() = degrees | speed

Function Index

destroy/0Destroys the initialized robot.
get_pid/0Extracts the cached pid in order to be used in low-level functions.
get_position/0Returns the current odometrical (inner rotation sensor) position of the robot.
init/2Shortest signature localhost and default port 6665 are used.
init/4A sorter signature allowing not to specify the nickname.
init/5This is the more rich signature of the init function allowing to specify both the hostname, ip and the port of the player server as well as the robot's nickname.
move/2The basic movement function.
results/1This function gets the results of selected device, for device list please consult the documentation of the dvh module.
rotate/2The basic rotation function.
set_option/2This function sets the options of the C driver.
start/0Starts the server.
stop/0stops a moving robot.

Function Details

destroy/0

destroy() -> ok | {error, atom()}

Destroys the initialized robot.

get_pid/0

get_pid() -> pid() | {errot, atom}

Extracts the cached pid in order to be used in low-level functions. Should be only used if more functions are needed, then player module can provide.

get_position/0

get_position() -> {X, Y, A} | {error, atom()}

Returns the current odometrical (inner rotation sensor) position of the robot. This position is local (every robot starts at (0,0,0)) and with some measurement errors due to the nature of the sensors.

Note: A is in radiants, from 0 to 2*Pi.

init/2

init(Driverpid::pid(), Id::integer()) -> ok | {error, atom()}

Shortest signature localhost and default port 6665 are used.

init/4

init(Driverpid::pid(), Hostname::string(), Port::integer(), Id::integer()) -> ok | {error, atom()}

A sorter signature allowing not to specify the nickname.

init/5

init(Driverpid::pid(), Hostname::string(), Port::integer(), Id::integer(), Nickname::string()) -> ok | {error, atom()}

This is the more rich signature of the init function allowing to specify both the hostname, ip and the port of the player server as well as the robot's nickname.

move/2

move(Type::movemode(), Value::movevalue()) -> ok | {error, atom}

The basic movement function. Supports a varriaty of arguments.
Arguments:

results/1

results(Device::atom()) -> {[float()], [float()]} | {error, atom}

This function gets the results of selected device, for device list please consult the documentation of the dvh module.

rotate/2

rotate(Type::rotationmode(), Value::float()) -> ok | {error, atom}

The basic rotation function. Allows to rotate for a certain amount of degrees or just with a certain speed. Positive value means mathematically positive rotation - counter clockwise. Rotating for degrees will block until robot stops.

set_option/2

set_option(Option::atom(), Value::any()) -> ok | {error, atom}

This function sets the options of the C driver.

start/0

start() -> pid() | {error, atom()}

Starts the server. Usually the first commant to run. Returns the pid to the server to allow communication to the driver.

stop/0

stop() -> ok

stops a moving robot.


Generated by EDoc, Aug 13 2009, 23:20:23.