Struct smr

From Rsewiki
Revision as of 13:20, 29 September 2008 by Lvm (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The struct smr datatype collects all of the sensor commands and data used in the embedded communication systems built into Automation's Small Mobile Robots. The datatype should not be defined by C programmers, it is already provided in a system header file. Programs should not rely on the exact layout of the struct, but they can (and should!) rely on the existence of the fields documented here.


Input/output data fields

 struct {              /* motor modules */
   uint16_t encoder;      /* position */
   int8_t speed;          /* command reference */
   int pwm;               /* motor voltage */
   int status;            /* error flags */
 } left, right;
 uint8_t ir[SMR_IR_N]; /* proximity module */
 uint8_t ls[SMR_LS_N]; /* line sensor */
 int ad[SMR_AD_N];     /* power supply analog inputs */
 int status;           /* power supply digital inputs */

The two fields, left and right, are themselves structs, they refer to the two motor modules. There are 3 input fields each:

  left.encoder right.encoder:   Position encoder: an unsigned 16 bit integer (0 .. 65535).
  left.pwm right.pwm:   Motor voltage: a signed integer.
  left.status right.status:   Motor status flags: a bitwise 'OR' of Encoder too fast=1, Motor blocked=2 and No encoder signal=4.

and one output field each:

  left.speed right.speed:   Motor speed command: a signed 8 bit integer (-128 .. 127).

Data from the line sensors and proximity detectors are stored in arrays:

  ls:   Line sensor data: array of (8) unsigned 8 bit integers.
  ir:   Proximity sensor data: array of (6) unsigned 8 bit integers.

The power supply module monitors five analog inputs and six digital inputs.

  ad:   Analog power supply inputs: array of (5) integers. adSMR_AD_BATTERY (ad0) is battery voltage, adSMR_AD_EXTERNAL (ad1) is external power input.
  status:   Digital power supply inputs: integer. Bit mask SMR_STATUS_POWER_ON (1) is main power switch.

Aynchronous message fields

 unsigned char msg[ENET_BYTES_MAX];
 void (*recv_hook)(struct smr *);

Sending and receiving asynchronous messages is achieved using a message buffer and an asynchronous receive function.

  msg:   Buffer for sending and receiving extra messages. Array of unsigned 8 bit integers.
  recv_hook:   Pointer to user's receive function. This function is called for each message received from smrd by smr_read().

Timing fields

 uint32_t tick;                /* sample number (10ms) */
 uint32_t ts;                  /* time stamp, cpu cycles (2ns) */

Programs can monitor timing using these fields.

  tick:   Smrd numbers samples consecutively. This tick count indicates how long smrd has been running, and can be used to see if any samples have been missed. Unsigned integer (rolls over after 497 days).
  ts:   Time when sample started, measured in CPU clock cycles, 2ns on a 500MHz processor. Unsigned integer (rolls over after 8.6 seconds).
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox