Created
April 6, 2021 13:35
-
-
Save fisherds/9c014de42af401bababfc5f2273f500b to your computer and use it in GitHub Desktop.
Starting code for testing the drive system of the RoseBot via Node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const prompt = require('prompt-sync')({sigint: true}); | |
| // # ------------------------------------------------------------------------- | |
| // # TODO: import rosebot | |
| // const rosebot = require("./rosebot"); | |
| // # ------------------------------------------------------------------------- | |
| function msleep(n) { | |
| Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, n); | |
| } | |
| function sleep(n) { | |
| msleep(n*1000); | |
| } | |
| function main() { | |
| console.log('--------------------------------------------------') | |
| console.log('Testing the DRIVE SYSTEM of a robot') | |
| console.log('--------------------------------------------------') | |
| // # ------------------------------------------------------------------------- | |
| // # TODO: Create a robot. | |
| // # ------------------------------------------------------------------------- | |
| while (true) { | |
| console.log("Wheel speeds should be integers between -100 and 100.") | |
| console.log("Enter values of 0 for both to exit.") | |
| let leftWheelSpeed = parseInt(prompt('Enter an integer for left wheel speed: ')); | |
| let rightWheelSpeed = prompt('Enter an integer for right wheel speed: '); | |
| rightWheelSpeed = parseInt(rightWheelSpeed); | |
| if (leftWheelSpeed == 0 && rightWheelSpeed == 0) { | |
| break; | |
| } | |
| prompt('Press the ENTER key when ready for the robot to start moving.'); | |
| // # ------------------------------------------------------------------------- | |
| // # TODO: Call the go method of the driveSystem of the robot, | |
| // # sending it the two wheel speeds. Keep going (sleep) for 3 seconds. | |
| // # Then call the stop method of the driveSystem of the robot. | |
| // # ------------------------------------------------------------------------- | |
| } | |
| } | |
| main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment