[Ros] Transplant and use cpp/h files

First of all thank all the authors of the open-source sharing, then transplanted from other programs .cppand .hfiles, how to use your own programs?

1. Migrate files

Create a new includefolder under the directory of the current function package , and move the .hfile to the includebottom. Move the .cppfile to the srcbottom. The structure is as follows: where the AStar.hsum AStar.cppis transplanted.

djq@djq-UX410UQK:~/catkin_ws/src/LocalPlanning$ tree -L 2
.
├── CMakeLists.txt
├── include
│   └── AStar.h
├── package.xml
└── src
    ├── AStar.cpp
    ├── for_test_hy.cpp

2. Modify the CmakeLists file

Add 1:

set(SOURCES
    ${CMAKE_CURRENT_SOURCE_DIR}/src/AStar.cpp
    )
set(HEADERS
    ${CMAKE_CURRENT_SOURCE_DIR}/include/AStar.h
    )

Add 2:

include_directories(include)

It's ok, when you use it in your own program, remember to add the header file.

#include "AStar.h"

Guess you like

Origin blog.csdn.net/qq_35632833/article/details/107215989