1.先建立一个新的功能包,参考过往文章。
2.功能包下的 include/功能包名 目录下新建头文件hello.h
#ifndef _HELLO_H
#define _HELLO_H
namespace hello_ns {
class My {
public:
void run();
};
}
#endif
3.建立hello.cpp文件
#include "test_manage/hello.h"
#include "ros/ros.h"
namespace hello_ns{
void My::run(){
ROS_INFO("hello,head and src ...");
}
}
4.为了后续包含头文件时不抛出异常,配置 .vscode 下 c_cpp_properties.json 的 includepath属性