git clone https://github.com/bloudman/CrazyRoomba.git && cd CrazyRoobma && npm run setup
Then you can use: npm start
to start server and watch the code.
If you just want to run the server you can run:
npm run serve
If you just want to watch and build you can run:
npm run build:watch
If you juste want to build then run:
npm run build
/
contains everything about the server.
roomba-app
contains client side
roomba-app/src
contains the angular 4 app
roomba-app/jsLibraries
contains js externals libraries including our Robot client library.
roomba-app/img
you can use this folder to put images for the client side.
This library will allow you to speak with roomba from the server side or from the client side with almost exactly the same code. It is based on socket.io.
This code will connect you to the robot, stream all sensors, put it in fullMode and will make it move. The connection to socket.io is implicit.
var roomba = new Robot();
roomba.on("connected", function(){
console.log("connected");
roomba.fullMode();
roomba.streamAllSensors();
roomba.fullMode();
roomba.driveDirect(128,128);
setTimeout(function(){
roomba.driveDirect(-128,-128);
setTimeout(function(){
roomba.driveDirect(0,0);
},2000);
}, 2000);
});
roomba.on("datas", function(datas){
console.log(datas);
});
The only difference between server and client side is the synchronization of datas. To avoid socket.io surcharge datas are send from the server to the client only every 50ms by default. You can change this from the client or from the server side using this command:
roomba.changeInterval(interval in ms)
With this library you can ask pretty much everything. Here is the method list available from the client side or from the server side:
Send a buffer command to the robot
Put roomba in passiveMode
Put roomba in safeMode
Put roomba in fullMode
Stop roomba's motors and the demo
Ask roomba to stream you sensors
Ask roomba to stream you all of his sensors
Pause the streaming
Resume streaming after pause
SensorName | ID | Unit |
---|---|---|
BumpsAndWheelDrops | 7 | |
CliffLeft | 8 | |
CliffFrontLeft | 10 | |
CliffFrontRight | 11 | |
CliffRight | 12 | |
VirtualWall | 13 | |
Overcurrents | 14 | |
IRByte | 17 | |
Buttons | 18 | |
Distance | 19 | mm |
Angle | 20 | mm |
ChargingState | 21 | |
Voltage | 22 | |
Current | 23 | |
BatteryTemperature | 24 | |
BatteryCharge | 25 | |
BatteryCapacity | 26 | |
WallSignal | 27 | |
CliffLeftSignal | 28 | |
CliffFrontLeftSignal | 29 | |
CliffFrontRightSignal | 30 | |
CliffRightSignal | 31 | |
UserDigitalInputs | 32 | |
UserAnalogInputs | 33 | |
ChargingSourcesAvailable | 34 | |
OIMode | 35 | |
SongNumber | 36 | |
SongPlaying | 37 | |
NumberOfStreamPackets | 38 | |
Velocity | 39 | |
Radius | 40 | |
RightVelocity | 41 | |
LeftVelocity | 42 |
These events are not library ones but events to emit via waitEvent(event).
EventName | Id |
---|---|
wheel-drop | 1 |
front-wheel-drop | 2 |
left-wheel-drop | 3 |
right-wheel-drop | 4 |
bump | 5 |
left-bump | 6 |
right-bump | 7 |
virtual-wall | 8 |
wall | 9 |
cliff | 10 |
left-cliff | 11 |
front-left-cliff | 12 |
front-right-cliff | 13 |
right-cliff | 14 |
home-base | 15 |
advance-button | 16 |
play-button | 17 |
digital-output-0 | 18 |
digital-output-1 | 19 |
digital-output-2 | 20 |
digital-output-3 | 21 |
passive | 22 |
DemoName | Id |
---|---|
abort | 255 |
cover | 0 |
cover-and-dock | 1 |
spot-cover | 2 |
mouse | 3 |
drive-figure-eight | 4 |
wimp | 5 |
home | 6 |
tag | 7 |
pachelbel | 8 |
banjo | 9 |
The library is based on EventEmitter (client side and server side). So you can track an event like this:
roomba.on('event', function(data){
console.log(data);
});
This event is send when the robot is connected
Retrieve the array of asked sensors every 50ms (by default see changeEmission interval to change default settings)
Single sensor data
The checksum of data receive is not correct
The received data does not correspond to any sensor of the list... we drop the data because it is an incorrect one.
When the robot is not correctly connected the server will run in "FakeRobot mode". It will send to the client fake data for debugging purposes.
There is a simple angularjs 1.6 app which allow you to show every sensors in HTML table and control it with your keyboard. (using zqzd)