using new message Age.msg
I need to create a python file that creates a publisher that indicates the age of the robot.
I have created a new message Age.msg:
float32 years
float32 months
float32 days
script:
#! /usr/bin/env python
import rospy
from std_msgs.msg import Float32
print "Age of our robot: "
rospy.init_node("publish_age_node")
pub = rospy.Publisher('/pub_custom_ros_msg', Float32, queue_size=1)
rate=rospy.Rate(5)
age=Float32()
age.years = 5
age.years = 10
age.years = 21
while not rospy.is_shutdown():
pub.publish(age)
rate.sleep()
SOMETHING WRONG HERE
So what is your question?
Looking at your code, this doesn't seem right:
first you make
age
aFloat32
, then you try using it like anAge
. That won't work.You'll want to
import
your custom message and makeage
an instance of that message.I need to make a simple python file that creates a publisher that indicates the age of the robot.
I have created a new message Age.msg:
float32 years float32 months float32 days
By using this Age.msg file I should create the Python file
Thanks!
Ok. Just making sure: have you completed the introductory tutorials about creating your own message and using it with
rospy
?Yes, I completed. I also completed publisher and subscriber part
Did that not give you an idea how to import your own message?
Why are you not using the same approach for your
Age
message?Maybe I am not sure how to do it properly.
Let me try one more time and I come back here later.
Thanks for comments!
I did exactly what was said here, in youtube video: https://www.youtube.com/watch?v=ZPmlF...
But still I am getting --- ImportError: No module named mode_publishers.msg
I just changed node_example to mode_publishers