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

Could not find the required component 'Float32' in ROS Service

asked 2019-07-29 17:48:19 -0500

Tawfiq Chowdhury gravatar image

updated 2019-07-30 00:16:43 -0500

I am trying to send float values from python client to C++ server using ros service call. I am getting this error message:

Could not find the required component 'Float32'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found. CMake Error at /opt/ros/indigo/share/catkin/cmake/catkinConfig.cmake:83 (find_package):

Could not find a package configuration file provided by "Float32" with any
  of the following names:

    Float32Config.cmake
    float32-config.cmake

  Add the installation prefix of "Float32" to CMAKE_PREFIX_PATH or set
  "Float32_DIR" to a directory containing one of the above files.  If
  "Float32" provides a separate development package or SDK, be sure it has
  been installed.

Here is my CmakeList.txt:

cmake_minimum_required(VERSION 2.8.3)
project(pr2_package)

find_package(catkin REQUIRED COMPONENTS
  moveit_core 
  moveit_ros_planning 
  moveit_ros_planning_interface 
  Float32
  roscpp
  rospy
  std_msgs
  message_generation
)


add_executable(pr2_package_1 src/gripper.cpp
)
target_link_libraries(pr2_package_1 ${catkin_LIBRARIES})
add_dependencies(pr2_package_1 ${PROJECT_NAME}_generate_messages_cpp)



## Generate messages in the 'msg' folder
 add_message_files(
   FILES
   Pose.msg
 )

## Generate services in the 'srv' folder
 add_service_files(
   FILES
   PoseSend.srv
 )


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

Here is my Pose.msg file:

Float32 data

Here is my srv file:

Float32 a
Float32 b
Float32 c
Float32 d
Float32 e
Float32 f
Float32 g
---
edit retag flag offensive close merge delete

Comments

Are you expecting there to be a ROS package named Float32? Moreover, should that package produce a Float32 message? Perhaps all of this is caused by the fact that you should be using float32 in your message definition instead of Float32.

The actual error about "could not find find package" is because of the Float32 line in your find_package call.

jarvisschultz gravatar image jarvisschultz  ( 2019-07-29 19:08:00 -0500 )edit

@jarvisschultz Ok, I will see if that works.

Tawfiq Chowdhury gravatar image Tawfiq Chowdhury  ( 2019-07-30 00:15:57 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-07-30 02:03:45 -0500

pavel92 gravatar image

Float32 is not a package but a data type and is part of std_msgs. In your message/service definition you should use float32 (for example: float32 data ). In order to use the Float32 message and your custom messages/services you need to include them in your script:

from std_msgs.msg import Float32
from your_pkg.msg import YourMsg

Also you need to add std_msgs as a dependency in your package.xml along with message generation and runtime for your custom message:

  <depend>std_msgs</depend>
  <build_depend>message_generation</build_depend>
  <exec_depend>message_runtime</exec_depend>

In your CMakeLists .txt you will need the following:

find_package(catkin REQUIRED COMPONENTS
  rospy
  message_generation
  std_msgs
)

## Uncomment this if the package has a setup.py
#catkin_python_setup()

add_message_files(
  FILES
  YourMsg.msg
)

add_service_files(
  FILES
  YourSrv.srv
)

generate_messages(
  DEPENDENCIES
  std_msgs
)

catkin_package(
  CATKIN_DEPENDS message_runtime std_msgs
)
...
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-07-29 17:48:19 -0500

Seen: 1,477 times

Last updated: Jul 30 '19