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.