Bug #64
open
Unability to define a port for "anonymous" type
Added by Arnaud Degroote over 10 years ago.
Updated 7 months ago.
Description
Try to define a port for some "anonymous" type such as long, short, double ... leads to the following genom3 error:
anonymous type is not allowed for port XXXX
It seems a bit strange, as it does not allow to write simple module, outputing base types. At least, it must be documented properly (with the technical reason) and the error message may point on this information.
ros ports need to have a ".msg" file, which cannot be created for such
anonymous types.
I agree this must be documented.
Hi Anthony,
I am "re-opening" the thread of this issue.
I think it would be sufficient to update the line of the doc in the project genom3.
In particular, I am talking about this one https://git.openrobots.org/projects/genom3/pages/dotgen/grammar#dotgen-rule-port
which, from my understanding, should be modified from
(22) port ::= "port" opt-multiple port-dir type-spec identifier opt-properties ";"
to
(22) port ::= "port" opt-multiple port-dir constructed-type-spec identifier opt-properties ";"
Additionally, also this part of the documentation (https://git.openrobots.org/projects/genom3/pages/dotgen/port) should be changed, from
(22) port ::= "port" opt-multiple port-dir type-spec identifier opt-properties ";"
to
(22) port ::= "port" opt-multiple port-dir constructed-type-spec identifier opt-properties ";"
Indeed, I understood that both base-type-spec
and template-type-spec
(which belong to the type "class" of simple-type-spec
) are considered as anonymous types
. However, I am not sure about scoped-names
. I guess that a scoped-name
that is constructed
may be used, while a scoped-name
that is anonymous cannot be used. If that is the case, then my fix mentioned earlier is not very precise, as it is including also scoped-names that are anonymous. If so, a possible solution could list the exact types? Something like constructed-types | (scoped-names & constructed-types)
.
Am I right, or am I missing something.
Thanks,
Gianluca
The 'doc' actually reflects the grammar used, so it should not be
changed without also changing the grammar.
But this anonymous port restriction is actually just a genom3-ros
restriction, not a genom3 one. It was put in genom to make sure
components can be compiled with all existing templates without
issue. But maybe this restriction should have just been put in the
genom3-ros templates instead, and maybe it could even be fixed (in the
spirit of Int8.msg, Float64.msg etc.) if that's really important.
Artificially restricting the grammar seems even worse to me than just
the current test that can easily be removed.
Do you have a use case with anonymous types? I've actually never seen
one ...
Usually, it's just a matter of typedef'ing the port datatype, e.g.
typedef double d;
port out d x;
Regarding your remark about scoped_name
, it's not a
type. scoped_name
is just a list of ::
separated identifiers. But
from that you can designate a named_type
if the context allows.
As the name suggests, named_type
is actually named (by construction,
since you can refer to it via it's name) and thus not anonymous :)
Also available in: Atom
PDF