enums in typekit??

Hi all,

I tired to place an enum in a typekit, just by extending the generated -types.hpp to:

 enum Numbers {ONE, TWO, THREE};

 struct MyPackData
 {
    /** Contains a sequence of doubles. */
    std::vector0 samples;
    Numbers nr;
 };
 MyPack-types.hpp (END) 
compilation and installation workes.

Wehn I open the deployer I can also see the new type MyPackData and create a var of this type e.g "var MyPackData test" However when I try to read test.nr I get only

 Deployer [S]> test.nr 
  = (/Numbers) 
and writing to test.nr seem also not possible. I tried test.nr = 0, test.nr = Numbers:One and some other variation but was not successful....

Is it possible to use enums at all in a typekit ? And does the deployer support this?

Ciao Joerg

enums in typekit??

2011/6/21 joerg [..] ... <joerg [..] ...>:
> Hi all,
>
> I tired to place an enum in a typekit, just by extending the generated -types.hpp to:
>
>  enum Numbers {ONE, TWO, THREE};
>
>  struct MyPackData
>  {
>    /** Contains a sequence of doubles. */
>    std::vector<double> samples;
>    Numbers nr;
>  };
>  MyPack-types.hpp (END)
>
> compilation and installation workes.
>
> Wehn I open the deployer I can also see the new type MyPackData and create a var of this type
> e.g "var MyPackData test"
> However when I try to read test.nr I get only
>
>  Deployer [S]> test.nr
>  = (/Numbers)
>
> and writing to test.nr seem also not possible. I tried test.nr = 0, test.nr = Numbers:One and some other variation but was not successful....
>
> Is it possible to use enums at all in a typekit ? And does the deployer support this?

The current version does not have any read and write operators
implemented for the deployer for enum like types, and so the
taskbrowser does not know how to display / read them. I submitted a
patch a time ago already (http://bugs.orocos.org/show_bug.cgi?id=811),
which already implements the write function (so the taskbrowser
actually displays what is inside the enum - assuming you have the enum
typekit loaded). The read function does not work yet - feel free to
extend it :).

Regards,

Steven

>
> Ciao
> Joerg
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>

enums in typekit??

On Tue, Jun 21, 2011 at 2:12 PM, Steven Bellens
<steven [dot] bellens [..] ...> wrote:
> 2011/6/21 joerg [..] ... <joerg [..] ...>:
>> Hi all,
>>
>> I tired to place an enum in a typekit, just by extending the generated -types.hpp to:
>>
>>  enum Numbers {ONE, TWO, THREE};
>>
>>  struct MyPackData
>>  {
>>    /** Contains a sequence of doubles. */
>>    std::vector<double> samples;
>>    Numbers nr;
>>  };
>>  MyPack-types.hpp (END)
>>
>> compilation and installation workes.
>>
>> Wehn I open the deployer I can also see the new type MyPackData and create a var of this type
>> e.g "var MyPackData test"
>> However when I try to read test.nr I get only
>>
>>  Deployer [S]> test.nr
>>  = (/Numbers)
>>
>> and writing to test.nr seem also not possible. I tried test.nr = 0, test.nr = Numbers:One and some other variation but was not successful....
>>
>> Is it possible to use enums at all in a typekit ? And does the deployer support this?
>
> The current version does not have any read and write operators
> implemented for the deployer for enum like types, and so the
> taskbrowser does not know how to display / read them. I submitted a
> patch a time ago already (http://bugs.orocos.org/show_bug.cgi?id=811),
> which already implements the write function (so the taskbrowser
> actually displays what is inside the enum - assuming you have the enum
> typekit loaded). The read function does not work yet - feel free to
> extend it :).

It's not that simple, it's actually incorrect. The taskbrowser will
use the write function to display the value of the enum, but the read
function has no use, since the taskbrowser sees '0' as an 'int'. What
you really need is A) a conversion from 'int' to the enum OR B) the
defintion of the enums as constants in the globals repository:

&#10;GlobalsRepository::shared_ptr globals = GlobalsRepository::Instance();&#10;globals-&gt;setValue( new Constant&lt;Numbers&gt;(&quot;ONE&quot;,ONE) );&#10;//... etc...&#10;

Option (B) is recommended. That in combination with Steven's patch
would help you out. I think we need something similar for the ROS
messages ? Don't they have enums or constants ?

Peter
--
Orocos-Users mailing list
Orocos-Users [..] ...
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users

enums in typekit??

2011/6/21 Peter Soetens <peter [..] ...>:
> On Tue, Jun 21, 2011 at 2:12 PM, Steven Bellens
> <steven [dot] bellens [..] ...> wrote:
>> 2011/6/21 joerg [..] ... <joerg [..] ...>:
>>> Hi all,
>>>
>>> I tired to place an enum in a typekit, just by extending the generated -types.hpp to:
>>>
>>>  enum Numbers {ONE, TWO, THREE};
>>>
>>>  struct MyPackData
>>>  {
>>>    /** Contains a sequence of doubles. */
>>>    std::vector<double> samples;
>>>    Numbers nr;
>>>  };
>>>  MyPack-types.hpp (END)
>>>
>>> compilation and installation workes.
>>>
>>> Wehn I open the deployer I can also see the new type MyPackData and create a var of this type
>>> e.g "var MyPackData test"
>>> However when I try to read test.nr I get only
>>>
>>>  Deployer [S]> test.nr
>>>  = (/Numbers)
>>>
>>> and writing to test.nr seem also not possible. I tried test.nr = 0, test.nr = Numbers:One and some other variation but was not successful....
>>>
>>> Is it possible to use enums at all in a typekit ? And does the deployer support this?
>>
>> The current version does not have any read and write operators
>> implemented for the deployer for enum like types, and so the
>> taskbrowser does not know how to display / read them. I submitted a
>> patch a time ago already (http://bugs.orocos.org/show_bug.cgi?id=811),
>> which already implements the write function (so the taskbrowser
>> actually displays what is inside the enum - assuming you have the enum
>> typekit loaded). The read function does not work yet - feel free to
>> extend it :).
>
> It's not that simple, it's actually incorrect. The taskbrowser will
> use the write function to display the value of the enum, but the read
> function has no use, since the taskbrowser sees '0' as an 'int'. What
> you really need is A) a conversion from 'int' to the enum OR B) the
> defintion of the enums as constants in the globals repository:
>
> &#10;&gt; GlobalsRepository::shared_ptr globals = GlobalsRepository::Instance();&#10;&gt; globals-&gt;setValue( new Constant&lt;Numbers&gt;(&quot;ONE&quot;,ONE) );&#10;&gt; //... etc...&#10;&gt;
>
> Option (B) is recommended. That in combination with Steven's patch
> would help you out.

Can you explain why option B is recommended? I implemented a small
test case to check and it's working properly, but now the enum types
just show up in the global repository (duh!). So I can assign a
variable of enumtype A a string value belonging to enumType B - as
it's just an int replacement. I think this would not be the case with
option A, right?

I think we need something similar for the ROS
> messages ? Don't they have enums or constants ?

They have constants which they just handle as regular ros msg types:
http://www.ros.org/wiki/msg

Steven

>
> Peter
>

enums in typekit??

On Tue, Jun 21, 2011 at 4:41 PM, Steven Bellens
<steven [dot] bellens [..] ...> wrote:
> 2011/6/21 Peter Soetens <peter [..] ...>:
>> On Tue, Jun 21, 2011 at 2:12 PM, Steven Bellens
>> <steven [dot] bellens [..] ...> wrote:
>>> 2011/6/21 joerg [..] ... <joerg [..] ...>:
>>>> Hi all,
>>>>
>>>> I tired to place an enum in a typekit, just by extending the generated -types.hpp to:
>>>>
>>>>  enum Numbers {ONE, TWO, THREE};
>>>>
>>>>  struct MyPackData
>>>>  {
>>>>    /** Contains a sequence of doubles. */
>>>>    std::vector<double> samples;
>>>>    Numbers nr;
>>>>  };
>>>>  MyPack-types.hpp (END)
>>>>
>>>> compilation and installation workes.
>>>>
>>>> Wehn I open the deployer I can also see the new type MyPackData and create a var of this type
>>>> e.g "var MyPackData test"
>>>> However when I try to read test.nr I get only
>>>>
>>>>  Deployer [S]> test.nr
>>>>  = (/Numbers)
>>>>
>>>> and writing to test.nr seem also not possible. I tried test.nr = 0, test.nr = Numbers:One and some other variation but was not successful....
>>>>
>>>> Is it possible to use enums at all in a typekit ? And does the deployer support this?
>>>
>>> The current version does not have any read and write operators
>>> implemented for the deployer for enum like types, and so the
>>> taskbrowser does not know how to display / read them. I submitted a
>>> patch a time ago already (http://bugs.orocos.org/show_bug.cgi?id=811),
>>> which already implements the write function (so the taskbrowser
>>> actually displays what is inside the enum - assuming you have the enum
>>> typekit loaded). The read function does not work yet - feel free to
>>> extend it :).
>>
>> It's not that simple, it's actually incorrect. The taskbrowser will
>> use the write function to display the value of the enum, but the read
>> function has no use, since the taskbrowser sees '0' as an 'int'. What
>> you really need is A) a conversion from 'int' to the enum OR B) the
>> defintion of the enums as constants in the globals repository:
>>
>> &#10;&gt;&gt; GlobalsRepository::shared_ptr globals = GlobalsRepository::Instance();&#10;&gt;&gt; globals-&gt;setValue( new Constant&lt;Numbers&gt;(&quot;ONE&quot;,ONE) );&#10;&gt;&gt; //... etc...&#10;&gt;&gt;
>>
>> Option (B) is recommended. That in combination with Steven's patch
>> would help you out.
>
> Can you explain why option B is recommended? I implemented a small
> test case to check and it's working properly, but now the enum types
> just show up in the global repository (duh!). So I can assign a
> variable of enumtype A a string value belonging to enumType B - as
> it's just an int replacement. I think this would not be the case with
> option A, right?

Hmm.. is this an 'int' auto-conversion kicking in ? We should then
turn of automatic conversion to int and force the user to write
int(enumB)...or enumB(..int..)

Option A is meaningless for his case, since nor the parser, nor the
taskbrowser uses this function. I think only the xml reader falls back
to this.

>
>
> I think we need something similar for the ROS
>> messages ? Don't they have enums or constants ?
>
>
> They have constants which they just handle as regular ros msg types:
> http://www.ros.org/wiki/msg

So we should register "CONSTANTNAME1" as a Constant<constanttype1> in
the globals repository when the msg is imported ?

Peter
--
Orocos-Users mailing list
Orocos-Users [..] ...
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users

enums in typekit??

2011/6/21 Peter Soetens <peter [..] ...>:
> On Tue, Jun 21, 2011 at 4:41 PM, Steven Bellens
> <steven [dot] bellens [..] ...> wrote:
>> 2011/6/21 Peter Soetens <peter [..] ...>:
>>> On Tue, Jun 21, 2011 at 2:12 PM, Steven Bellens
>>> <steven [dot] bellens [..] ...> wrote:
>>>> 2011/6/21 joerg [..] ... <joerg [..] ...>:
>>>>> Hi all,
>>>>>
>>>>> I tired to place an enum in a typekit, just by extending the generated -types.hpp to:
>>>>>
>>>>>  enum Numbers {ONE, TWO, THREE};
>>>>>
>>>>>  struct MyPackData
>>>>>  {
>>>>>    /** Contains a sequence of doubles. */
>>>>>    std::vector<double> samples;
>>>>>    Numbers nr;
>>>>>  };
>>>>>  MyPack-types.hpp (END)
>>>>>
>>>>> compilation and installation workes.
>>>>>
>>>>> Wehn I open the deployer I can also see the new type MyPackData and create a var of this type
>>>>> e.g "var MyPackData test"
>>>>> However when I try to read test.nr I get only
>>>>>
>>>>>  Deployer [S]> test.nr
>>>>>  = (/Numbers)
>>>>>
>>>>> and writing to test.nr seem also not possible. I tried test.nr = 0, test.nr = Numbers:One and some other variation but was not successful....
>>>>>
>>>>> Is it possible to use enums at all in a typekit ? And does the deployer support this?
>>>>
>>>> The current version does not have any read and write operators
>>>> implemented for the deployer for enum like types, and so the
>>>> taskbrowser does not know how to display / read them. I submitted a
>>>> patch a time ago already (http://bugs.orocos.org/show_bug.cgi?id=811),
>>>> which already implements the write function (so the taskbrowser
>>>> actually displays what is inside the enum - assuming you have the enum
>>>> typekit loaded). The read function does not work yet - feel free to
>>>> extend it :).
>>>
>>> It's not that simple, it's actually incorrect. The taskbrowser will
>>> use the write function to display the value of the enum, but the read
>>> function has no use, since the taskbrowser sees '0' as an 'int'. What
>>> you really need is A) a conversion from 'int' to the enum OR B) the
>>> defintion of the enums as constants in the globals repository:
>>>
>>> &#10;&gt;&gt;&gt; GlobalsRepository::shared_ptr globals = GlobalsRepository::Instance();&#10;&gt;&gt;&gt; globals-&gt;setValue( new Constant&lt;Numbers&gt;(&quot;ONE&quot;,ONE) );&#10;&gt;&gt;&gt; //... etc...&#10;&gt;&gt;&gt;
>>>
>>> Option (B) is recommended. That in combination with Steven's patch
>>> would help you out.
>>
>> Can you explain why option B is recommended? I implemented a small
>> test case to check and it's working properly, but now the enum types
>> just show up in the global repository (duh!). So I can assign a
>> variable of enumtype A a string value belonging to enumType B - as
>> it's just an int replacement. I think this would not be the case with
>> option A, right?
>
> Hmm.. is this an 'int' auto-conversion kicking in ? We should then
> turn of automatic conversion to int and force the user to write
> int(enumB)...or enumB(..int..)

It's hard to avoid if you define them in the global repository, as you
will, with multiple enum types, always have multiple mappings to the
same int. There is no problem the other way around of course, as this
is explicitly written in the typekit for a specific enum type.

>
> Option A is meaningless for his case, since nor the parser, nor the
> taskbrowser uses this function. I think only the xml reader falls back
> to this.
>
>>
>>
>> I think we need something similar for the ROS
>>> messages ? Don't they have enums or constants ?
>>
>>
>> They have constants which they just handle as regular ros msg types:
>> http://www.ros.org/wiki/msg
>
> So we should register "CONSTANTNAME1" as a Constant<constanttype1> in
> the globals repository when the msg is imported ?

Yup, that would do it I guess.

Steven

>
> Peter
>