示例#1
0
def do_ecto(bagname, msg_counts, Scheduler):
    sub_rgb = ImageSub("image_sub",
                       topic_name='/camera/rgb/image_color',
                       queue_size=0)
    sub_depth = ImageSub("depth_sub",
                         topic_name='/camera/depth/image',
                         queue_size=0)

    im2mat_rgb = ecto_ros.Image2Mat()
    im2mat_depth = ecto_ros.Image2Mat()
    counter_rgb = ecto.Counter(every=10)
    counter_depth = ecto.Counter()
    graph = [
        sub_rgb["output"] >> im2mat_rgb["image"],
        sub_depth["output"] >> im2mat_depth["image"],
        im2mat_rgb[:] >> counter_rgb[:], im2mat_depth[:] >> counter_depth[:]
    ]
    plasm = ecto.Plasm()
    plasm.connect(graph)
    sched = Scheduler(plasm)
    sched.execute_async()
    rosbag = play_bag(bagname, delay=1,
                      rate=0.5)  #rate hack for fidelity in message count FIXME
    wait_bag(rosbag)
    time.sleep(0.1)
    sched.stop()

    print "expecting RGB count:", msg_counts['/camera/rgb/image_color']
    print "RGB count:", counter_rgb.outputs.count
    print "expecting Depth count:", msg_counts['/camera/depth/image']
    print "Depth count:", counter_depth.outputs.count
    assert msg_counts['/camera/rgb/image_color'] >= counter_rgb.outputs.count
    assert msg_counts['/camera/rgb/image_color'] >= counter_depth.outputs.count
    assert counter_rgb.outputs.count != 0
    assert counter_depth.outputs.count != 0
示例#2
0
    def test_bag(self):
        bagname = os.path.join(
            find_in_workspaces(search_dirs=['share'], project='ecto_ros')[0],
            'tests', 't01.bag')
        counts = bag_counts(bagname)

        #test that the counts are the same.
        print counts
        self.assertEqual(counts['/camera/rgb/image_color'],
                         counts['/camera/depth/image'])
        self.assertNotEqual(counts['/camera/rgb/image_color'], 0)

        baggers = dict(
            image=ImageBagger(topic_name='/camera/rgb/image_color'),
            depth=ImageBagger(topic_name='/camera/depth/image'),
        )

        bagreader = BagReader(
            'Bag Ripper',
            baggers=baggers,
            bag=bagname,
        )
        im2mat_rgb = Image2Mat()
        im2mat_depth = Image2Mat()
        counter_rgb = ecto.Counter()
        counter_depth = ecto.Counter()

        graph = [
            bagreader["image"] >> im2mat_rgb["image"],
            bagreader["depth"] >> im2mat_depth["image"],
            im2mat_rgb[:] >> counter_rgb[:],
            im2mat_depth[:] >> counter_depth[:]
        ]

        plasm = ecto.Plasm()
        plasm.connect(graph)
        #ecto.view_plasm(plasm)

        plasm.execute(niter=0)
        print "expecting count:", counts['/camera/rgb/image_color']
        print "RGB count:", counter_rgb.outputs.count
        print "Depth count:", counter_depth.outputs.count
        assert counts['/camera/rgb/image_color'] == counter_rgb.outputs.count
        assert counts['/camera/depth/image'] == counter_depth.outputs.count
示例#3
0
def do_ecto():
    bagname = sys.argv[1]
    counts = bag_counts(bagname)

    #test that the counts are the same.
    assert counts['/camera/rgb/image_color'] == counts['/camera/depth/image']
    assert counts['/camera/rgb/image_color'] != 0

    baggers = dict(
        image=ImageBagger(topic_name='/camera/rgb/image_color'),
        depth=ImageBagger(topic_name='/camera/depth/image'),
    )

    bagreader = BagReader(
        'Bag Ripper',
        baggers=baggers,
        bag=bagname,
    )
    im2mat_rgb = Image2Mat()
    im2mat_depth = Image2Mat()
    counter_rgb = ecto.Counter()
    counter_depth = ecto.Counter()

    graph = [
        bagreader["image"] >> im2mat_rgb["image"],
        bagreader["depth"] >> im2mat_depth["image"],
        im2mat_rgb[:] >> counter_rgb[:], im2mat_depth[:] >> counter_depth[:]
    ]

    plasm = ecto.Plasm()
    plasm.connect(graph)
    #ecto.view_plasm(plasm)

    plasm.execute(niter=0)
    print "expecting count:", counts['/camera/rgb/image_color']
    print "RGB count:", counter_rgb.outputs.count
    print "Depth count:", counter_depth.outputs.count
    assert counts['/camera/rgb/image_color'] == counter_rgb.outputs.count
    assert counts['/camera/depth/image'] == counter_depth.outputs.count
示例#4
0
def do_ecto(bagname, msg_counts, Scheduler):
    ecto_ros.init(sys.argv, "image_sub_node")
    sub_rgb = ImageSub("image_sub",
                       topic_name='/camera/rgb/image_color',
                       queue_size=0)
    im2mat_rgb = ecto_ros.Image2Mat()
    counter_rgb = ecto.Counter()
    graph = [
        sub_rgb["output"] >> im2mat_rgb["image"],
        im2mat_rgb[:] >> counter_rgb[:],
    ]
    plasm = ecto.Plasm()
    plasm.connect(graph)
    sched = Scheduler(plasm)
    sched.execute_async()
    rosbag = play_bag(bagname, delay=0.5)
    wait_bag(rosbag)
    sched.stop()

    print "expecting RGB count:", msg_counts['/camera/rgb/image_color']
    print "RGB count:", counter_rgb.outputs.count
    assert msg_counts['/camera/rgb/image_color'] >= counter_rgb.outputs.count
    assert counter_rgb.outputs.count != 0
示例#5
0
from ecto_ros import Synchronizer
import ecto_ros.ecto_sensor_msgs as ecto_sensor_msgs

ImageSub = ecto_sensor_msgs.Subscriber_Image
CameraInfoSub = ecto_sensor_msgs.Subscriber_CameraInfo

subs = dict(
    image=ImageSub(topic_name='/camera/rgb/image_color', queue_size=0),
    depth=ImageSub(topic_name='/camera/depth/image', queue_size=0),
    depth_info=CameraInfoSub(topic_name='/camera/depth/camera_info',
                             queue_size=0),
    image_info=CameraInfoSub(topic_name='/camera/rgb/camera_info',
                             queue_size=0),
)

sync = Synchronizer('Synchronizator', subs=subs)
counter_rgb = ecto.Counter()
counter_depth = ecto.Counter()
counter_rgb_info = ecto.Counter()
counter_depth_info = ecto.Counter()

graph = [
    sync["image"] >> counter_rgb[:],
    sync["depth"] >> counter_depth[:],
    sync["image_info"] >> counter_rgb_info[:],
    sync["depth_info"] >> counter_depth_info[:],
]
plasm = ecto.Plasm()
plasm.connect(graph)
print(plasm)
示例#6
0
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

import ecto
import ecto.ecto_test as ecto_test

# run the generator 10 times
gen = ecto_test.Generate(start=0, step=1, stop=9)

# break on every second iteration
breaker = ecto_test.BreakEveryN(n=2)

cnt = ecto.Counter()

plasm = ecto.Plasm()
plasm.connect([gen[:] >> breaker[:], breaker[:] >> cnt[:]])

plasm.execute(niter=0)

# as cnt depends on breaker it will only be processed every second iteration
result = cnt.outputs.count
print "Counter ran " + str(result) + " times"
assert (result == 5)