Setup - loristissino/RoboThree GitHub Wiki
Files
There are three main directories:
programs
(for simple CLI programs with a high-level interface);servers
(containing the code of the robots' managers and the code for the behaviors of robots, aka application controllers);user-agents
(containing the code that should be read by a browser, like the simulation environment, the simulated infrared remote controls, etc.).
The application is meant to be a playground. This is why there is a separate directory, examples
, containing configuration files, robots' sample behaviors (application controllers) and representations, etc. The examples
directory contains three subdirectories, programs
, servers
and user-agents
, having the same structure of the main ones.
In order to let you play with the code and run your own experiments without risking of having your code
overwritten with git updates, copy the examples to the main directories, following the directory structure.
The simulated infrared remote controls need their own jQuery script and you should copy it from the directory user-agents/world/libs/vendor/
.
On Linux (with bash), you can get the whole job easily done with:
cd examples
for file in $(find . -type f); do cp -v "$file" "../$file"; done
cd ..
cp -v user-agents/world/libs/vendor/jquery-2.1.4.min.js user-agents/remote-controls/
On Windows, use a bash like the one provided by Git for Windows or copy the files manually.
You should get something like this:
.
βββ contributors.txt
...
βββ programs
βΒ Β βββ dashed_line.js
βΒ Β βββ node_modules
βΒ Β βββ RobotCommander.js
βββ README.md
βββ servers
βΒ Β βββ node
βΒ Β βββ controllers
βΒ Β βΒ Β βββ node_modules
βΒ Β βΒ Β βΒ Β βββ HC-SR04.js
βΒ Β βΒ Β βΒ Β βββ IRReceiver.js
βΒ Β βΒ Β βββ ThreeWheelDistanceSensingRobotController.js
βΒ Β βββ managers
βΒ Β βΒ Β βββ node_modules
βΒ Β βΒ Β βΒ Β βββ EspruinoSimulator.js
βΒ Β βΒ Β βββ simplemanager.js
βΒ Β βββ virtualizers
βΒ Β βββ node_modules
βΒ Β βββ ThreeWheelDistanceSensingRobotVirtualizer.js
βββ user-agents
βββ remote-controls
βΒ Β βββ codes
βΒ Β βΒ Β βββ nexPRO.json
βΒ Β βββ infrared.html
βΒ Β βββ jquery-2.1.4.min.js
βΒ Β βββ parseUri.js
βββ world
βββ assets
βΒ Β βββ textures
βΒ Β βββ general
βΒ Β βΒ Β βββ floor-wood-256.png
βΒ Β βΒ Β βββ floor-wood.jpg
βΒ Β βββ robot
βΒ Β βββ wheel.png
βββ config
βΒ Β βββ defaults.js
βΒ Β βββ gui.js
βββ libs
βΒ Β βββ robothree
βΒ Β βΒ Β βββ robothree.js
βΒ Β βββ vendor
βΒ Β βββ ammo.js
βΒ Β βββ chroma.js
βΒ Β βββ dat.gui.js
βΒ Β βββ jquery-2.1.4.min.js
βΒ Β βββ physi.js
βΒ Β βββ physijs_worker.js
βΒ Β βββ stats.min.js
βΒ Β βββ ThreeBSP.js
βΒ Β βββ three.min.js
βββ representations
βΒ Β βββ ThreeWheelDistanceSensingRobotRepresentation.js
βββ world.html
The file world/config/defaults.js
is the place where you can tweak the main configuration of the simulation environment. Edit it at will, but pay attention to IP addresses and port numbers in order to let them match your servers.
Running the robots' managers
You will need a working version of node and npm. Follow the instructions for your OS at nodejs.org. If you use a GNU/Linux distribution, chances are that you already have a packaged version of node (the packages involved could be nodejs and nodejs-legacy, but check the documentation for your distribution and OS version).
To run the servers, you will need the extend
module, that you can obtain by typing
npm install extend -g
(you might need to prepend this command with sudo
).
Go to the servers/node/managers
and run the following command:
node simplemanager.js
You should get an output like:
Activated robot: Β«greenΒ»
Activated robot: Β«redΒ»
Listening on port 9080
If you get an error that reads "Cannot find module 'extend'", you'll need to setup the NODE_PATH environment variable
(something like export NODE_PATH=/usr/local/lib/node_modules
or export NODE_PATH=/usr/lib/node_modules
, depending on how you installed node), or to use the npm link
command to link the global-installed modules to the node_modules
directories under managers
and virtualizers
.
You can use a different port, just adding the number as first parameter:
node simplemanager.js 10080
Opening the simulation
The files of the directory user-agents
must be served by a webserver. If you have one, configure it so that it offers the files. Otherwise, you can use a light webserver like node http-server. For instance, run
npm install http-server -g # only the first time
cd user-agents
http-server
On my computer, I get
Starting up http-server, serving ./
Available on:
http:127.0.0.1:8081
http:192.168.1.12:8081
Hit CTRL-C to stop the server
Open your browser and point it to the /world/world.html
resource.
You should be able to add meshes and robots, to open the simulated infrared remote controls, etc. Just remember that you should activate the simulation to see it action.