RTT-Lua ROS 'time' Variable assignment

I'm probably missing something very obvious, but is it possible to assign the value of a ROS 'time' variable from Lua?

> t = rtt.Variable('time')
> =t
0
> =t:getType()
time
> =type(t)
userdata
> t:assign(1)
stdin:1: __lua_todsb: can't convert lua number to time variable
stack traceback:
[C]: in function 'assign'
stdin:1: in main chunk
[C]: ?
> t = 1
> =type(t)
number

The "assign" method doesn't seem to work. And simply assigning it again breaks that it's a 'userdata' type.

--
Dustin Gooding
NASA/JSC Robotics

RTT-Lua ROS 'time' Variable assignment

Hi Dustin,

On Tue, Jul 02, 2013 at 05:24:31PM -0500, Gooding, Dustin R. (JSC-ER411) wrote:
> I'm probably missing something very obvious, but is it possible to assign the
> value of a ROS 'time' variable from Lua?
> > t = rtt.Variable('time')
> > =t
> 0
> > =t:getType()
> time
> > =type(t)
> userdata
> > t:assign(1)
> stdin:1: __lua_todsb: can't convert lua number to time variable
> stack traceback:
> [C]: in function 'assign'
> stdin:1: in main chunk
> [C]: ?

What is a ROS time, exactly?

> > t = 1
> > =type(t)
> number
> The "assign" method doesn't seem to work. And simply assigning it again breaks
> that it's a 'userdata' type.

Yes, that's overwriting it...

Markus

RTT-Lua ROS 'time' Variable assignment

On Jul 3, 2013, at 3:08 PM, Markus Klotzbuecher <markus [dot] klotzbuecher [..] ...> wrote:

> Hi Dustin,
>
> On Tue, Jul 02, 2013 at 05:24:31PM -0500, Gooding, Dustin R. (JSC-ER411) wrote:
>> I'm probably missing something very obvious, but is it possible to assign the
>> value of a ROS 'time' variable from Lua?
>>> t = rtt.Variable('time')
>>> =t
>> 0
>>> =t:getType()
>> time
>>> =type(t)
>> userdata
>>> t:assign(1)
>> stdin:1: __lua_todsb: can't convert lua number to time variable
>> stack traceback:
>> [C]: in function 'assign'
>> stdin:1: in main chunk
>> [C]: ?
>
> What is a ROS time, exactly?

http://www.ros.org/wiki/roscpp/Overview/Time
http://www.ros.org/doc/api/rostime/html/time_8h_source.html

Basically a fancy way of making a sec+nsec pair.

It's used primarily in ROS message headers (http://www.ros.org/wiki/msg#headerSect) which assign messages sequence numbers, time stamps, and a notion of what the message data is associated with (frame, etc).

I'm attempting to write a Lua-based unit test for a component. The component has ports that accept ROS messages with headers, and the component makes decisions based on the time values. The trouble is, I'm unable to assign the time values from Lua and therefore can't make an effective test.

Maybe the solution is to not unit test in Lua and instead figure out how to do it in C++?

-dustin

Ruben Smits's picture

RTT-Lua ROS 'time' Variable assignment

On Thu, Jul 4, 2013 at 8:37 PM, Gooding, Dustin R. (JSC-ER411) <
dustin [dot] r [dot] gooding [..] ...> wrote:

> On Jul 3, 2013, at 3:08 PM, Markus Klotzbuecher <
> markus [dot] klotzbuecher [..] ...> wrote:
>
> > Hi Dustin,
> >
> > On Tue, Jul 02, 2013 at 05:24:31PM -0500, Gooding, Dustin R. (JSC-ER411)
> wrote:
> >> I'm probably missing something very obvious, but is it possible to
> assign the
> >> value of a ROS 'time' variable from Lua?
> >>> t = rtt.Variable('time')
> >>> =t
> >> 0
> >>> =t:getType()
> >> time
> >>> =type(t)
> >> userdata
> >>> t:assign(1)
> >> stdin:1: __lua_todsb: can't convert lua number to time variable
> >> stack traceback:
> >> [C]: in function 'assign'
> >> stdin:1: in main chunk
> >> [C]: ?
> >
> > What is a ROS time, exactly?
>
> http://www.ros.org/wiki/roscpp/Overview/Time
> http://www.ros.org/doc/api/rostime/html/time_8h_source.html
>
> Basically a fancy way of making a sec+nsec pair.
>
> It's used primarily in ROS message headers (
> http://www.ros.org/wiki/msg#headerSect) which assign messages sequence
> numbers, time stamps, and a notion of what the message data is associated
> with (frame, etc).
>
> I'm attempting to write a Lua-based unit test for a component. The
> component has ports that accept ROS messages with headers, and the
> component makes decisions based on the time values. The trouble is, I'm
> unable to assign the time values from Lua and therefore can't make an
> effective test.
>
> Maybe the solution is to not unit test in Lua and instead figure out how
> to do it in C++?
>
>
Hi Dustin,

at the time we wrote the rtt_ros_integration, ROS::time was the (one of
the?) only primitive ROS type(s) that did not match a standard type like
float, double, int, etc. and also did not have a msg representation (and
AFAIK this is still the case?) (see
http://www.ros.org/wiki/msg#Message_Description_Specification). Therefor we
handcrafted a typeinfo for ROS::time in the the rtt_rosnode package (
http://git.mech.kuleuven.be/?p=robotics/rtt_ros_integration.git;a=blob;f...)
and apparently we only created a function to write out the variable but not
a read function.

There are two options here, or we create a read function to support float
input, or we implement it as a StructTypeInfo and provide getMember
functionality and enable separate secs/nsecs access.

Ruben

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

RTT-Lua ROS 'time' Variable assignment

On Jul 5, 2013, at 3:16 AM, Ruben Smits <ruben [dot] smits [..] ...ruben [dot] smits [..] ...>> wrote:
Hi Dustin,

at the time we wrote the rtt_ros_integration, ROS::time was the (one of the?) only primitive ROS type(s) that did not match a standard type like float, double, int, etc. and also did not have a msg representation (and AFAIK this is still the case?) (see http://www.ros.org/wiki/msg#Message_Description_Specification). Therefor we handcrafted a typeinfo for ROS::time in the the rtt_rosnode package (http://git.mech.kuleuven.be/?p=robotics/rtt_ros_integration.git;a=blob;f...) and apparently we only created a function to write out the variable but not a read function.

There are two options here, or we create a read function to support float input, or we implement it as a StructTypeInfo and provide getMember functionality and enable separate secs/nsecs access.

Ruben

ROS has two non-standard primitive types: time and duration. Time and Duration currently have message representations, both as elements ('time' type and 'duration' type) and as full messages ('Time' msg and 'Duration' msg). http://ros.org/doc/api/std_msgs/html/msg/Time.html and http://ros.org/doc/api/std_msgs/html/msg/Duration.html

Yeah, I was confused as to how I could display the value of a time variable, but not set it. The custom typekit explains that. Hmmm… Of the two options, if I had to pick between them, I'd say the single float input is easier to deal with for the user. Having said that, though, I notice there's also no way to access ros::Time::now() from RTTLua. If there were (and there probably should be?), then the output of the "now()" command and the input of the time setter should match. "time = now()" is a natural thing to want work.

-dustin

RTT-Lua ROS 'time' Variable assignment

It's not related to RTTLua but i would like to point that ros::Time::now()
from roslib is not compatible (lead to system crash) with xenomai target.
I'm using simple implementation for xenomai target :
https://github.com/RCPRG-ros-pkg/orocos_tools/blob/master/xeno_clock/inc...

Pozdrawiam
Konrad Banachowicz

2013/7/5 Gooding, Dustin R. (JSC-ER411) <dustin [dot] r [dot] gooding [..] ...>

> On Jul 5, 2013, at 3:16 AM, Ruben Smits <ruben [dot] smits [..] ...>
> wrote:
>
> Hi Dustin,
>
> at the time we wrote the rtt_ros_integration, ROS::time was the (one of
> the?) only primitive ROS type(s) that did not match a standard type like
> float, double, int, etc. and also did not have a msg representation (and
> AFAIK this is still the case?) (see
> http://www.ros.org/wiki/msg#Message_Description_Specification). Therefor
> we handcrafted a typeinfo for ROS::time in the the rtt_rosnode package (
> http://git.mech.kuleuven.be/?p=robotics/rtt_ros_integration.git;a=blob;f...)
> and apparently we only created a function to write out the variable but not
> a read function.
>
> There are two options here, or we create a read function to support float
> input, or we implement it as a StructTypeInfo and provide getMember
> functionality and enable separate secs/nsecs access.
>
> Ruben
>
>
> ROS has two non-standard primitive types: time and duration. Time and
> Duration currently have message representations, both as elements ('time'
> type and 'duration' type) and as full messages ('Time' msg and 'Duration'
> msg). http://ros.org/doc/api/std_msgs/html/msg/Time.html and
> http://ros.org/doc/api/std_msgs/html/msg/Duration.html
>
> Yeah, I was confused as to how I could display the value of a time
> variable, but not set it. The custom typekit explains that. Hmmm… Of the
> two options, if I had to pick between them, I'd say the single float input
> is easier to deal with for the user. Having said that, though, I notice
> there's also no way to access ros::Time::now() from RTTLua. If there were
> (and there probably should be?), then the output of the "now()" command and
> the input of the time setter should match. "time = now()" is a natural
> thing to want work.
>
> -dustin
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>
>