Add forklift moving to given section

This commit is contained in:
Jacob 2019-04-06 21:40:30 +02:00
parent e5e8669663
commit 991b41d05d
3 changed files with 25 additions and 22 deletions

View File

@ -8,6 +8,7 @@ class Forklift {
this.velocity = createVector(0, 0); this.velocity = createVector(0, 0);
this.direction = createVector(0, 0); this.direction = createVector(0, 0);
this.end = false; this.end = false;
this.currentSection = 0;
} }
draw() { draw() {
@ -16,6 +17,7 @@ class Forklift {
} }
setPath(path) { setPath(path) {
this.end = false;
this.path = path; this.path = path;
this.currentTarget = this.path[this.targetId]; this.currentTarget = this.path[this.targetId];
this.setVelocity(); this.setVelocity();
@ -27,10 +29,12 @@ class Forklift {
this.currentTarget = this.path[this.targetId]; this.currentTarget = this.path[this.targetId];
} else { } else {
this.end = true; this.end = true;
this.targetId = 0;
} }
} }
targetReached() { targetReached() {
this.currentSection = this.currentTarget;
return this.end; return this.end;
} }

View File

@ -66,10 +66,9 @@ function drawMagazine() {
function deliver() { function deliver() {
let data = { let data = {
graph: magazineToGraph(), graph: magazineToGraph(),
start_node: 0, start_node: forklift.currentSection,
dest_node: int(target.value()) dest_node: int(target.value())
}; };
console.log(data);
httpPost( httpPost(
'http://localhost:8000/shortestPath', 'http://localhost:8000/shortestPath',
data, data,
@ -91,13 +90,23 @@ function createMagazineLayout() {
sections = { sections = {
0: { x: unit * 2, y: 0 }, 0: { x: unit * 2, y: 0 },
1: createVector(unit, unit), 1: createVector(unit, unit),
2: createVector(2 * unit, unit), 2: createVector(unit, 2 * unit),
3: createVector(2 * unit, 2 * unit), 3: createVector(unit, 3 * unit),
4: createVector(3 * unit, 2 * unit), 4: createVector(3 * unit, unit),
5: createVector(unit, 3 * unit), 5: createVector(3 * unit, 2 * unit),
6: createVector(2 * unit, 3 * unit) 6: createVector(3 * unit, 3 * unit)
}; };
roads = [[0, 2], [1, 2], [1, 5], [5, 4], [5, 6], [4, 3], [2, 3], [3, 6]]; roads = [
[1, 5],
[2, 3],
[0, 1],
[0, 4],
[4, 5],
[5, 6],
[3, 6],
[4, 2],
[5, 3]
];
} }
function magazineToGraph() { function magazineToGraph() {

View File

@ -41,24 +41,14 @@
<div class="container"> <div class="container">
<div class="package"> <div class="package">
<h3 style="margin-top: 0;">Package description</h1> <h3 style="margin-top: 0;">Package description</h1>
<label for="width">Max Width</label> <label for="width">Sepal Width</label>
<input type="number" name="width"> <input type="number" name="width">
<label for="topWidth">Top Width</label> <label for="topWidth">Sepal Length</label>
<input type="number" name="topWidth"> <input type="number" name="topWidth">
<label for="botWidth">Bottom Width</label> <label for="botWidth">Petal Width</label>
<input type="number" name="botWidth"> <input type="number" name="botWidth">
<label for="height">Max Height</label> <label for="height">Petal Length</label>
<input type="number" name="height"> <input type="number" name="height">
<label for="topHeight">Top Height</label>
<input type="number" name="topHeight">
<label for="botHeight">Bottom Height</label>
<input type="number" name="botHeight">
<label for="depth">Max Depth</label>
<input type="number" name="depth">
<div style="margin-top: 5px">
<input type="radio" name="material"> Hard
<input type="radio" name="material"> Soft
</div>
<label for="target">Target</label> <label for="target">Target</label>
<input type="number" id="target" name="target"> <input type="number" id="target" name="target">
<button id="button">Send Package</button> <button id="button">Send Package</button>