On Tue, Feb 22, 2011 at 07:36:08AM +0100, Steven Bellens wrote: > 2011/2/21 Markus Klotzbuecher : > > Dear List, > > > > I just gave roslua a try and its working quite nicely. One smaller > > problem I noticed is when printing some array types: > > > > $ lua -lroslua > > Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio > >> twist = roslua.get_msgspec("geometry_msgs/Twist") > >> t=twist:instantiate() > >> t:print() > > geometry_msgs/Twist > > /home/mk/src/git/lua/roslua/src/roslua/msg_spec.lua:53: attempt to call method 'find' (a nil value) > > stack traceback: > >      /home/mk/src/git/lua/roslua/src/roslua/msg_spec.lua:53: in function 'is_array_type' > >      /home/mk/src/git/lua/roslua/src/roslua/message.lua:259: in function 'print_value' > >      /home/mk/src/git/lua/roslua/src/roslua/message.lua:285: in function 'print' > >      stdin:1: in main chunk > >      [C]: ? > >> > > > > Secondly I wondered if there is a more compact way to create messages > > which contain submessages. For instance to create and fill a > > "geometry_msgs/Twist" I did the following: > > > > local Vector3=roslua.get_msgspec("geometry_msgs/Vector3") > > > > local m = p.msgspec:instantiate() -- geometry_msgs/Twist message > > local vec3lin = Vector3:instantiate() > > local vec3ang = Vector3:instantiate() > > > > vec3lin.values.x=x > > vec3lin.values.y=y > > vec3lin.values.z=z > > vec3ang.values.x=xang > > vec3ang.values.y=yang > > vec3ang.values.z=zang > > > > m.values.linear = vec3lin > > m.values.angular = vec3ang > > > > > > Before that I tried > > > > m.values.linear.x = x > > m.values.linear.y = y > > ... > > > > but this didn't work. > > What is the 'values' for? > How about > > m.linear.x = x > m.linear.y = y ? The 'values' field is a Lua table which contains the message variables, so I believe this is correct. But it's not clear how to set fields if the submessage is not primitive, as in above case. Best regards Markus