Changed flower message
This commit is contained in:
parent
6be0b47f9e
commit
729ea72579
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -20,6 +20,7 @@ class Forklift {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setPath(path) {
|
setPath(path) {
|
||||||
|
debugger;
|
||||||
this.end = false;
|
this.end = false;
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.currentTarget = this.path[this.targetId];
|
this.currentTarget = this.path[this.targetId];
|
||||||
@ -27,8 +28,8 @@ class Forklift {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nextTarget() {
|
nextTarget() {
|
||||||
|
if (this.targetId < this.path.length - 1) {
|
||||||
this.targetId += 1;
|
this.targetId += 1;
|
||||||
if (this.targetId < this.path.length) {
|
|
||||||
this.currentTarget = this.path[this.targetId];
|
this.currentTarget = this.path[this.targetId];
|
||||||
} else {
|
} else {
|
||||||
// Final destination reached
|
// Final destination reached
|
||||||
@ -36,7 +37,6 @@ class Forklift {
|
|||||||
//this.removeCargo();
|
//this.removeCargo();
|
||||||
this.end = true;
|
this.end = true;
|
||||||
this.targetId = 0;
|
this.targetId = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ class Forklift {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async findPath(targetSection) {
|
findPath(targetSection) {
|
||||||
let data = {
|
let data = {
|
||||||
graph: magazineToGraph(),
|
graph: magazineToGraph(),
|
||||||
start_node: forklift.currentSection,
|
start_node: forklift.currentSection,
|
||||||
@ -73,6 +73,7 @@ class Forklift {
|
|||||||
serverUrl + '/shortestPath',
|
serverUrl + '/shortestPath',
|
||||||
data,
|
data,
|
||||||
response => {
|
response => {
|
||||||
|
console.log('Find path request data: ', data);
|
||||||
let path = response.split('').map(Number);
|
let path = response.split('').map(Number);
|
||||||
this.currentTarget = path[0];
|
this.currentTarget = path[0];
|
||||||
this.setPath(path);
|
this.setPath(path);
|
||||||
@ -86,13 +87,17 @@ class Forklift {
|
|||||||
|
|
||||||
completeOrder(order) {
|
completeOrder(order) {
|
||||||
this.waitUntilJobIsDone()
|
this.waitUntilJobIsDone()
|
||||||
.then(() => this.findPath(order.from))
|
.then(() => {
|
||||||
|
if (this.currentSection != order.from) {
|
||||||
|
this.findPath(order.from);
|
||||||
|
}
|
||||||
|
})
|
||||||
.then(() => this.waitUntilJobIsDone())
|
.then(() => this.waitUntilJobIsDone())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.setCargo(order.what)
|
this.setCargo(order.what);
|
||||||
magazineState[order.from] = magazineState[order.from].filter((flower) => {
|
magazineState[order.from] = magazineState[order.from].filter(flower => {
|
||||||
return flower != order.what;
|
return flower != order.what;
|
||||||
})
|
});
|
||||||
this.findPath(order.to);
|
this.findPath(order.to);
|
||||||
})
|
})
|
||||||
.then(() => this.waitUntilJobIsDone())
|
.then(() => this.waitUntilJobIsDone())
|
||||||
@ -131,6 +136,7 @@ class Forklift {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub(target, pos) {
|
sub(target, pos) {
|
||||||
|
console.log(target, pos);
|
||||||
return createVector(target.x - pos.x, target.y - pos.y);
|
return createVector(target.x - pos.x, target.y - pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ function setup() {
|
|||||||
|
|
||||||
// Create a forklift instance
|
// Create a forklift instance
|
||||||
forklift = new Forklift(sections[0].x, sections[0].y);
|
forklift = new Forklift(sections[0].x, sections[0].y);
|
||||||
setInterval(ageFlowers, 5000)
|
setInterval(ageFlowers, 5000);
|
||||||
|
|
||||||
select('#completeOrdersButton').mousePressed(forklift.completeOrders());
|
select('#completeOrdersButton').mousePressed(forklift.completeOrders());
|
||||||
}
|
}
|
||||||
@ -81,10 +81,12 @@ function addOrder() {
|
|||||||
petalWidth: pw,
|
petalWidth: pw,
|
||||||
petalLength: pl,
|
petalLength: pl,
|
||||||
};
|
};
|
||||||
console.log(data)
|
console.log(data);
|
||||||
httpPost(serverUrl + '/classify', data, response => {
|
httpPost(serverUrl + '/classify', data, response => {
|
||||||
magazineState[0].push(new Flower(response));
|
magazineState[0].push(new Flower(response));
|
||||||
forklift.completeOrder(new Order(0, magazineState[0][0], magazineState[0][0].type, 'cycki'));
|
forklift.completeOrder(
|
||||||
|
new Order(0, magazineState[0][0], magazineState[0][0].type, 'msg'),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,13 +143,18 @@ function ageFlowers() {
|
|||||||
let order;
|
let order;
|
||||||
let priority;
|
let priority;
|
||||||
if (int(key) == 0) {
|
if (int(key) == 0) {
|
||||||
order = new Order(0, flower, int(flower), "Delivering new flower");
|
order = new Order(0, flower, int(flower), 'Delivering new flower');
|
||||||
priority = 1;
|
priority = 1;
|
||||||
} else if (int(key) > 3) {
|
} else if (int(key) > 3) {
|
||||||
order = new Order(int(key), flower, 0, "Fully grown flower ready");
|
order = new Order(int(key), flower, 0, 'Fully grown flower ready');
|
||||||
priority = 3;
|
priority = 3;
|
||||||
} else {
|
} else {
|
||||||
order = new Order(int(key), flower, (int(key) + 3), "Moving grown flower seedling");
|
order = new Order(
|
||||||
|
int(key),
|
||||||
|
flower,
|
||||||
|
int(key) + 3,
|
||||||
|
'Moving grown flower seedling',
|
||||||
|
);
|
||||||
priority = 2;
|
priority = 2;
|
||||||
}
|
}
|
||||||
forklift.queue.enqueue([order, priority]);
|
forklift.queue.enqueue([order, priority]);
|
||||||
|
Loading…
Reference in New Issue
Block a user