Declare a message outside of a node (scope problems?)
I am trying to declare a new message outside of my ROS node, then pass it into the ROS node.
Multiple pieces of my program can generate GPS messages, but all the messages should be published to the one single publisher. Here are my publishers within my "Talker" node.
final Publisher<collab_msgs.SubjectPose> statePublisher
= connectedNode.newPublisher("/a/subject_pose", collab_msgs.SubjectPose._TYPE);
final Publisher<collab_msgs.SubjectGps> gpsPublisher
= connectedNode.newPublisher("/a/task_gps", collab_msgs.SubjectGps._TYPE);
Now, to create a new message within the node, I can of course do something like
collab_msgs.SubjectGps gpsMsg = gpsPublisher.newMessage();
However, if I want to create a message outside of this class, I no longer have access to the publisher to instantiate the message (I cannot make the publisher a class variable since it must be a constant and you must have the connectedNode parameter to instantiate a Publisher object).
It would be nice to be able to do something like
collab_msgs.SubjectGps a = new collab_msgs.SubjectGps();
and I saw some code from back in October '11 where this worked, but it appears that this has been changed since then.
Thanks for the help