Wiki
Clone wikiRVR CPP / Streaming
Streaming Sensors
Streaming sensor data is an important aspect of working with the RVR. This is the only way to some sensor data. Despite that restriction it is an innovative approach by Sphero. Please see the API Table for the details on the commands for streaming.
Overview
Processors: There are two processors in the RVR: the Nordic and the Bluetooth SOC. Each of these controls different sensors. The configuration table below relates the processors and the sensors. Because of this commands must be sent to the appropriate processor to initiate streaming.
Configuration: Prior to initiating streaming sets of configuration data is sent to the RVR. Each set is identified by a token. The token is returned by the RVR to identify the data being sent. Each token is followed by up to 5 sensor data requests. These sensros must all be controlled by the same processor.
A configuration cannot be modified while straming is active. Streaming must be stopped, the modified configuration sent, and streaming started again.
Starting, Stopping and Clearing: Streaming can be started, stopped and cleared.
- Starting a stream specifies the time interval between sending of sensor data. All configurations are sent at the same time interval.
- A Stop is needed if a configuration needs to be changed.
- Clearing removes all the configurations.
Data Format: The data returned is an integer scaled version of the sensor data. This needs to be scaled, or normalized, based on the minimum and maximum values of the sensors output. The formula is:
--- --- | integer reading - integer minimum | Normalized Sensor Data = | --------------------------------- * sensor output maximum - sensor output mininmum | + sensor output minimum | integer maximum - integer minimum | --- ---
Configuration
Streaming configuration specifies the data to be streamed.
Streaming Configuration Request Format
A streaming configuration consists of a configuration identifying token followed by up to 5 fields which contain a 2 byte integer (uint16_t) Id, and the size of the returned data. The data in the response is a scaled integer value based on the size specified.
The following example is for configuration 3. It requests the Ambient Light using Id of 0x000A
with a size of 2, and then ColorDetction using Id of 0x0003
with a size of 1.
0x03, 0x00, 0x0A, 0x02, 0x00, 0x03, 0x01
The configuration id may be any small value. It is used to identify the configuration. When a response is received this is the only way to determine the data in the response.
The Id is sent as two bytes in the order show, i.e. 0x000A
is sent as 0x00
, 0x0A
.
Streaming Configuration Table
The following table is from the Sphero Python code. Similar information is provided by Sphero.
Id | Processor | Token | Service | Attributes |
---|---|---|---|---|
0x0003 | Nordic (1) | 1 | ColorDetection | R, G, B, Index, Confidence |
0x000A | Nordic (1) | 2 | AmbientLight | Light |
----------------------------------------------------------------------------------------- | ||||
0x0000 | ST (2) | 1 | Quaternion | W, X, Y, Z |
0x0001 | ST (2) | 1 | IMU | Pitch, Roll, Yaw |
0x0002 | ST (2) | 1 | Accelerometer | X, Y, Z |
0x0004 | ST (2) | 1 | Gyroscope | X, Y, Z |
0x0006 | ST (2) | 2 | Locator | X, Y |
0x0007 | ST (2) | 2 | Velocity | X, Y |
0x0008 | ST (2) | 2 | Speed | Speed |
----------------------------------------------------------------------------------------- | ||||
0x0009 | Nordic (1), ST (2) | 3 | CoreTime | TimeUpper, TimeLower |
----------------------------------------------------------------------------------------- |
Streaming Size Enum
Enum | Size |
---|---|
0x00 | int8_t |
0x01 | int16_t |
0x02 | int32_t |
Stream Response
The streaming message contains the header as expected. The sequence number is not present and replaced with the value 0xFF
. The token follows as replacement for the error code. The data follows in the size specfied by the configuration. To illustrate:
<flags><tid><sid><did><cid><OxFF><token><data>
Streaming Conversions Information
Sensor | Item | Min Value | Max Value |
---|---|---|---|
Core time | 0 | 0xFFFFFFFF (4294967295) (UINT32_MAX) | |
Velocity | x | -5.0 | 5.0 |
y | -5.0 | 5.0 | |
Accelerometer | x | -16.0 | 16.0 |
y | -16.0 | 16.0 | |
z | -16.0 | 16.0 | |
Gyroscope | x | -2000.0 | 2000.0 |
y | -2000.0 | 2000.0 | |
z | -2000.0 | 2000.0 | |
IMU | pitch | -180.0 | 180.0 |
roll | -90.0 | 90.0 | |
yaw | -180.0 | 180.0 | |
Quaternion | w | -1.0 | 1.0 |
x | -1.0 | 1.0 | |
y | -1.0 | 1.0 | |
z | -1.0 | 1.0 | |
Color Detector | R | 0.0 | 255 |
G | 0.0 | 255 | |
B | 0.0 | 255 | |
Index | 0.0 | 1.0 | |
Confidence | 0.0 | 1.0 | |
Speed | 0.0 | 5.0 | |
Locator | x | -16000.0 | 16000.0 |
y | -16000.0 | 16000.0 | |
Velocity | x | -5.0 | 5.0 |
y | -5.0 | 5.0 | |
Ambient Light | 0.0 | 120,000 |
Units of Measurement
These are provided by Sphero along with other sensor information.
Updated