mambo-angular-service
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -18,2 +18,3 @@ /// <reference types="web-bluetooth" /> | ||
private initialiseFlightDefaults(); | ||
onDisconnected(): void; | ||
/** | ||
@@ -43,2 +44,3 @@ * Convenience method for setting the drone's altitude limitation | ||
land(): void; | ||
fire(): void; | ||
private sendFlightParams(); | ||
@@ -45,0 +47,0 @@ updateFlightParams(roll: number, pitch: number, yaw: number, altitude: number): void; |
21
drone.js
@@ -40,15 +40,15 @@ "use strict"; | ||
// info: Setting max altitude to 2m | ||
const maxAltitudeCommand = [8, 0, 0, 2, 0]; | ||
yield this.setMaxAltitude(2); | ||
// info: Setting max tilt to 40% (20° max) | ||
const maxTiltCommand = [8, 1, 0, 40, 0]; | ||
yield this.setMaxTilt(40); | ||
// info: Setting max vertical speed to 0.5 m/s | ||
const maxVerticalSpeedCommand = [1, 0, 0, 0, 0]; | ||
yield this.setMaxVerticalSpeed(0); | ||
// info: Setting max rotation speed to 150 °/s | ||
const maxRotationCommand = [1, 1, 0, 150, 0]; | ||
yield this.flightCommandInstructions.write(maxAltitudeCommand); | ||
yield this.flightCommandInstructions.write(maxTiltCommand); | ||
yield this.flightCommandInstructions.write(maxVerticalSpeedCommand); | ||
yield this.flightCommandInstructions.write(maxRotationCommand); | ||
yield this.setMaxRotationSpeed(150); | ||
}); | ||
} | ||
onDisconnected() { | ||
console.log('Drone disconnected'); | ||
this.stopFlightLoop(); | ||
} | ||
/** | ||
@@ -127,2 +127,3 @@ * Convenience method for setting the drone's altitude limitation | ||
stopFlightLoop() { | ||
debugger; | ||
if (this.flightLoopHandle > 0) { | ||
@@ -143,3 +144,7 @@ clearInterval(this.flightLoopHandle); | ||
} | ||
fire() { | ||
this.flightCommandInstructions.writeWithoutResponse([16, 2, 0, 0, 0, 0, 0, 0]); | ||
} | ||
sendFlightParams() { | ||
console.log('sendFlightParams'); | ||
const command = [0, 2, 0, 1, this.roll, this.pitch, this.yaw, this.altitude, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
@@ -146,0 +151,0 @@ this.flightParamsInstructions.writeWithoutResponse(command); |
@@ -5,2 +5,3 @@ import { Drone } from '.'; | ||
search(): Promise<Drone>; | ||
onDisconnected(): void; | ||
} |
@@ -29,7 +29,12 @@ "use strict"; | ||
const server = yield device.gatt.connect(); | ||
console.log('Drone ready to connect'); | ||
const drone = new _1.Drone(server); | ||
yield drone.connect(); | ||
console.log('Drone connected and ready to fly'); | ||
device.addEventListener('gattserverdisconnected', () => drone.onDisconnected()); | ||
return drone; | ||
}); | ||
} | ||
onDisconnected() { | ||
} | ||
}; | ||
@@ -36,0 +41,0 @@ MamboService = __decorate([ |
{ | ||
"name": "mambo-angular-service", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Angular Service to control Parrot Mambo drone", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,2 +7,4 @@ # mambo-angular-service | ||
## API | ||
@@ -16,26 +18,10 @@ | ||
setMaxAltitude(maxAltitude: number): Promise<any> | ||
* Sets the drone's altitude limitation | ||
* @param {Integer} altitude the altitude in meters (2m-10m for Airborne Cargo / 2m - 25m for Mambo) | ||
setMaxTilt(maxTilt: number): Promise<any> | ||
* Sets the drone's max tilt limitation | ||
* @param {integer} tilt The max tilt from 0-100 (0 = 5° - 100 = 20°) | ||
setMaxVerticalSpeed(maxVerticalSpeed: number): Promise<any> | ||
* Sets the drone's max vertical speed limitation | ||
* @param {integer} verticalSpeed The max vertical speed from 0.5m/s - 2m/s | ||
setMaxRotationSpeed(maxRotationSpeed: number): Promise<any> | ||
* Sets the drone's max rotation speed limitation | ||
* @param {integer} tilt The max rotation speed from (50°-360° for Airborne Cargo / 50° - 180° for Mambo) | ||
takeOff() | ||
#### `takeOff()` | ||
* Instructs the drone to take off | ||
land() | ||
#### `land()` | ||
* Instructs the drone to land | ||
public updateFlightParams(roll: number, pitch: number, yaw: number, altitude: number) | ||
* Sets the roll, pitch, yaw and altitude of drone's flight params | ||
#### `public updateFlightParams(roll: number, pitch: number, yaw: number, altitude: number)` | ||
* Sets the roll, pitch, yaw and altitude of drone's flight params in one go | ||
* @param roll turn speed, expected value from -1 (move left) to 1 (move right) | ||
@@ -46,17 +32,35 @@ * @param pitch turn speed, expected value from -1 (move back) to 1 (move forward) | ||
public setRoll(roll) | ||
#### `public setRoll(roll)` | ||
* Sets the roll speed of drone's flight params | ||
* @param roll turn speed, expected value from -1 (move left) to 1 (move right) | ||
public setPitch(pitch) | ||
#### `public setPitch(pitch)` | ||
* Sets the pitch of drone's flight params | ||
* @param pitch turn speed, expected value from -1 (move back) to 1 (move forward) | ||
public setYaw(yaw: number) | ||
#### `public setYaw(yaw: number)` | ||
* Sets the turn speed of drone's flight params | ||
* @param yaw turn speed, expected value from -1 (turn counter-clocwise) to 1 (turn clocwise) | ||
public setAltitude(altitude) | ||
#### `public setAltitude(altitude)` | ||
* Sets the altitude of drone's flight params | ||
* @param altitude turn speed, expected value from -1 (move down) to 1 (move up) | ||
#### `setMaxAltitude(maxAltitude: number): Promise<any>` | ||
* Sets the drone's altitude limitation | ||
* @param {Integer} altitude the altitude in meters (2m-10m for Airborne Cargo / 2m - 25m for Mambo) | ||
#### `setMaxTilt(maxTilt: number): Promise<any>` | ||
* Sets the drone's max tilt limitation | ||
* @param {integer} tilt The max tilt from 0-100 (0 = 5° - 100 = 20°) | ||
#### `setMaxVerticalSpeed(maxVerticalSpeed: number): Promise<any>` | ||
* Sets the drone's max vertical speed limitation | ||
* @param {integer} verticalSpeed The max vertical speed from 0.5m/s - 2m/s | ||
#### `setMaxRotationSpeed(maxRotationSpeed: number): Promise<any>` | ||
* Sets the drone's max rotation speed limitation | ||
* @param {integer} tilt The max rotation speed from (50°-360° for Airborne Cargo / 50° - 180° for Mambo) | ||
#### `public fire()` | ||
* Instructs the drone to fire the cannon |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
27427
416
64