[SOLVED] Nav_msgs not defined


#1

Hi everyone,
When I try to create a robot subscriber or robot publisher with nav_msgs.msg Ros Message the platform tells me that the name “nav_msgs” is not defined. How can I resolve this problem? Has the platform another syntax for nav_msgs message?
Thank you for the help.


Best regards,

Simone.


#2

Dear Simone,

do not forget to import the python class related to the message you need

from nav_msgs.msg import Odometry

It is required both at line 2 and at line 6 (i.e. at top level and in the body of the function).

Regards,

Ugo


#3

Dear Ugo,

I imported the python class both at top level and in the body of the function but the platform shows me the same error in the screenshot. Transfer function doesn’t recognize the nav_msgs name.

Thank you for the help.

Best regards,

Simone.


#4

Sounds like an import issue.

When the Odometry class is imported with the statement:
from nav_msgs.msg import Odometry
it can be referenced in the code simply by its class name: Odometry.

In order to use use is as nav_msgs.msg.Odometry instead,
the import statement must be import nav_msgs .

In case it doen’t work, please copy the TF code (with the imports) here so that I can test it.

Cheers


#5

Dear Ugo,

Now the import works.
Thank you for the help.