系统ubuntu22.04
ros2 humble
按照如下视频教程学习的:【古月居】古月·ROS2入门21讲 | 带你认识一个全新的机器人操作系统
此处仅记录我报错的地方,以及相应的解决方案,没有出错的略过!
对应的古月居ROS2入门21讲源码下载地址:
Gitee:https://gitee.com/guyuehome/ros2_21_tutorials
Github:https://github.com/guyuehome/ros2_21_tutorials
1. 第3讲:3. ROS2安装(我没有问题 ^_^)
视频教程:安装过程参照【古月居】古月·ROS2入门21讲 | 带你认识一个全新的机器人操作系统
或者一键安装:古月居的ROS安利 | ROS一键安装脚本 或者小鱼工具【ROS2】Ubuntu22.04安装ROS humble都可以。
我在这一步没有问题 ^_^
2. 第6讲:6.工作空间与功能包,开发过程的大本营
我在6.工作空间与功能包,开发过程的大本营这一步出错:
2.1 rosdepc install报错:Cannot locate rosdep definition for [rospy]
rosdepc install -i --from-path src --rosdistro humble -y
运行上面的指令时,报错:
xj@xj:~/dev_ws$ rosdep install -i --from-path src --rosdistro humble -y
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
learning_service: Cannot locate rosdep definition for [rospy]
learning_topic: Cannot locate rosdep definition for [rospy]
learning_parameter: Cannot locate rosdep definition for [rospy]
learning_launch: Cannot locate rosdep definition for [catkin]
learning_tf: Cannot locate rosdep definition for [tf]
xj@xj:~/dev_ws$
直接安装缺失的包,我按照下面的指令安装后就可以colcon build了
sudo apt-get install python3-rospy
确实缺挺多包的:
xj@xj:~/dev_ws$ sudo apt-get install python3-rospy
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:python3-catkin python3-genmsg python3-genpy python3-roscpp-msg python3-rosgraphpython3-rosgraph-msgs python3-roslib python3-rospkg python3-std-msgs
The following NEW packages will be installed:python3-catkin python3-genmsg python3-genpy python3-roscpp-msg python3-rosgraphpython3-rosgraph-msgs python3-roslib python3-rospkg python3-rospy python3-std-msgs
0 upgraded, 10 newly installed, 0 to remove and 5 not upgraded.
Need to get 248 kB of archives.
After this operation, 1,585 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://mirrors.xjtu.edu.cn/ubuntu jammy/universe amd64 python3-catkin all 0.8.10-7 [22.8 kB]
Get:2 https://mirrors.xjtu.edu.cn/ubuntu jammy/universe amd64 python3-genmsg all 0.5.16-5 [23.7 kB]
Get:3 https://mirrors.xjtu.edu.cn/ubuntu jammy/universe amd64 python3-genpy all 0.6.16-1 [31.4 kB]
Get:4 https://mirrors.xjtu.edu.cn/ubuntu jammy/universe amd64 python3-roscpp-msg all 1.15.14+ds-2build2 [6,782 B]
Get:5 https://mirrors.xjtu.edu.cn/ubuntu jammy/universe amd64 python3-rosgraph all 1.15.14+ds-2build2 [30.9 kB]
Get:6 https://mirrors.xjtu.edu.cn/ubuntu jammy/universe amd64 python3-std-msgs all 0.5.13-2 [10.7 kB]
Get:7 https://mirrors.xjtu.edu.cn/ubuntu jammy/universe amd64 python3-rosgraph-msgs all 1.11.3-2 [7,272 B]
Get:8 https://mirrors.xjtu.edu.cn/ubuntu jammy/universe amd64 python3-roslib all 1.15.8-3 [36.8 kB]
Get:9 https://mirrors.xjtu.edu.cn/ubuntu jammy/universe amd64 python3-rospy all 1.15.14+ds-2build2 [75.5 kB]
Get:10 http://packages.ros.org/ros2/ubuntu jammy/main amd64 python3-rospkg all 1.5.1-100 [2,524 B]
Fetched 248 kB in 2s (146 kB/s)
Selecting previously unselected package python3-catkin.
(Reading database ... 300924 files and directories currently installed.)
Preparing to unpack .../0-python3-catkin_0.8.10-7_all.deb ...
Unpacking python3-catkin (0.8.10-7) ...
Selecting previously unselected package python3-genmsg.
Preparing to unpack .../1-python3-genmsg_0.5.16-5_all.deb ...
Unpacking python3-genmsg (0.5.16-5) ...
Selecting previously unselected package python3-genpy.
Preparing to unpack .../2-python3-genpy_0.6.16-1_all.deb ...
Unpacking python3-genpy (0.6.16-1) ...
Selecting previously unselected package python3-roscpp-msg.
Preparing to unpack .../3-python3-roscpp-msg_1.15.14+ds-2build2_all.deb ...
Unpacking python3-roscpp-msg (1.15.14+ds-2build2) ...
Selecting previously unselected package python3-rospkg.
Preparing to unpack .../4-python3-rospkg_1.5.1-100_all.deb ...
Unpacking python3-rospkg (1.5.1-100) ...
Selecting previously unselected package python3-rosgraph.
Preparing to unpack .../5-python3-rosgraph_1.15.14+ds-2build2_all.deb ...
Unpacking python3-rosgraph (1.15.14+ds-2build2) ...
Selecting previously unselected package python3-std-msgs.
Preparing to unpack .../6-python3-std-msgs_0.5.13-2_all.deb ...
Unpacking python3-std-msgs (0.5.13-2) ...
Selecting previously unselected package python3-rosgraph-msgs.
Preparing to unpack .../7-python3-rosgraph-msgs_1.11.3-2_all.deb ...
Unpacking python3-rosgraph-msgs (1.11.3-2) ...
Selecting previously unselected package python3-roslib.
Preparing to unpack .../8-python3-roslib_1.15.8-3_all.deb ...
Unpacking python3-roslib (1.15.8-3) ...
Selecting previously unselected package python3-rospy.
Preparing to unpack .../9-python3-rospy_1.15.14+ds-2build2_all.deb ...
Unpacking python3-rospy (1.15.14+ds-2build2) ...
Setting up python3-genmsg (0.5.16-5) ...
Setting up python3-rospkg (1.5.1-100) ...
Setting up python3-rosgraph (1.15.14+ds-2build2) ...
Setting up python3-genpy (0.6.16-1) ...
Setting up python3-std-msgs (0.5.13-2) ...
Setting up python3-catkin (0.8.10-7) ...
Setting up python3-roscpp-msg (1.15.14+ds-2build2) ...
Setting up python3-rosgraph-msgs (1.11.3-2) ...
Setting up python3-roslib (1.15.8-3) ...
Setting up python3-rospy (1.15.14+ds-2build2) ...
xj@xj:~/dev_ws$
2.2 colcon build报错
含泪教训:古月居ROS2入门21讲源码下载错了,我原来下载的是ros1的教程源码,但是在ros2系统里编译,而catkin是ros1的编译命令,所以在ros2里就报错了~
下载ros2的教程源码就可以了!
再次
colcon build
源码编译成功!!
2.3 验证
上面都没有问题的话,再次运行指令:
rosdepc install -i --from-path src --rosdistro humble -y
不再报错了!!
终端打印全文
xj@xj:~/dev_ws$ rosdepc install -i --from-path src --rosdistro humble -y
您已经成功安装rosdepc,下面提示的用法中,请将rosdep替换为rosdepc使用~
欢迎使用国内版rosdep之rosdepc,我是作者小鱼!
学习机器人,就关注《鱼香ROS》(公众号|B站|CSDN)!
小鱼rosdepc正式为您服务
executing command [sudo -H apt-get install -y ros-humble-joint-state-publisher-gui]
[sudo] password for xj:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:ros-humble-joint-state-publisher
The following NEW packages will be installed:ros-humble-joint-state-publisher ros-humble-joint-state-publisher-gui
0 upgraded, 2 newly installed, 0 to remove and 5 not upgraded.
Need to get 31.6 kB of archives.
After this operation, 136 kB of additional disk space will be used.
Get:1 http://packages.ros.org/ros2/ubuntu jammy/main amd64 ros-humble-joint-state-publisher amd64 2.4.0-1jammy.20241128.030805 [16.1 kB]
Get:2 http://packages.ros.org/ros2/ubuntu jammy/main amd64 ros-humble-joint-state-publisher-gui amd64 2.4.0-1jammy.20241128.033111 [15.5 kB]
Fetched 31.6 kB in 2s (19.9 kB/s)
Selecting previously unselected package ros-humble-joint-state-publisher.
(Reading database ... 303527 files and directories currently installed.)
Preparing to unpack .../ros-humble-joint-state-publisher_2.4.0-1jammy.20241128.030805_amd64.deb ...
Unpacking ros-humble-joint-state-publisher (2.4.0-1jammy.20241128.030805) ...
Selecting previously unselected package ros-humble-joint-state-publisher-gui.
Preparing to unpack .../ros-humble-joint-state-publisher-gui_2.4.0-1jammy.20241128.033111_amd64.deb ...
Unpacking ros-humble-joint-state-publisher-gui (2.4.0-1jammy.20241128.033111) ...
Setting up ros-humble-joint-state-publisher (2.4.0-1jammy.20241128.030805) ...
Setting up ros-humble-joint-state-publisher-gui (2.4.0-1jammy.20241128.033111) ...
executing command [sudo -H apt-get install -y ros-humble-xacro]
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:ros-humble-xacro
0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded.
Need to get 36.8 kB of archives.
After this operation, 154 kB of additional disk space will be used.
Get:1 http://packages.ros.org/ros2/ubuntu jammy/main amd64 ros-humble-xacro amd64 2.0.8-1jammy.20241125.233221 [36.8 kB]
Fetched 36.8 kB in 1s (30.2 kB/s)
Selecting previously unselected package ros-humble-xacro.
(Reading database ... 303571 files and directories currently installed.)
Preparing to unpack .../ros-humble-xacro_2.0.8-1jammy.20241125.233221_amd64.deb ...
Unpacking ros-humble-xacro (2.0.8-1jammy.20241125.233221) ...
Setting up ros-humble-xacro (2.0.8-1jammy.20241125.233221) ...
#All required rosdeps installed successfully
---------------------------------------------------------------------------
---------------------------------------------------------------------------
小鱼科普:rosdep干什么用的?可以跳过吗?https://fishros.org.cn/forum/topic/2124
如果再使用过程中遇到任何问题,欢迎通过fishros.org.cn反馈,或者加入QQ交流群(139707339)
xj@xj:~/dev_ws$
3. 第18讲. Gazebo:三维物理仿真平台
22点07分开始运行gazebo,22点34分还没加载出来gazebo的橘色页面。。。
注:已经按照教程从这个网址https://github.com/osrf/gazebo_models
下载文件夹后,重命名为models文件夹,并保存到了~/.gazebo/models路径下了
3.1. 尝试重启–没用
重启没用。。。
3.2. 问chatgpt–解决
以下操作解决我的问题啦!!chatgpt详细回复见这个网页
为 Gazebo 和 ROS 2 进行环境变量设置:
编辑 ~/.bashrc 文件
添加以下内容:
# Gazebo 环境变量
export GAZEBO_MODEL_PATH=/usr/share/gazebo-${GAZEBO_VERSION}/models
export GAZEBO_PLUGIN_PATH=/usr/lib/gazebo-${GAZEBO_VERSION}/plugins
source /usr/share/gazebo/setup.sh
# ROS 2 环境变量
source /opt/ros/humble/setup.bash
将 ${GAZEBO_VERSION} 替换为 fortress。(我没替换也可以的)
执行以下命令使其生效:
source ~/.bashrc
我按照第2步操作就解决辣!!