wifi网速问题,可以使用压缩后的图像,效果很不错
如果是在子函数内部开启node,子函数退出之后node就没了,如果加上,那么节点就不会退出,主程序还可以继续往下运行
add_thread = threading.Thread(target = thread_job)
add_thread.setDaemon(True)
add_thread.start()
def thread_job():
rospy.spin()
tf2.ExtrapolationException
tf2.TransformException: Lookup would require extrapolation into the past. Requested time 1576844226.026989698 but the earliest data is at time 1576844226.064086676, when looking u
尝试解决方案:
时间戳的问题,需要将时间戳放到while大循环里面。保持rospy不关闭
没解决
自己摸索发现时时间的问题,注意rospy.Time(0),和rospy.Time.now()的细微区别
参考这里最下面
而且我发现,使用now的时候,虽然我们加了等待时间rospy.Duration(3),这个时间不要设的太小,否则在这个时间内没有建立好转换关系还是会报错,但是在等待的过程中tf似乎并没有干活,因为报的错仍然是第一个data比请求时间晚了零点几秒,而零点几秒显然是小于3秒的。
而且根据这篇文章,还需要注意,循环里外都要加这个wait函数,他们作用不同
注意!!!! 循环外面的wait要用Time,不要用Time.now(),循环里面的可以用now
data时间晚于请求时间报错我能理解,早于还报错我就不能理解了!
我发现同样涉及坐标转换
(a, bb) = trans.lookupTransform('/map', '/base_link', rospy.Time(0))
# goal=trans.transformPose("map",goal)
第一行代码没问题,第二行代码就会报这个错。
我好想知道原因了
goal = PoseStamped()
goal.pose = Pose(Point(22.7, 9.88, 0.000),Quaternion(0.000, 0.000, -0.309, 0.951))
goal.header.frame_id = 'base_link'
goal.header.stamp = rospy.Time(0)
goal = trans.transformPose("/map", goal)
我把这块改成Time(0)就没问题了,难道是因为使用now的时候,必须时间严格相等,小数点后差一点点都不行?但如果使用time(0)会涉及到缓存器里面消息序列的丢弃问题,因为计算机运算以及小车的运动要耗时间,且时间不确定。
发现上面这几行goal的代码其实也可以用now
只是必须加上
goal.header.stamp = rospy.Time.now()
trans.waitForTransform('/map', '/base_link', rospy.Time.now(), rospy.Duration(10))
而且这两行顺序不能反过来,实际上最好写成
goal.header.stamp = rospy.Time.now()
trans.waitForTransform('/map', '/base_link', goal.header.stamp, rospy.Duration(10))
这块写的有点乱,凑活看吧,懒得改了
使用goal=trans.transformPose("map",goal)
时出现此问题
注意:
A.由于tf的会把监听的内容存放到一个缓存中,然后再读取相关的内容,而这个过程可能会有几毫秒的延迟,也就是,tf的监听器并不能监听到“现在”的变换,所以如果不使用try,catch函数会导致报错:
并且会导致程序挂掉,使用try,catch之后就OK了。
引入这个包的时候说什么动态链接库的错误,估计和之前一样,需要自己下载源码用3,6编译一下,但是源码没有提供melodic的版本,所以没走这条路,后来下了indigo的版本,发现一样能用3.6编译,melodic一样可以用。所以版本不对也不一定不能用。另外运行的时候查了transformations 的路径,并不是py文件,而是pyc文件,所以自己直接把源码中的某个函数复制过来运行是有问题的。
尽量不要主从机同时开rviz,有些内容似乎会冲突
Display添加的时候尽量从topic下面添加,从by display type 下面添加的内容有时候会出现奇怪的问题
运行cartographer时候报错
ERROR: cannot launch node of type [cartographer_ros/cartographer_node]: can't locate node [cartographer_node] in package [cartographer_ros]
ERROR: cannot launch node of type [cartographer_ros/cartographer_occupancy_grid_node]: can't locate node [cartographer_occupancy_grid_node] in package [cartographer_ros]
process[rviz-4]: started with pid [1729]
process[playbag-5]: started with pid [1740]
[FATAL] [1576053693.421505084]: Error opening file: /home/ubuntu/cartographer_paper_deutsches_museum.bag
[playbag-5] process has died [pid 1740, exit code 1, cmd /opt/ros/kinetic/lib/rosbag/play --clock /home/ubuntu/cartographer_paper_deutsches_museum.bag __name:=playbag __log:=/home/ubuntu/.ros/log/e16aa31c-1bf1-11ea-aeb1-00e04c680194/playbag-5.log].
log file: /home/ubuntu/.ros/log/e16aa31c-1bf1-11ea-aeb1-00e04c680194/playbag-5*.log
[ERROR] [1576053694.199733288]: PluginlibFactory: The plugin for class 'Submaps' failed to load. Error: Could not find library corresponding to plugin Submaps. Make sure the plugin description XML file has the correct name of the library and that the library actually exists.
我手动在终端:
source ~/catkin_ws3/install_isolated/setup.bash
source ~/catkin_ws3/devel_isolated/setup.sh
解决了错误
我在bashrc文件里面明明已经:
source ~/catkin_ws3/install_isolated/setup.bash
source ~/catkin_ws3/devel_isolated/setup.sh
但是可能因为下面我在bashrc中又:
source ~/turbot_ws/devel/setup.bash
source了另一个工作空间,所以原先的空间被覆盖了?
总之尽量一个工程用一个空间,只source需要的空间就不会有问题
教程中需要添加的ppa源明明可以用浏览器打开,但就是ping不同,apt-get update也说什么 404或者 no release,奇怪。改DNS,也没什么用。
试了一下同样的教程用ubuntu16就可以,那说明是版本的问题
去ros-qtc-plugin官方教程找,发现不同版本安装教程不太一样
经验:以后尽量先去看官方教程!!
def thread_job():
rospy.spin()
#rospy.spin() # spin() simply keeps python from exiting until this node is stopped,但是这个函数会让程序无法向下进行,所以改用下面两行,开个线程
add_thread = threading.Thread(target = thread_job)
add_thread.start()
raceback (most recent call last):
File "/usr/bin/catkin", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 3250, in <module>
@_call_aside
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 3234, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 3263, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 583, in _build_master
ws.require(__requires__)
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 900, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 786, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'catkin-tools==0.4.5' distribution was not found and is required by the application
解决:pip3 install catkin-tools --user
不加–user会报错,有点奇怪
接着报错
Traceback (most recent call last):
File "/usr/bin/catkin", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 3250, in <module>
@_call_aside
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 3234, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 3263, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 583, in _build_master
ws.require(__requires__)
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 900, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 786, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'catkin-pkg>0.2.9' distribution was not found and is required by catkin-tools
我用 pip show查看
(pysot) dv@dv-Centre-M910t:~/pysot-master/David/catkin_ws$ pip show catkin-pkg
Name: catkin-pkg
Version: 0.4.14
Summary: catkin package library
Home-page: http://wiki.ros.org/catkin_pkg
Author: Dirk Thomas
Author-email: dthomas@osrfoundation.org
License: BSD
Location: /opt/ros/melodic/lib/python2.7/dist-packages
Requires: docutils, pyparsing, python-dateutil
Required-by: rospkg, catkin-tools
我用find查看
dv@dv-Centre-M910t:~/pysot-master/David/catkin_ws$ sudo find / -name *catkin_pkg*
/usr/lib/python2.7/dist-packages/catkin_pkg
/usr/lib/python2.7/dist-packages/catkin_pkg-0.4.13.egg-info
/usr/lib/python2.7/dist-packages/catkin_pkg_modules-0.4.13.egg-info
/usr/lib/python3/dist-packages/catkin_pkg
/usr/lib/python3/dist-packages/catkin_pkg_modules-0.4.14.egg-info
/home/dv/anaconda3/envs/ros/lib/python3.6/site-packages/catkin_pkg
/home/dv/anaconda3/envs/ros/lib/python3.6/site-packages/catkin_pkg-0.4.14.dist-info
/home/dv/anaconda3/envs/pysot/lib/python3.7/site-packages/catkin_pkg
/home/dv/anaconda3/envs/pysot/lib/python3.7/site-packages/catkin_pkg-0.4.14.dist-info
/home/dv/.cache/pip/wheels/01/5c/b4/6238d18c38c991628be01fb18bd12809efdd6b603ba067d0c3/catkin_pkg-0.4.14-cp27-none-any.whl
find: ‘/run/user/1000/gvfs’: Permission denied
find: ‘/run/user/121/gvfs’: Permission denied
/opt/ros/melodic/lib/python2.7/dist-packages/catkin_pkg
/opt/ros/melodic/lib/python2.7/dist-packages/catkin_pkg-0.4.14.dist-info
安装的catkin-pkg包明明都满足版本大于0.2.9的要求啊
我用pip(系统下的pip3)安装pip3 install catkin-pkg==0.4.14 --user
也都说已经满足
pip3 install catkin-pkg==0.4.14 --user
WARNING: The directory '/home/dv/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/dv/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: catkin-pkg==0.4.14 in /opt/ros/melodic/lib/python2.7/dist-packages (0.4.14)
Requirement already satisfied: docutils in /opt/ros/melodic/lib/python2.7/dist-packages (from catkin-pkg==0.4.14) (0.15.2)
Requirement already satisfied: python-dateutil in /opt/ros/melodic/lib/python2.7/dist-packages (from catkin-pkg==0.4.14) (2.8.1)
Requirement already satisfied: pyparsing in /opt/ros/melodic/lib/python2.7/dist-packages (from catkin-pkg==0.4.14) (2.4.5)
Requirement already satisfied: six>=1.5 in /opt/ros/melodic/lib/python2.7/dist-packages (from python-dateutil->catkin-pkg==0.4.14) (1.13.0)
WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
但还是报错
于是我注释掉bashrc文件里面的source /opt/ros/melodic/setup.bash
重开了一个终端,重新用pip安装
这次成功安装
安装之后catkin config不再报错
我猜原因是catkin config调用包的搜索路径的问题,只把当前python(系统的python3.6)的包的路径加了进去
而pip安装的时候也很奇怪,似乎其他环境下有了某个包,我这个环境就不能再下了,就一直说已经满足
这块再看看,尤其关于pip的路径问题
[ERROR] [1574859069.909132]: bad callback: <function callback at 0x7f8f09fe1f28>
Traceback (most recent call last):
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback
cb(msg)
File "/home/dv/pysot-master/tools/mytest.py", line 48, in callback
img = bridge.imgmsg_to_cv2(imgmsg, "bgr8")
File "/opt/ros/melodic/lib/python2.7/dist-packages/cv_bridge/core.py", line 163, in imgmsg_to_cv2
dtype, n_channels = self.encoding_to_dtype_with_channels(img_msg.encoding)
File "/opt/ros/melodic/lib/python2.7/dist-packages/cv_bridge/core.py", line 99, in encoding_to_dtype_with_channels
return self.cvtype2_to_dtype_with_channels(self.encoding_to_cvtype2(encoding))
File "/opt/ros/melodic/lib/python2.7/dist-packages/cv_bridge/core.py", line 91, in encoding_to_cvtype2
from cv_bridge.boost.cv_bridge_boost import getCvType
ImportError: dynamic module does not define module export function (PyInit_cv_bridge_boost)
一顿搜索
应该是cv_bridge要求opencv的版本不能太高
这里有个坑,查看opencv的版本可用命令pkg-config --modversion opencv
但这个查的是系统当前c++的opencv
查系统当前的Python的opencv 应该用pip show opencv-python
update:没有用,试了一下用python2的解释器from cv_bridge.boost.cv_bridge_boost import getCvType
不会报错,所以,这个错误还是归结到python2,3的问题上,现在正在尝试用python3编译cv_bridge的包主要参考
成功用python3编译了,这个问题解决了
目前初步个人不太成熟的建议是,把环境变量PYTHONPATH=xxx/melodic/xxx注释掉,然后把这个路径手动加在要执行的python文件里面,例如
sys.path.append("/opt/ros/melodic/lib/python2.7/dist-packages")
因为python import包的时候优先PYTHONPATH 这样修改之后,就可以先使用当前环境下的包,实在没有,再去melodic下面找
原因,import rospy的时候需要层层引入别的包,引入到yaml的时候,我的melodic下面本来有个yaml包,它在初始化的时候会from error import* 我melodic下面跟yaml同级的目录下明明有yaml文件,但就是报错说无法引入至今不知为啥
解决,将这个yaml包暂时移除到home下,改名为yaml-orgin,此时它会import /usr/lib/python3/dist-packages下面的yaml,这个就没问题
update2019-11-27似乎知道为啥了
1、如果 from 后面是 “X” 而非 “X.Y”的形式,则所导入的模块在该文件夹下的 “init.py”中;2、如果 from 后面是 “X.Y” 而非 “X”的形式,则所导入的模块在该文件夹下的 “Y.py”中
melodic下面的yaml的__init__.py 是 from error import *
而python3下面的是 from .error import *
因为melodic的python是2,7的 但我这个工程我要用的解释器是3.7的
我用3.7的解释器引入了2.7的包,当遇到语法区别的时候,自然会出错回头研究一下ros中使用python3的方法,能不能一次性解决各种语法兼容问题
看这里
原因:pycharm启动的时候没有加载bashrc里面的环境变量
解决 sudo gedit /usr/share/applications/pycharm.desktop
接着我们在变量 Exec 后面添加:bash -i -c,如下图所示:
结果暂时还是没用
因为一些bashrc里面的指令就是不能加载到pycharm里面的
解决python代码里面加上sys.path.append("/opt/ros/melodic/lib/python2.7/dist-packages")
此时还要注意,不管我当前用的什么python 似乎我pip install rospy 都是安装在上面这个路径下面
之前出过类似的问题,上次是明明生成了可执行的node,路径也加了就是说找不见,很奇怪,忘了怎么解决了
这次是我下载了usb_cam包之后选择单独编译也就是catkin_make -DCATKIN_WHITELIST_PACKAGES="包名"
之后出现这个问题
解决,删除build devel 重新编译即可解决问题
Traceback (most recent call last):
File "/opt/ros/melodic/bin/roscore", line 36, in <module>
from rosmaster.master_api import NUM_WORKERS
File "/opt/ros/melodic/lib/python2.7/dist-packages/rosmaster/__init__.py", line 35, in <module>
from .main import rosmaster_main
File "/opt/ros/melodic/lib/python2.7/dist-packages/rosmaster/main.py", line 43, in <module>
import rosmaster.master
File "/opt/ros/melodic/lib/python2.7/dist-packages/rosmaster/master.py", line 47, in <module>
import rosmaster.master_api
File "/opt/ros/melodic/lib/python2.7/dist-packages/rosmaster/master_api.py", line 72, in <module>
from rosmaster.util import xmlrpcapi
File "/opt/ros/melodic/lib/python2.7/dist-packages/rosmaster/util.py", line 48, in <module>
from defusedxml.xmlrpc import monkey_patch
ModuleNotFoundError: No module named 'defusedxml'
解决:改用python2.7
sudo update-alternatives --config python
因为ubuntu18.04不能装kinetic
解决sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key XXXXXXX
尝试
sudo aptitude install ros-***
代替 sudo apt-get install ros-***
选择降级方案,成功
网上给的方法没用
自己摸索解决:在launch文件里面加上一行
解决:换usb3.0,注意,公司的笔记本上只有右边的usb是3.0
原因,主从机未处于同一个局域网下(但是都处于一个nat的后面,因为两者可以ping通)。注意,两者都处于校园网,从机连的实验室的网,相当于校园网里面的小局域网,两者能ping通,都使用的非公网ip,但ros无法通信rosnode ping /rosout 没反应,很久以后ERROR: Unable to communicate with master!暂时不懂为啥。待查
妈个鸡,复习了一通计算机网络的知识,发现我的记忆并没有出错,今天还是同样的环境,同样的操作,再试一下就可以了??
好像唯一的变化就是/etc/hosts文件里面我把三个空格换成了tab 这tm应该不影响啥的吧,靠!
现在又遇到了这个问题,我把主从机连接到一台交换机,也就是不经过路由器,现在没问题了,所以怀疑是路由器的设置有问题,啥问题不清楚