Skip to content

Running ROS simulation

Cambridge edited this page Oct 8, 2016 · 3 revisions

Dependencies

The first two dependencies are for building the P language compiler. Please see Building P for more details involving installing required mono.

Building ROS simulation

Please refer to Dependencies first to install the required mono first.

  $ git clone https://github.com/Drona-Org/Drona.git
  $ cd Drona
  $ git submodule update --init --recursive
  $ cd Submodules/P/Bld; sh build.sh        # this step builds P Compiler, see Dependencies section for more details
  $ cd ../../../Src/ros_simulation/src
  $ catkin_init_workspace                   # init catkin workspace, please see ROS for more details
  $ cd ..
  $ catkin_make -DCMAKE_BUILD_TYPE=Release -DUSE_DIJKSTRA_PRECOMPUTATION=OFF -DUSE_ROBOTID_AS_PRIORITY=OFF

Running ROS simulation

Running all the pre-generated experiments

To run all experiments in the Drona paper, one can simply do the following:

  $ source devel/setup.bash                 # sourcing the built ROS workspace environment
  $ cd ../Workspaces                        # where the launch config files are located
  $ python run_experiments.py 

To re-generate all the experiments

  $ python experiments_generator.py         # This might take a while, as the random generator have to verify the generated map is fully connected during the generation

Running the experiments does not launch Rviz. The result should be viewable in Experiments/stats

Launching a ROS launch file

After building, one should expect build/ and devel/ directories inside ros_simulation;

  $ source devel/setup.bash                 # sourcing the built ROS workspace environment
  $ cd ../Workspaces                        # where the launch config files are located
  $ roslaunch Videos/16_8/Workspace.launch  # runs the 16x16 grid 8 drones example

The above command summarizes the workflow to run one simulation: source the ROS environment, and run the launch file. One might be wondering where the launch files came from: as ROS is a component-based framework, all the elements should be designed to be pluggable and reusable. We follow the same ideology here: each simulation launch configuration corresponds to a Workspace.xml, which encodes all the map information, including drone start locations, obstacle locations etc.. Then, a ROS launch file is written to specify the simulation configurations, including the ROS message indirection, Rviz view points etc..

Generating launch file from .xml configuration

To simplify workflow, we have a tool to generate a launch file from a Workspace.xml, applying some usual configuration we use for simulation.

For instance, consider the Workspace.xml file located under Workspaces/Exp1; the command

  $ cd Workspaces
  $ rosrun p_controller launch_file_converter.py -dir Exp1/ -w Exp1/Workspace.xml

Creates Workspace.launch and Workspace.rviz under Exp1 for Exp1/Workspace.xml

Generating .xml configuration from a text map file format

Now that we know how to generate launch files, one might want some more Workspaces to work with; however, directly working with Workspace.xml can be cumbersome, for this reason, we supply another simple text file format for specifying simple maps.

  $ cat Exp1/map.txt 

one should expect something like the following:

    # Map
    bb            bb
    ...
     ww  wwwwww  ww 
    ...
    bb            bb

In the printed ascii map, "w" corresponds to obstacles, "b" corresponds to start locations, "g" and "r" corresponds to start and end locations, and "y" correspond to charging locations. One can use the command

  $ python config_generator.py Exp1/map.txt Exp1/Workspace.xml

to generate a .xml from the simple map above

Generating Random map files

We also ships a small script to randomly generate reasonable random maps. To use it, one can do:

  $ mkdir tmp 
  $ python random_map_generator.py -g 16,16 -b 2,2 -s 4 -e 0 -c 0 -r 4 -d 0.2 tmp/map.txt

The above command generates a 16 by 16 map, with expected obstacles block size of 2, 4 start locations, 4 drones, and 0.2 density.