Exemplo n.º 1
0
def test_yaml():
    from ecto.opts import CellYamlFactory
    import yaml
    bb_yaml = CellYamlFactory(MyBlackBox(start=54), 'bb')
    bb_yaml.dump(sys.stdout)
    mm = bb_yaml.load(yaml.load(bb_yaml.dump()), 'bb')
    print mm.params.start
    assert mm.params.start == 54
Exemplo n.º 2
0
def test_yaml():
    from ecto.opts import CellYamlFactory
    import yaml
    bb_yaml = CellYamlFactory(MyBlackBox(start=54), 'bb')
    bb_yaml.dump(sys.stdout)
    mm = bb_yaml.load(yaml.load(bb_yaml.dump()), 'bb')
    print mm.params.start
    assert mm.params.start == 54
Exemplo n.º 3
0
                    type=str,
                    default='',
                    help='an image file to load.')
group = parser.add_argument_group('ecto scheduler options')
scheduler_options(group, default_niter=2)

multiply_factory = cell_options(parser, ecto_test.Multiply, prefix='mult')
const_factory = cell_options(parser,
                             ecto.Constant(value=0.50505),
                             prefix='const')

options = parser.parse_args()
print options.mult_factor
assert options.mult_factor == 3.14
c = const_factory(options)
m = multiply_factory(options)

cyaml = CellYamlFactory(c, 'const')
print cyaml.dump()
c = cyaml.load(yaml.load(cyaml.dump()))
assert c.params.value == 0.50505

pr = ecto_test.Printer()
plasm = ecto.Plasm()
plasm.connect(c[:] >> m[:], m[:] >> pr[:])

run_plasm(options, plasm, locals=vars())

print m.outputs.out
assert m.outputs.out == 1.585857
#!/usr/bin/env python
from object_recognition.common.io.ros.sink import Publisher
import sys

p = Publisher()

from ecto.opts import CellYamlFactory

assert "latched" in p.__doc__
assert "object_ids_topic" in p.__doc__
assert "pose_topic" in p.__doc__

pub_factory = CellYamlFactory(Publisher, prefix="pub_1")
# to demonstrate that you can have multiple factories.
# this takes on the default values of the instance.
pub_factory2 = CellYamlFactory(Publisher(pose_topic="/poses2", object_ids_topic="/object_ids2"), prefix="pub_2")

with open("pub.yaml", "w") as f:
    pub_factory.dump(f)
    pub_factory2.dump(f)
    print pub_factory.dump()
    print pub_factory2.dump()

with open("pub.yaml", "r") as f:
    import yaml

    parsed = yaml.load(f)
    p = pub_factory.load(parsed, cell_name="ros sink")
    p2 = pub_factory2.load(parsed, cell_name="another publisher")
    assert p2.params.pose_topic == "/poses2"
Exemplo n.º 5
0
#!/usr/bin/env python
from ecto import Constant
from ecto.ecto_test import Multiply
from ecto.opts import CellYamlFactory
import yaml
import os

m_factory = CellYamlFactory(Multiply, 'mult')

#write to file
tmp_name = os.tmpnam()
with open(tmp_name,'w') as f:
    m_factory.dump(f)

#to string
print '#some yaml\n',m_factory.dump() 

#read from file
parsed = {}
with open(tmp_name,'r') as f:
    parsed = yaml.load(f)
os.remove(tmp_name)

#create an instance from a parsed yaml file
m = m_factory.load(parsed,cell_name='my_mult_instance')
print m, m.name(), m.params.factor
Exemplo n.º 6
0
parser.add_argument('-i,--input', metavar='IMAGE_FILE', dest='imagefile',
                    type=str, default='', help='an image file to load.')
group = parser.add_argument_group('ecto scheduler options')
scheduler_options(group, default_niter=2)


multiply_factory = cell_options(parser, ecto_test.Multiply, prefix='mult')
const_factory = cell_options(parser, ecto.Constant(value=0.50505), prefix='const')

options = parser.parse_args()
print options.mult_factor
assert options.mult_factor == 3.14
c = const_factory(options)
m = multiply_factory(options)

cyaml = CellYamlFactory(c,'const')
print cyaml.dump()
c = cyaml.load(yaml.load(cyaml.dump()))
assert c.params.value == 0.50505

pr = ecto_test.Printer()
plasm = ecto.Plasm()
plasm.connect(c[:] >> m[:],
              m[:] >> pr[:]
              )

run_plasm(options, plasm, locals=vars())

print m.outputs.out
assert m.outputs.out == 1.585857
Exemplo n.º 7
0
#!/usr/bin/env python
from ecto import Constant
from ecto.ecto_test import Multiply
from ecto.opts import CellYamlFactory
import yaml
import os

m_factory = CellYamlFactory(Multiply, 'mult')

#write to file
tmp_name = os.tmpnam()
with open(tmp_name, 'w') as f:
    m_factory.dump(f)

#to string
print '#some yaml\n', m_factory.dump()

#read from file
parsed = {}
with open(tmp_name, 'r') as f:
    parsed = yaml.load(f)
os.remove(tmp_name)

#create an instance from a parsed yaml file
m = m_factory.load(parsed, cell_name='my_mult_instance')
print m, m.name(), m.params.factor
Exemplo n.º 8
0
#!/usr/bin/env python
from object_recognition.common.io.ros.sink import Publisher
import sys

p = Publisher()

from ecto.opts import CellYamlFactory

assert 'latched' in p.__doc__
assert 'object_ids_topic' in p.__doc__
assert 'pose_topic' in p.__doc__

pub_factory = CellYamlFactory(Publisher, prefix='pub_1')
#to demonstrate that you can have multiple factories.
#this takes on the default values of the instance.
pub_factory2 = CellYamlFactory(Publisher(pose_topic='/poses2',
                                         object_ids_topic='/object_ids2'),
                               prefix='pub_2')

with open('pub.yaml', 'w') as f:
    pub_factory.dump(f)
    pub_factory2.dump(f)
    print pub_factory.dump()
    print pub_factory2.dump()

with open('pub.yaml', 'r') as f:
    import yaml
    parsed = yaml.load(f)
    p = pub_factory.load(parsed, cell_name='ros sink')
    p2 = pub_factory2.load(parsed, cell_name='another publisher')
    assert p2.params.pose_topic == '/poses2'