Я настроил CLion для разработки ROS по этой ссылке от JetBrains: https://www.jetbrains.com/help/clion/2018.3/ros-setup-tutorial.html ... и я успешно провел некоторую разработку.
Но теперь пришло время разработать "Dynami c Reconfigure for Node" в c ++ в соответствии с этим руководством: http://wiki.ros.org/dynamic_reconfigure/Tutorials/SettingUpDynamicReconfigureForANode%28cpp%29 При использовании команды catkin_make
я могу легко все собрать (см. мои файлы ниже). Но как я могу собрать то же самое, используя CLion (а не catkin_make)? Когда я пытаюсь собрать этот код из CLion, появляется следующая ошибка:
/snap/clion/current/bin/cmake/linux/bin/cmake --build /home/maciej/ros/test_clion/build --target my_server_node -- -j 4
[ 50%] Building CXX object CMakeFiles/my_server_node.dir/nodes/server.cpp.o
/home/maciej/ros/test_clion/src/dynamic_tutorials/nodes/server.cpp:11:10: fatal error: dynamic_tutorials/TutorialsConfig.h: No such file or directory
#include <dynamic_tutorials/TutorialsConfig.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/my_server_node.dir/build.make:62: recipe for target 'CMakeFiles/my_server_node.dir/nodes/server.cpp.o' failed
make[3]: *** [CMakeFiles/my_server_node.dir/nodes/server.cpp.o] Error 1
CMakeFiles/Makefile2:105: recipe for target 'CMakeFiles/my_server_node.dir/all' failed
make[2]: *** [CMakeFiles/my_server_node.dir/all] Error 2
CMakeFiles/Makefile2:112: recipe for target 'CMakeFiles/my_server_node.dir/rule' failed
make[1]: *** [CMakeFiles/my_server_node.dir/rule] Error 2
Makefile:175: recipe for target 'my_server_node' failed
make: *** [my_server_node] Error 2
Структура моего пакета выглядит следующим образом:
dynamic_tutorials
---cfg
------Tutorials.cfg
---include
-------dynamic_tutorials (empty)
---nodes
------server.cpp
---CMakeLists.txt
---package.xml
Tutorials.cfg
#!/usr/bin/env python
PACKAGE = "dynamic_tutorials"
from dynamic_reconfigure.parameter_generator_catkin import *
gen = ParameterGenerator()
gen.add("int_param", int_t, 0, "An Integer parameter", 50, 0, 100)
gen.add("double_param", double_t, 0, "A double parameter", .5, 0, 1)
gen.add("str_param", str_t, 0, "A string parameter", "Hello World")
gen.add("bool_param", bool_t, 0, "A Boolean parameter", True)
size_enum = gen.enum([ gen.const("Small", int_t, 0, "A small constant"),
gen.const("Medium", int_t, 1, "A medium constant"),
gen.const("Large", int_t, 2, "A large constant"),
gen.const("ExtraLarge", int_t, 3, "An extra large constant")],
"An enum to set size")
gen.add("size", int_t, 0, "A size parameter which is edited via an enum", 1, 0, 3, edit_method=size_enum)
exit(gen.generate(PACKAGE, "dynamic_tutorials", "Tutorials"))
сервер. cpp
#include <ros/ros.h>
#include <dynamic_reconfigure/server.h>
#include <dynamic_tutorials/TutorialsConfig.h>
void callback(dynamic_tutorials::TutorialsConfig &config, uint32_t level) {
ROS_INFO("Reconfigure Request: %d %f %s %s %d",
config.int_param, config.double_param,
config.str_param.c_str(),
config.bool_param?"True":"False",
config.size);
}
int main(int argc, char **argv) {
ros::init(argc, argv, "dynamic_tutorials");
dynamic_reconfigure::Server<dynamic_tutorials::TutorialsConfig> server;
dynamic_reconfigure::Server<dynamic_tutorials::TutorialsConfig>::CallbackType f;
f = boost::bind(&callback, _1, _2);
server.setCallback(f);
ROS_INFO("Spinning node");
ros::spin();
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(dynamic_tutorials)
find_package(catkin REQUIRED COMPONENTS
dynamic_reconfigure
roscpp
)
generate_dynamic_reconfigure_options(
cfg/Tutorials.cfg
#...
)
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES dynamic_tutorials
# CATKIN_DEPENDS dynamic_reconfigure roscpp
# DEPENDS system_lib
)
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
add_executable(my_server_node nodes/server.cpp)
target_link_libraries(my_server_node ${catkin_LIBRARIES})
пакет. xml
<?xml version="1.0"?>
<package format="2">
<name>dynamic_tutorials</name>
<version>0.0.0</version>
<description>The dynamic_tutorials package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
<maintainer email="maciej@todo.todo">maciej</maintainer>
<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>dynamic_reconfigure</build_depend>
<build_depend>roscpp</build_depend>
<build_export_depend>dynamic_reconfigure</build_export_depend>
<build_export_depend>roscpp</build_export_depend>
<exec_depend>dynamic_reconfigure</exec_depend>
<exec_depend>roscpp</exec_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>