Communicate with KaisClan robots.
NPM usage
- First install the library and MQTT client
yarn add @kaisclan/client mqtt
- Ensure that you have active MQTT connect
mqtt.connect('ws://3dpslabs.com:9001')
- After connect you can use like
const { ClassRoom, Robot, Schemas } = require('kaisclan');
const mqtt = require('mqtt')
Now you can use the library.
Browser
- Add KaisClan and MQTT CDN libraries to your HTML page
<script type="text/javascript" src="//unpkg.com/@kaisclan/client@2.2.3"></script>
<script type="text/javascript" src="//unpkg.com/mqtt/dist/mqtt.min.js"></script>
Now you can use the library.
Usage
const client = mqtt.connect(`ws://3dpslabs.com:9001`);
client.on('connect', function () {
const classRoomABC = new ClassRoom('ABC123', client);
// Instance robot with ClassRoom
const robot1 = new Robot('1', classRoomABC);
robot1.moveTo(200, 200);
// Instance robot by self
const robot2 = new Robot('2', classRoomABC, { x: 100, y: 200, a: 120 });
robot2
.moveBackward(20)
.changeAngle(160)
.moveForward(80);
})
Test locally
-
npm link
will allow you install your package in locally projects - On your test project use
npm link kaisclan
to install project