Accessing ROS message "enums" from RTT-Lua

Take for instance the diagnostic_msgs/DiagnosticStatus message. It has a couple of hard-coded "enum" values. How would one access those values from RTT-Lua?

--
Dustin Gooding
NASA/JSC Robotics
IM: dgooding [..] ...<xmpp:dgooding [..] ...>

Accessing ROS message "enums" from RTT-Lua

Hi Dustin,

On Tue, Feb 19, 2013 at 01:47:13PM -0600, Gooding, Dustin R. (JSC-ER411) wrote:
> Take for instance the diagnostic_msgs/DiagnosticStatus message. It has a couple
> of hard-coded "enum" values. How would one access those values from RTT-Lua?

I honestly don't know, I've never tried or needed to, since the RTT
enums are available in the global service. What happens if you
access/change these?

Markus

Accessing ROS message "enums" from RTT-Lua

On Feb 21, 2013, at 10:06 AM, Markus Klotzbuecher <markus [dot] klotzbuecher [..] ...> wrote:

> Hi Dustin,
>
> On Tue, Feb 19, 2013 at 01:47:13PM -0600, Gooding, Dustin R. (JSC-ER411) wrote:
>> Take for instance the diagnostic_msgs/DiagnosticStatus message. It has a couple
>> of hard-coded "enum" values. How would one access those values from RTT-Lua?
>
> I honestly don't know, I've never tried or needed to, since the RTT
> enums are available in the global service. What happens if you
> access/change these?
>
> Markus

The rtt.globals are specifically for Orocos things. Accessing them is easy and we do it when we're defining our connection policies, activity schedulers, and understanding port data interactions. Changing rtt.globals seems to be easy as well (just an assignment).

These ROS msg constants (what they're actually called) allow for an integer msg member variable that has pre-defined values available to use. For example, the diagnostic_msgs/DiagnosticStatus has a member named "level" and three possible pre-defined values "OK=0, WARN=1, ERROR=2". This kinda-sorta helps folks pass well-defined values in an otherwise generic container. Folks are still free to set "level" to something other than 0-2, but the value will be undefined.

In RTT-Lua, I'd like to be able to make a variable of type diagnostic_msgs/DiagnosticStatus, and read/assign the "level" member using those constants, instead of the integer value. This way, even our Lua scripts are capable of sending/receiving well-defined messages.

-dustin

Accessing ROS message "enums" from RTT-Lua

Hi Dustin,

Sorry for the late answer.

On Thu, Feb 21, 2013 at 10:25:46AM -0600, Gooding, Dustin R. (JSC-ER411) wrote:
> On Feb 21, 2013, at 10:06 AM, Markus Klotzbuecher <markus [dot] klotzbuecher [..] ...> wrote:
>
> > Hi Dustin,
> >
> > On Tue, Feb 19, 2013 at 01:47:13PM -0600, Gooding, Dustin R. (JSC-ER411) wrote:
> >> Take for instance the diagnostic_msgs/DiagnosticStatus message. It has a couple
> >> of hard-coded "enum" values. How would one access those values from RTT-Lua?
> >
> > I honestly don't know, I've never tried or needed to, since the RTT
> > enums are available in the global service. What happens if you
> > access/change these?
> >
> > Markus
>
> The rtt.globals are specifically for Orocos things. Accessing them
> is easy and we do it when we're defining our connection policies,
> activity schedulers, and understanding port data
> interactions. Changing rtt.globals seems to be easy as well (just an
> assignment).
>
> These ROS msg constants (what they're actually called) allow for an
> integer msg member variable that has pre-defined values available to
> use. For example, the diagnostic_msgs/DiagnosticStatus has a member
> named "level" and three possible pre-defined values "OK=0, WARN=1,
> ERROR=2". This kinda-sorta helps folks pass well-defined values in
> an otherwise generic container. Folks are still free to set "level"
> to something other than 0-2, but the value will be undefined.
>
> In RTT-Lua, I'd like to be able to make a variable of type
> diagnostic_msgs/DiagnosticStatus, and read/assign the "level" member
> using those constants, instead of the integer value. This way, even
> our Lua scripts are capable of sending/receiving well-defined
> messages.

It makes sense, I wonder how this could be supported. For instance the
ROS message typekit generation could install these constants as
globals (e.g. rtt.globals.diagnostic_msgs/DiagnosticStatus.WARN=2). Or
it could also happen in Lua only, e.g. by reusing the roslua msg
parsing infrastructure.

Markus

Accessing ROS message "enums" from RTT-Lua

On Thu, Mar 14, 2013 at 4:38 PM, Markus Klotzbuecher
<markus [dot] klotzbuecher [..] ...> wrote:
> Hi Dustin,
>
> Sorry for the late answer.
>
> On Thu, Feb 21, 2013 at 10:25:46AM -0600, Gooding, Dustin R. (JSC-ER411) wrote:
>> On Feb 21, 2013, at 10:06 AM, Markus Klotzbuecher <markus [dot] klotzbuecher [..] ...> wrote:
>>
>> > Hi Dustin,
>> >
>> > On Tue, Feb 19, 2013 at 01:47:13PM -0600, Gooding, Dustin R. (JSC-ER411) wrote:
>> >> Take for instance the diagnostic_msgs/DiagnosticStatus message. It has a couple
>> >> of hard-coded "enum" values. How would one access those values from RTT-Lua?
>> >
>> > I honestly don't know, I've never tried or needed to, since the RTT
>> > enums are available in the global service. What happens if you
>> > access/change these?
>> >
>> > Markus
>>
>> The rtt.globals are specifically for Orocos things. Accessing them
>> is easy and we do it when we're defining our connection policies,
>> activity schedulers, and understanding port data
>> interactions. Changing rtt.globals seems to be easy as well (just an
>> assignment).
>>
>> These ROS msg constants (what they're actually called) allow for an
>> integer msg member variable that has pre-defined values available to
>> use. For example, the diagnostic_msgs/DiagnosticStatus has a member
>> named "level" and three possible pre-defined values "OK=0, WARN=1,
>> ERROR=2". This kinda-sorta helps folks pass well-defined values in
>> an otherwise generic container. Folks are still free to set "level"
>> to something other than 0-2, but the value will be undefined.
>>
>> In RTT-Lua, I'd like to be able to make a variable of type
>> diagnostic_msgs/DiagnosticStatus, and read/assign the "level" member
>> using those constants, instead of the integer value. This way, even
>> our Lua scripts are capable of sending/receiving well-defined
>> messages.
>
> It makes sense, I wonder how this could be supported. For instance the
> ROS message typekit generation could install these constants as
> globals (e.g. rtt.globals.diagnostic_msgs/DiagnosticStatus.WARN=2). Or
> it could also happen in Lua only, e.g. by reusing the roslua msg
> parsing infrastructure.

Both are possible. For generating the constant in the typekit, we'd
need to extend the python create_boost_headers.py script to generate
these as well, and include that code in the compiled typekit.

Peter