ros2学习笔记

1.问题描述:

Caught exception in launch (see debug for traceback): [Errno 2] No such file or directory: '/home/wkl/demo_ros2/install/multi_robot_pkg/share/multi_robot_pkg/models/wpb_home_lidar.model'

问题分析:

出现该问题后,可以看到gazebo的机器人模型和各种其余模型均无法加载,检查launch发现各种模型的路径添加均未产生错误。这时候需要检查构建系统的配置,尤其是CMakeLists.txt中的install部分是否正确地将模型文件包含进去。

检查CMakeLists.txt文件的时候发现确实没有将机器人模型文件夹安装到目标路径,如下所示:

install(
  DIRECTORY 
  config launch maps rviz worlds
  DESTINATION share/${PROJECT_NAME}
)

只需要将models文件添加到路径即可解决问题

install(
  DIRECTORY 
  config launch maps rviz worlds models
  DESTINATION share/${PROJECT_NAME}
)

### ROS2 C++ Topic Communication Learning Materials and Tutorials For those interested in exploring how to use topics for communication within the ROS2 framework using C++, several resources provide comprehensive guidance on this subject. The official documentation of ROS 2 offers an extensive tutorial that covers setting up publishers and subscribers with detailed explanations and code examples written in C++. This resource is invaluable as it not only explains the theory but also provides practical steps necessary to establish topic-based communications between nodes[^1]. Additionally, a popular choice among developers includes tutorials available from Robot Ignite Academy which presents step-by-step instructions alongside video demonstrations specifically tailored towards understanding message passing through topics via C++ interfaces in ROS2 environments. These sessions are designed to cater both beginners who need foundational knowledge about ROS concepts along with more advanced users looking into optimizing their applications' performance when dealing with real-time data exchange over networks. Another noteworthy mention goes out to Open Robotics’ own set of educational materials where one can find well-documented samples illustrating various aspects related to working with messages across different programming languages including C++; these documents often include best practices recommendations ensuring efficient utilization while adhering closely to community standards established around ROS ecosystem development processes. ```cpp // Example Code Snippet Demonstrating Basic Publisher Node Implementation Using rclcpp Library In C++ #include "rclcpp/rclcpp.hpp" using namespace std::chrono_literals; int main(int argc, char * argv[]) { rclcpp::init(argc, argv); auto node = rclcpp::Node::make_shared("example_publisher"); auto publisher = node->create_publisher<std_msgs::msg::String>("topic", 10); auto msg = std_msgs::msg::String(); msg.data = "Hello, world!"; rclcpp::WallRate loop_rate(1s); // Publish every second while (rclcpp::ok()) { RCLCPP_INFO(node->get_logger(), "Publishing: '%s'", msg.data.c_str()); publisher->publish(msg); rclcpp::spin_some(node); loop_rate.sleep(); } rclcpp::shutdown(); } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值