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

Service won't build with geometry messages

asked 2020-08-05 05:51:20 -0600

LukeAI gravatar image

updated 2020-08-05 05:55:16 -0600

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="me@todo.todo">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>
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-08-05 06:37:13 -0600

Tahir M. gravatar image

updated 2020-08-05 06:37:37 -0600

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
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-08-05 05:51:20 -0600

Seen: 1,258 times

Last updated: Aug 05 '20