"rostopic pub" does not work from out of eclipse. [closed]
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();
runtime.exec(cmdarr);
System.out.println("Ready!");
}
}
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