postlog
Drivers

Driver for storing log data into PostgreSQL database. More...

Driver for storing log data into PostgreSQL database.

The postlog driver is for storing log data into given tables of given PostgreSQL database.

Compile-time dependencies

- libpqxx

Provides

- log : can be used to turn logging on/off
- (optional) list of devices to provide (see "Configuration file options" below)

Requires

- list of devices to subscribe (see "Configuration file options" below) (can be empty only if there are provided interfaces for logging commands)

Configuration requests

- PLAYER_LOG_REQ_SET_WRITE_STATE
- PLAYER_LOG_REQ_GET_STATE

Configuration file options

- tables (string tuple)
  - Default: empty tuple
  - Names of tables in the database, data (or commands) obtained from each subscribed/provided device will be written into given table; these names are also used as key names for distinguishing devices in 'Requires' and 'Provides' lists.
- init_state (integer)
  - Default: 1
  - Initial write state (1 - ON, 0 - OFF).
  - Write state can be changed by PLAYER_LOG_REQ_SET_WRITE_STATE request.
- wait_for_all
  - Default: 0
  - If set to non-zero, this driver will be waiting for complete set of data and commands, it means that data (and commands) will be stored right after receiving them from all provided and subscribed interfaces; data or commands from one interface received more frequently will be dropped.
  - Devices that send many subtypes of data to one subscribed interface may make confusions here.
- dbname (string)
  - Default: "postlog"
  - The name of the Postgresql database to connect to.
- host (string)
  - Default: "127.0.0.1"
  - The name of the database host.
- user (string)
  - Default: "postgres"
  - The name of the database user.
- port (string)
  - Default: "5432"
  - The port of the database.
- password (string)
  - Default: ""
  - The password for the database user.
- sequence (string)
  - Default: "postlog_seq"
  - Sequence name for primary keys (see "database prerequisites").

Database prerequisites

Before using this driver, you need to have database created in your PostgreSQL server. You can create it using UNIX shell by typing such command:

createdb postlog

('postlog' is example database name; depending on database server policies, you may be asked for database user password after entering this; if you do not have database user account, ask database administrator to create one for you).

Then you can enter database shell by typing such command:

psql postlog

Now you can enter SQL commands. First you need to create incremental sequence that will be used as primary key ('postlog_seq' is example sequence name):

CREATE SEQUENCE postlog_seq START 1 INCREMENT 1 MINVALUE 1;

Then you have to create table for each subscribed (or provided) device. Although record structure for each table depends on interface type, first fields are common for each table:

id INT4 PRIMARY KEY, index INT2 NOT NULL, unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL

Additionally, you can add PostgreSQL date and time fields that will be filled automatically:

date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4)

Time from four different sources (system clock, data header, Player global clock, SQL server clock) will give you whole image of this infrastructure time dependencies.

Currently supported interfaces are:

- position1d
  - for commands: CREATE TABLE table1 ( id INT4 PRIMARY KEY, index INT2 NOT NULL, date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4), unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL, state BOOLEAN DEFAULT NULL, pos DOUBLE PRECISION DEFAULT NULL, vel DOUBLE PRECISION DEFAULT NULL );
  - for data: CREATE TABLE table1 ( id INT4 PRIMARY KEY, index INT2 NOT NULL, date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4), unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL, pos DOUBLE PRECISION DEFAULT NULL, vel DOUBLE PRECISION DEFAULT NULL, stall BOOLEAN DEFAULT NULL, status INTEGER DEFAULT NULL );
- position2d
  - for commands: CREATE TABLE table1 ( id INT4 PRIMARY KEY, index INT2 NOT NULL, date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4), unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL, state BOOLEAN DEFAULT NULL, px DOUBLE PRECISION DEFAULT NULL, py DOUBLE PRECISION DEFAULT NULL, pa DOUBLE PRECISION DEFAULT NULL, vx DOUBLE PRECISION DEFAULT NULL, vy DOUBLE PRECISION DEFAULT NULL, va DOUBLE PRECISION DEFAULT NULL, velocity DOUBLE PRECISION DEFAULT NULL, angle DOUBLE PRECISION DEFAULT NULL );
  - for data: CREATE TABLE table1 ( id INT4 PRIMARY KEY, index INT2 NOT NULL, date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4), unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL, px DOUBLE PRECISION DEFAULT NULL, py DOUBLE PRECISION DEFAULT NULL, pa DOUBLE PRECISION DEFAULT NULL, vx DOUBLE PRECISION DEFAULT NULL, vy DOUBLE PRECISION DEFAULT NULL, va DOUBLE PRECISION DEFAULT NULL, stall BOOLEAN DEFAULT NULL );
- position3d
  - for commands: CREATE TABLE table1 ( id INT4 PRIMARY KEY, index INT2 NOT NULL, date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4), unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL, state BOOLEAN DEFAULT NULL, px DOUBLE PRECISION DEFAULT NULL, py DOUBLE PRECISION DEFAULT NULL, pz DOUBLE PRECISION DEFAULT NULL, proll DOUBLE PRECISION DEFAULT NULL, ppitch DOUBLE PRECISION DEFAULT NULL, pyaw DOUBLE PRECISION DEFAULT NULL, vx DOUBLE PRECISION DEFAULT NULL, vy DOUBLE PRECISION DEFAULT NULL, vz DOUBLE PRECISION DEFAULT NULL, vroll DOUBLE PRECISION DEFAULT NULL, vpitch DOUBLE PRECISION DEFAULT NULL, vyaw DOUBLE PRECISION DEFAULT NULL );
  - for data: CREATE TABLE table1 ( id INT4 PRIMARY KEY, index INT2 NOT NULL, date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4), unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL, px DOUBLE PRECISION DEFAULT NULL, py DOUBLE PRECISION DEFAULT NULL, pz DOUBLE PRECISION DEFAULT NULL, proll DOUBLE PRECISION DEFAULT NULL, ppitch DOUBLE PRECISION DEFAULT NULL, pyaw DOUBLE PRECISION DEFAULT NULL, vx DOUBLE PRECISION DEFAULT NULL, vy DOUBLE PRECISION DEFAULT NULL, vz DOUBLE PRECISION DEFAULT NULL, vroll DOUBLE PRECISION DEFAULT NULL, vpitch DOUBLE PRECISION DEFAULT NULL, vyaw DOUBLE PRECISION DEFAULT NULL, stall BOOLEAN DEFAULT NULL );
- aio
  - for commands: CREATE TABLE table1 ( id INT4 PRIMARY KEY, index INT2 NOT NULL, date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4), unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL, io_id INTEGER DEFAULT NULL, voltage DOUBLE PRECISION DEFAULT NULL );
  - for data: CREATE TABLE table1 ( id INT4 PRIMARY KEY, index INT2 NOT NULL, date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4), unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL, count INTEGER NOT NULL, v0 DOUBLE PRECISION DEFAULT NULL, v1 DOUBLE PRECISION DEFAULT NULL, ... ); Add as many v* fields as needed.
- bumper
  - for data: CREATE TABLE table1 ( id INT4 PRIMARY KEY, index INT2 NOT NULL, date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4), unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL, count INTEGER NOT NULL, bumper0 BOOLEAN DEFAULT NULL, bumper1 BOOLEAN DEFAULT NULL, ... ); Add as many bumper* fields as needed.
- dio
  - for both commands and data: CREATE TABLE table1 ( id INT4 PRIMARY KEY, index INT2 NOT NULL, date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4), unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL, count INTEGER DEFAULT NULL, d31 BOOLEAN DEFAULT NULL, d30 BOOLEAN DEFAULT NULL, d29 BOOLEAN DEFAULT NULL, d28 BOOLEAN DEFAULT NULL, d27 BOOLEAN DEFAULT NULL, d26 BOOLEAN DEFAULT NULL, d25 BOOLEAN DEFAULT NULL, d24 BOOLEAN DEFAULT NULL, d23 BOOLEAN DEFAULT NULL, d22 BOOLEAN DEFAULT NULL, d21 BOOLEAN DEFAULT NULL, d20 BOOLEAN DEFAULT NULL, d19 BOOLEAN DEFAULT NULL, d18 BOOLEAN DEFAULT NULL, d17 BOOLEAN DEFAULT NULL, d16 BOOLEAN DEFAULT NULL, d15 BOOLEAN DEFAULT NULL, d14 BOOLEAN DEFAULT NULL, d13 BOOLEAN DEFAULT NULL, d12 BOOLEAN DEFAULT NULL, d11 BOOLEAN DEFAULT NULL, d10 BOOLEAN DEFAULT NULL, d9 BOOLEAN DEFAULT NULL, d8 BOOLEAN DEFAULT NULL, d7 BOOLEAN DEFAULT NULL, d6 BOOLEAN DEFAULT NULL, d5 BOOLEAN DEFAULT NULL, d4 BOOLEAN DEFAULT NULL, d3 BOOLEAN DEFAULT NULL, d2 BOOLEAN DEFAULT NULL, d1 BOOLEAN DEFAULT NULL, d0 BOOLEAN DEFAULT NULL ); The 'count' value here tells how many bits (starting from d0 on the right) were actually set by sender.
- gripper
  - for commands: CREATE TABLE table1 ( id INT4 PRIMARY KEY, index INT2 NOT NULL, date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4), unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL );
  - for data: CREATE TABLE table1 ( id INT4 PRIMARY KEY, index INT2 NOT NULL, date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4), unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL, state INTEGER DEFAULT NULL, beams INTEGER DEFAULT NULL, stored INTEGER DEFAULT NULL );
- ptz
  - for commands: CREATE TABLE table1 ( id INT4 PRIMARY KEY, index INT2 NOT NULL, date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4), unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL, pan DOUBLE PRECISION DEFAULT NULL, tilt DOUBLE PRECISION DEFAULT NULL, zoom DOUBLE PRECISION DEFAULT NULL, panspeed DOUBLE PRECISION DEFAULT NULL, tiltspeed DOUBLE PRECISION DEFAULT NULL );
  - for data: CREATE TABLE table1 ( id INT4 PRIMARY KEY, index INT2 NOT NULL, date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4), unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL, pan DOUBLE PRECISION DEFAULT NULL, tilt DOUBLE PRECISION DEFAULT NULL, zoom DOUBLE PRECISION DEFAULT NULL, panspeed DOUBLE PRECISION DEFAULT NULL, tiltspeed DOUBLE PRECISION DEFAULT NULL, status INTEGER DEFAULT NULL );
- ranger
  - for data: CREATE TABLE table1 ( id INT4 PRIMARY KEY, index INT2 NOT NULL, date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4), unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL, count INTEGER DEFAULT NULL, r0 DOUBLE PRECISION DEFAULT NULL, r1 DOUBLE PRECISION DEFAULT NULL, ... ); Add as many r* fields as needed.
- speech
  - for commands: CREATE TABLE table1 ( id INT4 PRIMARY KEY, index INT2 NOT NULL, date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4), unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL, string_count INTEGER DEFAULT NULL, phrase VARCHAR(....) DEFAULT NULL ); Set the maximal lenght of the phraze as needed (in VARCHAR parenthesis). The 'string_count' value tells what is the actual length of the phraze.

Example

    driver
    (
      name "postlog"
      tables ["table1" "table2"]
      requires ["table1::6665:position2d:0"]
      provides ["log:0" "table2:::position2d:10"]
      wait_for_all 1
      alwayson 1
    )
    driver
    (
      name "cmdsplitter"
      provides ["position2d:0"]
      devices 2
      requires ["1::6665:position2d:0" "0:::position2d:10"]
    )

This is not a threaded driver, it is good idea to keep it in separate Player instance.

Author
  Paul Osmialowski

Last updated 12 September 2005 21:38:45