0
$\begingroup$

Rosanswers logo

I cannot build a service that uses geometry_msgs/Polygon I've added in the same way as std_msgs which seems to be fine. Where am I going wrong? Weirdly enough, "Polygon.msg" does exist in /opt/ros/kinetic/share/geometry_msgs/cmake/../msg which CMake explicitly states is in the search path.

The error:

Could not find messages which
  '/home/luke/projects/AQC_CAS/src/computing/perception/apm_detector/srv/APMDetection.srv'
  depends on.  Did you forget to specify generate_messages(DEPENDENCIES ...)?

  Cannot locate message [Polygon]: unknown package [apm_detector] on search
  path [{{'std_msgs': ['/opt/ros/kinetic/share/std_msgs/cmake/../msg'],
  'sensor_msgs': ['/opt/ros/kinetic/share/sensor_msgs/cmake/../msg'],
  'geometry_msgs': ['/opt/ros/kinetic/share/geometry_msgs/cmake/../msg']}}]
Call Stack (most recent call first):
  /opt/ros/kinetic/share/genmsg/cmake/genmsg-extras.cmake:307 (include)
  computing/perception/apm_detector/CMakeLists.txt:23 (generate_messages)

APMDetection.srv

---
Header header
string class_name
int32 class_index
Polygon bounding_box

CMakeLists.txt

cmake_minimum_required(VERSION 3.0.2)
project(apm_detector)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  rospy
  std_msgs
  sensor_msgs
  geometry_msgs
  message_generation 
)

add_service_files(
   FILES
   APMDetection.srv
   APMDetectionArray.srv
)

## Generate added messages and services with any dependencies listed here
generate_messages(
#  DEPENDENCIES
   sensor_msgs
   std_msgs
   geometry_msgs
)

catkin_package(
  INCLUDE_DIRS include
  CATKIN_DEPENDS cv_bridge rospy sensor_msgs std_msgs geometry_msgs message_runtime
#  DEPENDS system_lib
)

###########
## Build ##
###########

include_directories(
# include
  ${catkin_INCLUDE_DIRS}
)

package.xml

<?xml version="1.0"?>
<package format="2">
  <name>apm_detector</name>
  <version>0.0.0</version>
  <description>The apm_detector package</description>

  <maintainer email="[email protected]">luke</maintainer>
  <license>TODO</license>

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>cv_bridge</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>geometry_msgs</build_depend>
  <build_depend>sensor_msgs</build_depend>
  <build_export_depend>cv_bridge</build_export_depend>
  <build_export_depend>rospy</build_export_depend>
  <build_export_depend>std_msgs</build_export_depend>
  <build_export_depend>geometry_msgs</build_export_depend>
  <build_export_depend>sensor_msgs</build_export_depend>
  <exec_depend>cv_bridge</exec_depend>
  <exec_depend>rospy</exec_depend>
  <exec_depend>sensor_msgs</exec_depend>
  <exec_depend>std_msgs</exec_depend>
  <exec_depend>geometry_msgs</exec_depend>

  <!-- for custom messages -->
  <build_depend>message_generation</build_depend>
  <exec_depend>message_runtime</exec_depend>

  <!-- The export tag contains other, unspecified, tags -->
  <export>
    <!-- Other tools can request additional information be placed here -->

  </export>
</package>

Originally posted by LukeAI on ROS Answers with karma: 131 on 2020-08-05

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You need to include package name with your message type. The exact syntax is:

PackageName/VariableType variable_name

As described here PackageName/ is left out when referring to message from the same package.

With this I was able to create the service in my package:

mbs@mbs-rosPC:~$ rossrv show mbs_msgs/APMDetection 
---
std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
string class_name
int32 class_index
geometry_msgs/Polygon bounding_box
  geometry_msgs/Point32[] points
    float32 x
    float32 y
    float32 z

Originally posted by Tahir M. with karma: 213 on 2020-08-05

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.