1.执行python脚本时,不能导入模块
这时我们需要在py程序前加上:
#!/usr/bin/env python
目的是在运行python脚本的时候告诉操作系统我们要用python解释器去运行py脚本
2.调包时,提示错误信息:找不到该包。
$ echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
$ source ~/.bashrc
catkin_ws是当前工作空间,运行时换成自己的。
3.解决python编码错误问题,File “/home/daniel/rospy_ws/src/rospy_topic/src/rospy_listener.py”, line 4 SyntaxError: Non-ASCII character ‘\xe5’ in file /home/daniel/rospy_ws/src/rospy_topic/src/rospy_listener.py on line 4, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
错误原因:是因为xxx.py中有中文字符。
解决方法:
- 对于python3.6版本,在py文件开始处加上
# coding=gbk
- 对于python2.7版本(ros中是2.7版本),在py文件开始处加上
# -*-coding:utf8 -*-
4 针对古月博客上建立自己的urdf,模型出现如下错误
the config file ‘/opt/ros/hydro/share/urdf_tutorial/urdf.vcg’ is a .vcg file, which is the old rviz config format.
解决办法是:
由于文中指定使用.vcg格式的文件引起,将base.urdf.rviz.launch文件的内容做如下更改后可以正常运行
<launch>
<arg name="model" />
<arg name="gui" default="False" />
<param name="robot_description" textfile="$(find smartcar_description)/urdf/smartcar.urdf" />
<param name="use_gui" value="$(arg gui)"/>
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" ></node>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find urdf_tutorial)/urdf.rviz" />
</launch>
5.创建机器人模型smartcar过程中,小车模型4个轮子没有出现,rviz中错误提示为:No transform from [left_back_wheel] to [base_link]
原因是:由于joint_state_publisher 未能解析urdf.xml文件而出错。
解决办法:因此把urdf文件中第一行代码<?xml version="1.0"?>去掉,问题也解决了。
ROS 编译时报错 cfg: Permission denied
[ 33%] Built target rosgraph_msgs_generate_messages_py
../catkin_generated/env_cached.sh: 16: exec: /home/daniel/ROS_Learning/smartcar_description/src/readyaml/cfg/
Test.cfg: Permission denied
readyaml/CMakeFiles/readyaml_gencfg.dir/build.make:63: recipe for target '/home/daniel/ROS_Learning/smartcar_
description/devel/include/readyaml/TestConfig.h' failed
make[2]: *** [/home/daniel/ROS_Learning/smartcar_description/devel/include/readyaml/TestConfig.h] Error 126
CMakeFiles/Makefile2:1215: recipe for target 'readyaml/CMakeFiles/readyaml_gencfg.dir/all' failed
make[1]: *** [readyaml/CMakeFiles/readyaml_gencfg.dir/all] Error 2
make[1]: *** 正在等待未完成的任务....
解决办法:
根据提示使用ls -al命令查看该文件权限
ls -al /home/daniel/ROS_Learning/smartcar_description/src/readyaml/cfg/Test.cfg
如果该文件没有x权限时,使用chmod +x命令赋予文件权限
chmod +x /home/daniel/ROS_Learning/smartcar_description/src/readyaml/cfg/Test.cfg
然后再重新编译,就通过啦
python中的作用域以及global的用法
https://blog.csdn.net/rongdang/article/details/81045706
采用rqt形式启动Gazebo环境中的Controller
rosrun rqt_joint_trajectory_controlr rqt_joint_trajectory_controller