@Override public void run() { Topic echoBack = new Topic(ros, this.topic, topicType); echoBack.subscribe(new TopicCallback() { @Override public void handleMessage(Message message) { events.add(message.toString().getBytes()); } }); }
public void initialize() { if (!initialized) { feedbackListener = new Topic(ros, this.serverName + "/feedback", this.actionName + "Feedback" ); feedbackListener.subscribe(new TopicCallback() { resultListener = new Topic(ros, this.serverName + "/result", this.actionName + "Result" ); resultListener.subscribe(new TopicCallback() { statusListener = new Topic(ros, this.serverName + "/status", GoalStatusArray.TYPE ); statusListener.subscribe(new TopicCallback() { goalTopic = new Topic(ros, this.serverName + "/goal", this.actionName + "Goal" ); goalTopic.advertise(); cancelTopic = new Topic(ros, this.serverName + "/cancel", GoalID.TYPE); cancelTopic.advertise();
@Override public void startAdapter() throws AdapterException { this.ros = new Ros(this.host); this.ros.connect(); String topicType = getMethodType(this.ros, this.topic); Topic echoBack = new Topic(ros, this.topic, topicType); echoBack.subscribe(new TopicCallback() { @Override public void handleMessage(Message message) { InputStream stream = new ByteArrayInputStream(message.toString().getBytes(StandardCharsets.UTF_8)); jsonObjectParser.parse(stream, new ParseData()); } }); }