node-red-contrib-periph-imu 1.4.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/examples/bno055/demo.json +85 -0
- package/nodes/bno055/bno055.html +71 -0
- package/nodes/bno055/bno055.js +51 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ npm install node-red-contrib-periph-imu
|
|
|
16
16
|
|
|
17
17
|
| Node | Kind | Description |
|
|
18
18
|
|------|------|-------------|
|
|
19
|
+
| `periph-bno055` | input | Reads the fused absolute orientation of a Bosch BNO055 9-axis sensor over I²C (0x29 with COM3 high, 0x28 with COM3 low). The chip stretches the I²C clock, so the host bus must support clock stretching. Allow up to about one second after deploying for the chip to boot. |
|
|
19
20
|
| `periph-icm20948` | input | Reads acceleration, angular rate, die temperature and (optionally) the magnetic field from a TDK InvenSense ICM-20948 9-axis MotionTracking device over I²C. The AK09916 magnetometer is read through the chip's own I²C master, so only one I²C address is needed. VDDIO must be 1.71–1.95 V. |
|
|
20
21
|
| `mpu6050-device` | config | I²C bus and address for a MPU6050 |
|
|
21
22
|
| `mpu6050` | input | Reads 3-axis acceleration and 3-axis angular rate from an MPU6050 IMU over I²C. |
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "bno055-tab",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "BNO055 orientation",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Reads the fused orientation of a BNO055 every 100 ms and formats heading, roll and pitch (rad) together with the calibration status. Demonstrates the absolute-orientation output; move the board in a figure eight until the calibration values reach 3."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "bno055-inject",
|
|
11
|
+
"type": "inject",
|
|
12
|
+
"z": "bno055-tab",
|
|
13
|
+
"name": "100 ms timer",
|
|
14
|
+
"props": [
|
|
15
|
+
{
|
|
16
|
+
"p": "payload"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"repeat": "0.1",
|
|
20
|
+
"crontab": "",
|
|
21
|
+
"once": false,
|
|
22
|
+
"onceDelay": 0.1,
|
|
23
|
+
"topic": "",
|
|
24
|
+
"payloadType": "date",
|
|
25
|
+
"x": 170,
|
|
26
|
+
"y": 160,
|
|
27
|
+
"wires": [
|
|
28
|
+
[
|
|
29
|
+
"bno055-node"
|
|
30
|
+
]
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "bno055-node",
|
|
35
|
+
"type": "periph-bno055",
|
|
36
|
+
"z": "bno055-tab",
|
|
37
|
+
"name": "BNO055",
|
|
38
|
+
"bus": "1",
|
|
39
|
+
"address": "0x29",
|
|
40
|
+
"mode": "12",
|
|
41
|
+
"x": 400,
|
|
42
|
+
"y": 160,
|
|
43
|
+
"wires": [
|
|
44
|
+
[
|
|
45
|
+
"bno055-format"
|
|
46
|
+
]
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "bno055-format",
|
|
51
|
+
"type": "function",
|
|
52
|
+
"z": "bno055-tab",
|
|
53
|
+
"name": "Format orientation",
|
|
54
|
+
"func": "const p = msg.payload;\nconst c = p.calibration;\nmsg.payload = 'heading ' + p.heading.toFixed(2) + ' rad, roll ' + p.roll.toFixed(2) + ', pitch ' + p.pitch.toFixed(2) +\n ' (cal sys ' + c.sys + ' gyr ' + c.gyr + ' acc ' + c.acc + ' mag ' + c.mag + ')';\nreturn msg;",
|
|
55
|
+
"outputs": 1,
|
|
56
|
+
"noerr": 0,
|
|
57
|
+
"initialize": "",
|
|
58
|
+
"finalize": "",
|
|
59
|
+
"libs": [],
|
|
60
|
+
"x": 650,
|
|
61
|
+
"y": 160,
|
|
62
|
+
"wires": [
|
|
63
|
+
[
|
|
64
|
+
"bno055-debug"
|
|
65
|
+
]
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": "bno055-debug",
|
|
70
|
+
"type": "debug",
|
|
71
|
+
"z": "bno055-tab",
|
|
72
|
+
"name": "Orientation",
|
|
73
|
+
"active": true,
|
|
74
|
+
"tosidebar": true,
|
|
75
|
+
"console": false,
|
|
76
|
+
"tostatus": false,
|
|
77
|
+
"complete": "payload",
|
|
78
|
+
"targetType": "msg",
|
|
79
|
+
"statusVal": "",
|
|
80
|
+
"statusType": "auto",
|
|
81
|
+
"x": 890,
|
|
82
|
+
"y": 160,
|
|
83
|
+
"wires": []
|
|
84
|
+
}
|
|
85
|
+
]
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType('periph-bno055', {
|
|
3
|
+
category: 'Peripheral',
|
|
4
|
+
color: '#C084FC',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '0x29' },
|
|
9
|
+
mode: { value: '12', required: true, validate: RED.validators.number() }
|
|
10
|
+
},
|
|
11
|
+
inputs: 1,
|
|
12
|
+
outputs: 1,
|
|
13
|
+
icon: 'bridge.svg',
|
|
14
|
+
label: function() {
|
|
15
|
+
return this.name || ('BNO055 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script type="text/html" data-template-name="periph-bno055">
|
|
21
|
+
<div class="form-row">
|
|
22
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
23
|
+
<input type="text" id="node-input-name" placeholder="BNO055">
|
|
24
|
+
</div>
|
|
25
|
+
<div class="form-row">
|
|
26
|
+
<label for="node-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
27
|
+
<input type="number" id="node-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
28
|
+
</div>
|
|
29
|
+
<div class="form-row">
|
|
30
|
+
<label for="node-input-address"><i class="fa fa-microchip"></i> I²C address</label>
|
|
31
|
+
<select id="node-input-address" style="width:160px">
|
|
32
|
+
<option value="0x29" selected>0x29 (COM3 = high)</option>
|
|
33
|
+
<option value="0x28">0x28 (COM3 = low)</option>
|
|
34
|
+
</select>
|
|
35
|
+
</div>
|
|
36
|
+
<div class="form-row">
|
|
37
|
+
<label for="node-input-mode"><i class="fa fa-cog"></i> Operation mode</label>
|
|
38
|
+
<select id="node-input-mode" style="width:260px">
|
|
39
|
+
<option value="12" selected>NDOF (9-DOF absolute orientation)</option>
|
|
40
|
+
<option value="11">NDOF, fast magnetometer calibration off</option>
|
|
41
|
+
<option value="8">IMU (relative orientation)</option>
|
|
42
|
+
<option value="9">COMPASS</option>
|
|
43
|
+
<option value="10">M4G</option>
|
|
44
|
+
</select>
|
|
45
|
+
</div>
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<script type="text/html" data-help-name="periph-bno055">
|
|
49
|
+
<p>Reads the fused absolute orientation of a Bosch BNO055 9-axis sensor over I²C (0x29 with COM3 high,
|
|
50
|
+
0x28 with COM3 low). The chip stretches the I²C clock, so the host bus must support clock stretching.
|
|
51
|
+
Allow up to about one second after deploying for the chip to boot.</p>
|
|
52
|
+
<h3>Inputs</h3>
|
|
53
|
+
<dl class="message-properties">
|
|
54
|
+
<dt>payload <span class="property-type">any</span></dt>
|
|
55
|
+
<dd>Any incoming message triggers one measurement.</dd>
|
|
56
|
+
</dl>
|
|
57
|
+
<h3>Outputs</h3>
|
|
58
|
+
<dl class="message-properties">
|
|
59
|
+
<dt>payload.heading <span class="property-type">number</span></dt>
|
|
60
|
+
<dd>Heading in rad (0 … 2π).</dd>
|
|
61
|
+
<dt>payload.roll <span class="property-type">number</span></dt>
|
|
62
|
+
<dd>Roll in rad.</dd>
|
|
63
|
+
<dt>payload.pitch <span class="property-type">number</span></dt>
|
|
64
|
+
<dd>Pitch in rad.</dd>
|
|
65
|
+
<dt>payload.calibration <span class="property-type">object</span></dt>
|
|
66
|
+
<dd><code>{ sys, gyr, acc, mag }</code>, each 0 (uncalibrated) … 3 (fully calibrated). Absolute heading is
|
|
67
|
+
only accurate once the magnetometer and system values reach 3.</dd>
|
|
68
|
+
</dl>
|
|
69
|
+
<h3>Configuration</h3>
|
|
70
|
+
<p>I²C bus number, I²C address and the operation mode (default NDOF, 100 Hz absolute orientation).</p>
|
|
71
|
+
</script>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { BNO055Full } = require('periph/src/chips/imu/bno055');
|
|
6
|
+
|
|
7
|
+
function BNO055Node(config) {
|
|
8
|
+
RED.nodes.createNode(this, config);
|
|
9
|
+
const node = this;
|
|
10
|
+
try {
|
|
11
|
+
const address = parseInt(config.address, 16) || 0x29;
|
|
12
|
+
const connection = new I2CConnection(parseInt(config.bus), address);
|
|
13
|
+
node.connection = connection;
|
|
14
|
+
node.driver = new BNO055Full(connection);
|
|
15
|
+
// The driver initialises itself asynchronously (it waits for the chip to boot).
|
|
16
|
+
node.ready = (async () => {
|
|
17
|
+
await node.driver.init();
|
|
18
|
+
const mode = parseInt(config.mode);
|
|
19
|
+
if (!Number.isNaN(mode) && mode !== 12) await node.driver.setMode(mode);
|
|
20
|
+
})();
|
|
21
|
+
node.ready.catch((e) => {
|
|
22
|
+
node.error('BNO055 init failed: ' + e.message);
|
|
23
|
+
});
|
|
24
|
+
} catch (e) {
|
|
25
|
+
node.error('BNO055 init failed: ' + e.message);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
node.on('input', async function(msg, send, done) {
|
|
29
|
+
if (!node.driver) {
|
|
30
|
+
node.error('BNO055 not initialised', msg);
|
|
31
|
+
done();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
await node.ready;
|
|
36
|
+
const [heading, roll, pitch] = await node.driver.euler();
|
|
37
|
+
const [sys, gyr, acc, mag] = await node.driver.calibrationStatus();
|
|
38
|
+
msg.payload = { heading, roll, pitch, calibration: { sys, gyr, acc, mag } };
|
|
39
|
+
send(msg);
|
|
40
|
+
done();
|
|
41
|
+
} catch (e) {
|
|
42
|
+
done(e);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
node.on('close', function() {
|
|
47
|
+
if (node.connection) node.connection.close();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
RED.nodes.registerType('periph-bno055', BNO055Node);
|
|
51
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-periph-imu",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Node-RED nodes for IMU chips",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"node-red": {
|
|
14
14
|
"nodes": {
|
|
15
|
+
"bno055": "nodes/bno055/bno055.js",
|
|
15
16
|
"icm20948": "nodes/icm20948/icm20948.js",
|
|
16
17
|
"mpu6050": "nodes/mpu6050/mpu6050.js",
|
|
17
18
|
"mpu9250": "nodes/mpu9250/mpu9250.js",
|