"rostopic pub" does not work from out of eclipse. [closed]

asked 2014-07-03 15:39:28 -0600

fhurlbrink gravatar image

updated 2014-07-03 15:40:29 -0600

Hello, I write a little Java program. that communicates with the listener node from the beginner_tutorials package. It uses the rostopic pub command.

package rolex;

import java.io.IOException;
import java.util.Random;

public class Rolex {
    public static void main(String[] args) throws IOException {
        Random random = new Random();

    String cmdarr[] = { "/opt/ros/hydro/bin/rostopic", "pub", "-1",
            "/chatter", "std_msgs/String", "Hello! " + random.nextInt(100) };
    Runtime runtime = Runtime.getRuntime();

When, after compiling, I call it manually via

$ java rolex.Rolex

it works fine. A message "Hello!" with a random number appended is sent to the /chatter topic via rostopic pub.

But when I run it directly out if Eclipse, it seems to run (no compile errors, Ready message at the end appears), but no message is sent to the chatter topic. What is wrong?

It just want to run it directly from Eclipse without manually calling $ java rolex.Rolex

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2016-06-28 22:14:54.176869