赞
踩
此部分是自建仿真环境然后运行小车
安装运行有问题的先参照资料解决一下
ROS基础(12)——机器人建模之gazebo
gazebo
先运行出小车模型
roslaunch racecar_gazebo racecar.launch
对准小车的地方放置刚自建的环境模型
刚开始放障碍物就会无限下沉直到见,结果就是看不到障碍物,但有显示加上了
所以尝试了一下先放障碍物,再放我绘制的墙,就可以了,不知道为什么
保存在ROS/src/racecar/racecar_gazebo/worlds
路径下
在ROS/src/racecar/racecar_gazebo/launch路径下新建launch文件
cd ~/ROS/src/racecar/racecar_gazebo/launch
gedit try.launch
文件内容:
<?xml version="1.0"?>
<launch>
<include file="$(find racecar_gazebo)/launch/racecar.launch">
<arg name="world_name" value="try"/>
</include>
</launch>
保存后开启新终端输入:
roslaunch racecar_gazebo try.launch
新开启一个终端输入
roslaunch racecar_gazebo slam_gmapping.launch
控制小车跑完环境建出地图
cd ROS/src/racecar/racecar_gazebo/map/
rosrun map_server map_saver -f mycar_map
这个办法用起来是有点小问题的,我还没想通,后续想通了会重新优化,建议用方法二
cd ROS/src/racecar/racecar_gazebo/launch
gedit racecar_runway_navigation.launch
将
改为
cd ~/ROS/src/racecar/racecar_gazebo/launch
gedit try2.launch
内容如下:
<?xml version="1.0"?> <launch> <!-- Launch the racecar --> <include file="$(find racecar_gazebo)/launch/racecar.launch"> <arg name="world_name" value="try"/> </include> <!-- Launch the built-map --> <node name="map_server" pkg="map_server" type="map_server" args="$(find racecar_gazebo)/map/mycar_map.yaml" /> <!--Launch the move base with time elastic band--> <param name="/use_sim_time" value="true"/> <node pkg="move_base" type="move_base" respawn="false" name="move_base" output="screen"> <rosparam file="$(find racecar_gazebo)/config/costmap_common_params.yaml" command="load" ns="global_costmap" /> <rosparam file="$(find racecar_gazebo)/config/costmap_common_params.yaml" command="load" ns="local_costmap" /> <rosparam file="$(find racecar_gazebo)/config/local_costmap_params.yaml" command="load" /> <rosparam file="$(find racecar_gazebo)/config/global_costmap_params.yaml" command="load" /> <rosparam file="$(find racecar_gazebo)/config/teb_local_planner_params.yaml" command="load" /> <param name="base_global_planner" value="global_planner/GlobalPlanner" /> <param name="planner_frequency" value="0.01" /> <param name="planner_patience" value="5.0" /> <!--param name="use_dijkstra" value="false" /--> <param name="base_local_planner" value="teb_local_planner/TebLocalPlannerROS" /> <param name="controller_frequency" value="5.0" /> <param name="controller_patience" value="15.0" /> <param name="clearing_rotation_allowed" value="false" /> </node> </launch>
开启两个终端分别输入如下指令(建议用方法二的启动方式)
# 第一个指令:
# 用下面这个指令启动显示找不到建模信息,但明明已经设定好了
roslaunch racecar_gazebo racecar_runway_navigation.launch
# 用下面这个指令启动gazebo时是正常的,但再启动rviz时是没有地图的
roslaunch racecar_gazebo try.launch
# 第二个指令
roslaunch racecar_gazebo racecar_rviz.launch
roslaunch racecar_gazebo try2.launch
roslaunch racecar_gazebo racecar_rviz.launch
在rviz中使用2D Nav Goal设置目标
rosrun racecar_gazebo path_pursuit.py
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。