Version 55 (modified by tviehmann, 6 months ago) (diff) |
---|
Table of Contents
RoboCup Logistics League Simulation Setup
These instructions describe the setup of the RoboCup Logistics League Simulation. The simulation is also used for the Planning Competition for Logistics Robots In Simulation.
Please use the fawkes development mailing list to discuss questions and improvements, and the ICAPS Planning Competition Google Group for questions specific to that competition.
Requirements
Prepare your machine according to the instructions on FawkesOnFedora.
Some features of both fawkes and the Refbox utilize rapidJSON. It can be obtained via:
sudo dnf install rapidjson-devel
In order to run make-check:
sudo dnf install clang yamllint parallel
This guide assumes an installation of all components into the base directory
cd
Robotino Simulation Overview
The simulation requires these principal components:
- Gazebo with RCLL-specific models and plugins (gazebo-rcll)
# read-write access git clone git@github.com:robocup-logistics/gazebo-rcll.git # if you don't have permissions, use this for read-only access git clone https://github.com/robocup-logistics/gazebo-rcll.git
- RCLL Refbox (Refbox)
git clone https://github.com/robocup-logistics/rcll-refbox.git
- Fawkes RCLL release
2019.
If you have access, you can also clone the repository instead:
$ git clone --recurse-submodules git@github.com:carologistics/fawkes-robotino.git
Environmental Variables
Setup the environmental variables in your .bashrc (or similar for other install locations):
export FAWKES_DIR=~/fawkes-robotino export GAZEBO_RCLL=~/gazebo-rcll export GAZEBO_PLUGIN_PATH=$GAZEBO_PLUGIN_PATH:$GAZEBO_RCLL/plugins/lib/gazebo export GAZEBO_MODEL_PATH=$GAZEBO_RCLL/models export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:$GAZEBO_RCLL/models/carologistics export LLSF_REFBOX_DIR=~/rcll-refbox export GAZEBO_WORLD_PATH=~/gazebo-rcll/worlds/carologistics/llsf.world
Refbox
Follow the installation instructions in the RefBox wiki.
The default configuration is properly setup to be used in simulation.
You may also have to set the team-name and crypto-key in the config. This depends on how your robots are configured. The crypto-key has to match the key in fawkes-robotino/cfg/conf.d/clips-agent.yaml under clips-agent/llsf2015/crypto-key.
If you want to use the MongoDB logging feature make sure that it has been compiled. Then set /llsfrb/mongodb/enable: true.
Gazebo Models and Plugins
You can find the models and plugins we use for gazebo here: https://github.com/robocup-logistics
# read-write access git clone git@github.com:robocup-logistics/gazebo-rcll.git # if you don't have permissions, use this for read-only access git clone https://github.com/robocup-logistics/gazebo-rcll.git
Build the plugins:
cd gazebo-rcll/plugins make
ROS move_base (2017+)
Since 2017 a custom setup of the ROS move_base is used for navigation purposes. Follow the next steps to enable the usage of move_base within the RCLL Simulation.
Note: This requires permissions to clone the repository git.fawkesrobotics.org:carologistics-ros!
- Make sure to have the latest ROS distribution installed as described in FawkesOnFedora and that the ROS setup path is sourced, e.g., by running
echo 'source usr/lib64/ros/setup.bash' >> ~/.bashrc source ~/.bashrc
and install ROS via:sudo dnf install ros-desktop_full-devel
- In addition, install the following dependencies:
sudo dnf install ros-move_base_msgs ros-tf2 ros-tf2_geometry_msgs ros-pcl_conversions ros-pcl_ros-devel orocos-bfl-devel suitesparse-devel ros-move_base_msgs-devel ros-libg2o-devel ros-tf2_sensor_msgs-devel sudo dnf install python2-rospkg sudo dnf install python2-wstool sudo dnf install eigen3-devel
- Create a catkin workspace
mkdir -p ~/catkin_ws/src cd ~/catkin_ws catkin_make echo 'source ~/catkin_ws/devel/setup.bash' >> ~/.bashrc source ~/.bashrc
- Clone the carologistics-ros repository:
cd ~/catkin_ws/src git clone git@github.com:fawkesrobotics/fawkes_msgs.git git clone git@github.com:carologistics/carologistics-ros.git
and check out the branch for ROS melodic:cd carologistics-ros/ git checkout nlimpert/melodic cd ..
Now, run:~/catkin_ws/src/carologistics-ros/update.sh cd .. catkin_make
Fawkes
- For the pddl-robot-memory plugin:
sudo dnf install ctemplate-devel
- To run make check:
sudo dnf install clang yamllint parallel
- For MongoDB, make sure the driver is installed:
sudo dnf install mongo-cxx-driver sudo dnf install mongo-cxx-driver-devel sudo dnf install mongo-c-driver sudo dnf install mongo-c-driver-devel
Install MongoDB version 4.0 by enabling the rpm. For x86_64 architecture this can be done via:
sudo bash -c 'echo "[mongodb-org-4.0] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.0/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc" > /etc/yum.repos.d/mongodb-org-4.0.repo'
For other architectures adapt the baseurl accordingly.
Install MongoDB:
sudo dnf install mongodb-org
Now the fawkes rcll software stack can be built via:
cd ~/fawkes-robotino make
NOTE: If you have problems with compiling/linking check pkg-config --libs/--cflags 'gazebo' for single -l/-I and remove them.
Configuration
It is possible to define multiple overall-strategy configurations for different simulation runs. These are represented by the folders in cfg/gazsim-configurations. Every overall-strategy has seperated configurations for each of the three Robotinos. Every configuration consists of the robotinoX.yaml, which replaces the default config.yaml, and the host_robotino_X.yaml, which acts as an host.yaml and overrides config values defined in cfg/conf.d/. If you want to create a new overall-strategy, you have to link the host_robotino_X.yaml in the robotinoX.yaml.
Webview
Webview2 is a useful GUI to obtain information at runtime. After following the installation instructions in the wiki, it can be used by typing localhost:808 i, where i is a robot number from 1 to 3 while the simulation is running.
Start the Simulation
Make sure mongodb is running:
sudo systemctl start mongod
Using the scripts
You can use scripts to start the simulation quickly. There are three scripts in etc/scripts which are linked in the bin folder:
gazsim.bash
Atomatically starts or ends a whole simulation with everything needed.
gazsim.bash -h for more details.
Example how to start a full RCLL Game:
./gazsim.bash -x start -n 1 -r -a
Set the -n parameter to the number of robots to run (1 to 3). The -r flag enables ROS support. If you compiled without, remove it. Finally, the -a flag loads the default agent, remove it to load your own agent (cf. -m flag in help with -h flag).
It may be useful to start the robots separately from the GUI to decrease the load on startup. To do so, add the -l flag. The GUI can be started later via calling
gzclient
gazsim-schedule.bash
Automatically runs multiple simulations with multiple configurations, keeps statistics and records the games.
You can configure the automated runs in cfg/gazsim-configurations/automated-competition-conf.bash .
gazsim-startup.bash
Starts a specified programm for the simulation.
gazsim-startup.bash -h for more details.
Temporary Problems
Currently the gazebo simulation is not working on the latest branches. Both the Refbox and Gazebo should be on branch:
common/labHLAP2019
If gzclient does not start with a generic window error on F31, do not use Wayland: simply relog and select classic gnome instead.
Running a Game
To run a game a few steps are necessary.
- Verify terminals: once gazsim.bash finishes you should have a terminal with at least 6 tabs (it is five tabs plus one for each robot, so 6 for a single simulated robot). The tabs are (in order): gazebo, roscore, refbox, refbox-shell, fawkes (robot), fawkes (comm).
If you get less than six tabs (for a single robot), edit the profile settings of the terminal (right click in terminal -> profiles -> profile preferences). Go to the second tab "Command" and choose "Hold the terminal open" for "When command exits". This will allow you to see the error message there. A typical issue is that the refbox-shell complains about insufficient lines. In that case, reduce the font size of your terminal.
To reduce the size of the gazebo window, go to the window and press the F11 key twice. Afterwards gazebo will be a regular window to resize and move.
- Set the teams: go to the fourth tab (refbox-shell). Press F4, in the appearing dialog choose "Cyan" and then "Carologistics" (or later the team color and team name you want to set, but this is the setting to bootstrap the simulation). After a short while you should see the robots appearing, e.g. R-1 of Carologistics if running with a single robot.
- Start the game: press the "space" key in the refbox shell. The game phase will change to SETUP and the state to RUNNING. The lights of the machines in the upper right corner will toggle. The machines will now be instantiated in the simulation. This takes some time, wait about 15 seconds.
Check on the fifth terminal (Fawkes for first robot). You will see some messages of the form "ColliThread?: LaserInterface? writer has been inactive for too long (1.094230 > 0.500000)". This is fine, it is because the simulation instantiates the machines. However, if you see this stop, and then reappear counting again up the time it took too long, the simulation has a hiccup. Close the terminal and start over again. This is a bug we are currently investigating. It happens typically in about one run out of ten.
- Switch phase: you can start the game without waiting for the SETUP phase to complete. Do this after the markers appear properly on the machines (after about 30 sec). Then go to the refbox-shell and press F3. Select "EXPLORATION" in the appearing dialog.
The robot(s) will now start to move and to explore the machines (assuming you run the agent with the -a parameter of gazsim.bash). The simulation has been started successfully.
Skiller Simulation
To run games without gazebo, fawkes offers a mockup on skill level. To run the skiller simulation, simply load the meta plugin:
./gazsim.bash -r -k -m m-skill-sim-clips-exec -o -n 3
The exploration phase does not work when the skiller-simulator is used. Simply go from SETUP phase to PRODUCTION phase directly (do not skip the SETUP phase as it is used to clean the robotmemory of old data, skipping it will lead to undefined behaviour)
To configure the skiller simulator take a look at
cfg/conf.d/execution_time_estimator.yaml cfg/conf.d/meta_plugins_gazebo.yaml
Do not forget to load the execution-time-estimator-navgraph plugin if you want to use it (by adding it to the meta plugin).
Refbox Tweaks
Problems you might encounter when using the skiller-simulator:
1.
- Problem: Ring station breaks due to insufficient number of bases paid
- Solution: make sure that your Refbox contains the following branches (e.g., be on the latest master)
tviehmann/no-ring-payment-check tviehmann/update-config-parser
2.
- Problem: Robots deliver products too early
- Solution: This is a bug in the current agent, to workround you can tweak the delivery windows in the refbox. In src/games/rcll/game.clp in rule game-parameterize reset deliver-start to 0 after it is set:
(bind ?deliver-start 0)
In general it makes sense to look at the following files in the refbox when trying so do minor game changes:
src/games/rcll/game.clp src/games/rcll/facts.clp
E.g., to change everything related to game randomization game.clp is good point to start looking and in order to control the amount and complexity of orders that are posted during the game facts.clp is probably the right address.
Agent Debugging with the Simulation
If you want to verify behavioral changes, the easiest way is to look at the gazebo UI. However, sometimes that might be not enough. To support the overview at runtime, the webview acts as frontend to the agent at runtime.
It can be accessed via your browser under localhost:808i, where i is the agent number. For monitoring high-level behaviour the goal tab using autorefesh can give a detailed view on an agent's decision process. In case you encounter unexpected behaviour, you may want to verify that all facts that should be known are indeed part of the fact-base. To do so, simply head to the clips tab and use the filter option to verify your assumptions.
Log files provide a dry but effective way to get a grasp on a game that is already over. A quick overview:
- The full clips log of all agents can e found in fawkes-robotino/debugi_latest.log, where i is the agent number.
- fawkes-robotino/bin/refbox.log provides the Refbox shell log
- fawkes-robotino/bin/clips.log provides the full Refbox clips log
It can be beneficial to make yourself familiar with the searching tools of your favorite text editor.
For vim users a good tip is to take a look at global searches (see https://vim.fandom.com/wiki/Power_of_g). An example to get all wm-facts of workpiece positions (wm-fact with non-empty id that contain ' wp-at args'):
:g/wm-fact (id ..*").* wp-at args
Another important feature is the possibility to run integration tests for the agent. To manually invoke them issue
make integration_test
To inspect the tests while they are running, attach tmux to the testing session (see https://gist.github.com/MohamedAlaa/2961058):
tmux a -t gazsim
Navigate through the tabs using <ctrl>+b followed by either n (next), p (previous) or a number. It might happen that the refbox shell is not loaded correctly, you may ignore that.
To write tests have a look at
fawkes-robotino/src/clips-specs/rcll/simtest.clp
Test logs are found in
fawkes-robotino/tests.d
Make sure that mongod is not running when launching the tests:
sudo systemctl stop mongod
Advanced Features
These are features that you do 'not' need usually, but that can be helpful, e.g. when debugging. Do not bother to read unless someone suggested this could be helpful.
Running the Simulation manually
Start Gazebo
gazebo $GAZEBO_WORLD_PATH
Start Fawkes with the default configuration in fawkes-robotino/bin
./fawkes -c gazsim-configurations/default/robotino1.yaml -p gazebo
Now you can start the needed simulation plugins and all other plugins as usual. A list of all simulation Plugins can be viewed here?.
Replay
If you recorded a game you can replay it with
gazebo -p path-to-replay/state.log
If the file is corrupt you may have to add '</gazebo_log>' at the end.