Quesiton: When using catkin to build a project, how do you set one package to finish compiling before another executes?
Background: I am making a robot with custom messages/services on an Arduino using catkin. The project layout is rather similar to the Clearpath Robotics Husky where the project is separated into packages: msgs, hardware, description, ... etc. Everything works and the Arduino even compiles and uploads though catkin_make commands as outlined by this rosserial_arduino tutorial. The current project layout is as follows:
- catkin_ws/
- src/
- robot_msgs: description of custom ros messages/services (Status.msg & Command.srv)
- robot_hardware: source code for Arduino (runs rosserial_client & rosserial_arduino)
- robot_description: robot description files (urdf/xacro)
- robot_viz: opens RVIZ with robot model
Problem: When building from a fresh install (no build/devel folders in the main catkin workspace), the issue arises when executing catkin_make
for the first time. It seems that the robot_hardware
package builds and compiles a new ros_lib
before robot_msgs
can add Status.msg
or Command.srv
to the project directory (robot_msgs folder is absent in the final ros_lib folder). However, if robot_hardware
is temporarily removed while catkin_make
is run, then afterwards replaced and catkin_make
is run again, everything compiles and robot_msgs now exists in ros_lib. Is there anyway to add a dependency to the CMakeLists.txt file in robot_hardware
to force it to go last so that the project compiles using catkin_make
without tinkering with the project folders in a such a way?
Supplementary:
robot_hardware/CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(robot_hardware)
find_package(catkin REQUIRED COMPONENTS
rosserial_arduino
rosserial_client
robot_msgs
)
catkin_package()
rosserial_generate_ros_lib(
PACKAGE rosserial_arduino
SCRIPT make_libraries.py
)
# Added as a suggestion from @jayess (Sept 15 '17)
add_dependencies(robot_hardware_ros_lib
robot_msgs_generate_messages
robot_msgs_generate_messages_cpp
robot_msgs_generate_messages_eus
robot_msgs_generate_messages_lisp
robot_msgs_generate_messages_nodejs
robot_msgs_generate_messages_py
)
rosserial_configure_client(
DIRECTORY firmware
TOOLCHAIN_FILE ${ROSSERIAL_ARDUINO_TOOLCHAIN}
)
rosserial_add_client_target(firmware robot_base ALL)
rosserial_add_client_target(firmware robot_base-upload)
robot_msgs/CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(robot_msgs)
find_package(catkin REQUIRED COMPONENTS
message_generation
std_msgs
)
add_message_files(FILES
Status.msg
)
add_service_files(FILES
Command.srv
)
generate_messages(DEPENDENCIES
std_msgs
)
catkin_package(CATKIN_DEPENDS std_msgs message_runtime)
runtime error on fresh build
...
[86%] Building CXX object CMakeFiles/robot_base.dir/robot_hardware.cpp.obj
/home/user/catkin_ws/src/robot_hardware/firmware/robot_hardware.cpp:52:34: fatal error: robot_msgs/Command.h: No such file or directory
#include <robot_msgs/Command.h>
^
compilation terminated.
...
Originally posted by djiglesias on ROS Answers with karma: 31 on 2017-09-15
Post score: 3