ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

image_transport between ROS node and ROSJava node

asked 2011-11-19 09:12:56 -0600

spagi gravatar image

updated 2011-11-19 20:53:26 -0600

Hi, am getting a picture with kinect and I want to tranfer it a Rosjava node to use it there. I have managed to exchange messages between those two nodes, but the image_transport is unclear on the Rosjava side. I cannot find documentation on which imports to make and what libraries to refer to. I am trying to edit a normal message listener rosjava node to make it able to receive images. This is my base code that I try to change:

public class Javacvtransfer implements NodeMain {
private Node node;
  @Override
  public void main(Node node)
  {
      Preconditions.checkState(this.node == null);
      this.node = node;
        try {
            final Log log = node.getLog();
            node.newSubscriber("camera/image", "std_msgs/String",
                new MessageListener<org.ros.message.std_msgs.String>() 
            {
                  @Override
                  public void onNewMessage(org.ros.message.std_msgs.String message) {
                    log.info("I heard: \"" + message.data + "\"");
                  }
                });
          } catch (Exception e) {
            if (node != null) {
              node.getLog().fatal(e);
            } else {
              e.printStackTrace();
            }
          }
        }
  @Override
  public void shutdown() {
    node.shutdown();
    node = null;
  } }

I dont know what imports to make also for the image_transport in rosjava. Any help would be appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2011-11-21 09:32:32 -0600

Patrick Mihelich gravatar image

I haven't used rosjava yet, but probably you just need to use sensor_msgs/Image instead of std_msgs/String. The class should be org.ros.message.sensor_msgs.Image.

I wouldn't worry about image_transport in Java yet. image_transport is a C++ package that basically wraps a normal ROS image topic and provides compressed versions of the image stream, which can be very useful when publishing over a bandwidth-limited network. I believe rosjava has an example of subscribing to a JPEG-compressed image topic directly, but there isn't a nice wrapper for arbitrary compressed transports like in C++.

edit flag offensive delete link more

Comments

See this answer for more info on that! http://answers.ros.org/question/60086...

jubeira gravatar image jubeira  ( 2017-04-17 08:57:26 -0600 )edit

Question Tools

Stats

Asked: 2011-11-19 09:12:56 -0600

Seen: 917 times

Last updated: Nov 21 '11