Commit 2e4aa090 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

integration_utils.py

parent 92d9e01e
#!/usr/bin/env python2
from argparse import ArgumentParser
from pathlib import Path
from subprocess import Popen
import pinocchio as pin
from pinocchio.robot_wrapper import RobotWrapper
parser = ArgumentParser()
parser.add_argument('robotpkg_prefix', nargs='?', default='/opt/openrobots')
from integration_utils import wrap_with_processes
DEPS = ['py-pinocchio', 'py-qt-gepetto-viewer-corba', 'example-robot-data']
def main(robotpkg_prefix):
def main(robotpkg_prefix, **kwargs):
pkg = Path(robotpkg_prefix) / 'share/example-robot-data'
urdf = 'talos_data/robots/talos_reduced.urdf'
robot = RobotWrapper.BuildFromURDF(str(pkg / urdf), [str(pkg)], pin.JointModelFreeFlyer())
......@@ -21,10 +20,4 @@ def main(robotpkg_prefix):
if __name__ == '__main__':
gepetto_gui = Popen('gepetto-gui')
try:
main(**vars(parser.parse_args()))
finally:
gepetto_gui.terminate()
print('Done. Press Enter to exit')
raw_input()
wrap_with_processes(['gepetto-gui'], main, DEPS)
from argparse import ArgumentParser
from subprocess import CalledProcessError, Popen, check_call
parser = ArgumentParser()
parser.add_argument('robotpkg_prefix', nargs='?', default='/opt/openrobots')
parser.add_argument('python', nargs='?', default=27)
parser.add_argument('qt', nargs='?', default=4)
def wrap_with_processes(processes, f, deps):
kwargs = vars(parser.parse_args())
check_installed(deps, **kwargs)
try:
plist = [Popen(process) for process in processes]
f(**kwargs)
print('Done. Press Enter to exit')
raw_input()
finally:
for process in plist:
process.terminate()
def check_installed(pkgs, python, qt, **kwargs):
for pkg_name in pkgs:
pkg = 'robotpkg-' + pkg_name
pkg = pkg.replace('py-', 'py%i-' % python)
pkg = pkg.replace('qt-', 'qt%i-' % qt)
try:
check_call(['dpkg', '-s', pkg])
except CalledProcessError:
print('please run: sudo apt install -qqy %s' % pkg)
Supports Markdown
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