Skip to content

Commit

Permalink
Update Web App to Reflect Peripheral Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TekuConcept committed Mar 22, 2017
1 parent c7e94ff commit b34020d
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 57 deletions.
37 changes: 21 additions & 16 deletions BoneCentral/Brain/CppInterface/ThrustController.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,50 @@ module.exports = (function(){
this._cmdOut = cmdOut;
}

ThrustController.prototype.goDirection = function(forward, strafe, dive) {
ThrustController.prototype.goDirection = function(move, secondDive, dive) {
var cmdString =
"goDirection " + forward + " " + strafe + " " + " " + dive + "\n";
"goDirection " + move + " " + secondDive + " " + " " + dive + "\n";
this._cmdOut.write(cmdString);
};

ThrustController.prototype.faceDirection = function(yaw, dive){
ThrustController.prototype.rotate = function(yaw, pitch, roll){
var cmdString =
"faceDirection " + yaw + " " + dive + "\n";
"rotate " + yaw + " " + pitch + " " + roll + "\n";
this._cmdOut.write(cmdString);
};

ThrustController.prototype.setDiveOffset = function(front, back) {
var cmdString = "setDiveOffset " + front + " " + back + "\n";
ThrustController.prototype.move = function (throttle) {
var cmdString = "move " + throttle + "\n";
this._cmdOut.write(cmdString);
};

ThrustController.prototype.setForwardTrim = function(left, right) {
var cmdString = "setForwardTrim " + left + " " + right + "\n";
ThrustController.prototype.secondaryDive = function (throttle) {
var cmdString = "secondaryDive " + throttle + "\n";
this._cmdOut.write(cmdString);
};

ThrustController.prototype.setStrafeTrim = function(left, right) {
var cmdString = "setStrafeTrim " + left + " " + right + "\n";
ThrustController.prototype.dive = function (throttle) {
var cmdString = "primaryDive " + throttle + "\n";
this._cmdOut.write(cmdString);
};

ThrustController.prototype.setDiveTrim = function(front, back) {
var cmdString = "setDiveTrim " + front + " " + back + "\n";
ThrustController.prototype.yaw = function (throttle) {
var cmdString = "yaw " + throttle + "\n";
this._cmdOut.write(cmdString);
};

ThrustController.prototype.thrustForward = function (left, right) {
var cmdString = "thrustForward " + left + " " + right + "\n";
ThrustController.prototype.pitch = function (throttle) {
var cmdString = "pitch " + throttle + "\n";
this._cmdOut.write(cmdString);
};

ThrustController.prototype.dive = function (forward, rear) {
var cmdString = "dive " + forward + " " + rear + "\n";
ThrustController.prototype.roll = function (throttle) {
var cmdString = "roll " + throttle + "\n";
this._cmdOut.write(cmdString);
};

ThrustController.prototype.kill = function () {
var cmdString = "killThrust\n";
this._cmdOut.write(cmdString);
};

Expand Down
71 changes: 38 additions & 33 deletions BoneCentral/WebApplication/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,65 +53,70 @@ app.post('/thrust', function(req, res) {
res.send('thrust ' + req.body.powerLevel);
});


app.get('/stdoutData', function(req, res) {
res.send(webLogger.pull());
});

app.post('/thrustForward', function (req, res) {
var params = req.body;
thrustController.thrustForward(params.left, params.right);
res.send('');
// From IThrustController
app.post('/move', function (req, res) {
var params = req.body;
thrustController.move(params.throttle);
res.send('');
});

app.post('/dive', function (req, res) {
// From IThrustController
app.post('/secondaryDive', function (req, res) {
var params = req.body;
thrustController.dive(params.forward, params.rear);
thrustController.secondaryDive(params.throttle);
res.send('');
});

// From IThrustController
app.post('/goDirection', function(req, res) {
var params = req.body;
thrustController.goDirection(params.forward, params.strafe, params.dive);
res.send('');
app.post('/dive', function (req, res) {
var params = req.body;
thrustController.dive(params.throttle);
res.send('');
});

app.post('/faceDirection', function(req, res) {
thrustController.faceDirection(req.body.yaw, req.body.dive);
res.send('');
// From IThrustController
app.post('/yaw', function (req, res) {
var params = req.body;
thrustController.yaw(params.throttle);
res.send('');
});

// From setForwardTrim

app.post('/setForwardTrim', function(req, res) {
var params = req.body;
thrustController.setForwardTrim(params.left, params.right);
res.send('');
// From IThrustController
app.post('/pitch', function (req, res) {
var params = req.body;
thrustController.pitch(params.throttle);
res.send('');
});

// From setStrafeTrim
// From IThrustController
app.post('/roll', function (req, res) {
var params = req.body;
thrustController.roll(params.throttle);
res.send('');
});

app.post('/setStrafeTrim', function(req, res) {
// From IThrustController
app.post('/goDirection', function(req, res) {
var params = req.body;
thrustController.setStrafeTrim(params.left, params.right);
thrustController.goDirection(params.move, params.secondaryDive, params.dive);
res.send('');
});

// From setDiveTrim

app.post('/setDiveTrim', function(req, res) {
// From IThrustController
app.post('/rotate', function(req, res) {
var params = req.body;
thrustController.setDiveTrim(params.front, params.back);
thrustController.rotate(params.yaw, params.pitch, params.roll);
res.send('');
});

// From diveOffset

app.post('/setDiveOffset', function(req, res) {
var params = req.body;
thrustController.setDiveOffset(params.front, params.back);
res.send('');
// From IThrustController
app.get('/killThrust', function(req, res) {
thrustController.kill();
res.send('killThrust');
});

// From Imu
Expand Down
17 changes: 9 additions & 8 deletions BoneCentral/WebApplication/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,15 @@
<single-get-tag url='/exit'></single-get-tag>
</div>
<div style="width: 22%; float: left;">
<post-tag url='/thrustForward' arguments='["left", "right"]' min="-1" max="1" step="0.01"></post-tag>
<post-tag url='/dive' arguments='["forward", "rear"]' min="-1" max="1" step="0.01"></post-tag>
<post-tag url='/goDirection' arguments='["forward", "strafe", "dive"]' min="-1" max="1" step="0.01"></post-tag>
<post-tag url='/faceDirection' arguments='["yaw", "dive"]' min="-1" max="1" step="0.01"></post-tag>
<post-tag url='/setForwardTrim' arguments='["left", "right"]' min="-1" max="1" step="0.01"></post-tag>
<post-tag url='/setStrafeTrim' arguments='["left", "right"]' min="-1" max="1" step="0.01"></post-tag>
<post-tag url='/setDiveTrim' arguments='["front", "back"]' min="-1" max="1" step="0.01"></post-tag>
<post-tag url='/setDiveOffset' arguments='["front", "back"]' min="-1" max="1" step="0.01"></post-tag>
<post-tag url='/move' arguments='["throttle"]' min="-1" max="1" step="0.01"></post-tag>
<post-tag url='/secondaryDive' arguments='["throttle"]' min="-1" max="1" step="0.01"></post-tag>
<post-tag url='/dive' arguments='["throttle"]' min="-1" max="1" step="0.01"></post-tag>
<post-tag url='/yaw' arguments='["throttle"]' min="-1" max="1" step="0.01"></post-tag>
<post-tag url='/pitch' arguments='["throttle"]' min="-1" max="1" step="0.01"></post-tag>
<post-tag url='/roll' arguments='["throttle"]' min="-1" max="1" step="0.01"></post-tag>
<post-tag url='/goDirection' arguments='["move", "secondaryDive", "dive"]' min="-1" max="1" step="0.01"></post-tag>
<post-tag url='/rotate' arguments='["yaw", "pitch", "roll"]' min="-1" max="1" step="0.01"></post-tag>
<single-get-tag url='/killThrust'></single-get-tag>
</div>
<div style="width: 22%; float: left;">
<single-get-tag url='/getAcceleration'></single-get-tag>
Expand Down

0 comments on commit b34020d

Please sign in to comment.