ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
import rospy
import VescState.msg # (or from VescState import XXX)
In rospy
, the ROS package name is the module name, and the message filename is the classname. As a package can include both messages and services, either a msg
or srv
submodule needs to be affixed.
So the .msg
is not the .msg
extension of the filename, but a module.
For the package you link (vesc_msgs
), the import statement should probably be:
from vesc_msgs.msg import VescState
or if you just want to import all messages:
from vesc_msgs.msg import *
It seems as if not this forum or the tutorials have a solution for this simple question
This is always difficult, but I have the impression (but I've obviously been doing this for so long that it's easy for me to find this) that most tutorials and example code shows examples of this.
See wiki/ROS/tutorials/Defining Custom Messages - Including or Importing Messages - Python fi.
2 | No.2 Revision |
import rospy
import VescState.msg # (or from VescState import XXX)
In rospy
, the ROS package name is the module name, and the message filename is the classname. As a package can include both messages and services, either a msg
or srv
submodule needs to be affixed.
So the .msg
is not the .msg
extension of the filename, but a module.
For the package you link (vesc_msgs
), the import statement should probably be:
from vesc_msgs.msg import VescState
or if you just want to import all messages:
from vesc_msgs.msg import *
It seems as if not this forum or the tutorials have a solution for this simple question
This is always difficult, but I have the impression (but I've obviously been doing this for so long that it's easy for me to find this) that most tutorials and example code shows examples of this.
See wiki/ROS/tutorials/Defining Custom Messages - Including or Importing Messages - Python fi.
3 | No.3 Revision |
import rospy import VescState.msg # (or from VescState import XXX)
In rospy
, the ROS package name is the module name, and the message filename is the classname. As a package can include both messages and services, either a msg
or srv
submodule needs to be affixed.added.
So the .msg
is not the .msg
extension of the filename, but a module.
For the package you link (vesc_msgs
), the import statement should probably be:
from vesc_msgs.msg import VescState
or if you just want to import all messages:
from vesc_msgs.msg import *
It seems as if not this forum or the tutorials have a solution for this simple question
This is always difficult, but I have the impression (but I've obviously been doing this for so long that it's easy for me to find this) that most tutorials and example code shows examples of this.
See wiki/ROS/tutorials/Defining Custom Messages - Including or Importing Messages - Python fi.