---
title: Usage of virtual_wall
---
***Usage***: By publish two points to create a virtual wall that prevents a robot can go through.
download link: https://github.com/DylanLN/virtual_wall
required packages:
+ navigation: https://github.com/ros-planning/navigation
+ turtlebot3: https://github.com/ROBOTIS-GIT/turtlebot3 -- for simulation.
move_base package inside navigation is the brain of our program that can be read file config of our map
such as : global and local costmap yaml file.
for example:
<!-- move_base -->
```
<node pkg="move_base" type="move_base" respawn="false" name="move_base2" output="screen">
<param name="base_local_planner" value="dwa_local_planner/DWAPlannerROS" />
<rosparam file="$(find turtlebot3_navigation)/param/costmap_common_params_$(arg model).yaml" command="load" ns="global_costmap" />
<rosparam file="$(find turtlebot3_navigation)/param/costmap_common_params_$(arg model).yaml" command="load" ns="local_costmap" />
<rosparam file="$(find turtlebot3_navigation)/param/local_costmap_params.yaml" command="load" />
<rosparam file="$(find turtlebot3_navigation)/param/global_costmap_params.yaml" command="load" />
<rosparam file="$(find turtlebot3_navigation)/param/move_base_params.yaml" command="load" />
<rosparam file="$(find turtlebot3_navigation)/param/dwa_local_planner_params_$(arg model).yaml" command="load" />
<remap from="cmd_vel" to="$(arg cmd_vel_topic)"/>
<remap from="odom" to="$(arg odom_topic)"/>
<param name="DWAPlannerROS/min_vel_x" value="0.0" if="$(arg move_forward_only)" />
</node>
```
***Note: change to our real path of yaml file***
we use turtlebot3 for example of adding virtual wall.Two files that we need to modify include globalcostmapparams.yaml && localcostmapparams.yaml
change detail of two files inside
+*catkinws/src/turtlebot3/turtlebot3navigation/param/globalcostmapparams.yaml*
```
global_costmap:
global_frame: map
robot_base_frame: base_footprint
update_frequency: 10.0
publish_frequency: 10.0
transform_tolerance: 0.5
static_map: true
plugins:
- {name: static_layer, type: "costmap_2d::StaticLayer"}
- {name: obstacle_layer, type: "costmap_2d::VoxelLayer"}
- {name: virtual_wall, type: "virtual_wall::VirtualWall"}
- {name: inflation_layer, type: "costmap_2d::InflationLayer"}
```
+*catkinws/src/turtlebot3/turtlebot3navigation/param/localcostmapparams.yaml*
```
local_costmap:
global_frame: odom
robot_base_frame: base_footprint
update_frequency: 10.0
publish_frequency: 10.0
transform_tolerance: 0.5
static_map: false
rolling_window: true
width: 3.0
height: 3.0
resolution: 0.05
plugins:
- {name: static_layer, type: "costmap_2d::StaticLayer"}
- {name: virtual_wall, type: "virtual_wall::VirtualWall"}
- {name: obstacle_layer, type: "costmap_2d::VoxelLayer"}
- {name: inflation_layer, type: "costmap_2d::InflationLayer"}
```
**Step1**:
cd catkin_ws
export TURTLEBOT3_MODEL=burger
source devel/setup.bash
roslaunch turtlebot3_gazebo turtlebot3_world.launch
**Step2**:
cd catkin_ws
export TURTLEBOT3_MODEL=burger
source devel/setup.bash
roslaunch turtlebot3_navigation turtlebot3_navigation.launch
OR: roslaunch turtlebot3_navigation turtlebot3_navigation.launch map_file:=$HOME/map.yaml(FOR SPECIFIC SCANED MAP)
use QMTT to publish two points with topic as :
/clicked_point
# **Note: Add Maker in rviz to see the wall + to publish points to create a wall please use the command : **
```
rostopic pub /clicked_point geometry_msgs/PointStamped '{header: {stamp: now, frame_id: map}, point: { x: -0.951733231544, y: -1.90567553043, z: 0.00247192382812}}'
rostopic pub /clicked_point geometry_msgs/PointStamped '{header: {stamp: now, frame_id: map}, point: { x: 0.367253124714, y: -1.8252556324, z: 0.00247192382812}}'
```
format of json we can take a look : http://library.isr.ist.utl.pt/docs/roswiki/ROS(2f)YAMLCommandLine.html
# To list all ids of walls please command:
`rostopic echo virtual_wall_list`
each wall will be index from 0
To delete a wall:
`rostopic pub /delete_wall std_msgs/Int32 '0'`
# *The way to create an layer plugin, please take a look at* : http://wiki.ros.org/costmap_2d/Tutorials/Creating%20a%20New%20Layer
Idea: Amap contain many layers such as static_layer map, obstacle map and inflation_layer
The static map layer: the map is scan by SLAM
The obstacle layer: tracks the obstacles as read by the sensor data
The inflation layer: is an optimization that adds new values around lethal obstacles
Robots will avoid to move through by read each layer; therefore, you can add one layer such as virtual wall.
# Result:
