Skip to content

Commit

Permalink
Merge pull request #482 from chrismbirmingham/iRobot-Create
Browse files Browse the repository at this point in the history
iRobotCreate
  • Loading branch information
tcorbly authored Jan 18, 2024
2 parents 835b384 + 4c1cd6c commit 86b0966
Show file tree
Hide file tree
Showing 320 changed files with 8,382 additions and 6,049 deletions.
2 changes: 0 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ module.exports = {
"dist",
// Ignore webpack config files
"/configs",
// Ignore included ammo.js library
"/src/ammo.js",
// Ignore static files
"/static",
// Ignore dependencies
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ dump.rdb



.dependencygraph/setting.json
.vscode/settings.json
4 changes: 1 addition & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@
[submodule "dependencies/emsdk"]
path = dependencies/emsdk
url = https://github.com/emscripten-core/emsdk
[submodule "dependencies/ammo.js"]
path = dependencies/ammo.js
url = https://github.com/kipr/ammo.js

7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
{
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint",
"editor.formatOnPaste": false, // required
"editor.formatOnType": false, // required
"editor.formatOnSave": true, // optional
"editor.formatOnSaveMode": "file", // required to format on save
"files.autoSave": "onFocusChange", // optional but recommended
"vs-code-prettier-eslint.prettierLast": "false" // set as "true" to run 'prettier' last not first
}
8 changes: 3 additions & 5 deletions configs/webpack/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ try {

const modules = ['node_modules'];
if (dependencies.cpython) modules.push(resolve(dependencies.cpython));
if (dependencies.ammo) modules.push(resolve(dependencies.ammo));

let libkiprCDocumentation = undefined;
if (dependencies.libkipr_c_documentation) {
Expand All @@ -37,7 +36,7 @@ try {
module.exports = {
entry: {
app: './index.tsx',
login: './login/index.tsx',
login: './components/Login/index.tsx',
'editor.worker': 'monaco-editor/esm/vs/editor/editor.worker.js',
'ts.worker': 'monaco-editor/esm/vs/language/typescript/ts.worker.js',
},
Expand All @@ -64,7 +63,7 @@ module.exports = {
path: false,
},
alias: {
'@i18n': resolve(__dirname, '../../src/i18n'),
'@i18n': resolve(__dirname, '../../src/util/i18n'),
},
symlinks: false,
modules
Expand Down Expand Up @@ -137,12 +136,11 @@ module.exports = {
},
plugins: [
new HtmlWebpackPlugin({ template: 'index.html.ejs', excludeChunks: ['login'] }),
new HtmlWebpackPlugin({ template: 'login/login.html.ejs', filename: 'login.html', chunks: ['login'] }),
new HtmlWebpackPlugin({ template: 'components/Login/login.html.ejs', filename: 'login.html', chunks: ['login'] }),
new DefinePlugin({
SIMULATOR_VERSION: JSON.stringify(require('../../package.json').version),
SIMULATOR_GIT_HASH: JSON.stringify(commitHash),
SIMULATOR_HAS_CPYTHON: JSON.stringify(dependencies.cpython !== undefined),
SIMULATOR_HAS_AMMO: JSON.stringify(dependencies.ammo !== undefined),
SIMULATOR_LIBKIPR_C_DOCUMENTATION: JSON.stringify(libkiprCDocumentation),
SIMULATOR_I18N: JSON.stringify(i18n),
}),
Expand Down
1 change: 0 additions & 1 deletion dependencies/ammo.js
Submodule ammo.js deleted from a8b359
78 changes: 26 additions & 52 deletions dependencies/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@
import multiprocessing

def is_tool(name):
"""Check whether `name` is on PATH and marked as executable."""
from shutil import which
return which(name) is not None
"""Check whether `name` is on PATH and marked as executable."""
from shutil import which
return which(name) is not None

# Sanity checks

if not is_tool('cmake'):
print('CMake is not installed. Please install CMake and try again.')
exit(1)
print('CMake is not installed. Please install CMake and try again.')
exit(1)

if not is_tool('make'):
print('Make is not installed. Please install Make and try again.')
exit(1)
print('Make is not installed. Please install Make and try again.')
exit(1)

if not is_tool('swig'):
print('SWIG is not installed. Please install SWIG and try again.')
exit(1)
print('SWIG is not installed. Please install SWIG and try again.')
exit(1)

if not is_tool('doxygen'):
print('Doxygen is not installed. Please install Doxygen and try again.')
exit(1)
print('Doxygen is not installed. Please install Doxygen and try again.')
exit(1)

working_dir = pathlib.Path(__file__).parent.absolute()

Expand Down Expand Up @@ -116,31 +116,31 @@ def is_tool(name):

print('Applying cpython patches...')
for patch_file in (working_dir / 'cpython_patches').glob('*.patch'):
print('Applying patch:', patch_file)
with open(patch_file) as patch:
subprocess.run(
['patch', '-p0', '--forward'],
stdin = patch,
cwd = working_dir
)
print('Applying patch:', patch_file)
with open(patch_file) as patch:
subprocess.run(
['patch', '-p0', '--forward'],
stdin = patch,
cwd = working_dir
)

print('Finding latest host python...')

python = 'python3'
if is_tool('python3.12'):
python = 'python3.12'
python = 'python3.12'
elif is_tool('python3.11'):
python = 'python3.11'
python = 'python3.11'
elif is_tool('python3.10'):
python = 'python3.10'
python = 'python3.10'
elif is_tool('python3.9'):
python = 'python3.9'
python = 'python3.9'
elif is_tool('python3.8'):
python = 'python3.8'
python = 'python3.8'
elif is_tool('python3.7'):
python = 'python3.7'
python = 'python3.7'
else:
print('Warning: Python 3.7+ could not be found. Using python3. This might not work.')
print('Warning: Python 3.7+ could not be found. Using python3. This might not work.')

print(f'Building cpython with {python}...')
subprocess.run(
Expand Down Expand Up @@ -196,31 +196,6 @@ def is_tool(name):
env = env
)

print('Configuring ammo.js...')
ammo_dir = working_dir / 'ammo.js'
ammo_build_dir = working_dir / 'ammo_build'
os.makedirs(ammo_build_dir, exist_ok=True)
subprocess.run(
[
'emcmake',
'cmake',
'-DCLOSURE=1',
'-DTOTAL_MEMORY=268435456',
'-DALLOW_MEMORY_GROWTH=1',
ammo_dir
],
cwd = ammo_build_dir,
check = True,
env = env
)

print('Building ammo.js...')
subprocess.run(
[ 'emmake', 'make', f'-j{multiprocessing.cpu_count()}' ],
cwd = ammo_build_dir,
check = True,
env = env
)

print('Generating JSON documentation...')
libkipr_c_documentation_json = f'{libkipr_build_c_dir}/documentation/json.json'
Expand All @@ -244,9 +219,8 @@ def is_tool(name):
'libkipr_c': f'{libkipr_install_c_dir}',
'libkipr_python': f'{libkipr_build_python_dir}',
'cpython': f'{cpython_emscripten_build_dir}',
'ammo': f'{ammo_build_dir}',
"libkipr_c_documentation": libkipr_c_documentation_json,
})

with open(working_dir / 'dependencies.json', 'w') as f:
f.write(output)
f.write(output)
2 changes: 2 additions & 0 deletions dependencies/generate_doxygen_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def eprint(*args, **kwargs):


# Get all XML files in a directory passed in as the first argument
# add create*.xml to the list of files to parse
xml_file_matches = [
'create*.xml',
'analog*.xml',
'botball*.xml',
'button*.xml',
Expand Down
1 change: 0 additions & 1 deletion express.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ app.use('/api', proxy(config.dbUrl));

// If we have libkipr (C) artifacts and emsdk, we can compile.
if (config.server.dependencies.libkipr_c && config.server.dependencies.emsdk_env) {
console.log('Compiling C programs is enabled.');

app.post('/compile', (req, res) => {
if (!('code' in req.body)) {
Expand Down
2 changes: 1 addition & 1 deletion i18n/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as fs from 'fs';
import * as path from 'path';
import { walkDir } from './util';
import { PO_PATH } from './po';
import { I18n } from '../src/i18n';
import { I18n } from '../src/util/i18n';
import LocalizedString from '../src/util/LocalizedString';


Expand Down
24 changes: 8 additions & 16 deletions intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Base File Structure:
* static
* test

The two most important folders to get familiar with are the dependencies and the src folders, but here we will cover them all in order. Let's go over these one at a time.
The two most important folders to get familiar with are the [dependencies](#dependencies) and the [src](#src) folders, but here we will cover them all in order. Let's go over these one at a time.

## Configs

Expand All @@ -25,14 +25,12 @@ Configures the webpack bundling for development of production. From Webpack's do
## Dependencies

Dependencies are code modules used by the simulator. They include several external repositories such as libwallaby, cpython, emsdk, and ammojs. After running build.py as part of the install process, they will also contain the build and install modules for the related dependencies.
Dependencies are code modules used by the simulator. They include several external repositories such as libwallaby, cpython, and emsdk. After running build.py as part of the install process, they will also contain the build and install modules for the related dependencies.

To purpose of the core dependencies is as follows:

* libwallaby
* Developed by KIPR, libwallaby is a library for programming the robot.
* ammo.js
* A direct port of the Bullet Physics Engine.
* emsdk
* Emscripten is a complete Open Source compiler toolchain to WebAssembly. Emscripten compiles C and C++ to WebAssembly using LLVM and Binaryen. Emscripten output can run on the Web, in Node.js, and in wasm runtimes.
* cpython
Expand Down Expand Up @@ -81,15 +79,11 @@ Next of course is App.tsx, which will check if you have been logged in and ask y
* /challenge/:challengeId
* This displays the ChallengeRoot component, which renders a given challenge

Rendered on top of the components described above is the DocumentationWindow component, however this will (may?) only show for the Root and ChallengeRoot components.
The main pages besides the actual simulator (in Root and ChallengeRoot) are the Dashboard page, the Tutorials page, and the LoginPage.

The main pages besides the actual simulator are the Dashboard page, the Tutorials page, and the LoginPage, which is located outside /pages, in /login.
The simulator itself is rendered either through the Root or ChallengeRoot.

The simulator itself is rendered either through the Root or ChallengeRoot components which are located in the /components folder.

Components - where most of the UI exists:
* root is where the logic exists for laying out the UI
* holds the code that exists, the simulator state, settings, current theme
The main components - where most of the UI exists - include:
* layouts
* Side layout and overlay layout
* Editor
Expand All @@ -109,16 +103,16 @@ Static contains unchanging (static) items, including:
* Pictures
* .glb files
* “GL Transmission Format Binary file”, is a standardized file format used to share 3D data. Precisely, it can contain information about 3D models, scenes, models, lighting, materials, node hierarchy and animations.
* .blend files
* A BLEND file is a 3D image or animation project created with Blender, an open-source 3D modeling program.
* draco_decoder files (.js/.wasm)
* Decompresses 3D files

> Note:
> The blender files for the nodes and robots are stored seperately in a google drive folder. Please contact one of the maintainers for access.

## test

Seems to be for verifying unit math?
Primarily for verifying unit math currently, future work includes expanding these tests.


# Key Simulator Concepts
Expand Down Expand Up @@ -151,8 +145,6 @@ See /state/reducer/

We capture the entire state of the world with a library called redux, which creates a global json blob that can be rendered to the view. The redux library helps reduce the computation by ensuring only components that need to be updated are updated. Through the redux we can add or remove scenes or nodes.

The primary reason for using redux is because of the database. This will allow us to load scenes from the database.

One important type is Async - this allows us to note the difference in state between the client and that database. The async type has the brief (which can be sent very cheaply - just name and description) and the type is the full record. This can be in a number of states. The Async is a state machine of the processes that can happen between the client and the database.

Redux allows us to make the following work: State + Action -> NewState. This is only for global state settings, not for local state.
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simulator",
"version": "1.3.0",
"version": "1.4.0",
"sideEffects": false,
"main": "dist/index.js",
"author": "KISS Institute for Practical Robotics",
Expand Down Expand Up @@ -53,14 +53,15 @@
"webpack-merge": "^5.7.3"
},
"dependencies": {
"@babylonjs/core": "^5.22.1",
"@babylonjs/loaders": "^5.22.1",
"@babylonjs/core": "6.18.0",
"@babylonjs/loaders": "6.18.0",
"@babylonjs/havok": "^1.0.0",
"@fortawesome/fontawesome-svg-core": "^6.2.0",
"@fortawesome/free-brands-svg-icons": "^6.2.0",
"@fortawesome/free-solid-svg-icons": "^6.2.0",
"@fortawesome/react-fontawesome": "^0.2.0",
"@types/react": "^16.9.25",
"babylonjs-gltf2interface": "^5.22.0",
"babylonjs-gltf2interface": "6.18.0",
"body-parser": "^1.19.0",
"colorjs.io": "^0.4.2",
"connected-react-router": "^6.9.3",
Expand Down
Loading

0 comments on commit 86b0966

Please sign in to comment.