Translation and Rotation controls now function
This commit is contained in:
12
index.html
12
index.html
@ -26,14 +26,14 @@
|
|||||||
<legend>Translation & Rotation</legend>
|
<legend>Translation & Rotation</legend>
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label for="vx-slider">Move Forward/Backward (m/s)</label>
|
<label for="vx-slider">Move Forward/Backward (pixels/s)</label>
|
||||||
<input type="range" id="vx-slider" min="-3" max="3" step="0.1" value="0">
|
<input type="range" id="vx-slider" min="-300" max="300" step="0.1" value="0">
|
||||||
<output id="vx-value">0.0</output>
|
<output id="vx-value">0.0</output>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label for="vy-slider">Strafe Left/Right (m/s)</label>
|
<label for="vy-slider">Strafe Left/Right (pixels/s)</label>
|
||||||
<input type="range" id="vy-slider" min="-3" max="3" step="0.1" value="0">
|
<input type="range" id="vy-slider" min="-300" max="300" step="0.1" value="0">
|
||||||
<output id="vy-value">0.0</output>
|
<output id="vy-value">0.0</output>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -50,8 +50,8 @@
|
|||||||
<legend>Performance Limits</legend>
|
<legend>Performance Limits</legend>
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label for="max-speed-slider">Max Module Speed (m/s)</label>
|
<label for="max-speed-slider">Max Module Speed (pixels/s)</label>
|
||||||
<input type="range" id="max-speed-slider" min="1" max="5" step="0.1" value="4">
|
<input type="range" id="max-speed-slider" min="1" max="300" step="0.1" value="4">
|
||||||
<output id="max-speed-value">4.0</output>
|
<output id="max-speed-value">4.0</output>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
21
script.js
21
script.js
@ -301,24 +301,9 @@ function animate() {
|
|||||||
ctx.translate(canvas.width / 2, canvas.height / 2);
|
ctx.translate(canvas.width / 2, canvas.height / 2);
|
||||||
|
|
||||||
// Animation for testing
|
// Animation for testing
|
||||||
xSpeed += xDir;
|
xSpeed = vxSlider.value;
|
||||||
ySpeed += yDir;
|
ySpeed = vySlider.value;
|
||||||
turnSpeed += turnDir;
|
turnSpeed = omegaSlider.value;
|
||||||
if (xSpeed > 100)
|
|
||||||
xDir = -1;
|
|
||||||
else if (xSpeed < -100)
|
|
||||||
xDir = 1;
|
|
||||||
|
|
||||||
if (ySpeed > 100)
|
|
||||||
yDir = -0.8;
|
|
||||||
else if (ySpeed < -100)
|
|
||||||
yDir = 0.8;
|
|
||||||
|
|
||||||
if (turnSpeed > 1)
|
|
||||||
turnDir = -0.01;
|
|
||||||
else if (turnSpeed < -1)
|
|
||||||
turnDir = 0.01;
|
|
||||||
|
|
||||||
|
|
||||||
// Animate the grid with robot movement
|
// Animate the grid with robot movement
|
||||||
let offsetSpeedDivisor = (100 - gridSquareSize <= 0 ? 1 : 100 - gridSquareSize);
|
let offsetSpeedDivisor = (100 - gridSquareSize <= 0 ? 1 : 100 - gridSquareSize);
|
||||||
|
|||||||
Reference in New Issue
Block a user