虛擬牆是在turtlebot2那裏調包出來修改的,主要在RVIZ上面佈置一些虛擬的牆體,並加進去虛擬的激光,好讓虛擬的牆體也擁有膨脹區域,機器人到達虛擬牆體能夠進行避障。
1、安裝好yocs_virtual_sensor的包,這個包需要安裝比較多的依賴文件
$ git clone https://github.com/yujinrobot/yujin_ocs.git
$ sudo apt-get install ros-kinetic-ecl-*
$ git clone https://github.com/yujinrobot/yocs_msgs.git
$ sudo apt-get install ros-kinetic-ar-track-alvar
2、編譯yovs_virtual_sensor包,這個包需要自己更改CMakeLists.txt文件,不然啓動launch文件時候會提示找不到節點,主要更改下面這幾句:
## Specify additional locations of header files
include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
## Declare a cpp executable
add_executable(virtual_sensor_node src/virtual_sensor_node.cpp)
## Add cmake target dependencies of the executable/library
add_dependencies(virtual_sensor_node yocs_msgs_gencpp)
## Specify libraries to link a library or executable target against
target_link_libraries(virtual_sensor_node ${catkin_LIBRARIES})
#############
## Install ##
#############
install(TARGETS virtual_sensor_node
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
3、配置standalone.launch文件,需要添加yaml文件進去,還有虛擬牆的節點。
<launch>
<arg name="virtual_wall" default="$(find yocs_virtual_sensor)/data/wall_list.yaml"/>
<node name="virtual_sensor" pkg="yocs_virtual_sensor" type="virtual_sensor_node" >
<param name="range_min" value="0.0"/>
<param name="range_max" value="6.0"/>
<param name="frequency" value="10.0"/>
<param name="hits_count" value="3"/>
<param name="global_frame" value="/map"/>
<param name="sensor_frame" value="/base_link"/>
</node>
<node pkg="tf" type="static_transform_publisher" name="base_to_virtual" args="0 0 0 0 0 0 /base_footprint /virtual_laser 50"/>
<node name="wall_publisher" pkg="yocs_virtual_sensor" type="wall_publisher.py" required="true" >
<param name="~filename" value="$(arg virtual_wall)"/>
</node>
</launch>
4、添加好虛擬激光進去costmap.yaml文件,本來一個scan的,現在添加爲兩個scan。
obstacle_layer:
enabled: true
combination_method: 1
track_unknown_space: true
obstacle_range: 2.5
raytrace_range: 3.0
observation_sources: scan scan1
scan: {
sensor_frame: /laser_link,
data_type: LaserScan,
topic: /scan,
marking: true,
clearing: true
}
scan1: {
sensor_frame: /laser_link,
data_type: LaserScan,
topic: /virtual_sensor_scan,
marking: true,
clearing: false
}
5、修改wall_publisher.py。
#修改
wall_pub = rospy.Publisher('wall_pose_list', WallList, latch = True)
#爲
wall_pub = rospy.Publisher('wall_pose_list', WallList, latch = True,queue_size= 10)
6、可以啓動導航包看效果了,後面牆的參數自己再好好消化。