org.ros.internal.message cannot be cast to std_msgs.String
I'm working recently with Rosjava Kinetic and I have some problems and doubts. I have imported the project to Eclipse to mix it with another project that I have, called PELEA, composed of several modules, to make the message passing through a client-server. Of course, I have a terminal running roscore and a server running inside eclipse. I make the new client and the new message in this way:
public void onStart(final ConnectedNode connectedNode) {
ServiceClient<std_msgs.String, std_msgs.String> serviceClient;
try {
serviceClient = connectedNode.newServiceClient("custom_service", std_msgs.String._TYPE);
} catch (ServiceNotFoundException e) {
throw new RosRuntimeException(e);
}
final std_msgs.String request = serviceClient.newMessage(); //ERROR!!
request.setData("Hello");
serviceClient.call(request, new ServiceResponseListener<std_msgs.String>() {
@Override
public void onSuccess(std_msgs.String response) {
connectedNode.getLog().info(String.format("The response is: "));
response.getData();}
@Override
public void onFailure(org.ros.exception.RemoteException e) {
throw new RosRuntimeException(e);
}
});
}
And I get this error:
Exception in thread "pool-1-thread-3" java.lang.ClassCastException: org.ros.internal.message.$Proxy4 cannot be cast to std_msgs.String
at org.squeleton.executiondeclarative.ExecutionSqueleton.clientManagement(ExecutionSqueleton.java:591)
at org.squeleton.executiondeclarative.Client.onStart(Client.java:57)
at org.ros.internal.node.DefaultNode$5.run(DefaultNode.java:507)
at org.ros.internal.node.DefaultNode$5.run(DefaultNode.java:504)
at org.ros.concurrent.EventDispatcher.loop(EventDispatcher.java:43)
at org.ros.concurrent.CancellableLoop.run(CancellableLoop.java:56)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
So.. I don't know what is the problem, I think it should works..
I appreciate any help, advide or guide.
Thanks a lot and sorry for my bad english.
Just so you know, the
<pre>
and<code>
tags don't do a very good job at marking up code and terminal output. It's usually easier to highlight the text then click on the101010
button instead. That way your code is marked up with syntax highlighting.Ok, you are right... sorry.
It's not a problem, just for reference for the next time that you ask a question :)