Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
Place robot working (pos bullshit)
Browse files Browse the repository at this point in the history
  • Loading branch information
utcoupe-dev rpi3-3 committed May 23, 2017
1 parent c8ac25a commit adf94cb
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 5 deletions.
2 changes: 2 additions & 0 deletions clients/asserv/asserv.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ class Asserv{
*/
setPid(p, i, d){}

doStartSequence(params) {}

addOrderToFifo(name, params){
this.logger.debug("Adding order to fifo : " + name);
// this.logger.debug(order.params);
Expand Down
13 changes: 10 additions & 3 deletions clients/asserv/asserv.real.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ class AsservReal extends Asserv{
/********************************************************************/

setPos(pos) {
this.ordersSerial.sendOrder(this.asservCommands.SET_POS, [parseInt(pos.x), parseInt(pos.y), this.myWriteFloat(pos.a)], function() { this.fifo.orderFinished(); }.bind(this));
if (!!this.ordersSerial) {
this.ordersSerial.sendOrder(this.asservCommands.SET_POS, [parseInt(pos.x), parseInt(pos.y), this.myWriteFloat(pos.a)], function() { this.fifo.orderFinished(); }.bind(this));
}
}

clean(){
Expand Down Expand Up @@ -112,8 +114,8 @@ class AsservReal extends Asserv{
goxy(x, y, sens) {
//todo sens in english
var sensInt;
if(sens == "avant") sensInt = 1;
else if(sens == "arriere") sensInt = -1;
if(sens == "forward") sensInt = 1;
else if(sens == "backward") sensInt = -1;
else sensInt = 0;
this.ordersSerial.sendOrder(this.asservCommands.GOTO, [parseInt(x), parseInt(y), parseInt(sensInt)], function() { this.fifo.orderFinished(); }.bind(this));
}
Expand All @@ -126,6 +128,11 @@ class AsservReal extends Asserv{
this.ordersSerial.sendOrder(this.asservCommands.PIDALL, [this.myWriteFloat(p), this.myWriteFloat(i), this.myWriteFloat(d)], function() { this.fifo.orderFinished(); }.bind(this));
}

doStartSequence(params){
this.goxy(params.x, params.y, "forward");
this.goa(params.a, () => {});
}

/********************************************************************\
*
* HELPERS FUNCTIONS
Expand Down
4 changes: 4 additions & 0 deletions clients/asserv/asserv.simu.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ class AsservSimu extends Asserv{
this.fifo.orderFinished();
}

doStartSequence(params){
this.fifo.orderFinished();
}

simu_speed(speed, x, y, a, dt) {
return function() {
this.pos = {
Expand Down
3 changes: 3 additions & 0 deletions clients/robot/robot.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class Robot extends Client{
//this.acts.clean();
this.orderInProgress = false;
break;
case "do_start_sequence":
this.asserv.doStartSequence(params);
break;
case "stop":
//TODO DO it with new actuators
//this.acts.clean();
Expand Down
15 changes: 15 additions & 0 deletions ia/gr.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,34 @@ class Gr extends Robot{
d: 390
};

/** Initial position */
if (this.ia.color == "blue") {
} else {
}

/** Initial position */
if (this.ia.color == "blue") {
this.initialPos = {
x: 175,
y: 175,
a: 0,
}
this.startPos = {
x: 275,
y: 175,
a: 0,
}
} else {
this.initialPos = {
x: 2825,
y: 175,
a: 3.1415,
}
this.startPos = {
x: 2725,
y: 175,
a: 3.1415,
}
}

this.pos.x = this.initialPos.x;
Expand Down
20 changes: 20 additions & 0 deletions ia/pr.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ class Pr extends Robot{
y: 175,
a: 1.5707,
}
this.startPos = {
x: 900,
y: 175,
a: 0,
}
} else {
this.initialPos = {
x: 2100,
y: 175,
a: 1.5707,
}
this.startPos = {
x: 2100,
y: 175,
a: 3.1415,
}
}

/** Place position */
if (this.ia.color == "blue") {
} else {
this.initialPos = {
x: 2100,
Expand Down
6 changes: 4 additions & 2 deletions ia/robot.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class Robot{
/** Robot actions */
this.actions = null;
this.Actions = require('./actions.class.js');

this.startPos = this.initialPos;
}

/**
Expand Down Expand Up @@ -178,9 +180,9 @@ class Robot{
* Place robot before starting the match
*/
place () {
this.ia.client.send(this.name, "asserv.setpos", this.initialPos);
this.sendInitialPos ()

this.ia.client.send(this.name, "do_start_sequence", {});
this.ia.client.send(this.name, "do_start_sequence", this.startPos);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions webclient/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ angular.module('app').controller('IndexCtrl', ['$rootScope', '$scope', 'UTCoupe'
$scope.stop = function(u) {
Client.send(u, 'stop');
};
$scope.place = function(u) {
Client.send("ia", u + '.place');
};

$scope.jack = function() {
Client.send('ia', 'ia.jack', {});
Expand Down
2 changes: 2 additions & 0 deletions webclient/index.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<button type="button" class="btn" ng-show="utcoupe.gr" ng-click="kill('gr')">Arrêter</button>
<button type="button" class="btn" ng-click="start('gr')">Start</button>
<button type="button" class="btn" ng-click="stop('gr')">Stop</button>
<button type="button" class="btn" ng-click="place('gr')">Placer</button>
<!-- /!\ Met du temps à cause du sudo /!\ -->
<br /><br />
</li>
Expand All @@ -61,6 +62,7 @@
<button type="button" class="btn" ng-show="utcoupe.pr" ng-click="kill('pr')">Arrêter</button>
<button type="button" class="btn" ng-click="start('pr')">Start</button>
<button type="button" class="btn" ng-click="stop('pr')">Stop</button>
<button type="button" class="btn" ng-click="place('pr')">Placer</button>
<br /><br />
</li>
<li>
Expand Down

0 comments on commit adf94cb

Please sign in to comment.