报错情况
colcon build --packages-up-to example_action_rclcpp ✔ │ 13:06:55
[0.526s] WARNING:colcon.colcon_core.package_identification:Failed to parse ROS package manifest in 'src/example_action_rclcpp': Error(s) in package 'src/example_action_rclcpp/package.xml':
Invalid email "fishros@foxmail.com/" for person "fishros"
Starting >>> robot_control_interfaces
Finished <<< robot_control_interfaces [0.47s]
Starting >>> example_action_rclcpp
--- stderr: example_action_rclcpp
Error parsing '/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/package.xml':
Traceback (most recent call last):
File "/opt/ros/humble/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py", line 150, in <module>
main()
File "/opt/ros/humble/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py", line 53, in main
raise e
File "/opt/ros/humble/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py", line 49, in main
package = parse_package_string(
File "/home/gkj/.local/lib/python3.10/site-packages/catkin_pkg/package.py", line 788, in parse_package_string
pkg.validate(warnings=warnings)
File "/home/gkj/.local/lib/python3.10/site-packages/catkin_pkg/package.py", line 330, in validate
raise InvalidPackage('\n'.join(errors), self.filename)
catkin_pkg.package.InvalidPackage: Error(s) in package '/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/package.xml':
Invalid email "fishros@foxmail.com/" for person "fishros"
CMake Error at /opt/ros/humble/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:95 (message):
execute_process(/usr/bin/python3.10
/opt/ros/humble/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/package.xml
/home/gkj/d2lros2/chapt4/chapt4_ws/build/example_action_rclcpp/ament_cmake_core/package.cmake)
returned error code 1
Call Stack (most recent call first):
/opt/ros/humble/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:49 (_ament_package_xml)
/opt/ros/humble/share/ament_lint_auto/cmake/ament_lint_auto_find_test_dependencies.cmake:31 (ament_package_xml)
CMakeLists.txt:43 (ament_lint_auto_find_test_dependencies)
---
Failed <<< example_action_rclcpp [1.35s, exited with code 1]
Summary: 1 package finished [2.25s]
1 package failed: example_action_rclcpp
1 package had stderr output: example_action_rclcpp
解决
maintainer邮箱使用小鱼的fishros失败
ros2 pkg create example_action_rclcpp --build-type ament_cmake --dependencies rclcpp rclcpp_action robot_control_interfaces --destination-directory src --node-name action_robot_01 --maintainer-name "fishros" --maintainer-email "fishros@foxmail.com"
将最后的--maintainer-name "fishros" --maintainer-email "fishros@foxmail.com
去掉或者改为自己,bug修复。不知bug的原因是什么。
修复后编译出错
Starting >>> robot_control_interfaces
Finished <<< robot_control_interfaces [0.42s]
Starting >>> example_action_rclcpp
--- stderr: example_action_rclcpp
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:4:7: error: no declaration matches ‘float Robot::move_step()’
4 | float Robot::move_step() {
| ^~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:4:7: note: no functions named ‘float Robot::move_step()’
In file included from /home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:1:
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/include/example_action_rclcpp/robot.h:9:7: note: ‘class Robot’ defined here
9 | class Robot {
| ^~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:14:6: error: no declaration matches ‘bool Robot::set_goal(float)’
14 | bool Robot::set_goal(float distance) {
| ^~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:14:6: note: no functions named ‘bool Robot::set_goal(float)’
In file included from /home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:1:
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/include/example_action_rclcpp/robot.h:9:7: note: ‘class Robot’ defined here
9 | class Robot {
| ^~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:27:7: error: no declaration matches ‘float Robot::get_current_pose()’
27 | float Robot::get_current_pose() { return current_pose_; }
| ^~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:27:7: note: no functions named ‘float Robot::get_current_pose()’
In file included from /home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:1:
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/include/example_action_rclcpp/robot.h:9:7: note: ‘class Robot’ defined here
9 | class Robot {
| ^~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:28:5: error: no declaration matches ‘int Robot::get_status()’
28 | int Robot::get_status() { return status_; }
| ^~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:28:5: note: no functions named ‘int Robot::get_status()’
In file included from /home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:1:
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/include/example_action_rclcpp/robot.h:9:7: note: ‘class Robot’ defined here
9 | class Robot {
| ^~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:30:6: error: no declaration matches ‘bool Robot::close_goal()’
30 | bool Robot::close_goal() { return fabs(target_pose_ - current_pose_) < 0.01; }
| ^~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:30:6: note: no functions named ‘bool Robot::close_goal()’
In file included from /home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:1:
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/include/example_action_rclcpp/robot.h:9:7: note: ‘class Robot’ defined here
9 | class Robot {
| ^~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:31:6: error: no declaration matches ‘void Robot::stop_move()’
31 | void Robot::stop_move() {
| ^~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:31:6: note: no functions named ‘void Robot::stop_move()’
In file included from /home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/robot.cpp:1:
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/include/example_action_rclcpp/robot.h:9:7: note: ‘class Robot’ defined here
9 | class Robot {
| ^~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/action_robot_01.cpp: In member function ‘rclcpp_action::CancelResponse ActionRobot01::handle_cancel(std::shared_ptr<rclcpp_action::ServerGoalHandle<robot_control_interfaces::action::MoveRobot> >)’:
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/action_robot_01.cpp:48:11: error: ‘class Robot’ has no member named ‘stop_move’
48 | robot.stop_move(); /*认可取消执行,让机器人停下来*/
| ^~~~~~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/action_robot_01.cpp: In member function ‘void ActionRobot01::execute_move(std::shared_ptr<rclcpp_action::ServerGoalHandle<robot_control_interfaces::action::MoveRobot> >)’:
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/action_robot_01.cpp:58:11: error: ‘class Robot’ has no member named ‘set_goal’
58 | robot.set_goal(goal->distance);
| ^~~~~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/action_robot_01.cpp:59:35: error: ‘class Robot’ has no member named ‘close_goal’
59 | while (rclcpp::ok() && !robot.close_goal()) {
| ^~~~~~~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/action_robot_01.cpp:60:13: error: ‘class Robot’ has no member named ‘move_step’
60 | robot.move_step();
| ^~~~~~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/action_robot_01.cpp:62:30: error: ‘class Robot’ has no member named ‘get_current_pose’
62 | feedback->pose = robot.get_current_pose();
| ^~~~~~~~~~~~~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/action_robot_01.cpp:63:32: error: ‘class Robot’ has no member named ‘get_status’
63 | feedback->status = robot.get_status();
| ^~~~~~~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/action_robot_01.cpp:67:30: error: ‘class Robot’ has no member named ‘get_current_pose’
67 | result->pose = robot.get_current_pose();
| ^~~~~~~~~~~~~~~~
/home/gkj/d2lros2/chapt4/chapt4_ws/src/example_action_rclcpp/src/action_robot_01.cpp:76:26: error: ‘class Robot’ has no member named ‘get_current_pose’
76 | result->pose = robot.get_current_pose();
| ^~~~~~~~~~~~~~~~
gmake[2]: *** [CMakeFiles/action_robot_01.dir/build.make:90:CMakeFiles/action_robot_01.dir/src/robot.cpp.o] 错误 1
gmake[2]: *** 正在等待未完成的任务....
gmake[2]: *** [CMakeFiles/action_robot_01.dir/build.make:76:CMakeFiles/action_robot_01.dir/src/action_robot_01.cpp.o] 错误 1
gmake[1]: *** [CMakeFiles/Makefile2:137:CMakeFiles/action_robot_01.dir/all] 错误 2
gmake: *** [Makefile:146:all] 错误 2
---
Failed <<< example_action_rclcpp [2.49s, exited with code 2]
Summary: 1 package finished [3.33s]
1 package failed: example_action_rclcpp
1 package had stderr output: example_action_rclcpp
初步判断应该是鱼师傅的代码放的不全,需要自己补全一下相关的代码。
判断错误,应该是自己手敲的代码存在错误,使用鱼师傅的代码集重新编译,顺利完成compile。