rosjs/rosjs — pull request #4 by baalexander (2012-04-24 03:47:22+00:00)
Title: Builds a message class (and children messages).

buildMessage will return a message class with fields and meta information. If a message has children messages, the children message classes will also be created recursively.

Here is an example usage:

```javascript
// Passes in the details object, this will be JSON returned
// from rosbridge:
var Pose = buildMessage({
md5: 'e45d45a5a1ce597b249e23fb30fc871f'
, messageType: 'geometry_msgs/Pose'
, packageName: 'geometry_msgs'
, messageName: 'Pose'
, constants: []
, fields: [
{
name: 'position'
, type: 'geometry_msgs/Point'
, messageType: {
md5: '4a842b65f413084dc2b10fb484ea7f17'
, messageType: 'geometry_msgs/Point'
, packageName: 'geometry_msgs'
, messageName: 'Point'
, constants: []
, fields: [
{
name: 'x'
, type: 'float64'
, messageType: null
}
, {
name: 'y'
, type: 'float64'
, messageType: null
}
, {
name: 'z'
, type: 'float64'
, messageType: null
}
]
}
}
]
});

// The class Point is available as a child of Pose
var Point = Pose.fields[0].messageType;
var point = new Point({ x: 1, y: 2, z: 3 });
console.log(point);

var pose = new Pose({ point: point });
console.log(pose);
```