Publish a complex msg on a topic
Hey,
I read the topic on publishing for python scipt but now I would like to published complex msg like :
People.msg
Inside
Int Age
String FName
String LName
I don't know what I am supposed to write in the python script to publish data ob the different part of the message ? Something like :
pub_People = rospy.Publisher('people', People);
And the I change the value of the people.age
before publishing ?
People.age =10
pub_People .publish(people.age)
Thank you for your help.
Asked by azfboom on 2015-10-26 04:53:35 UTC
Answers
Something like :
pub_People = rospy.Publisher('people', People);
And the I change the value of the
people.age
before publishing ?People.age =10 pub_People .publish(people.age)
Yes, that is the gist of it.
You'd work with an instance of the message though, not the People
class itself. So:
from wherever.msg import People
...
pub_People = rospy.Publisher('people', People)
...
my_msg = People()
my_msg.age = 10
my_msg....
...
pub_People.publish(my_msg)
I've skipped things like initialisation and spinning, be sure to add those as well.
Asked by gvdhoorn on 2015-10-26 05:10:34 UTC
Comments