diff --git a/clients/asserv/asserv.js b/clients/asserv/asserv.js
index 8de71e3..e814130 100644
--- a/clients/asserv/asserv.js
+++ b/clients/asserv/asserv.js
@@ -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);
diff --git a/clients/asserv/asserv.real.js b/clients/asserv/asserv.real.js
index 8953b5c..7d0b436 100644
--- a/clients/asserv/asserv.real.js
+++ b/clients/asserv/asserv.real.js
@@ -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(){
@@ -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));
}
@@ -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
diff --git a/clients/asserv/asserv.simu.js b/clients/asserv/asserv.simu.js
index 322af6b..47311de 100644
--- a/clients/asserv/asserv.simu.js
+++ b/clients/asserv/asserv.simu.js
@@ -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 = {
diff --git a/clients/robot/robot.js b/clients/robot/robot.js
index 18f6e81..1271660 100644
--- a/clients/robot/robot.js
+++ b/clients/robot/robot.js
@@ -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();
diff --git a/ia/gr.class.js b/ia/gr.class.js
index 2ec5799..fa0bf93 100644
--- a/ia/gr.class.js
+++ b/ia/gr.class.js
@@ -36,6 +36,11 @@ class Gr extends Robot{
d: 390
};
+ /** Initial position */
+ if (this.ia.color == "blue") {
+ } else {
+ }
+
/** Initial position */
if (this.ia.color == "blue") {
this.initialPos = {
@@ -43,12 +48,22 @@ class Gr extends Robot{
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;
diff --git a/ia/pr.class.js b/ia/pr.class.js
index 630fb45..55454a3 100644
--- a/ia/pr.class.js
+++ b/ia/pr.class.js
@@ -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,
diff --git a/ia/robot.class.js b/ia/robot.class.js
index cfac3f3..3cccb57 100644
--- a/ia/robot.class.js
+++ b/ia/robot.class.js
@@ -65,6 +65,8 @@ class Robot{
/** Robot actions */
this.actions = null;
this.Actions = require('./actions.class.js');
+
+ this.startPos = this.initialPos;
}
/**
@@ -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);
}
/**
diff --git a/webclient/index.js b/webclient/index.js
index 09f0cae..78c35ec 100644
--- a/webclient/index.js
+++ b/webclient/index.js
@@ -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', {});
diff --git a/webclient/index.tpl.html b/webclient/index.tpl.html
index 7b4e491..45aa578 100644
--- a/webclient/index.tpl.html
+++ b/webclient/index.tpl.html
@@ -52,6 +52,7 @@
+
@@ -61,6 +62,7 @@
+