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

Commit

Permalink
Virtually all actuators working (short circuit on continuous servo)
Browse files Browse the repository at this point in the history
  • Loading branch information
utcoupe-dev rpi3-3 committed May 23, 2017
1 parent aebf958 commit c8ac25a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
5 changes: 3 additions & 2 deletions clients/actuators/ax12.real.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ class Ax12Real extends Ax12 {
}
// this.ordersSerial.sendOrder(this.actuatorCommands.PARAMETER, [], callback);
this.logger.debug("INIT movements")
this.ordersSerial.sendOrder(this.actuatorCommands.AX12_ONE, [this.actuatorCommands.PR_MODULE_GRABBER], () => {});
this.ordersSerial.sendOrder(this.actuatorCommands.AX12_ONE, [this.actuatorCommands.PR_MODULE_GRABBER], () => {
this.ordersSerial.sendOrder(this.actuatorCommands.AX12_INIT, [this.actuatorCommands.PR_MODULE_GRABBER], () => {});
});

this.ordersSerial.sendOrder(this.actuatorCommands.AX12_ONE, [this.actuatorCommands.PR_MODULE_DUMMY], () => {
this.ordersSerial.sendOrder(this.actuatorCommands.AX12_INIT, [this.actuatorCommands.PR_MODULE_DUMMY], () => {});
Expand Down Expand Up @@ -140,7 +141,7 @@ class Ax12Real extends Ax12 {

stop() {
// this.logger.error("TODO: AX12 real stop()");
if (this.stdStreamConnected) {
if (this.stdStreamConnected && !!this.ordersSerial) {
this.ordersSerial.sendOrder(this.actuatorCommands.HALT, []);
} else {
this.logger.error("TODO: AX12 real stop()");
Expand Down
21 changes: 21 additions & 0 deletions clients/actuators/servo.real.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,27 @@ class ServoReal extends Servo {
if (receivedCommand.indexOf("0;") == 0) {
this.serialPortConnected = true;
this.ordersSerial = require("../shared/orders.serial")(this.serialPort);


this.logger.debug("INIT movements")
this.ordersSerial.sendOrder(this.actuatorCommands.SERVO_OPEN, [this.actuatorCommands.PR_MODULE_ARM_ROTATE], () => {
this.ordersSerial.sendOrder(this.actuatorCommands.SERVO_CLOSE, [this.actuatorCommands.PR_MODULE_ARM_ROTATE], () => {});
});
this.ordersSerial.sendOrder(this.actuatorCommands.SERVO_CLOSE, [this.actuatorCommands.PR_MODULE_ARM], () => {
this.ordersSerial.sendOrder(this.actuatorCommands.SERVO_OPEN, [this.actuatorCommands.PR_MODULE_ARM], () => {});
});

this.ordersSerial.sendOrder(this.actuatorCommands.SERVO_OPEN, [this.actuatorCommands.PR_MODULE_DROP_R], () => {
this.ordersSerial.sendOrder(this.actuatorCommands.SERVO_CLOSE, [this.actuatorCommands.PR_MODULE_DROP_R], () => {});
});
this.ordersSerial.sendOrder(this.actuatorCommands.SERVO_OPEN, [this.actuatorCommands.PR_MODULE_DROP_L], () => {
this.ordersSerial.sendOrder(this.actuatorCommands.SERVO_CLOSE, [this.actuatorCommands.PR_MODULE_DROP_L], () => {});

});




}
}
}
Expand Down
6 changes: 3 additions & 3 deletions clients/extension/baseconstructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ class BaseConstructor extends Extension {
this.nbModulesToDrop--;
} else {
this.logger.error("Aucun module à déposer !");
this.fifo.orderFinished();
// this.fifo.orderFinished();
}
this.servos.moduleDrop( () => {
this.logger.fatal("Entering in moduleDrop callback");
this.fifo.orderFinished();
});
this.fifo.newOrder(() => {
this.sendDataToIA("pr.module--", {});
this.fifo.orderFinished();
}, "sendModule--");
break;
case "engage":
Expand Down Expand Up @@ -241,7 +241,7 @@ class BaseConstructor extends Extension {
if (this.color != "null")
this.fifo.newOrder(() => {
this.processFifoOrder("rotate", {color: this.color})
});
}, "rotate");

}

Expand Down
8 changes: 7 additions & 1 deletion clients/shared/fifo.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Fifo {
constructor() {
this.logger = require('log4js').getLogger('Fifo');
this.clean();

this.current_order_name = null;
}

/**
Expand All @@ -29,12 +31,15 @@ class Fifo {
this.fifo = [];
/** @type {boolean} */
this.order_in_progress = false;
this.current_order_name = null;
}

/**
* Fonction à appeler lorsque un ordre est terminé. Cette fonction invoque directement l'ordre suivant (si il existe)
*/
orderFinished () {
this.logger.info(this.current_order_name + " done !");
this.current_order_name = null;
this.order_in_progress = false;
this.nextOrder();
}
Expand Down Expand Up @@ -62,7 +67,8 @@ class Fifo {
// logger.debug(this.fifo.length);
this.order_in_progress = true;
var object = this.fifo.shift();
// logger.debug("Calling : "+object.name);
this.current_order_name = object.name;
this.logger.info("Doing "+this.current_order_name);
object.callback();
}
}
Expand Down

0 comments on commit c8ac25a

Please sign in to comment.