ROS机器人开发学习遇到的问题
1、
wlp@ubuntu:~/catkin_ws$ catkin_make
Base path: /home/wlp/catkin_ws
Source space: /home/wlp/catkin_ws/src
Build space: /home/wlp/catkin_ws/build
Devel space: /home/wlp/catkin_ws/devel
Install space: /home/wlp/catkin_ws/install
Error(s) in package '/home/wlp/catkin_ws/src/learning_communication/package.xml':
Error(s):
- The manifest of package "learning_communication" (with format version 2) must not contain the following tags: run_depend
- Please replace <run_depend> tags with <exec_depend> tags.
ROS 功能包的 package.xml 文件中使用了过时的标签。在 ROS Catkin 构建系统中,package.xml 的格式版本 2 不再支持 <run_depend> 标签,需要替换为 <exec_depend> 标签
2、
yaml.scanner.ScannerError: mapping values are not allowed here
rosservice call 命令里的参数格式不符合 YAML 语法规范,导致解析失败。
rosservice call 的参数需严格遵循 YAML 语法,正确命令应该用换行和缩进区分字段
rosservice call /spawn "x: 8.0
y: 8.0
theta: 0.0
name: 'turtle2'"
3、
/home/wlp/catkin_ws/src/learning_communication/src/client.cpp:18:35: error: conversion from ‘<unresolved overloaded function type>’ to non-scalar type ‘ros::ServiceClient’ requested
18 | ros::ServiceClient client = n.serviceClient<learning_communication::AddTwoInts>
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/wlp/catkin_ws/src/learning_communication/src/client.cpp:21:5: error: ‘srv’ was not declared in this scope
21 | srv.request.a = atoll(argv[1]);
| ^~~
make[2]: *** [learning_communication/CMakeFiles/client.dir/build.make:63: learning_communication/CMakeFiles/client.dir/src/client.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:464: learning_communication/CMakeFiles/client.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 95%] Linking CXX executable /home/wlp/catkin_ws/devel/lib/learning_communication/server
[ 95%] Built target server
make: *** [Makefile:141: all] Error 2
Invoking "make -j4 -l4" failed
语法错误,缺少服务名
// 错误代码
ros::ServiceClient client = n.serviceClient<learning_communication::AddTwoInts>;
// 修正后
ros::ServiceClient client = n.serviceClient<learning_communication::AddTwoInts>("add_two_ints");
浙公网安备 33010602011771号