ROSJAVA : Implementing geometry_msgs.Vector3
Hi,
How do I code the function toRawMessage when I implement geometry_msgs.Vector3 ?
Currently the structure of my class is as shown below. Is there any documentation.
public class Vector3_self implements geometry_msgs.Vector3 {
public double x,y,z;
@Override
public RawMessage toRawMessage() {
// TODO Auto-generated method stub
return null;
}
@Override
public double getX() {
// TODO Auto-generated method stub
return x;
}
But when I try to publish an Imu value using this class, I get the null exception error:
Code:
protected void loop() throws InterruptedException {
sensor_msgs.Imu imu_accel = publisher.newMessage();
accel_values.setX( 5.0 ); // [ where accel_value is defined as public Vector3_selg accel_values = new Vector3_self() ];
accel_values.setY( 6.0 );
accel_values.setZ( 7.0 );
imu_accel.setLinearAcceleration(accel_values);
publisher.publish(imu_accel);
sequenceNumber += 10;
Thread.sleep(1000);
}
Error:
Exception in thread "pool-1-thread-6" java.lang.NullPointerException at org.ros.internal.message.ValueField.getSerializedSize(ValueField.java:76) at org.ros.internal.message.MessageImpl.getSerializedSize(MessageImpl.java:452) at org.ros.internal.message.MessageImpl.serialize(MessageImpl.java:459) at org.ros.internal.message.DefaultMessageSerializer.serialize(DefaultMessageSerializer.java:30) at org.ros.internal.message.DefaultMessageSerializer.serialize(DefaultMessageSerializer.java:26) at org.ros.internal.transport.OutgoingMessageQueue.writeMessageToChannel(OutgoingMessageQueue.java:79) at org.ros.internal.transport.OutgoingMessageQueue.access$100(OutgoingMessageQueue.java:38) at org.ros.internal.transport.OutgoingMessageQueue$Writer.loop(OutgoingMessageQueue.java:56) at org.ros.concurrent.CancellableLoop.run(CancellableLoop.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:679)
Thank you.