cd ~/ws/src,输入如下指令创建功能包
ros2 pkg create dog --build-type ament_cmake --dependencies rclcpp
创建结果如下:
在~/ws/src/dog/src下创建CPP文件
2. 代码编写导入库时,发现如下问题,无法找到相关库(仅在VScode中出现如下问题)
打开"include path setting",添加/opt/ros/eloquent
public:
DogBarkNode(std::string name):Node(name)
{
RCLCPP_INFO(this->get_logger(), "Hello, tom. I will bark at you.");
// RCLCPP_INFO(this->get_logger(), "Hello, tom. %s will bark at you.", name.c_str());
}
};
int main(int argc, char **argv){
//init client
rclcpp::init(argc, argv);
//create new node
auto node = std::make_shared 修改配置文件CMakeLists.txt 【鱼香ROS】动手学ROS2|ROS2基础入门到实践教程|小鱼带你手把手学习ROS2_哔哩哔哩_bilibili 欢迎分享,转载请注明来源:内存溢出add_executable(dog_node_bark src/dog_bark.cpp)
ament_target_dependencies(dog_node_bark rclcpp)
install(TARGETS
dog_node_bark
DESTINATION lib/${PROJECT_NAME}
)
参考链接:
评论列表(0条)