ROS学习笔记1-前六章

2021.12.25:

1.编译报错:

CMake Error at learning_communication/CMakeLists.txt:152 (add_dependencies):
  The dependency target "learning_communication_generate_message_cpp" of
  target "talker" does not exist.

  原因:换新终端后环境变量不全。

  解决:

source ~/catkin_ws/devel/setup.zsh

2.编译报错:

    fatal error: ros/ros.h: No such file or directory
    1 | #include "ros/ros.h"

原因:CMakeLists.txt中的内容填写错误

解决:一定要注意,${}

3.编译报错:

CMake Error at learning_communication/CMakeLists.txt:148 (add_dependencies):
  The dependency target "learning_communication_gencpp" of target "talker"
  does not exist.

原因:未知

解决:将CMakeList.txt中的cmake_minimum_required由VERSION 3.0.2改为2.8.3,即可解决。

2021.12.26

1.话题异步通讯,编译warning:

CMake Warning (dev) at learning_communication/CMakeLists.txt:155 (add_dependencies):
  Policy CMP0046 is not set: Error on non-existent dependency in
  add_dependencies.  Run "cmake --help-policy CMP0046" for policy details.
  Use the cmake_policy command to set the policy and suppress this warning.

  The dependency target "learning_communication_generate_message_cpp" of target "talker"
  does not exist.
This warning is for project developers.  Use -Wno-dev to suppress it.

原因:应该是CMakeLists.txt中的依赖和书中的版本不同。

解决:将:

add_dependencies(talker ${PROJECT_NAME}_generate_message_cpp)

改为:

add_dependencies(talker ${PROJECT_NAME}_gencpp)

2.自定义服务器,AddTwoInts.cpp已经编译成功,但是引用头文件:

#include "learning_communication/AddTwoInts.h"

时VSCODE检测到错误

解决:将catkin_ws目录下的.vscode文件夹备份好后删除,然后重新启动Vscode即可。

注意:AddTwoInts.h的位置在Home/catkin_ws/devel/include/learning_communication/

2021.12.28

1.使用rviz时,运行luanch文件,rviz界面中显示:Global Status:Error

解决方法:点击Global Options下的Fixed Frame,将map改为base_link

之后点击左下角Add,选择RobotModel,则urdf模型可以正常显示。

2.将xacro文件转化为urdf文件的过程中,输入:

rosrun xacro xacro.py mrobot.urdf.xacro > mrobot.urdf

打开生成的urdf文件,显示:

[rosrun] Couldn't find executable named xacro.py below /opt/ros/noetic/share/xacro

原因:新版本的neotic和书上的执行方式不一样

解决:启动roscore后:

rosrun xacro xacro mrobot.urdf.xacro > mrobot.urdf

之后就可以

check_urdf mrobot.urdf

2022.1.3

1.check_urdf的时候报错:

Error:   No link elements found in urdf file
         at line 206 in /build/urdfdom-VnCcob/urdfdom-1.0.4+ds/urdf_parser/src/model.cpp
ERROR: Model Parsing the xml failed

原因:新版本的neotic和书上写的不一样。

解决:原来的mrobot.urdf.xacro引用mrobot:




    

    
    

将mrobot_body改为  xacro:mrobot_body  即可。

但是这样的话,在xacro>urdf的过程中可能会有其他的报错,目前debug中。

2022.1.6

1.xacro和rviz没有报错,但是缺少8根立柱

原因:新旧版本引用宏定义的方式不同。

解决:将mrobot_body.urdf.xacro中原来的引用方式:

改为:

在新版neotic的xacro文件中引用宏定义时,都要在前面加上

xacro:

2022.1.8

1.运行arbotix时报错:

ModuleNotFoundError: No module named 'serial'
[arbotix-2] process has died [pid 137519, exit code 1, cmd /home/joe/catkin_ws/src/arbotix_ros/arbotix_python/bin/arbotix_driver __name:=arbotix __log:=/home/joe/.ros/log/ad4cd2ee-7081-11ec-944f-db16eb48948a/arbotix-2.log].
log file: /home/joe/.ros/log/ad4cd2ee-7081-11ec-944f-db16eb48948a/arbotix-2*.log

Qt: Session management error: Could not open network socket

 原因:不光要看飙红的错误提示,错误提示上面的提示也要看一下。

解决:提示缺少模组"serial",因此安装serial即可。

pip install serial

2.运行mrobot_teleop.launch时出错:

process[mrobot_teleop-1]: started with pid [146737]

/usr/bin/env: ‘python’: No such file or directory

[mrobot_teleop-1] process has died [pid 146737, exit code 127, cmd /home/joe/catkin_ws/

src/mrobot_teleop/scripts/mrobot_teleop.py __name:=mrobot_teleop __log:=/home/joe/.ros/

log/e5c27f02-7081-11ec-944f-db16eb48948a/mrobot_teleop-1.log].

log file: /home/joe/.ros/log/e5c27f02-7081-11ec-944f-db16eb48948a/mrobot_teleop-1*.log

all processes on machine have died, roslaunch will exit

 原因:ros neotic用的是python3,作者用的是python2,因此表达方式不同。

解决:将~/catkin_ws/src/mbot_teleop/scripts/mbot_teleop.py文件中所有的print后面加()。

3.运行arbotix和rviz仿真时提示:

[ WARN] [1641647623.094050493]: Joint state with name: "base_l_wheel_joint" was received but not found in URDF

 原因:警告:关节名称“base_l_wheel_joint”在urdf文件中不存在。也就是说arbootix中的关节名称是base_l_wheel_joint,但是urdf文件中的关节名称是left_wheel_joint,因此对应不上。

解决:将mrobot_body.urdf.xacro文件中的关节名称改为:base_l_wheel_joint和base_r_wheel_joint即可。

2022.1.15

 1.根据书中的源码,在rviz中显示模型是正常的,但是在gazebo中显示模型缺少两个后轮子。

原因:描述轮子惯性的惯性矩阵是用宏的调用实现的,新版本的gazebo11调用宏前要加xacro:的。

解决:找到轮子的惯性矩阵宏,在前面加上xacro: 即可。

2.无法启动mrobot_teleop功能包下面的mrobot_teleop.launch:

ERROR: cannot launch node of type [mrobot_teleop/mrobot_teleop.py]: Cannot locate node of type [mrobot_teleop.py] in package [mrobot_teleop]. Make sure file exists in package path and permission is set to executable (chmod +x)

原因:文件缺少可执行权限

解决:对mrobot_teleop.py添加可执行权限

cd ~/catkin_ws/src/mrobot_teleop/scripts
chmod +x mrobot_teleop.py

2022.1.16

1.将ros功能包放到~/catkin_ws/src路径下后,经过catkin_make和source后找不到包

原因:未知

解决:运行:

rospack find robot_vision 

之后又catkin_make了以下,之后就好使了。

2.运行:

roslaunch robot_vision usb_cam.launch

提示警告:

[ WARN] [1642290615.303586262]: sh: 1: v4l2-ctl: not found

 原因:系统中缺少  v4l-utils

解决:

sudo apt install v4l-utils

你可能感兴趣的:(c++,ubuntu,linux)