Advanced Usage
Welcome to the Advanced Usage doc! Here, we will be setting up Social Gym so that each submodule runs on it’s own, allowing you to set up debuggers and step through each C submodule and the python code! There’s a FAQ at the bottom about common errors you might encounter.
WARNING: The authors of this project have had numerous issues with Docker and Docker-Compose when installed via snap. We recommend uninstalling docker and docker-compose if you have GPU-related issues with the docker images and installing them via
apt
.
Requirements
We have only tested this full process on Pycharm and CLion Professional IDEs. However, what’s really needed is the ability to have a remote source or remote server that you can plug your IDE into. Specifically, we are going to plug our IDE (Pycharm/CLion) into a docker container via SSH. Our IDE’s allow us to do this somewhat trivially with run/debug configurations pretty much already set up. If you do not have this, you may need to look more stuff up on how to get these to work :/
Advanced Usage setup (buckle up!)
We’ve broken this tutorial into 3 parts, the first is the basic setup, the second will get the submodules running, and the final part will focus on the python code and running the actual simulator end to end.
Part 2: Setting up the submodules
This part of the setup was heavily inspired by https://github.com/nocoinman/ros-docker-clion – big shoutout to this project :)
1.) SSH into the ROS submodules container
ssh rosdev@localhost -p 2222
yes
12345
The password for the container is 12345
for all containers - it can be changed in the dockerfiles found in
{PROJECT_ROOT}/docker
This is the container where all the C projects will be built and ran. We are diving into their container now so we can set some stuff up manually before we plug our IDE into it.
2.) Build static dependencies.
There are a few submodules that really just contain libraries or code that does not need to be ran. We still need to compile them so that we can reference them in the other sobumodules.
source ~/set_paths.sh
rosdep update
cd social_gym/submodules/amrl_msgs
make
cd ../pedsim_ros
catkin_make
cd ../
Make sure rosdep udpate
succeeds! If it fails, you won’t be able to build the submodules.
5.) Setup UT Multirobot Sim with your IDE
For this next step I like creating a new terminal in a new IDE window, but that’s entirely up to you.
Keep those environment parameters we copied from the Graph Navigation setup for this step as well!
I am going to go a bit faster here since almost all the steps are repeating what we’ve already done for Graph Nav.
1.) Navigate to your UT_Multirobot_sim IDE window and open a new terminal with a new ssh connection into the same
container ssh rosdev@localhost -p 2222
(password is 12345
unless you changed it)
2.) Set up the shell
cd social_gym/submodules/ut_multirobot_sim/
3.) Edit the source file to include a new submodule
vim ~/set_paths.sh
Uncomment the second line write and quit
4.) Source variables.
source ./set_paths.sh
5.) Update rosdep
rosdep update
6.) Make the simulator
make
NOTE: The next steps assume you’ve followed the Graph Navigation setup meaning that your remote host toolchain is already created
7.) Open the settings window file < settings
8.) Navigate to Build,Execution,Deploy < CMake
and copy your Debug
profile and then rename the copied debug profile
to something memorable (I use RemoteDebugger
)
9.) In the Environment
text’ box paste your environment variables (remember you can get them by running ~/get_vars.sh
)
10.) Change the toolchain dropdown to the remote host toolchain you created in the Graph Navigation setup.
11.) Click apply then navigate to Build,Execution,Deployment < Deployment
and navigate to the Mappings
tab for your
remote host toolchain. Update the Deployment Path
textbox to the value
/home/rosdev/social_gym/submodules/ut_multirobot_sim
12.) Click Apply and OK to close the settings window.
13.) Clean the projects CMAKE configs
sudo rm -r cmake-build-debug/
sudo rm -r cmake-build-remotedebugger/
14.) Go to the CMake tab on your IDE (by the terminal window tab)
15.) Click the refresh button
16.) You should now have Run Configurations you can select in the dropdown by the run button in your IDE. Go to it and
find the run config simulator
(it may be defaulted to that value)
17.) Click the dropdown again and edit your configuration
18.) Update the configuration values
Program arguments:
should have -sim_config /home/rosdev/social_gym/config/gym_gen/sim_config.lua -scene_config /home/rosdev/social_gym/config/gym_gen/scene.xml -speedup_factor 1.0 --localize --use_pedsim
Working Directory
should have /home/rosdev/social_gym/submodules/ut_multirobot_sim
Environment Variables
should have the pasted environment variables from ~/get_vars.sh
19.) Click the Run button
20.) You should see the project rebuild and then an error message
/home/rosdev/social_gym/submodules/ut_multirobot_sim/cmake-build-debug-docremotetest/../bin/simulator -sim_config /home/rosdev/social_gym/config/gym_gen/sim_config.lua -scene_config /home/rosdev/social_gym/config/gym_gen/scene.xml -speedup_factor 1.0 --localize --use_pedsim
UT Multi-Robot Simulator
Publish GoAlone message
Publish GoAlone message
ERROR: Unable to load map maps/closed/door/t1/closed/door/t1.vectormap.txt
Run-time stats for Pass : mean run time = -nan ms, invocations = 0
Run-time stats for Follow : mean run time = -nan ms, invocations = 0
Run-time stats for GoAlone : mean run time = 0.017613 ms, invocations = 2
Run-time stats for Halt : mean run time = -nan ms, invocations = 0
Run-time stats for Publishing Halt : mean run time = -nan ms, invocations = 0
Run-time stats for Step : mean run time = -nan ms, invocations = 0
Run-time stats for StepUTMRS : mean run time = -nan ms, invocations = 0
Run-time stats for StepPedsim : mean run time = -nan ms, invocations = 0
Process finished with exit code 1
This is okay! This means the project was built correctly but the current configuration in the python project is incorrect, which is fine since we haven’t touched it yet. We are close to the end now :)
21.) Congratulations, you now have a UT Multirobot Sim project you can place breakpoints on and debug with. Of course to actually use it, we have to update the python project a little bit and run it – then the ut multirobot sim will work correctly.
Part 3: Setting up Python and Running everything!
1.) Open up Pycharm to the root folder of the project
2.) Set up your IDE with the container via SSH (Pycharm Specific)
Similar to the UT Multirobot Sim and Graph Navigation guides, we assume your IDE has remote host available and if not, there’s some useful stuff here but you may have to translate the steps for your ide.
1.) Open the settings window file < settings
2.) Navigate to tools < ssh configurations
3.) Create a new ssh configuration exactly the same way we did for Graph Navigation EXCEPT make the port
2223
(this is important!)
4.) Click Apply and navigate the settings window to Project < interpreter
create a new interpreter by clicking the cog
icon and hitting add new
then in the types of interpreters you can select on the left most panel select the
SSH Terminal
option
5.) Select existing ssh terminal and choose the configuration you just made in the previous steps
6.) Finish the guide for setting up the interpreter and then double check that you see python packages installed in the interpreter window.
7.) In the interpreter window select the path mappings
text box and edit it. Make sure to set the local path to your
project root and the mapped path to the location /home/rosdev/social_gym
(you can find this through the folder
explore to ensure there are no typos)
8.) Open the file config_run.py
and try to run it (so that it will create the run config, it should error for now)
9.) Edit the run config that was just made
Parameters
should have -c ./tmp_config.json
Environment variables
should have the pasted env vars we keep getting in the previous steps.
10.) Open a new ssh terminal
ssh rosdev@localhost -p 2223
cd ./social_gym/submodules
vim ~/set_paths.sh
# uncomment the second line then save the file
source ~/set_paths.sh
rosdep update
pip install sb3_contrib
pip install supersuit==3.5.0
pip install gym==0.26.2
11.) Click run in your pycharm editor. It should hang around the input
...
Waiting on UTMRS
[WARN] [1671386774.168961]: wait_for_service(/utmrsStepper): failed to contact, will keep trying
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-rosdev'
[ INFO] [1671386774.188148416]: Updated sim with live config: Rate=40 incoming rate=40
[ INFO] [1671386774.192522299]: Using default queue size of 10 for publisher queues...
[ INFO] [1671386774.199740381]: Loading scene [/home/rosdev/social_gym/config/gym_gen/scene.xml] for simulation
[ INFO] [1671386774.204534827]: node initialized, now running
Service Mode
This means we can fire up the UT Multirobot simulator now
12.) Run your ut multirobot sim simulator run config.
13.) If the python program crashed, rerun it.
14.) You should now see cubes loaded into the RVIS window after awhile, and eventually they’ll start moving around!
FAQ
All my files are missing!: If at any point your files are missing or empty check out your path mappings for your
project and make sure they are valid. Then, do git stash
for every project that has missing or empty files
This includes SUB folders as well! i.e. social_gym/ut_multirobot_sim/submodules/config_reader
You will get tons of compile errors when you make a submodule saying “geometry” is undefined etc. This means you have
to do git stash
anywhere a thirdparty source is being used.
ROSDEP errors: If you see anything during the install about ROSDEP not working correctly, make sure you are doing
source ~/set_paths.sh
rosedep update
often – once you have built pedsim via catkin_make
, you should remove the comment on the 2nd line of ~/set_paths.sh
then rerun the commands above. This is also pretty important for when you run get_vars.sh
, since that commented out
line has env variables you want your IDE to know.
CMAKE errors: CMake is not fun. If you see weird issues with cmake not building or not finding stuff make sure you are removing the cmake folders then rebuilding.
Permission Issues: The easiest way to resolve weird permission issues when setting up the advanced usage is to run
sudo chmod -R 777 .
from the project root. This effectively gives all users access to the folder (warning: this may be too open if you are working on a shared machine). Usually permissions misconfiguration happens when files are generated from the SSH terminal connection / remote debugger and not by the local user.
This is hard: Yep… it’s an art, and you should expect this to take at least 3-6hours if it’s your first time :( I would like to make this process easier, but it’s difficult to automate… maybe a video at some point? Open to suggestions!! I promise it wasn’t made difficult intentionally lol :)