ternaris / marv

THIS REPOSITORY HAS BEEN MERGE INTO
https://github.com/ternaris/marv-robotics
GNU Affero General Public License v3.0
3 stars 4 forks source link

Usage of atomic capnp types #23

Closed beetleskin closed 6 years ago

beetleskin commented 6 years ago

I wrote a node that just produces floats (actually only a single one) from some bag-input:

@marv.node(capnp.types.Float64)
@marv.input('message_stream', default=marv.select(raw_messages, "/some/topic"))
def atomic_value_node(message_stream):
    proto_msg = yield marv.pull(message_stream)
    # do some stuff with the input ..
    yield marv.set_header(title="my_fancy_stream_title")
    yield marv.push(42.3)

Adding this node to the config:

listing_columns =
..
atomic   | Atomic    | string    | (get "atomic_value_node")

.. results in this error:

2018-01-07 17:00:23,048 INFO marv.collection.bags added <Dataset hjgcowbkm5ocihh5rnk6kuvvua 2017-09-11--08-44-13--1st_demo_part1>
Traceback (most recent call last):
  File "/usr/local/bin/marv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python2.7/dist-packages/marv_cli/__init__.py", line 131, in cli
    marv(auto_envvar_prefix='MARV')
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/marv/cli.py", line 424, in marvcli_scan
    create_app().site.scan(dry_run)
  File "/usr/local/lib/python2.7/dist-packages/marv/site.py", line 375, in scan
    collection.scan(scanroot, dry_run)
  File "/usr/local/lib/python2.7/dist-packages/marv/collection.py", line 500, in scan
    self._add_batch(log, batch)
  File "/usr/local/lib/python2.7/dist-packages/marv/collection.py", line 565, in _add_batch
    row, fields, relfields = self.render_listing(dataset)
  File "/usr/local/lib/python2.7/dist-packages/marv/collection.py", line 656, in render_listing
    value = calltree(functree, funcs)
  File "/usr/local/lib/python2.7/dist-packages/marv/config.py", line 92, in calltree
    return func(*args)
  File "/usr/local/lib/python2.7/dist-packages/marv/config.py", line 126, in getnode
    nodename, rest = rest, None
UnboundLocalError: local variable 'rest' referenced before assignment

Removing the node from the listing, and running it manually (marv run --collection=bags --node atomic_value_node), results in:

2018-01-07 17:20:06,744 ERRO marv.cli Exception occured for dataset bgqgc5rs4w2mvxvh2fv6bbrhyu:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/marv/cli.py", line 390, in marvcli_run
    cachesize=cachesize)
  File "/usr/local/lib/python2.7/dist-packages/marv/site.py", line 355, in run
    deps=deps, cachesize=cachesize)
  File "/usr/local/lib/python2.7/dist-packages/marv_node/run.py", line 75, in run_nodes
    done, send_queue_empty = process_task(current, task)
  File "/usr/local/lib/python2.7/dist-packages/marv_node/run.py", line 329, in process_task
    return loop()
  File "/usr/local/lib/python2.7/dist-packages/marv_node/run.py", line 254, in loop
    promise = current.send(send)
  File "/usr/local/lib/python2.7/dist-packages/marv_node/driver.py", line 156, in _run
    msg._data = Wrapper.from_dict(schema, msg._data)
  File "/usr/local/lib/python2.7/dist-packages/marv_pycapnp/__init__.py", line 78, in from_dict
    setid = data.pop('id', None)
AttributeError: 'float' object has no attribute 'pop'
2018-01-07 17:20:06,745 ERRO marv.cli Error occured for dataset bgqgc5rs4w2mvxvh2fv6bbrhyu: 'float' object has no attribute 'pop'

Any ideas on what I'm doing wrong? From the code, it looks like you always expect a dict type. Can't I use atomic types, i.e. do I have to define my own, although its just a float?

chaoflow commented 6 years ago

@beetleskin It is not possible to instantiate atomic types directly, capnp needs structs to create messages.

chaoflow commented 6 years ago

relates #33

chaoflow commented 6 years ago

A set of basic types with and without timestamp will be part of the upcoming 3.2 release.