project:brmbot_outdoor:protocol
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
project:brmbot_outdoor:protocol [2011/04/28 19:54] – axtheb | project:brmbot_outdoor:protocol [2011/05/10 22:23] (current) – Remove D. joe | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
+ | ====== Basic Reusable Mechanics protocol ====== | ||
+ | |||
+ | //BRM protocol// | ||
+ | |||
+ | |||
+ | |||
+ | ===== Communication ===== | ||
+ | |||
+ | The protocol is used over serial (RS-232) or similar connections. | ||
+ | |||
+ | The basic element of the protocol is the '' | ||
+ | |||
+ | Each '' | ||
+ | In this document we refer to direction in the terms of who | ||
+ | is sending the message - with two possible sources: | ||
+ | |||
+ | * **uC** - microcontroller (typically Arduino or similar) of the chassis being controlled | ||
+ | * **SW** - controlling software (typically running on a PC) | ||
+ | |||
+ | ===== Message format ===== | ||
+ | |||
+ | Each message is a single line of text, ending with ' | ||
+ | |||
+ | Allowed are only ASCII printable characters. Actually used are only the characters | ||
+ | explicitly mentioned in any part of this specification. | ||
+ | |||
+ | Each message consists of fields. Each field is delimited by single space ' ' (0x20, space) character. | ||
+ | Fields are numbered from 0 (zero). Numbers in fields are in decimal notation unless specified otherwise. | ||
+ | |||
+ | There are mandatory and optional fields. | ||
+ | |||
+ | Mandatory fields are: | ||
+ | |||
+ | ^ Number ^ Name ^ Length ^ Description ^ | ||
+ | | 0 | MId | 2 | " | ||
+ | | 1 | Type | 1 | Specific type or command, must be uppercase letter. | | ||
+ | |||
+ | All other fields are optional. They could be mandatory for specific message type (see below). | ||
+ | |||
+ | |||
+ | ===== Messages listing ===== | ||
+ | |||
+ | ^ Type ^ SW ^ uC ^ Short description ^ | ||
+ | | C | 00 C | 00 C M:-99:99 M:0:99 S:0:10 | Capabilities | | ||
+ | | M | 00 M #1 #2 [#3 #4 ...] | 00 M OK | Run motor #1 at speed #2, motor #3 at #4 ... | | ||
+ | | S | 00 S #1 | 00 S #1 #2 | Get sensor #1 value, the value is #2 | | ||
+ | | A | --- | -2 A #1 [#2 ...] | Alert number #1, further fields depend on implementation | | ||
+ | | E | 00 E #1 [0/1] | 00 E #1 0/1 | Query or enable/ | ||
+ | | V | 00 V #1 [#2] | 00 V #1 #2 | Get/set configuration variable | | ||
+ | | W | 00 W #1 [#2] | 00 W #1 #2 | Get/set steering wheel angle - or similar thing | | ||
+ | | R | --- | 00 R [#1] | Resend line 00, reason in #1 | | ||
+ | | I | 00 I | 00 I OK | Reinitialize uC | | ||
+ | |||
+ | Possible messages: | ||
+ | |||
+ | * Q - query current motor state | ||
+ | * T - trigger some action (fire a cannon) | ||
+ | |||
+ | |||
+ | ==== Capabilities ==== | ||
+ | |||
+ | The capabilities message returns a number of fields. Each field has a device type | ||
+ | which should correspond to device command (M for motor, S for sensor...) and allowed | ||
+ | scale, grouped by : character . For binary devices (triggers, lights) it doesn' | ||
+ | |||
+ | Returned fields order does matter. All devices of given type are given a number | ||
+ | according to where they appeared in the capabilities reply. Each device type has | ||
+ | its own numbering starting from 0 (zero). | ||
+ | |||
+ | Known capabilities specifications: | ||
+ | |||
+ | ^ Notation ^ Description ^ | ||
+ | | M:# | ||
+ | | S:# | ||
+ | | A[: | ||
+ | | E[: | ||
+ | | V:# | ||
+ | | W:# | ||
+ | |||
+ | ===== Example ===== | ||
+ | |||
+ | ^ Source ^ Message ^ Description ^ | ||
+ | | SW: | 00 C | Hi, who's there? | | ||
+ | | uC: | 00 C M:-99:99 M:-99:99 S: | ||
+ | | SW: | 01 V 0 10 | Set alert level on sensor 0 to 10 | | ||
+ | | uC: | 01 V 0 10 | Ok, we did it. | | ||
+ | | SW: | 02 M 0 50 1 -50 | Start spinning | | ||
+ | | uC: | 02 M OK | We started. | | ||
+ | | --- | --- | Sleep for some time | | ||
+ | | SW: | 03 M 0 0 1 0 | Stop spinning | | ||
+ | | uC: | 03 M OK | We stopped. | | ||
+ | | SW: | 04 M 0 50 1 50 | Drive forward | | ||
+ | | uC: | 04 M OK | We're driving. | | ||
+ | | --- | --- | Sleep for some time | | ||
+ | | uC: | -2 A 0 | Alert 0: Interpreted as something on sensor 0 | | ||
+ | | SW: | 05 S 0 | What is the value of your sensor 0? | | ||
+ | | uC: | 05 S 0 10 | Sensor reports 10, the highest value (say it means there' | ||
+ | | SW: | 06 M 0 0 1 0 | Stop driving. | | ||
+ | | uC: | 06 M OK | We stopped. | | ||
+ | |||
+ | ===== Implementation ===== | ||
+ | |||
+ | Current example implementation as a " | ||
+ | |||
+ | ===== Versions ===== | ||
+ | |||
+ | This document specifies BRM protocol version 1. | ||