Skip to content
Snippets Groups Projects
Commit 61090dc1 authored by lguyot's avatar lguyot
Browse files

[DEPLOYMENT ENHANCEMENT] Makes the deployment of models simpler and faster: no...

[DEPLOYMENT ENHANCEMENT] Makes the deployment of models simpler and faster: no thumbnails creation, no blender files among web assets and a separate script to build gzbridge

Change-Id: Ida7773288f9c3a773fa82b791ac41473ceb4912f
parent f5385b54
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
source $HOME/.bashrc
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
if ! node --version | grep -q v0.10
then
if ! nvm use 0.10 2>/dev/null
then
printf "\033[0;31mYou must use node v0.10 or use nvm and install v0.10 (ie. nvm install 0.10)\033[0m\n"
exit 1
fi
fi
# Install node modules
npm install
# install bower components
bower install
#
# build the c++ server component
#
rm -rf build
mkdir build
cd build
# Run cmake and check for the exit code
cmake ..
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo There are cmake errors, exiting.
exit 1
fi
# continue building if cmake is happy
make -j 8
cd ../gzbridge
$DIR/node_modules/.bin/node-gyp configure
$DIR/node_modules/.bin/node-gyp build -r
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo There are node-gyp build errors, exiting.
exit 1
fi
echo "Done"
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
echo "Copy models from ${HOME}/.gazebo/models to ${DIR}/http/client/assets"
./get_local_models_v2.py $DIR/http/client/assets
echo "Webifying the models (paths in .dae files will be adapted)"
./webify_models_v3.py $DIR/http/client/assets
echo "Web assets are ready to use!"
#!/usr/bin/python
from __future__ import print_function
import sys
import os
import shutil
import distutils.core
def copy_models(src, dst):
list_dir = [os.path.join(src, x) for x in os.listdir(src)]
sub_dirs = [x for x in list_dir if os.path.isdir(x)]
for model_path in sub_dirs:
if 'model.config' in os.listdir(model_path):
# sys.stdout.write(" copying %s" % model_path)
print (".", end="")
dest_dir = os.path.join(dst, os.path.split(model_path)[1])
if os.path.isdir(dest_dir):
shutil.rmtree(dest_dir)
print("overriding model %s" % model_path)
if os.path.isdir(model_path):
os.makedirs(dest_dir)
for asset in os.listdir(model_path):
if os.path.basename(asset) is not 'blender': # Assets filtering
source_asset = os.path.join(model_path, asset)
dest_asset = os.path.join(dest_dir, asset)
if os.path.isdir(source_asset):
shutil.copytree(source_asset, dest_asset)
else:
shutil.copy(source_asset, dest_dir)
else:
print (" %s ignored" % model_path)
dest_dir = sys.argv[1]
print("copying local models to %s" % dest_dir)
unique_paths = None
try:
gazebo_path = os.environ['GAZEBO_MODEL_PATH'].split(':')
model_paths = [x for x in gazebo_path if os.path.isdir(x)]
unique_paths = list(set(model_paths))
except:
print ("No local models.")
# exit(0)
if unique_paths is not None:
for path in unique_paths:
print("\nmodel path: [%s]" % path)
copy_models(path, dest_dir)
print("local models transfered")
print("copying local resources to %s" % dest_dir)
def copy_resources(src, dst):
media_path = os.path.join(src, "media")
if os.path.exists(media_path) and os.path.isdir(media_path):
dest_dir = os.path.join(dst, "media")
distutils.dir_util.copy_tree(media_path, dest_dir)
unique_paths = None
try:
resource_path = os.environ['GAZEBO_RESOURCE_PATH'].split(':')
resource_paths = [x for x in resource_path if os.path.isdir(x)]
unique_paths = list(set(resource_paths))
except:
print ("No local resources")
exit(0)
if unique_paths is not None:
for path in unique_paths:
print("\nresource path: [%s]" % path)
copy_resources(path, dest_dir)
print("local resources transfered")
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment