网站怎么做视频的软件,营销推广有哪些公司,基础建设文本网站,成都网站建设优化文章目录运行环境#xff1a;思路#xff1a;1.1 编写头文件1.2 includepath添加头文件路径1.3 编写可执行文件1.4 配置文件1.5 编译运行运行环境#xff1a;
ubuntu20.04 noetic 宏基暗影骑士笔记本
思路#xff1a;
类和函数#xff1a; 头文件 声明 可执行文件 定义…
文章目录运行环境思路1.1 编写头文件1.2 includepath添加头文件路径1.3 编写可执行文件1.4 配置文件1.5 编译运行运行环境
ubuntu20.04 noetic 宏基暗影骑士笔记本
思路
类和函数 头文件 声明 可执行文件 定义 和 调用
另外在CMakeLists.txt 添加头文件路径 include_directories
1.1 编写头文件
1在功能包下的 include/功能包名 目录下新建头文件 hello.h
#ifndef _HELLO_H
#define _HELLO_Hnamespace hello_ns{class HelloPub {public:void run();
};}#endif
1.2 includepath添加头文件路径
添加到功能包的include文件夹
/home/duduzai/demo01_ws/src/demo01_pub/include/**1.3 编写可执行文件
在 src 目录下新建文件 hello.cpp #include 功能包/.h
#include ros/ros.h
#include demo01_pub/hello.h// 命名空间可以更好的管理代码命名防止命名冲突
namespace hello_ns {void HelloPub::run(){ROS_INFO(自定义头文件的使用....);
}}int main(int argc, char *argv[])
{setlocale(LC_ALL,);ros::init(argc,argv,test_head_node);// 创建 hello_ns命名空间 HelloPub类 对象helloPubhello_ns::HelloPub helloPub;// 通过对象.调用run函数helloPub.run();return 0;
}1.4 配置文件
配置CMakeLists.txt文件
include_directories(
include${catkin_INCLUDE_DIRS}
)可执行文件配置和以前一样
add_executable(hello src/hello.cpp)target_link_libraries(hello${catkin_LIBRARIES}
)1.5 编译运行
# 编译
ctrlshiftB# 运行
roscore
source ./devel/setup.bash
rosrun demo01_pub hello.cpp⭐⭐⭐嘟嘟崽 ⭐⭐⭐ ⭐⭐⭐祝你成功 ⭐⭐⭐