## Compile as C++11, supported in ROS Kinetic and newer # add_compile_options(-std=c++11)
## Find catkin macros and libraries ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) ## is used, also find other catkin packages find_package(catkin REQUIRED COMPONENTS roscpp std_msgs flora_msgs )
...
################################### ## catkin specific configuration ## ################################### ## The catkin_package macro generates cmake config files for your package ## Declare things to be passed to dependent projects ## INCLUDE_DIRS: uncomment this if your package contains header files ## LIBRARIES: libraries you create in this project that dependent projects also need ## CATKIN_DEPENDS: catkin_packages dependent projects also need ## DEPENDS: system dependencies of this project that dependent projects also need catkin_package( #INCLUDE_DIRS include #LIBRARIES flora_say CATKIN_DEPENDS roscpp std_msgs flora_msgs #DEPENDS system_lib )
########### ## Build ## ###########
## Specify additional locations of header files ## Your package locations should be listed before other locations include_directories( # include ${catkin_INCLUDE_DIRS} )
## Declare a C++ library # add_library(${PROJECT_NAME} # src/${PROJECT_NAME}/flora_say.cpp # )
## Add cmake target dependencies of the library ## as an example, code may need to be generated before libraries ## either from message generation or dynamic reconfigure # add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Declare a C++ executable ## With catkin_make all packages are built within a single CMake context ## The recommended prefix ensures that target names across packages don't collide add_executable(${PROJECT_NAME}_node src/flora_say_node.cpp)
## Rename C++ executable without prefix ## The above recommended prefix causes long target names, the following renames the ## target back to the shorter version for ease of user use ## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node" # set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
## Add cmake target dependencies of the executable ## same as for the library above add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Specify libraries to link a library or executable target against target_link_libraries( ${PROJECT_NAME}_node ${catkin_LIBRARIES} )
修改 package.xml,引入依赖
... <!-- Use build_depend for packages you need at compile time: --> <build_depend>message_generation</build_depend> <!-- Use build_export_depend for packages you need in order to build against this package: --> <!-- <build_export_depend>message_generation</build_export_depend> --> <!-- Use buildtool_depend for build tool packages: --> <!-- <buildtool_depend>catkin</buildtool_depend> --> <!-- Use exec_depend for packages you need at runtime: --> <exec_depend>message_runtime</exec_depend> <!-- Use test_depend for packages you need only for testing: --> <!-- <test_depend>gtest</test_depend> --> <!-- Use doc_depend for packages you need only for building documentation: --> <!-- <doc_depend>doxygen</doc_depend> --> <buildtool_depend>catkin</buildtool_depend> <build_depend>roscpp</build_depend> <build_depend>std_msgs</build_depend> <build_depend>flora_msgs</build_depend> <build_export_depend>roscpp</build_export_depend> <build_export_depend>std_msgs</build_export_depend> <exec_depend>roscpp</exec_depend> <exec_depend>std_msgs</exec_depend> <exec_depend>flora_msgs</exec_depend> ...
## Compile as C++11, supported in ROS Kinetic and newer # add_compile_options(-std=c++11)
## Find catkin macros and libraries ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) ## is used, also find other catkin packages find_package(catkin REQUIRED COMPONENTS roscpp std_msgs ) catkin_package( # INCLUDE_DIRS include # LIBRARIES flora_listen CATKIN_DEPENDS roscpp std_msgs # DEPENDS system_lib )
########### ## Build ## ###########
## Specify additional locations of header files ## Your package locations should be listed before other locations include_directories( # include ${catkin_INCLUDE_DIRS} ) ## Declare a C++ library # add_library(${PROJECT_NAME} # src/${PROJECT_NAME}/flora_listen_node.cpp # ) ## Add cmake target dependencies of the library ## as an example, code may need to be generated before libraries ## either from message generation or dynamic reconfigure # add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) ## Declare a C++ executable ## With catkin_make all packages are built within a single CMake context ## The recommended prefix ensures that target names across packages don't collide add_executable(${PROJECT_NAME}_node src/flora_listen_node.cpp) ## Rename C++ executable without prefix ## The above recommended prefix causes long target names, the following renames the ## target back to the shorter version for ease of user use ## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node" # set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "") ## Add cmake target dependencies of the executable ## same as for the library above add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) ## Specify libraries to link a library or executable target against target_link_libraries(${PROJECT_NAME}_node ${catkin_LIBRARIES} )
flora_msg
# ~/catkin_ws $ cat src/flora_msgs/msg/FloraMsg.msg string detail int32 id
$ sudo docker run -itd -v$(pwd):/data ros:kinetic 4a9c7b8170285696db2d1575d593fdc53b387127b793c8692f534dd31a21d0de
-itd
-v$(pwd):/data
$ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4a9c7b817028 ros:kinetic "/ros_entrypoint.sh …" 2 minutes ago Up 2 minutes awesome_einstein
klose@self-driving:~/catkin_ws$ sudo docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4a9c7b817028 ros:kinetic "/ros_entrypoint.sh …" 8 minutes ago Up 8 minutes awesome_einstein klose@self-driving:~/catkin_ws$ sudo docker commit 4a9c7b817028 myimage sha256:b17e1ef21afbaaf7e04cc0c8a52f3a8118ece554b568e03c63577f8183429e0f klose@self-driving:~/catkin_ws$ sudo docker images REPOSITORY TAG IMAGE ID CREATED SIZE myimage latest b17e1ef21afb 5 seconds ago 1.13GB ros kinetic a3c5711abb29 16 months ago 1.13GB