Table of contents
-
- Question 1. When using xarco to create urdf, an error is reported when running joint_state_publisher/joint_state_publisher_gui
- Question 2. `No laser scan received` warning is reported when using amcl to locate. The /scan topic has data, and amcl also subscribes to this topic.
- Question 3. Running the .py file reports an error
- Question 4. ModuleNotFoundError: No module named 'xxxxx' is reported when a launch file is launched in roalaunch
- Question 5. The character spacing of the vscode terminal is too large
- Question 6. When starting Gazebo in ROS for the first time, Err [REST.cc:205] Error in REST request appears
- Set the default to use python3
- Question 7. File character set incompatibilities such as joint_state_publisher
Question 1. When using xarco to create urdf, an error is reported when running joint_state_publisher/joint_state_publisher_gui
The error is as follows:
[joint_state_publisher_gui-4] process has died [pid 97153, exit code 1, cmd /opt/ros/melodic/lib/joint_state_publisher_gui/joint_state_publisher_gui __name:=joint_state_publisher_gui __log:=/home/ros/.ros/log/4422783c-0504-11ee-8b5a-000c29b0c758/joint_state_publisher_gui-4.log].
log file: /home/ros/.ros/log/4422783c-0504-11ee-8b5a-000c29b0c758/joint_state_publisher_gui-4*.log
Reason: generally because urdf contains Chinese characters
solution:
- Delete all Chinese characters in the urdf file;
- Modify joint_state_publisher and joint_state_publisher_gui configuration
- cd /opt/ros/melodic/lib/joint_state_publisher (joint_state_publisher_gui类似)
- sudo gedit joint_state_publisher
- Revise
- Add reload(sys) sys.setdefaultencoding("utf-8") after import sys
- If the error is still reported, modify the execution permission:
cd /opt/ros/melodic/lib/joint_state_publisher
chmod 777 joint_state_publisher
Question 2. When using amcl to locate No laser scan received
, there is a warning. The /scan topic has data, and amcl has also subscribed to this topic.
The error looks like this:
amcl: No laser scan received (and thus no pose updates have been published) for xxxx seconds ?
Reason: There is no odometer information, causing the amcl coordinate system to be disordered.
solution:
- Add odometer information
- post /odom topic
- Add conversion from base_link to odom
参考
amcl: No laser scan received (and thus no pose updates have been published) for xxxx seconds ?
Question 3. Running the .py file reports an error
reason:
- Whether to grant .py file permissions,
- Whether to mark executable files in CMakeLists.txt,
- Is it because of the Chinese remarks.
solution:
- sudo chomod +x .py
-
## Mark executable scripts (Python etc.) for installation ## in contrast to setup.py, you can choose the destination # catkin_install_python(PROGRAMS # scripts/my_python_script # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} # ) # catkin_install_python(PROGRAMS scripts/talker.py DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} )
- Add at the top of the python file
#! /usr/bin/env python # -*- coding: UTF-8 -*-
Question 4. ModuleNotFoundError: No module named 'xxxxx' is reported when a launch file is launched in roalaunch
Problem Description:
Traceback (most recent call last):
File "/home/ros/catkin_workspace/src/arbotix_ros/arbotix_python/bin/arbotix_driver", line 30, in <module>
import rospy
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/__init__.py", line 49, in <module>
from .client import spin, myargv, init_node, \
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/client.py", line 52, in <module>
import roslib
File "/opt/ros/melodic/lib/python2.7/dist-packages/roslib/__init__.py", line 50, in <module>
from roslib.launcher import load_manifest # noqa: F401
File "/opt/ros/melodic/lib/python2.7/dist-packages/roslib/launcher.py", line 42, in <module>
import rospkg
ModuleNotFoundError: No module named 'rospkg'
reason
Because the ros version used by ubuntu18.04 is melodic, and melodic uses python2 by default, but we actually use python3 to run the code.
solution
- Add in the bashrc file
alias python=python3
- after saving
source ~/.bashrc
- download
pip3 install rospkg
Question 5. The character spacing of the vscode terminal is too large
Problem Description:
Cause
Due to the font under Linux, the character spacing is too large
solution
Question 6. When starting Gazebo in ROS for the first time, Err [REST.cc:205] Error in REST request appears
-
Problem Description
-
Solution:
Here you need to modify the .ignition/fuel/config.yaml fileOpen the yaml file command:
sudo gedit ~/.ignition/fuel/config.yaml
Comment
url : https://api.ignitionfuel.org
out with #then add
url: https://api.ignitionrobotics.org
As shown below:
<!-- 将 Urdf 文件的内容加载到参数服务器 -->
<param name="robot_description" textfile="$(find simu02)/urdf/urdf02_helloworld.urdf" />
<node pkg="rviz" type="rviz" name="rviz" />
<!-- 启动 gazebo -->
<!-- <include file="$(find gazebo_ros)/launch/empty_world.launch" /> -->
<!-- 在 gazebo 中显示机器人模型 -->
<!-- <node pkg="gazebo_ros" type="spawn_model" name="model" args="-urdf -model car -param robot_description" /> -->
Set the default to use python3
- Default Python2 adjusted to Python3
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 200
- Default Python3 adjusted to Python2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 200 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 100
- Enter python in the terminal and find that python3 is used by default successfully!
Question 7. File character set incompatibilities such as joint_state_publisher
-
Problem Description
UnicodeEncodeError: 'ascii' codec can't encode characters in position 53-57: ordinal not in range(128) [joint_state_publisher-1] process has died [pid 9340, exit code 1, cmd /opt/ros/melodic/lib/joint_state_publisher/joint_state_publisher __name:=joint_state_publisher __log:=/home/yzh/.ros/log/5314feca-c547-11ed-b4c2-000c2907fba7/joint_state_publisher-1.log]. log file: /home/yzh/.ros/log/5314feca-c547-11ed-b4c2-000c2907fba7/joint_state_publisher-1*.log
-
problem causes
It is due to the problem of the character set. I saw many solutions saying not to write Chinese comments, but the comments are very important, otherwise you will not know what you are doing when you re-examine the code in the future.
-
Solution
Find the file in /opt/ros/melodic/lib/joint_state_publisher/joint_state_publisher and add it
reload(sys) sys.setdefaultencoding( "utf-8" )
These two lines of code can solve the character set problem.