ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.

Something like : :

pub_People = rospy.Publisher('people', People); People);

And the I change the value of the people.age people.age before publishing ? ?

People.age =10 =10
pub_People .publish(people.age) 

.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.