0
$\begingroup$

Rosanswers logo

I'm a ROS beginner working on a custom controller for a UUV using Gazebo to simulate the environment and ROS to control everything. I'm using the uuv_simulator package, which does a lot of the heavy lifting for me. Currently, when certain conditions are met (i.e. the sonar reads a certain depth) I want the sub to stop moving. Fortunately, there's a service for that, /rexrov/hold_vehicle. Here's the results of a rosservice info request on it:

$ rosservice info /rexrov/hold_vehicle

Node:
/rexrov/plane_search_standard_controller

URI:
rosrpc://ncopeSub-VirtualBox:35331

Type: uuv_control_msgs/Hold 

Args:

I've read all the tutorials I can find, and I'm working heavily with the services chapter of Jason O'Kane's book, but even when everything's how I think it should be I keep getting this error when I run catkin_make:

/home/catkin_ws/src/plane_search_standard/plane_detect_anomaly.cpp:4:35:
fatal error: uuv_control_msgs/Hold.h:
No such file or directory 

compilation terminated.

plane_search_standard/CMakeFiles/subscribe_and_publish.dir/build.make:62:
recipe for target
'plane_search_standard/CMakeFiles/subscribe_and_publish.dir/plane_detect_anomaly.cpp.o'
failed make[2]: ***
[plane_search_standard/CMakeFiles/subscribe_and_publish.dir/plane_detect_anomaly.cpp.o]
Error 1 CMakeFiles/Makefile2:586:
recipe for target
'plane_search_standard/CMakeFiles/subscribe_and_publish.dir/all'
failed make[1]: ***
[plane_search_standard/CMakeFiles/subscribe_and_publish.dir/all]
Error 2 Makefile:138: recipe for
target 'all' failed make: *** [all]
Error 2 Invoking "make -j6 -l6" failed

Which seems to say that catkin_make doesn't know about the service header file for /rexrov/hold_vehicle. But by everything I've read, it should.

Here're my inclusions in the node file doing the service call:

#include <sstream>
#include <cmath>
#include <uuv_control_msgs/Hold.h>
#include "ros/ros.h"
#include "std_msgs/String.h"
#include "sensor_msgs/LaserScan.h"

Here's the line where I create the service client:

ros::ServiceClient stopSubCaller = n.serviceClient<uuv_control_msgs::Hold>("/rexrov/hold_vehicle");

Here're the lines where I actually call the service:

uuv_control_msgs::Hold::Request req;
uuv_control_msgs::Hold::Response resp;
bool success = stopSubCaller.call(req, resp);

And here's my messy CMakeLists.txt file:

 cmake_minimum_required(VERSION 2.8.3)
project(plane_search_standard)

## Find catkin and any catkin packages
find_package(catkin REQUIRED COMPONENTS rospy roscpp std_msgs sensor_msgs uuv_control_msgs)



catkin_package()

catkin_install_python(PROGRAMS scripts/plane_search_standard_controller.py DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

install(DIRECTORY launch
        DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
PATTERN "*~" EXCLUDE)


include_directories(include ${catkin_INCLUDE_DIRS})



add_executable(subscribe_and_publish plane_detect_anomaly.cpp)
target_link_libraries(subscribe_and_publish ${catkin_LIBRARIES})

add_dependencies(subscribe_and_publish ${catkin_EXPORTED_TARGETS})

Does anyone have an idea as to how I'm going wrong here? I'd really appreciate it - I'm about at my wit's end.


More info:

Running rossrv show uuv_control_msgs/Hold simply returns:

---
bool success

If I put uuv_control_msgs in the find_package command, catkin_make generates four errors like this, just with different endings where the _cpp is:

CMake Error at /home/ncope/catkin_ws/build/uuv_simulator/uuv_control/uuv_control_msgs/cmake/uuv_control_msgs-genmsg.cmake:321 (add_custom_target):
  add_custom_target cannot create target
  "uuv_control_msgs_generate_messages_cpp" because another target with the
  same name already exists.  The existing target is a custom target created
  in source directory "/home/ncope/catkin_ws/src/plane_search_standard".  See
  documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  /opt/ros/kinetic/share/genmsg/cmake/genmsg-extras.cmake:307 (include)
  uuv_simulator/uuv_control/uuv_control_msgs/CMakeLists.txt:41 (generate_messages)

If I'm reading it right, it's saying genmsg already builds those files? And cutting genmsg of course cuts the generate_messages command entirely.

package.xml contents:

<?xml version="1.0"?>
<package>
  <name>plane_search_standard</name>
  <version>0.0.0</version>
  <description>The plane_search_standard package</description>

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

  <buildtool_depend>catkin</buildtool_depend>

  <export>

  </export>
</package>

I now get an error that looks like this:

Could not find the required component 'uuv_control_msgs'. 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/kinetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
  Could not find a package configuration file provided by "uuv_control_msgs"
  with any of the following names:

    uuv_control_msgsConfig.cmake
    uuv_control_msgs-config.cmake

  Add the installation prefix of "uuv_control_msgs" to CMAKE_PREFIX_PATH or
  set "uuv_control_msgs_DIR" to a directory containing one of the above
  files.  If "uuv_control_msgs" provides a separate development package or
  SDK, be sure it has been installed.
Call Stack (most recent call first):
  plane_search_standard/CMakeLists.txt:5 (find_package)

Originally posted by swordsgnat on ROS Answers with karma: 1 on 2017-09-27

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

What happens if you run

rossrv show uuv_control_msgs/Hold

?

If you're getting a complaint that ROS can't find it or something along those lines then you may need to source your setup.bash.

Also, it looks like your CMakeLists.txt is missing uuv_control_msgs from the find_package command. Try adding it there and removing it from generate_messages and see what happens.


Edit:

As @gvdhoorn explained in the comments:

The missing uuv_control_msgs declaration (in the find_package(catkin ..)) is the problem. [...] uuv_control_msgs is only a DEPENDENCIES of your generate_messages(..) if you are actually building any msgs yourself (ie: in your own pkg). Afaict, you're not. You only depend on someone else's messages. In that case, you need to find that dependency when building, which is what the find_package(catkin REQUIRED COMPONENTS .. uuv_control_msgs ..) will do.


Edit 2:

Now, in your package.xml you need to add a dependency on uuv_control_msgs so add the following lines

<build_depend>uuv_control_msgs</build_depend>
<run_depend>uuv_control_msgs</run_depend>

Also, give the tutorials another go as a refresher for you. I still refer to them.


Originally posted by jayess with karma: 6155 on 2017-09-27

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by gvdhoorn on 2017-09-27:
The missing uuv_control_msgs declaration (in the find_package(catkin ..) is the problem.

@swordsgnat: uuv_control_msgs is only a DEPENDENCIES of your generate_messages(..) if you are actually building any msgs yourself (ie: in your own pkg). Afaict, you're not. You only depend ..

Comment by gvdhoorn on 2017-09-27:
.. on someone else's messages. In that case, you need to find that dependency when building, which is what the find_package(catkin REQUIRED COMPONENTS .. uuv_control_msgs ..) will do.

Comment by jayess on 2017-09-27:
Thanks for the explanation @gvdhoorn. I should have included that.

Comment by swordsgnat on 2017-09-27:
Hi, thanks for the reply! There wasn't enough space in the comment here so I edited that additional information into the original question at the bottom there.

Comment by swordsgnat on 2017-09-27:
Just read @gvdhoorn's replies (and thank you for the reply): when I add uuv_control_msgs to the find_package(catkin REQUIRED COMPONENTS..) command, it spits out an error like the one I edited in, claiming that it already has those targets. This persists even when I remove the other packages.

Comment by jayess on 2017-09-27:
@swordsgnat: Did you remove uuv_control_msgs from generate_messages() after adding it to find_package()? That last error is saying that there's already a package with the name uuv_control_messages . See https://github.com/ros/catkin/issues/477

Comment by swordsgnat on 2017-09-27:
Yes sir - and that error crops up even if I remove the whole generate_messages() line.

Comment by gvdhoorn on 2017-09-27:
@swordsgnat: please update your original question with the contents of both package.xml and your edited CMakeLists.txt. Also: do an rm -rf /home/ncope/catkin_ws/build and rm -rf /home/ncope/catkin_ws/devel. Then try again.

Comment by gvdhoorn on 2017-09-27:
Also: remove genmsg and message_generation from your find_package(catkin ..) statement, unless you are actually defining your own messages.

Comment by swordsgnat on 2017-09-27:
Reattempted after the rm lines, and I got a new error. I edited it in. I've never touched package.xml - is that the issue?

Comment by gvdhoorn on 2017-09-27:
You should get a different error in that case (something like "uuv_control_msgs should be a build depend of X"), but in any case: check C++ message or service dependencies to make sure you have everything correct.

Comment by gvdhoorn on 2017-09-27:
The error message you quote seems to suggest that Catkin (or really: CMake) cannot find the uuv_control_msgs. Make sure you don't have a typo in there somewhere.

I would also suggest to add some entries to your catkin_package(..) call, but that can be done later.

$\endgroup$

Your Answer

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