Skip to content

Commit

Permalink
Merge branch 'dddanmar-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
noerw committed Dec 4, 2016
2 parents 4c62d85 + 2b97382 commit 15f0b2c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ I recommend testing the button layout [here](http://html5gamepad.com/) first, an
|Button 2 / B|hover / stop current motion|
|Button 3 / Y|flip (front)|
|Button 4 / X|flat trim|
|Button 9|disable emergency|
|Button 9|disable emergency (enable takeoff again eg after a crash)|

## Installing & activating the plugin
You will need the
Expand All @@ -46,7 +46,7 @@ To install `adrone-webflight`, see the respective repo.
Link `webflight-gamepad` into webflight's `plugins` directory, or add it as a git submodule:

```
cd ardrone-webflight/plugins
cd ardrone-webflight/plugins
ln -s ../../webflight-gamepad gamepad
```

Expand All @@ -55,16 +55,15 @@ so it looks something like this:

```
plugins: [
"video-stream" // Display the video as a native h264 stream decoded in JS
"video-stream" // Display the video as a native h264 stream decoded in JS
, "hud" // Display the artificial horizon, altimeter, compass, etc.
, "pilot" // Pilot the drone with the keyboard
, "gamepad" // Pilot the drone with a joystick/gamepad
]
```

## configuration

All controls may be remapped.
All controls may be remapped in webflights' main configuration file.
Also, custom commands (eg. for other plugins) may be added!

The default configuration looks like this, and is merged with the `config.gamepad` object in `ardrone-webflight/config.js`:
Expand Down Expand Up @@ -93,9 +92,7 @@ The default configuration looks like this, and is merged with the `config.gamepa
```

### autoStabilize

The auto-stabilization feature is disabled by default.
When enabled in the config, the drone will automatically hover after the specified delay, once you don't touch any of the sticks!
When `autoStabilize` is enabled, the drone will automatically hover once you the sticks let go after the specified delay.

### custom commands
To define a custom command, add an object with the following structure to the `gamepad.customCommands` array:
Expand All @@ -113,4 +110,6 @@ Any websocket message may be sent this way to the node server!
## License
Published under the [apache license 2.0](http://www.apache.org/licenses/LICENSE-2.0).

Originially written by [wiseman](https://github.com/wiseman/webflight-gamepad), updated & extended by [noerw](https://github.com/noerw/webflight-gamepad)
---

Originially written by [wiseman](https://github.com/wiseman/webflight-gamepad), updated & extended by [noerw](https://github.com/noerw/webflight-gamepad)
16 changes: 8 additions & 8 deletions public/js/gamepad.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
flatTrim: 3,
takeoff: 6,
land: 7,
recoverEmergency: 8
disableEmergency: 8
},
customCommands: []
};
Expand Down Expand Up @@ -187,7 +187,7 @@
if (gamepadsChanged) {}
}
};

Gamepad.prototype.updateDisplay = function(gamepadId) {
var gamepad = this.gamepads[gamepadId],
cfg = this.config.controls,
Expand All @@ -197,19 +197,19 @@
gamepad.axes[cfg.pitch.axis], gamepad.axes[cfg.roll.axis],
gamepad.axes[cfg.yaw.axis], gamepad.axes[cfg.altitude.axis]
);

if(gamepad.buttons[cfg.flip].pressed)
socket.emit('/pilot/animate', { action: 'flipAhead' });

if(gamepad.buttons[cfg.takeoff].pressed)
socket.emit('/pilot/move', { action: 'takeoff' });

if(gamepad.buttons[cfg.land].pressed) {
this.droneIsMoving = false;
socket.emit('/pilot/move', { action: 'land' });
}
if(gamepad.buttons[cfg.recoverEmergency].pressed)

if(gamepad.buttons[cfg.disableEmergency].pressed)
socket.emit('/pilot/move', { action: 'disableEmergency' });

if(gamepad.buttons[cfg.hover].pressed) {
Expand All @@ -219,7 +219,7 @@

if(gamepad.buttons[cfg.flatTrim].pressed && !this.droneIsMoving)
socket.emit('/pilot/ftrim');

if(gamepad.buttons[cfg.switchCams].pressed)
socket.emit('/pilot/channel');

Expand All @@ -232,4 +232,4 @@

window.Cockpit.plugins.push(Gamepad);

}(window, document, jQuery));
}(window, document, jQuery));

0 comments on commit 15f0b2c

Please sign in to comment.