← Back to search

[ROS Q&A] 027 - How to create and import a custom message

The Construct Robotics Institute 17:42

19,922 views · 118 likes Watch on YouTube ↗

In this video you will learn how to create and use a custom message, importing it into a Python script.

Here you have the video response to the question in GazeboAnswers:
https://answers.ros.org/question/270324/importerror-no-module-named-node_examplemsg/

[ Further learning course for this video ]
ROS Basics Course for Beginner: Learn the main concepts required to create and understand ROS programs
- http://www.theconstructsim.com/construct-learn-develop-robots-using-ros/robotigniteacademy_learnros/ros-courses-library/ros-courses-ros-basics-in-5-days-c/3Rndd4 (C++)
- http://www.theconstructsim.com/construct-learn-develop-robots-using-ros/robotigniteacademy_learnros/ros-courses-library/ros-basics-in-5-days/ (Python)

[ Question of the Tutorial ]
I have a package named node_example containing an msg folder containing these files

ViewTemplate.msg To run a python file depending on this message I used :

from node example.msg import ViewTemplate
But I get this error :

from node_example.msg import ViewTemplate
ImportError: No module named node_example.msg
The CMakeLists.txt is here :

cmake_minimum_required(VERSION 2.8.3)
project(node_example)

find_package(catkin REQUIRED COMPONENTS
dynamic_reconfigure
message_generation
roscpp
rosgraph_msgs
nav_msgs
rospy
std_msgs
)

add_message_files(FILES
NodeExampleData.msg
TopologicalAction.msg
TopologicalEdge.msg
TopologicalMap.msg
TopologicalNode.msg
ViewTemplate.msg
)

generate_messages(DEPENDENCIES
geometry_msgs
std_msgs
)

generate_dynamic_reconfigure_options(cfg/nodeExample.cfg)

catkin_package(CATKIN_DEPENDS
dynamic_reconfigure
message_runtime
roscpp
rosgraph_msgs
rospy
std_msgs
visualization_msgs
)

include_directories(include ${catkin_INCLUDE_DIRS})

install(PROGRAMS
src/main_lv.py
src/pylistener.py
src/pytalker.py
src/ratslam/posecell_network.py
src/ratslam/experience_map_younes.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(PROGRAMS
src/main_lv.py
src/main_em.py
src/pytalker.py
src/ratslam/posecell_network.py
src/ratslam/experience_map_younes.py
src/ratslam/local_view_match.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

Category (YouTube): Science & Technology

Playback is via YouTube's official embedded player. Data from YouTube; Exumo is not affiliated with YouTube.