Skip to content

Latest commit

 

History

History
executable file
·
242 lines (214 loc) · 7.45 KB

README_old.md

File metadata and controls

executable file
·
242 lines (214 loc) · 7.45 KB

CrazyRoomba

Basic installation:

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

How folders are organize?

/ contains everything about the server.
roomba-app contains client side
roomba-app/srccontains the angular 4 app
roomba-app/jsLibrariescontains js externals libraries including our Robot client library.
roomba-app/img you can use this folder to put images for the client side.

What the principle of the library

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.

Client base code:

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);
});

Difference between client side and server side

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)

What can you ask to the robot?

With this library you can ask pretty much everything. Here is the method list available from the client side or from the server side:

_sendCommand(buffer)

Send a buffer command to the robot


passiveMode()

Put roomba in passiveMode


safeMode()

Put roomba in safeMode


fullMode()

Put roomba in fullMode


sing(notes)


drive(velocity, radius, direct=false)


driveDirect(leftMotor, rightMotor)


stop()

Stop roomba's motors and the demo

startDemo(number)


setLED(number, color, intensity)


setDigitalOuputPort(value)


setDigitalOutputPin(pin, state)


getDigitalOutputPort()


getDigitalOutputState(pin)


setPWLLowSideDrivers(driver1, driver2, driver3)


streamSensors(ids)

Ask roomba to stream you sensors


streamAllSensors()

Ask roomba to stream you all of his sensors


pauseStreaming()

Pause the streaming


resumeStreaming()

Resume streaming after pause


wait(time)


waitDistance(distance)


waitAngle(angle)


waitEvent(event)


Sensors we can use:

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
BatteryTemperature24
BatteryCharge25
BatteryCapacity26
WallSignal27
CliffLeftSignal28
CliffFrontLeftSignal29
CliffFrontRightSignal30
CliffRightSignal31
UserDigitalInputs32
UserAnalogInputs33
ChargingSourcesAvailable34
OIMode35
SongNumber36
SongPlaying37
NumberOfStreamPackets38
Velocity39
Radius40
RightVelocity41
LeftVelocity42

Events from the robot:

These events are not library ones but events to emit via waitEvent(event).

EventNameId
wheel-drop1
front-wheel-drop2
left-wheel-drop3
right-wheel-drop4
bump5
left-bump6
right-bump7
virtual-wall8
wall9
cliff10
left-cliff11
front-left-cliff12
front-right-cliff13
right-cliff14
home-base15
advance-button16
play-button17
digital-output-018
digital-output-119
digital-output-220
digital-output-321
passive22

Differents demos:

DemoNameId
abort255
cover0
cover-and-dock1
spot-cover2
mouse3
drive-figure-eight4
wimp5
home6
tag7
pachelbel8
banjo9

Events from the library

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);
});

Client and server side:

connected

This event is send when the robot is connected


datas

Retrieve the array of asked sensors every 50ms (by default see changeEmission interval to change default settings)


Server side only

data

Single sensor data


errordata

The checksum of data receive is not correct


packetNotFound

The received data does not correspond to any sensor of the list... we drop the data because it is an incorrect one.

What happens when the robot is not correctly connected?

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.

What's in the webApp folder?

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)