Symbiotic Design for Cyber Physical Systems
Project description available here
Documentation available here
You can evaluate random designs generated by the grammar via command line
pdm run generate_random --n=500 --n_wings_max=0
Generates 500 new designs with no wings and evaluates them.
Make sure that in your eval_pipeline
there is this branch. If you have problems with the submodule, just clone it inside eval_pipeline
.
After pulling the latest main branch from this repo and challenge_data
repo, you can launch these commands to have a clean installation:
make uninstall
sudo rm -r eval_pipeline
git clone -b features/oct-22-fdm-update --single-branch https://github.com/LOGiCS-Project/swri-simple-uam-pipeline.git ./eval_pipeline
pdm install
Make sure that the challenge_data
is updated to the latest version and then run again:
sudo pdm run suam-config install --no-symlink --input=../challenge_data/data/broker.conf.yaml
If the file exists already on your system, delete it and run the command again.
-
Clone the two repos and their submodules in the same folder
git clone --recurse-submodules https://github.com/uc-berkeley-data-discovery-2022/berkeley-cps-symbiotic-design.git
git clone https://github.com/uc-berkeley-data-discovery-2022/challenge_data.git
-
Navigate to
berkeley-cps-symbiotic-design
folder and install dependenciescd berkeley-cps-symbiotic-design
You don't have to create a virual environment with pdm, you can launch the command:
pdm config python.use_venv false
and then
pdm install
-
Download the
aws-cvpn-config.ovpn
configuration file from the challenge_data repo repo and use it to connect to the AWS VPN. Here are the instructions for Linux , MacOS and Windows. -
Create the folder
../challenge_data/aws
if it does not exist already.- (Optional) notify your IDE to exclude the
aws
folder from being indexed. For example in PyCharm doRight Click on aws - Mark directory as - Excluded
- (Optional) notify your IDE to exclude the
-
Mount the shared folder in
../challenge_data/aws
. Instructions here. Make sure you are connected via the VPN before mounting the shared drive.- Suggestion: from the root folder of the repo, you can try one of the following commands, according to your OS and
preferences
sudo mount -t nfs 10.0.137.113:/fsx/ ../challenge_data/aws
sudo mount_nfs -o resvport 10.0.137.113:/fsx/ ../challenge_data/aws
sudo mount -o resvport -t nfs 10.0.137.113:/fsx/ ../challenge_data/aws
- Suggestion: from the root folder of the repo, you can try one of the following commands, according to your OS and
preferences
-
After have successfully installed the dependencies and activated the conda environment. Launch the following command from the root of the repo
sudo pdm run suam-config install --no-symlink --input=../challenge_data/data/broker.conf.yaml
-
Clone the two repos and their submodules in the same folder
git clone --recurse-submodules https://github.com/uc-berkeley-data-discovery-2022/berkeley-cps-symbiotic-design.git
git clone https://github.com/uc-berkeley-data-discovery-2022/challenge_data.git
-
Navigate to
berkeley-cps-symbiotic-design
folder and launch docker script.cd berkeley-cps-symbiotic-design & \ ./docker_run_old.sh bash
You can now launch the scripts and the python files. For example:
pdm run init
To initialize the library of components and seed design
pdm run custom-design "working/test_quad_abstraction_3"
To generate a custom design from json file (this script does not send it to evaluation)
pdm run evaluate "test_quad_cargo"
To generate a custom design from json file, send it to evaluation and retrieve the results.
The results appear in the challenge_data/output/<DESIGN_NAME>
automatically (a json file with the evaluation results and an STL file with the 3D model).
Any change you make to the files in berkeley-cps-symbiotic-design
will be immediately available inside the docker container.
The docker image contains an ssh server that you can connect from your IDE and run your code/debug directly inside docker without the need of installing any dependencies.
Launch:
./docker_run_old.sh
to launch the docker image as a new container running in background.
Then connect to the python interpreter via SSH on port 9922 of localhost as explained below:
- Go to:
Preference > Build, Execution… > Deployment
- Add new
SFTP
. - Give a name, e.g. :
docker-sym-cps
. - Add a new SSH configuration:
- Host: localhost
- Port: 9922
- Username: root
- Password: password
- Root path:
/root
- Mappings:
- Local path ‘<LOCAL_PATH>/berkeley-cps-symbiotic-design’
- Deployment path ‘/ide’
Got to: Preferences > Project… > Python Interpreter > Add Interpreter > On SSH
and select Existing Connection the SSH connection previously created, then select the “System Interpreter” as Python runtime configuration, i.e. the interpreter at /usr/bin/python3’. “Sync folders” insert
→/root/ide`
On Python Interpreter
, click on Show all
and select the Remote Python interpreter that you have just created. On the top right of the window clock on Show Interpreter Paths, and add a new path /root/host/__pypackages__/3.10/lib
.
When running a python script from command line, insert pdm run
before. For example:
pdm run python src/sym_cps/examples/library.py
When running a python script from command line, insert pdm run
before. For example:
pdm run pdm run python src/sym_cps/examples/library.py
With PEP 582, dependencies will be installed into pypackages directory under the project root. With PEP 582 enabled globally, you can also use the project interpreter to run scripts directly. Check pdm documentation on PEP 582.
PYCHARM
Add __pypackages__/3.10/lib
and src
folders to your PYTHONPATH. With PyCharm you can simple right click on the folders and select Mark Directory as
- Source folder
.
VSCODE
To configure VSCode to support PEP 582, open .vscode/settings.json
(create one if it does not exist) and add the following entries:
{
"python.autoComplete.extraPaths": ["__pypackages__/3.10/lib"],
"python.analysis.extraPaths": ["__pypackages__/3.10/lib"]
}
Check the example folder and look at the code of the python files to get familiar with the API. Here's some example you can launch.
Populate the library of components from the data
folder
pdm run python src/sym_cps/examples/library.py
Extracts the seed designs
pdm run python src/sym_cps/examples/designs.py
Create a new design from scratch. First choosing and topology and then concretize it.
pdm run python src/sym_cps/examples/topology.py
Evaluate designs from command line specifying the path of the design_swri,json
in <design-file>
:
sudo pdm run suam-client direct2cad.process-design --design=<design-file> --results=../challenge_data/aws/results
For example:
pdm run suam-client direct2cad.process-design --design=../challenge_data/output/designs/TestQuad/design_swri_orog.json --results=../challenge_data/aws/results
Evaluate designs from python
pdm run python src/sym_cps/examples/evaluation.py
Run the back-end by executing backend/app.py
Install react dependencies via npm by running:
npm install --legacy-peer-deps
inside the frontend
folder.
Then run the front-end:
npm run start
Mac users:
brew install gprof2dot
If you have problems with the environment you can clean up the files and folders created by pdm and conda by running
make uninstall
Then try installation process again.
pdm install
Make sure the submodules are correctly imported and updated
git submodule init
git submodule update --
Make sure that eval_pipeline
folder is not empty.
If the submodule was not pulled correctly you can simply
clone this repo and copy its content
inside eval_pipeline
folder.
For Mac M1 users, if you have architecture problems (i.e. some packages are not available for arm), you can try simulating x86_64 architecture and install the dependencies again.
env /usr/bin/arch -x86_64 /bin/zsh
However, all the dependencies right now should support arm and you should not change architecture.
To run a x86 terminal by default in VSCode, add the following to your settings.json
"terminal.integrated.profiles.osx": {
"x86 bash": {
"path": "/usr/bin/arch",
"args": ["-arch", "x86_64", "/bin/bash"]
}},
"terminal.integrated.defaultProfile.osx": "x86 bash"
To run a x86 terminal by default in PyCharm, go to Preferences/Tools/Terminal and set the shell path to be:
env /usr/bin/arch -x86_64 /bin/zsh --login
Fully typed with annotations and checked with mypy, PEP561 compatible