Hello, I try to follow MAVROS offboard example, but I have problem with building it; I made new package which will intend to use installed MAVROS, but when trying to build it by catkin, it fails:
Errors << collision_research:make /home/kris/catkin_ws/logs/collision_research/build.make.000.log
In file included from /usr/include/boost/function/detail/maybe_include.hpp:18:0,
from /usr/include/boost/function/detail/function_iterate.hpp:14,
from /usr/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:52,
from /usr/include/boost/function.hpp:64,
from /opt/ros/melodic/include/ros/forwards.h:40,
from /opt/ros/melodic/include/ros/common.h:37,
from /opt/ros/melodic/include/ros/ros.h:43,
from /home/kris/catkin_ws/src/collision_research/src/offb_node.cpp:1:
/usr/include/boost/function/function_template.hpp: In instantiation of ‘static void boost::detail::function::void_function_invoker1<FunctionPtr, R, T0>::invoke(boost::detail::function::function_buffer&, T0) [with FunctionPtr = void (*)(boost::shared_ptr<const mavros_msgs::State_<std::allocator<void> > >&); R = void; T0 = const boost::shared_ptr<const mavros_msgs::State_<std::allocator<void> > >&]’:
/usr/include/boost/function/function_template.hpp:925:38: required from ‘void boost::function1<R, T1>::assign_to(Functor) [with Functor = void (*)(boost::shared_ptr<const mavros_msgs::State_<std::allocator<void> > >&); R = void; T0 = const boost::shared_ptr<const mavros_msgs::State_<std::allocator<void> > >&]’
/usr/include/boost/function/function_template.hpp:716:7: required from ‘boost::function1<R, T1>::function1(Functor, typename boost::enable_if_c<(! boost::is_integral<Functor>::value), int>::type) [with Functor = void (*)(boost::shared_ptr<const mavros_msgs::State_<std::allocator<void> > >&); R = void; T0 = const boost::shared_ptr<const mavros_msgs::State_<std::allocator<void> > >&; typename boost::enable_if_c<(! boost::is_integral<Functor>::value), int>::type = int]’
/usr/include/boost/function/function_template.hpp:1061:16: required from ‘boost::function<R(T0)>::function(Functor, typename boost::enable_if_c<(! boost::is_integral<Functor>::value), int>::type) [with Functor = void (*)(boost::shared_ptr<const mavros_msgs::State_<std::allocator<void> > >&); R = void; T0 = const boost::shared_ptr<const mavros_msgs::State_<std::allocator<void> > >&; typename boost::enable_if_c<(! boost::is_integral<Functor>::value), int>::type = int]’
/home/kris/catkin_ws/src/collision_research/src/offb_node.cpp:20:36: required from here
/usr/include/boost/function/function_template.hpp:118:11: error: binding reference of type ‘boost::shared_ptr<const mavros_msgs::State_<std::allocator<void> > >&’ to ‘const boost::shared_ptr<const mavros_msgs::State_<std::allocator<void> > >’ discards qualifiers
BOOST_FUNCTION_RETURN(f(BOOST_FUNCTION_ARGS));
^
make[2]: *** [CMakeFiles/offb_node.dir/src/offb_node.cpp.o] Error 1
make[1]: *** [CMakeFiles/offb_node.dir/all] Error 2
make: *** [all] Error 2
I think I need to add something to depedencies in CMake, but I don’t know how to write that; I did ROS example from their site, but since I use message libraries from MAVROS, I have no clue how to define that…
package.xml:
<?xml version="1.0"?>
<package format="2">
<name>collision_research</name>
<version>0.0.0</version>
<description>The collision_research package</description>
<maintainer email="kris@todo.todo">kris</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>geometry_msgs</build_depend>
<build_depend>mavros</build_depend>
<build_depend>mavros_msgs</build_depend>
<build_export_depend>geometry_msgs</build_export_depend>
<build_export_depend>mavros</build_export_depend>
<build_export_depend>mavros_msgs</build_export_depend>
<exec_depend>geometry_msgs</exec_depend>
<exec_depend>mavros</exec_depend>
<exec_depend>mavros_msgs</exec_depend>
<export>
</export>
</package>
CMakeLists.txt:
cmake_minimum_required(VERSION 3.0.2)
project(collision_research)
find_package(catkin REQUIRED COMPONENTS
geometry_msgs
mavros
mavros_msgs
)
catkin_package(
)
include_directories(
include ${catkin_INCLUDE_DIRS}
)
add_executable(offb_node src/offb_node.cpp)
target_link_libraries(offb_node ${catkin_LIBRARIES})