| The Uniform Robotic Control Protocol (URCP) is a protocol that is the result of developing control systems for several unrelated devices that use a common numbering system. The common numbering system allows the devices to communicate with and/or control other devices which use the same numbering system without the need for conversion. The goal is to use the lease amount of memory and processing required to evaluate the most amount of data. In URCP, the common value types used in robotics use a single byte of memory. Currently, there are 3 levels of URCP.
- Distance
- Heading
- Power
In each of these, the numbering system used was for the advantage of the robot's computational capabilities and in no way was biased towards working with any particular standard navigational system. Three Objects encapsulate the 3 URCP data types.
| Object | Description | A1 | A2 | B1 | B2 | C1 |
| oDistance | Manages a URCP Distance value. | x | x | x |
| oHeading | Manages a URCP Heading value. | x | x | x |
| oPower | Manages a URCP Power value. | x | x | x |
|
| URCP Heading values deal with circles, trigonometry, angles and headings. The common numbering system chosen for this is Binary-Radians (Brads) which divides a full circle (360 degrees) into 256 even parts. 256 brads per 360 degrees is used so that a single byte can represent a full circle. Objects such as the oJoystick, oTracker, oServoX, etc. use URCP Heading values. This allows one device such as the oTracker to read a heading from a line on the ground. This value then can be copied to an oServoX Object to steer a robot in the direction needed to follow a line. Similarly, the oJoystick can be used to provide the heading. The oHeading Object manages a URCP Heading value. It includes methods for manipulating and converting the heading value.
Degrees vs. Brads.
In standard mathematics, it has long since been decreed that there should be 360 degrees of arc in a complete circle. This was because the corner of an equilateral triangle was divided into 60 degrees and 60 degrees was chosen because it could be divided by 2, 3, 4, 5 and 6 without remainder. However, 360 does not work well in a binary system for the following reasons:
1. The very reason that 360 was chosen does not work well in binary. | |
| Division by non-binary numbers such as 3 and 5 are not binary friendly. What makes this even worse is that 360 does not work well with decimal numbers when divided up multiple times. When dividing by 2 or 3, it can only be evenly divided 2 or 3 times before the divisions become fractional numbers. For example: 360/3=120, 120/3=40, 40/3=10.3333 and 360/2=180, 180/2=90, 90/2=45, 45/2=22.5 |
2. 360 does not fit evenly into a binary number. |
| While binary numbers are typically 8 or 16 bits, it takes 9 bits to represent 360. In order to make it fit into a single 8-bit binary number, it must be divided in half (0 to 180). However, when that is done, not only does it loose some precision, but it no longer fits the mathematical formulas. If 16-bits are used to represent 360 then 7 bits are wasted. |
3. 360 does not wrap. |
| On a compass 300 degrees + 100 degrees equals 40 degrees which wraps properly on a compass, but in binary, 300+100 = 400 which does not wrap properly. |
The solution to all these problems is to use Binary-Radians (Brads) which has 256 Brads of arc in a complete circle.
1. A circle with 256 Brads can be evenly divided up all the way down to 1 brad. | |
| (256/2=128, 128/2=64, 64/2=32, 32/2=16, 16/2=8, 8/2=4, 4/2=2, 2/2=1) |
2. 256 fits evenly into a binary number because it is a binary number. |
| This takes the full advantage of every bit of precision that a byte will allow. If more precision is needed, a 2nd byte can be tacked onto the lease significant side acting as a fractional part of Brad resulting in a circle being dived down to 65536 even parts. This also can be evenly divided down to 1 part. |
3. 256 wraps properly. |
| Any Brad added to any Brad will result in the correct resulting Brad. Even with a second byte for precision, the formula still works properly. For example: 48 + 128 = 176 (128 is 1/2 of the circle and 48 and 176 are on opposite sides of the circle.) |
Brads have more advantages:
1. The Most-Significant-Bit (MSB) can be used as sign bit. | |
| If the Most-Significant-Bit (MSB) is used to denote a twos-complement-negative number, then the compass bearing becomes a heading. From 0, a single Brad to one direction is +1 and a single Brad to the other direction is -1. Straight ahead is a positive number and straight back is a negative number. Using Brads in this way, they are still evenly divisible and wrap properly. |
2. Flipping the direction is an easy formula. |
|
- To flip from left to right, negate the number. (+64 becomes -64) and (+16 becomes -16)
- To flip from front to back, invert the MSB. (112 becomes 16) and (-112 becomes -16)
|
|