Exemple #1
0
def get_usual_observers(w, scene=True, perf=True, h5=False, daenim=True):
    from arboris.visu.dae_writer import write_collada_scene
    from arboris.visu            import pydaenimCom
    from arboris.observers import PerfMonitor, Hdf5Logger
    obs = []
    if scene:
        write_collada_scene(w, "scene.dae", flat=True)
    if perf:
        obs.append(PerfMonitor(True))
    if h5:
        obs.append(Hdf5Logger("sim.h5", group="/", mode="w", flat=True))
    if daenim:
        obs.append(pydaenimCom("scene.dae", flat=True))
    return obs
Exemple #2
0
def view(world, browser=None, **kwargs):
    """
    """
    if isinstance(world, World):

        tempdir = tempfile.gettempdir()
        collada_path = tempdir + os.sep + "temp_scene.dae"

        write_collada_scene(world, collada_path)

    elif isinstance(world, basestring):
        collada_path = world

    pydaenim.create_pydaenimViewer(collada_path, **kwargs)
Exemple #3
0
def view(world, browser=None, **kwargs):
    """
    """
    if isinstance(world, World):

        tempdir = tempfile.gettempdir()
        collada_path = tempdir+os.sep+"temp_scene.dae"

        write_collada_scene(world, collada_path)

    elif isinstance(world, basestring):
        collada_path = world

    pydaenim.create_pydaenimViewer(collada_path, **kwargs)
Exemple #4
0
w.update_dynamic()


##### Add ctrl
from arboris.controllers import WeightController

w.register(WeightController())


##### Add observers
from arboris.observers import PerfMonitor, Hdf5Logger

from arboris.visu.dae_writer import write_collada_scene, write_collada_animation, add_shapes_to_dae
from arboris.visu            import pydaenimCom
flat = False
write_collada_scene(w, "./scene.dae", flat=flat)

shapes_info = [
    ["Arm"        , "./dae/icub_simple.dae#head"],                                 # parent frame, child shape node id
    ["Forearm"    , "./dae/icub_simple.dae#head", transl(0,0.3,0)],                # parent frame, child shape node id, H_frame_shape
    ["EndEffector", "./dae/icub_simple.dae"     , transl(0,0.3,0), (0.3,0.3,0.3)], # parent frame, child shape file   , H_frame_shape, shape_scale
]
add_shapes_to_dae("./scene.dae", shapes_info)     # add argument output_file="out.dae" if you want to keep original dae file


obs = []
pobs = PerfMonitor(True)
dobs = pydaenimCom("./scene.dae", flat=flat)
h5obs = Hdf5Logger("sim.h5", mode="w", flat=flat)
obs.append(pobs)
obs.append(dobs)
obs = []

from arboris.observers import PerfMonitor
obs.append(PerfMonitor(True))               # to print simulation time


from arboris.observers import Hdf5Logger
obs.append(Hdf5Logger("sim.h5", mode="w", flat=True))       # to save simulation data in hdf5 file ...

from arboris.observers import PickleLogger
obs.append(PickleLogger("sim.pkl", mode="wb", flat=True))   # ... or in pickle file


from arboris.visu.dae_writer import write_collada_scene
from arboris.visu import pydaenimCom                        # visualize with pydaenim ...
write_collada_scene(w, "scene.dae", flat=True)
obs.append(pydaenimCom("scene.dae", flat=True))

from arboris.visu.visu_collada import write_collada_scene as visu_collada_scene
from arboris.visu.visu_collada import DaenimCom             # ... or with daenim program if installed
visu_collada_scene(w, "scene_daenim.dae", flat=True)
obs.append(DaenimCom("scene_daenim.dae", flat=True))


########################################################
## SIMULATION
########################################################
dt = 5e-3
simulate(w, arange(0, 1., dt), obs)

Exemple #6
0
obs = []

from arboris.observers import PerfMonitor
obs.append(PerfMonitor(True))  # to print simulation time

from arboris.observers import Hdf5Logger
obs.append(Hdf5Logger("sim.h5", mode="w",
                      flat=True))  # to save simulation data in hdf5 file ...

from arboris.observers import PickleLogger
obs.append(PickleLogger("sim.pkl", mode="wb",
                        flat=True))  # ... or in pickle file

from arboris.visu.dae_writer import write_collada_scene
from arboris.visu import pydaenimCom  # visualize with pydaenim ...
write_collada_scene(w, "scene.dae", flat=True)
obs.append(pydaenimCom("scene.dae", flat=True))

from arboris.visu.visu_collada import write_collada_scene as visu_collada_scene
from arboris.visu.visu_collada import DaenimCom  # ... or with daenim program if installed
visu_collada_scene(w, "scene_daenim.dae", flat=True)
obs.append(DaenimCom("scene_daenim.dae", flat=True))

########################################################
## SIMULATION
########################################################
dt = 5e-3
simulate(w, arange(0, 1., dt), obs)

########################################################
## RESULTS