diff --git a/src/services/path/pathfinding/lib/Makefile~ b/src/services/path/pathfinding/lib/Makefile~ deleted file mode 100644 index ca540e8..0000000 --- a/src/services/path/pathfinding/lib/Makefile~ +++ /dev/null @@ -1,2 +0,0 @@ -all: - g++ $(find -name '*.cpp' ! -name '*Binder.cpp') -o test \ No newline at end of file diff --git a/src/services/position/PositionService.js b/src/services/position/PositionService.js index 4a4b38c..1ea7a27 100644 --- a/src/services/position/PositionService.js +++ b/src/services/position/PositionService.js @@ -100,14 +100,29 @@ class PositionService { points.splice(0, 1); positionService._basicSet(point, direction, tolerance, speed).then(goToNext); return; - } - resolve(); + } else { + resolve(); + } } goToNext(); }); } + _promiseToReachDestionation() { + return new Promise((resolve, reject) => { + this.motionDriver.on('stateChanged', (state) => { + if (state === MotionDriverConstants.STATE_IDLE) { + resolve(); + } + else if (state === MotionDriverConstants.STATE_ERROR || + state === MotionDriverConstants.STATE_STUCK) { + reject(state); + } + }); + }); + } + _basicSet(point, direction, tolerance, speed) { // Set speed if (speed !== undefined && this.currentSpeed !== speed) { @@ -127,33 +142,13 @@ class PositionService { Mep.Log.debug(TAG, 'Robot move command sent.', point); // Check when robot reached the position - return new Promise((resolve, reject) => { - this.motionDriver.on('stateChanged', (state) => { - if (state === MotionDriverConstants.STATE_IDLE) { - resolve(); - } - else if (state === MotionDriverConstants.STATE_ERROR || - state === MotionDriverConstants.STATE_STUCK) { - reject(state); - } - }); - }); + return this._promiseToReachDestionation(); } arc(point, angle, direction) { this.motionDriver.moveArc(point.getX(), point.getY(), angle, direction); - return new Promise((resolve, reject) => { - this.motionDriver.on('stateChanged', (state) => { - if (state === MotionDriverConstants.STATE_IDLE) { - resolve(); - } - else if (state === MotionDriverConstants.STATE_ERROR || - state === MotionDriverConstants.STATE_STUCK) { - reject(state); - } - }); - }); + return this._promiseToReachDestionation(); } rotate(tunedAngle, options) { diff --git a/src/utils/DriverChecker.js b/src/utils/DriverChecker.js index cad5477..161ca0f 100644 --- a/src/utils/DriverChecker.js +++ b/src/utils/DriverChecker.js @@ -34,9 +34,6 @@ class DriverChecker { if (typeof driver.getPosition !== 'function') { throw TypeError(driverClassName + ' requires method getPosition()'); } - if (driver.getPosition().constructor.name !== 'Point') { - throw TypeError('Method '+ driverClassName +'.getPosition() must return Point'); - } } static _checkTerrain(driver) {