def __init__(self, stim_xml_filename=None, num_points=5, scale_factor=0.01, ghost_length=20, resolution=4):

        # initialize the viewer window
        self.f = mlab.figure(size=(800, 600))
        self.f.scene.anti_aliasing_frames = 1
        visual.set_viewer(self.f)

        ################# moving fly objects ################
        self.num_points = num_points
        self.plot_objects = [
            Object(ghost_length=ghost_length, scale_factor=scale_factor, resolution=resolution)
            for i in range(self.num_points)
        ]
        ######################################################

        self.objects = None
        self.speed = np.zeros(self.num_points)

        ################### stimulus xml #####################
        if stim_xml_filename is not None:
            actors = []
            stim_xml = xml_stimulus.xml_stimulus_from_filename(stim_xml_filename)
            actors.extend(stim_xml.get_tvtk_actors())
            for a in actors:
                visual.show_actor(a)
        ######################################################

        # ROS stuff
        rospy.Subscriber("flydra_mainbrain_super_packets", flydra_mainbrain_super_packet, self.callback)
        rospy.init_node("listener", anonymous=True)

        # run the animation
        self.animate()
Beispiel #2
0
If you want to modify the data plotted by the mlab (as in the
`mlab.test_plot3d()` call) to create an animation, please see section
:ref:`mlab-animating-data`.

"""
# Author: Prabhu Ramachandran <prabhu [at] aero.iitb.ac.in>
# Copyright (c) 2009, Enthought, Inc.
# License: BSD Style.

from enthought.mayavi import mlab
from enthought.tvtk.tools import visual
# Create a figure
f = mlab.figure(size=(500,500))
# Tell visual to use this as the viewer.
visual.set_viewer(f)

# A silly visualization.
mlab.test_plot3d()

# Even sillier animation.
b1 = visual.box()
b2 = visual.box(x=4., color=visual.color.red)
b3 = visual.box(x=-4, color=visual.color.red)
b1.v = 5.0

@mlab.show
@mlab.animate(delay=250)
def anim():
    """Animate the b1 box."""
    while 1:
Beispiel #3
0
If you want to modify the data plotted by the mlab (as in the
`mlab.test_plot3d()` call) to create an animation, please see section
:ref:`mlab-animating-data`.

"""
# Author: Prabhu Ramachandran <prabhu [at] aero.iitb.ac.in>
# Copyright (c) 2009, Enthought, Inc.
# License: BSD Style.

from enthought.mayavi import mlab
from enthought.tvtk.tools import visual
# Create a figure
f = mlab.figure(size=(500, 500))
# Tell visual to use this as the viewer.
visual.set_viewer(f)

# A silly visualization.
mlab.test_plot3d()

# Even sillier animation.
b1 = visual.box()
b2 = visual.box(x=4., color=visual.color.red)
b3 = visual.box(x=-4, color=visual.color.red)
b1.v = 5.0


@mlab.show
@mlab.animate(delay=250)
def anim():
    """Animate the b1 box."""