gazebo创建环境并用于仿真

1 $gazebo
2 ctrl+b
3 import
gazebo创建环境并用于仿真_第1张图片4 点击create walls,在右上角2d View中右击画图,双击相应需要编辑的内容修改参数。在左上角model name 输入square one,file——save as ——.gazebo/models,保存后不可再次编辑。

5 world文件 usr/share/gazebo-7/worlds
gazebo创建环境并用于仿真_第2张图片

sart@sart-Lenovo-S41-70:~$ sudo su
[sudo] password for sart:

root@sart-Lenovo-S41-70:/home/sart# cd …
root@sart-Lenovo-S41-70:/home# cd …
root@sart-Lenovo-S41-70:/# cd usr/share/gazebo-7/worlds
root@sart-Lenovo-S41-70:/usr/share/gazebo-7/worlds# cd …
root@sart-Lenovo-S41-70:/# chmod -R 777 worlds/
root@sart-Lenovo-S41-70:/usr/share/gazebo-7# cd worlds
root@sart-Lenovo-S41-70:/usr/share/gazebo-7/worlds# gedit square1.world

square1.world文件内容:

model://ground_plane model://sun model://Robot_house

6 launch文件 gazebo_ros/launch
/home/sart/helloworld/xacro/gazebo_ros/launch

##权限问题
sart@sart-Lenovo-S41-70:~$ chmod -R 777 usr/share/gazebo-7/worlds
chmod: 无法访问"usr/share/gazebo-7/worlds": 没有那个文件或目录
sart@sart-Lenovo-S41-70:~$ sudo su
[sudo] password for sart:
root@sart-Lenovo-S41-70:/home/sart# chmod -R 777 usr/share/gazebo-7/worlds
chmod: 无法访问"usr/share/gazebo-7/worlds": 没有那个文件或目录
root@sart-Lenovo-S41-70:/home/sart# chmod -R 777 /usr/share/gazebo-7/worlds

##报错_roslaunch turtlebot_gazebo turtlebot_world.launch
1.
ERROR: cannot launch node of type [gazebo_ros/gzserver]: can’t locate node [gzserver] in package [gazebo_ros]
ERROR: cannot launch node of type [gazebo_ros/gzclient]: can’t locate node [gzclient] in package [gazebo_ros]
ERROR: cannot launch node of type [gazebo_ros/spawn_model]: can’t locate node [spawn_model] in package [gazebo_ros]
解决:
sart@sart-Lenovo-S41-70:~$ cd catkin_ws
sart@sart-Lenovo-S41-70:~/catkin_ws$ source devel/setup.bash

##报错——gazebo
2.
sart@sart-Lenovo-S41-70:~$ echo “source /opt/ros/indigo/setup.bash” >> ~/.bashrc
sart@sart-Lenovo-S41-70:~$ roslaunch turtlebot_gazebo turtlebot_world.launch[turtlebot_world.launch] is neither a launch file in package [turtlebot_gazebo] nor is [turtlebot_gazebo] a launch file name
The traceback for the exception was written to the log file
解决:
这个问题一般有两个可能的原因:
第一个是忘了进行source
只需要回到上层进行source即可
sart@sart-Lenovo-S41-70:~$ cd catkin_ws
sart@sart-Lenovo-S41-70:~/catkin_ws$ source devel/setup.bash
sart@sart-Lenovo-S41-70:~/catkin_ws$ cd …
sart@sart-Lenovo-S41-70:~$ roslaunch rbx1_bringup fake_turtlebot.launch

第二个错误是我最近刚发现的,因为我们默认的包是gitclone在src下的,当你将新的包gitclone在其他地方时,source命令就会出错。因此我将该包剪切至src下,并重新执行

$source devel/setup.bash后,命令执行成功。

上面两个问题其实是一样的原因,就是系统没有把对应launch 文件添加到路径里,最好的办法就是将经常git的路径的source添加到~/.bashrc里面

3.gazebo仿真报错
[joint_state_publisher-4] process has died [pid 18240, exit code 1, cmd /opt/ros/indigo/lib/joint_state_publisher/joint_state_publisher _use_gui:=False __name:=joint_state_publisher __log:=/home/sart/.ros/log/865b0a42-ff0e-11ea-9b5c-54ee75633e82/joint_state_publisher-4.log].
log file: /home/sart/.ros/log/865b0a42-ff0e-11ea-9b5c-54ee75633e82/joint_state_publisher-4*.log

我的系统是ubuntu14.04 +indigo
解决办法:
sart@sart-Lenovo-S41-70:~$ sudo apt-get install ros-indigo-joint-state-publisher

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