-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from tue-robotics/robot
Robot
- Loading branch information
Showing
9 changed files
with
190 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
language: node_js | ||
node_js: | ||
- '10' | ||
install: | ||
- npm install | ||
script: | ||
- npm run build | ||
before_deploy: | ||
- npm run deploy-linux | ||
- tar -pzcvf hero-dashboard-linux-x64-$TRAVIS_TAG.tar.gz -C dist/hero-dashboard-linux-x64/ . | ||
deploy: | ||
provider: releases | ||
api_key: | ||
secure: J49WAQALh8sa7Gc+t2xKzGGRfIzvUO7Hlh4PuJK4oK1zCMXIDEoku2rjcLNo1ni/ZR6e9pBmJ19Pe9sPihqAYmhC2Wagg6Ql/FTbc7nCqIBj8c7yow5AjTJgt+g+J5sxIlCIlhtP0H00LeOy2S/eV3ZuPeuvjv6mxo/I0uR7GvwU9o0ggcNYZM40g+OddR/f1DowuwODYdWHaJaRHicMG0FpR+AMH8boSsNDLRtHTzHJKRh1rBh7W2sGLQyfbp83QVXZiYBO0pZtxGssaoVCUpH6f2wakB7MXO8H5oITkXdfxAtv5Gb9y1wzeMl16zSFyvHY20PCod6nnGsqudtcQpZziZqQ531arcAnE/uyCVpkeKFWDlrAyAQgou/fEQENXGZs2EsDKh1/wfGE4oe5QWlzctLsn5i+myL2ZN+LqJ56ypzSqSh/8wqGMxUj+jTUce/PT//fOjfd8szyt92JN4rs6JQmDh4BZVVF1vDj/8zbmwb8erZLHWaWAD3MelmMtoou3Gie1l2XxCJuRvYtRvHgb7nef02/2Mkel42etK75SfBuOjRtKy/86I/A6qluRU788dHMTneldELHWu5Xj/IEsR+41m7j0P6HRlb5f6+jDF2S07B7xBjY6gmlXk+8CvuCd5aJeZAk81I13WTncjum/9TaMWg3yvhUwdIkaA8= | ||
file_glob: true | ||
file: hero-dashboard-linux-x64-*.tar.gz | ||
skip_cleanup: true | ||
on: | ||
repo: tue-robotics/hero-dashboard | ||
tags: true | ||
all_branches: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
{ | ||
"name": "hero-dashboard", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"private": true, | ||
"main": "main.js", | ||
"dependencies": { | ||
"@fortawesome/fontawesome-free": "^5.8.1", | ||
"bootstrap": "^4.3.1", | ||
"electron": "^4.1.4", | ||
"eventemitter2": "^4.1.2", | ||
"react": "^16.8.6", | ||
"react-bootstrap": "^1.0.0-beta.6", | ||
"react-dom": "^16.8.6", | ||
"react-scripts": "0.9.5", | ||
"roslib": "^1.0.1" | ||
}, | ||
"devDependencies": {}, | ||
"devDependencies": { | ||
"electron": "^4.1.4", | ||
"electron-packager": "^13.0.0" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --env=jsdom", | ||
"eject": "react-scripts eject", | ||
"electron": "electron ." | ||
"electron": "electron .", | ||
"deploy-linux": "electron-packager . hero-dashboard --overwrite --asar=true --platform=linux --arch=x64 ---prune=true --out=dist" | ||
}, | ||
"homepage": "." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,78 @@ | ||
import {hostname} from 'os'; | ||
import {EventEmitter2} from 'eventemitter2'; | ||
import ROSLIB from 'roslib'; | ||
|
||
export default new ROSLIB.Ros({ | ||
url: 'ws://localhost:9090', | ||
}); | ||
// Private variables | ||
const host = hostname() || 'localhost'; | ||
const defaultUrl = `ws://${host}:9090`; | ||
|
||
// reconnect timeout in ms | ||
const RECONNECT_TIMEOUT = 5000; | ||
|
||
class AutoRos extends EventEmitter2 { | ||
|
||
constructor() { | ||
super(); | ||
|
||
this.ros = new ROSLIB.Ros({ | ||
encoding: 'ascii' | ||
}); | ||
|
||
this.ros.on('connection', this.onConnection.bind(this)); | ||
this.ros.on('close', this.onClose.bind(this)); | ||
this.ros.on('error', this.onError.bind(this)); | ||
|
||
// reconnect behavior | ||
this.on('status', function (status) { | ||
switch (status) { | ||
case 'closed': | ||
setTimeout(this.connect.bind(this), RECONNECT_TIMEOUT); | ||
break; | ||
default: | ||
break; | ||
} | ||
}); | ||
} | ||
|
||
get status() { | ||
return this._status; | ||
} | ||
|
||
set status(value) { | ||
this._status = value; | ||
this.emit('status', value); | ||
} | ||
|
||
/** | ||
* Connect to rosbridge | ||
* | ||
* If an url is provided, it will connect to that one. Else it will | ||
* use the previous url. Uses a url based on the hostname if no urls | ||
* are provided. | ||
*/ | ||
connect(url) { | ||
this.url = url || this.url || defaultUrl; | ||
|
||
console.log(`connecting to ${this.url}`); | ||
this.ros.connect(this.url); | ||
this.status = 'connecting'; | ||
} | ||
|
||
// ros status event handling | ||
onConnection() { | ||
console.log('connection'); | ||
this.status = 'connected'; | ||
} | ||
|
||
onClose() { | ||
console.log('connection closed'); | ||
this.status = 'closed'; | ||
} | ||
|
||
onError() { | ||
// console.log('connection error'); | ||
this.status = 'error'; | ||
} | ||
} | ||
|
||
export default new AutoRos(); |