Xamla / torch-ros

Torch7/lua wrapper of roscpp via ffi.
http://www.xamla.com/
BSD 3-Clause "New" or "Revised" License
20 stars 5 forks source link

Using a Custom ROS Message #7

Closed vkee closed 8 years ago

vkee commented 8 years ago

Hi,

I was wondering how to use custom ROS messages, if it was at all possible.

When I create a custom message in a package following the ROS tutorials, I am able to use it fine with roscpp and rospy. However, when I try to use it in torchros doing

string_spec = ros.MsgSpec('live_icp/RegViz')

where live_icp is the package and RegViz is the name of the message, I get the following error

/home/rosie/torch/install/bin/luajit: /home/rosie/torch/install/share/lua/5.1/ros/env.lua:65: Package path could not be found for live_icp stack traceback: [C]: in function 'assert' /home/rosie/torch/install/share/lua/5.1/ros/env.lua:65: in function 'find_package' /home/rosie/torch/install/share/lua/5.1/ros/MsgSpec.lua:169: in function 'load_msgspec' /home/rosie/torch/install/share/lua/5.1/ros/MsgSpec.lua:220: in function '__init' /home/rosie/torch/install/share/lua/5.1/torch/init.lua:91: in function </home/rosie/torch/install/share/lua/5.1/torch/init.lua:87> [C]: in function 'MsgSpec' test_publish.lua:10: in main chunk [C]: in function 'dofile' ...osie/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk [C]: at 0x00405d50

Thanks!

andreaskoepf commented 8 years ago

Using your custom ROS messages should work without problems. Could you verify that you sourced your catkin_ws/devel/setup.bash? Internall torch-ros uses the rospack find <package_name> executable of the active ros version env.lua#L58. Could you try whether rospack find live_icp works in the same shell from which you start your th session?

vkee commented 8 years ago

I did source the setup.bash. rospack find live_icp works too.

andreaskoepf commented 8 years ago

@vkee The error message you see comes from the function:

function ros.find_package(package)
  if not rospack_path_cache[package] then
    local p = io.popen("rospack find " .. package .. " 2>/dev/null")
    rospack_path_cache[package] = p:read("*l")
    p:close()
  end

  assert(rospack_path_cache[package] and #rospack_path_cache[package] > 0,
    "Package path could not be found for " .. package)
  return rospack_path_cache[package]
end

Could you debug on your side why it is not working on your machine when called with 'live_icp' as package argument? I used it today on more than one Ubuntu 16.04 machine and ros kinetic with custom messages without problems.

vkee commented 8 years ago

I initially got it to work using

string_spec = ros.MsgSpec('/RegViz') from the same package as the message.

It seems like now

string_spec = ros.MsgSpec('live_icp/RegViz')

is working too. I'm not sure what exactly I did since it successfully catkin_make and catkin_make installed earlier.

andreaskoepf commented 8 years ago

Great, glad to hear that it is working now.