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

No Module named 'laser_line_extraction.msg'

asked 2019-02-05 05:07:45 -0500

Liz gravatar image

Hi All,

I am trying to import a message type from my ROS package 'laser_line_extraction' into my python script that is located in another ROS package called 'drone'.

The first part of my python script that throws the error is as below.

#!/usr/bin/env python
import rospy
from geometry_msgs.msg import PoseStamped
from std_msgs.msg import Int32, Float32
import numpy as np
import message_filters
from laser_line_extraction.msg import LineSegmentList

Running this script gives the error 'no module named 'laser_line_extraction.msg' exists'. However, when I run

rosmsg show laser_line_extraction/LineSegmentList

It gives the correct message format.

Also, the file 'LineSegmentList.msg' is correctly located within a msg folder of laser_line_extraction.

Both 'drone' and 'laser_line_extraction' are ROS packages within the same catkin_ws/src folder. I have ran catkin_make and sourced the devel/setup.bash to no avail.

After seeing this similar post, I tried to follow the instructions and edit my CMakeLists and the package.xml of the drone ROS package and recompile and source the catkin workspace and this didn't work. However, my problem is different as I am trying to access the ROS message from a different package so there is probably something I have missed.

My drone package.xml main body:

  <name>drone</name>

      <version>0.0.0</version>



          <buildtool_depend>catkin</buildtool_depend>
      <build_depend>roscpp</build_depend>
      <build_depend>std_msgs</build_depend>
  <build_depend>image_transport</build_depend>
      <build_depend>laser_line_extraction</build_depend>
      <build_depend>message_generation</build_depend>

    <run_depend>roscpp</run_depend>
      <run_depend>std_msgs</run_depend>
      <run_depend>image_transport</run_depend>
      <run_depend>laser_line_extraction</run_depend>
      <run_depend>message_runtime</run_depend>
    </package>

My drone CMakeLIsts file:

cmake_minimum_required(VERSION 2.8.3)
project(drone)
find_package(catkin REQUIRED COMPONENTS
laser_line_extraction
message_generation
    )

add_message_files(
    FILES
    LineSegment.msg
    LineSegmentList.msg
    )

    generate_messages(
        DEPENDENCIES
        laser_line_extraction)
    catkin_package(
    CATKIN_DEPENDS roscpp std_msgs image_transport laser_line_extraction 
    )
include_directories(
    ${catkin_INCLUDE_DIRS}
)

I am running Ubuntu 16.04 and ROS kinetic using Python 2.7

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-02-06 02:24:10 -0500

Delb gravatar image

You just made a little confusion but you have most of the work done. All your modifications related to the message in your package.xml and CMakeLists.txt are correct but you just did it in the wrong package. It's in your package laser_line_extraction that you should do those modifications and simply use find_package(laser_line_extraction)in your package drone, I will list the elements required for what you need to achieve :

laser_line_extraction package.xml :

  <build_depend>message_generation</build_depend>
  <run_depend>message_runtime</run_depend>

laser_line_extraction CMakeLists.txt :

find_package(catkin REQUIRED COMPONENTS
    message_generation
    std_msgs)

add_message_files(
    DIRECTORY msg  #if you put your messages in a folder msg
    FILES
    LineSegment.msg
    LineSegmentList.msg
)

#add the types from your custom message here (std_msgs for example)
generate_messages(
    DEPENDENCIES
    std_msgs)

catkin_package(
    CATKIN DEPENDS
    message_runtime
    std_msgs)

drone package.xml :

<depend>laser_line_extraction</depend>

drone CMakeLists.txt :

find_package(catkin REQUIRED COMPONENTS
    laser_line_extraction)

catkin_package(
    CATKIN DEPENDS
    laser_line_extraction)
edit flag offensive delete link more

Question Tools

Stats

Asked: 2019-02-05 05:07:45 -0500

Seen: 285 times

Last updated: Feb 06 '19